Skip to content
StaticScope
Overview
Get StaticScope

Add-on hooks

Hooks from the Forms, GitHub, S3, Pagefind and Your server add-ons, with signatures and real use cases.

Developers Updated 21 November 2026 6 min read

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/.

HookSignatureUse case
staticscope_forms_fieldsarray $fields, keyed by input nameAdd a field or change an existing one. Each field sets label, type, required, autocomplete, maxlength, placeholder, description, always and optionally rows.
staticscope_forms_attributesarray $attributesChange the block attributes at the start of rendering, before labels and provider decoration are read.
staticscope_forms_providerarray $decoration, string $form_name, bool $has_subjectChange the endpoint, hidden values, honeypot or messages. Not called for the editor preview or an unconfigured provider.
staticscope_forms_form_attributesarray $form_attributes, array $attributes, array $providerAdd a data-* attribute, a class or a target to the form tag.
staticscope_forms_hidden_fieldsarray $hidden, array $attributes, array $providerAdd tracking or routing fields as name to value pairs.
staticscope_forms_field_htmlstring $html, string $key, array $field, string $id, bool $labels_hiddenReplace one field’s markup. Called once per field, including the dropdown, from two render sites with the same signature.
staticscope_forms_htmlstring $html, array $attributes, array $providerWrap 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/.

HookSignatureUse case
staticscope_github_api_urlstring $url: https://api.github.comPoint the API at GitHub Enterprise Server, such as https://github.example.com/api/v3.
staticscope_github_git_urlstring $url: https://github.comPoint links such as the token page and repository URLs at the same host.
staticscope_github_publish_capabilitystring $capability: publish_pagesChange 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_pathsstring[] $paths: the built-in keep listFiles 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_wranglerbool $patch: trueReturn false to stop the add-on rewriting a Wrangler config when publishing to a Cloudflare environment.
staticscope_github_publishedarray $environment, array $result, string $triggerAfter 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/.

HookSignatureUse case
staticscope_s3_content_typestring $content_type, string $pathOverride the guessed type. Defaults to application/octet-stream when the extension is unknown. Use it for fonts or unusual media.
staticscope_s3_cache_controlstring $cache_control, string $pathDefaults to public, max-age=0, must-revalidate for HTML and public, max-age=3600 for everything else.
staticscope_s3_multipart_thresholdint $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.

Next