The add-ons own 18 hooks between them. They follow the same conventions as core: staticscope_<addon>_<thing>, filters return a value, actions do not. None of them fire without the add-on being active. Each add-on registers itself on staticscope_addons, so a hook from an inactive add-on never fires and there is no error to catch.
Forms
Forms has the widest surface: seven filters covering the field list, the provider, the form tag, hidden fields, individual fields and the finished markup. File paths are relative to wp-content/plugins/staticscope-addon-forms/.
| Hook | Signature | Use case |
|---|---|---|
staticscope_forms_fields | array $fields, keyed by input name | Add a field or change an existing one. Each field sets label, type, required, autocomplete, maxlength, placeholder, description, always and optionally rows. |
staticscope_forms_attributes | array $attributes | Change the block attributes at the start of rendering, before labels and provider decoration are read. |
staticscope_forms_provider | array $decoration, string $form_name, bool $has_subject | Change the endpoint, hidden values, honeypot or messages. Not called for the editor preview or an unconfigured provider. |
staticscope_forms_form_attributes | array $form_attributes, array $attributes, array $provider | Add a data-* attribute, a class or a target to the form tag. |
staticscope_forms_hidden_fields | array $hidden, array $attributes, array $provider | Add tracking or routing fields as name to value pairs. |
staticscope_forms_field_html | string $html, string $key, array $field, string $id, bool $labels_hidden | Replace one field’s markup. Called once per field, including the dropdown, from two render sites with the same signature. |
staticscope_forms_html | string $html, array $attributes, array $provider | Wrap or change the finished form. Only runs for a configured provider; the unconfigured path returns earlier. |
Plain types text, email, tel, url and textarea render automatically. Anything else, such as a radio group or a select, needs staticscope_forms_field_html. Setting always to true puts a field in every form whether the block selected it or not, which is why the email field behaves that way. Field order follows the array order, so reordering the definitions changes the rendered order.
Forms also protects its markup during preparation. It listens to staticscope_process_html at priority 5 to protect the form, then restores it at 20. An HTML rewrite that runs between those priorities sees the protected version, not the finished form. Run before 5 or after 20 if you need to touch form markup.
add_filter( 'staticscope_forms_fields', function ( array $fields ) {
$fields['company'] = [
'label' => 'Company',
'type' => 'text',
'required' => false,
'autocomplete' => 'organization',
'maxlength' => 100,
'placeholder' => '',
'description' => '',
'always' => false,
];
return $fields;
} );
add_filter( 'staticscope_forms_field_html', function ( string $html, string $key, array $field, string $id, bool $labels_hidden ) {
if ( $key !== 'topic' ) {
return $html;
}
return '<fieldset class="my-radios"><legend>' . esc_html( $field['label'] ) . '</legend>'
. '<label><input type="radio" name="topic" value="support" /> Support</label>'
. '<label><input type="radio" name="topic" value="sales" /> Sales</label>'
. '</fieldset>';
}, 10, 5 );
GitHub
GitHub has six hooks. They are mostly for GitHub Enterprise Server and for telling something else that a publish happened. File paths are relative to wp-content/plugins/staticscope-addon-github/.
| Hook | Signature | Use case |
|---|---|---|
staticscope_github_api_url | string $url: https://api.github.com | Point the API at GitHub Enterprise Server, such as https://github.example.com/api/v3. |
staticscope_github_git_url | string $url: https://github.com | Point links such as the token page and repository URLs at the same host. |
staticscope_github_publish_capability | string $capability: publish_pages | Change who can publish. Setting the add-on up still needs manage_options. The value is also fed into core’s staticscope_publish_capability. |
staticscope_github_keep_paths | string[] $paths: the built-in keep list | Files already in the repository that are kept rather than deleted. A trailing slash means a folder. Defaults include .github/, CNAME, _headers, _redirects, netlify.toml, vercel.json and the Wrangler configs. |
staticscope_github_patch_wrangler | bool $patch: true | Return false to stop the add-on rewriting a Wrangler config when publishing to a Cloudflare environment. |
staticscope_github_published | array $environment, array $result, string $trigger | After a successful publish. The trigger is manual, scheduled, staticscope or cli. Purge a CDN or notify a channel. |
add_filter( 'staticscope_github_keep_paths', function ( array $paths ) {
$paths[] = 'static.json';
return $paths;
} );
add_action( 'staticscope_github_published', function ( array $environment, array $result, string $trigger ) {
if ( $result['unchanged'] ) {
return;
}
my_cdn_purge( $environment['name'] );
}, 10, 3 );
staticscope_github_published only fires when the publish succeeded. Use staticscope_publish_failed for the other branch. Check $result['unchanged'] before purging a cache: a publish with no file changes still reports success, and a purge for nothing costs money on some providers. The trigger value is useful for skipping work on a scheduled publish when a person is not waiting for it.
Undocumented filter. staticscope_github_patch_wrangler is in the source at src/Publishing/RepositoryPush.php but is not in the add-on’s readme. It only matters for Cloudflare publishes where the environment has a wrangler.jsonc, wrangler.json or wrangler.toml. Return false if you manage that file yourself.
S3
Three filters, all applied per file before upload. They control what S3 stores rather than what the build contains. File paths are relative to wp-content/plugins/staticscope-addon-s3/.
| Hook | Signature | Use case |
|---|---|---|
staticscope_s3_content_type | string $content_type, string $path | Override the guessed type. Defaults to application/octet-stream when the extension is unknown. Use it for fonts or unusual media. |
staticscope_s3_cache_control | string $cache_control, string $path | Defaults to public, max-age=0, must-revalidate for HTML and public, max-age=3600 for everything else. |
staticscope_s3_multipart_threshold | int $threshold: 67108864 (64 MB) | When a file switches to a multipart upload. Lower it for tests; leave it alone on a real site. |
add_filter( 'staticscope_s3_content_type', function ( string $type, string $path ) {
return str_ends_with( $path, '.woff2' ) ? 'font/woff2' : $type;
}, 10, 2 );
add_filter( 'staticscope_s3_cache_control', function ( string $cache, string $path ) {
return str_ends_with( $path, '.css' ) ? 'public, max-age=31536000, immutable' : $cache;
}, 10, 2 );
The immutable header is only safe for files whose name changes when the content changes. If your CSS keeps a fixed name, a year-long cache will serve the old file after a deploy.
These filters set object metadata at upload time. They do not change a CDN’s cache policy, and they do not apply to objects that were already there unless the file is uploaded again. If you front the bucket with CloudFront, set the cache policy there as well. The multipart threshold is checked per file, so one large video can upload in parts while everything around it goes in a single request.
Pagefind
Pagefind has one filter. It receives the CSS selectors excluded from the index immediately before indexing runs. Add selectors for anything that would pollute search results: adverts, cookie banners, repeated calls to action.
add_filter( 'staticscope_pagefind_exclude_selectors', function ( array $selectors ) {
$selectors[] = '.advert';
$selectors[] = '.cookie-banner';
return $selectors;
} );
The add-on runs Pagefind at staticscope_post_process_complete and tells the site check that the index folder is allowed to exist through staticscope_runtime_paths. Excluding a selector only affects the index, not the HTML that ships.
Your server
One filter: staticscope_server_transport. It receives the current transport, which is null for the built-in SSH client, and the saved settings. Return an object implementing StaticScopeServer\Ssh\Transport to swap the implementation. The add-on’s own end-to-end tests use it to talk to a local SFTP server.
The filter only applies to the saved settings, so a transport you return is used for every upload and every connection test from that screen. Keep it stateless or read what you need from $settings.
This is an escape hatch for a host with unusual SSH behaviour, or for routing through a proxy. If you only need a different port or key, use the add-on’s settings screen instead.