Skip to content
StaticScope
Overview
Get StaticScope

Core actions

Every action StaticScope core fires, grouped by build stage, with its arguments and examples.

Developers Updated 21 November 2026 7 min read

Core has 21 actions. They tell you that something is about to happen or has happened. None of them expect a return value. If you need to change data rather than react to it, use a filter from the core filters reference.

Arguments below are the ones from the call sites. Where a hook takes two arguments, declare 10, 2 on your callback or you will only receive the first. The same action can fire from three places: an admin request when you press a button, a background job on a schedule, or a WP-CLI command. The arguments do not change, but the surrounding state does. An admin request has a current user; a cron run does not. Do not assume wp_get_current_user() returns anyone useful in a callback that also runs from the queue.

Detection and crawl

HookWhen it runsArguments
staticscope_detectAt the start of URL detection, before any page, file or sitemap is found.None.
staticscope_crawlAfter detection, when the site is copied. The core crawler is attached to this hook.$static_site_path (string), $crawler_slug (string).

staticscope_detect is for preparing state or warming a cache. Adding URLs here does nothing. Use staticscope_modify_initial_crawl_list for that.

staticscope_crawl is how a replacement crawler gets in. The core crawler checks the slug and returns early when it is not staticscope, so an add-on can copy the site its own way. The slug is how StaticScope tells the built-in crawler apart from an add-on’s; a crawler add-on registers itself with the crawl type on the Add-ons screen and receives its slug here. Most sites never touch this.

Crawl finished

HookWhen it runsArguments
staticscope_crawling_completeAt the end of the crawl, after unused files are pruned and the 404 page is saved.$summary (array) with staticSitePath, crawled and cache_hits.

The count is files copied, not pages found. A cache hit is a page that was unchanged since the last crawl and was reused. This is the right place to log crawl cost per run. Hit counts are only meaningful when crawl caching is on, which staticscope_use_crawl_cache controls; with caching off every run reports zero.

Preparation

HookWhen it runsArguments
staticscope_post_process_startBefore the prepared folder is emptied and the copied files are processed.$static_site_path (string), the copied site.

RobotsTxt uses this to add a missing robots.txt to the copy, and publishing add-ons use it to change the destination address. Changes here affect the copy, so they flow into every prepared file.

Per-file processing

HookWhen it runsArguments
staticscope_process_robots_txtAs the prepared robots.txt is processed.$filename (string).
staticscope_process_htmlAs each HTML file is processed, before staticscope_process_html_complete.$filename (string).
staticscope_process_html_completeImmediately after staticscope_process_html for the same file.$filename (string).
staticscope_process_cssAs each CSS file is processed.$filename (string).
staticscope_process_jsAs each JS file is processed.$filename (string).
staticscope_process_xmlAs each XML file is processed, including sitemaps and feeds.$filename (string).
staticscope_process_xslAs each XSL file is processed.$filename (string).
staticscope_process_jsonAs each JSON or .webmanifest file is processed.$filename (string).

Each one passes the path to the file in the prepared folder, not the copy. Read it, change it, write it back. The HTML pair is useful when you need to see the result of another callback on staticscope_process_html: Forms protects its markup at priority 5 and restores it at 20.

The prepared folder is rebuilt for every run, so an edit here lasts for one build. The next build starts from a fresh copy of WordPress rather than last week’s patched HTML. Write to the path you are given and do not cache file contents between runs.

An exception from a per-file action aborts preparation and the build is marked failed. If the work might fail, catch the error and log it rather than throwing, unless a bad file should stop the release.

Finished site

HookWhen it runsArguments
staticscope_post_process_completeAfter every file has been copied and processed.$directory (string), with no trailing slash.

This is the broadest extension point before the site check and publishing. It is where you add a version.txt, patch a generated file, or fail the build when something is missing. The built-in listeners have already run in a fixed order, so pick a priority with that in mind. Anything you add is included in the site check, so a file nothing references also needs a staticscope_runtime_paths entry.

Build and publish

HookWhen it runsArguments
staticscope_before_buildBefore a build started from the Overview screen. Core calls it with build or all.$steps (string): build, publish or all.
staticscope_before_publishBefore an existing build is published from the Overview, and immediately before GitHub, S3 and Your server upload.$steps (string).
staticscope_deployWhen the site is published, from the queue, the Overview or WP-CLI.$processed_site_path (string), $deployer (string).
staticscope_post_deploy_triggerAfter publishing, for notifications and follow-up.$deployer (string); optional $details (array).
staticscope_publish_failedWhen a queued stage fails with nobody watching, such as a scheduled job.$message (string).

staticscope_before_build and staticscope_before_publish both run inside a try block. Throw an exception and its message is shown in the Overview and written to the Activity log. That is the supported way to refuse a build or a publish.

$steps is the button the editor pressed: build, publish or all. Core never passes publish to staticscope_before_build, because that path does not build. It does pass all, which means build and then publish. Use the value to tell a preview from a release when that changes what you check.

The deployer slug comes from the type => deploy entry an add-on registers on staticscope_addons. Only the chosen publisher should act, which is why every official add-on checks the slug before doing anything.

The second argument is conditional. staticscope_post_deploy_trigger declares an optional $details array with summary and addresses. Core does not pass it; GitHub does. Give your callback a default value or it will fail when core fires the hook.

Settings saves

HookWhen it runsArguments
staticscope_addon_ui_save_optionsAfter the core Settings screen is saved, except during AJAX.None.
staticscope_addon_ui_save_job_optionsAfter the Background jobs screen is saved.None.
staticscope_addon_ui_save_advanced_optionsAfter the Advanced screen is saved.None.

They fire from Settings::afterUpdate() when the settings option changes, which is normally a form save through options.php. Capability and nonce checks have already happened by then, so your callback only needs to sanitise and store its own fields.

All three are skipped during AJAX, because the guard sits before the screen check. If your add-on saves its fields with its own request to admin-ajax.php, save in that handler instead.

Examples

Stop a build with a precondition

add_action( 'staticscope_before_build', function ( string $steps ) {
	if ( get_option( 'my_content_frozen' ) ) {
		throw new RuntimeException( 'Content is frozen. Unfreeze it before building.' );
	}
}, 10, 1 );

The message is what the editor sees. Keep it actionable. This fires for Overview builds only; a wp staticscope crawl runs the stage directly.

Add a file to the finished site

add_action( 'staticscope_post_process_complete', function ( string $dir ) {
	$stamp = gmdate( 'c' ) . ' ' . wp_get_environment_type();
	file_put_contents( $dir . '/build.txt', $stamp . PHP_EOL );
}, 30 );

Priority 30 puts this after the built-in listeners, including DeadLinks at 20. The site check still runs afterwards, so a file nothing references needs a staticscope_runtime_paths entry as well. Remember the path has no trailing slash.

React to a publish

add_action( 'staticscope_deploy', function ( string $path, string $deployer ) {
	if ( $deployer !== 'my-host' ) {
		return;
	}

	My_Host_Client::sync( $path );
}, 10, 2 );

staticscope_deploy fires for every publisher, so return early unless the slug is yours. Throwing here stops the publish; use priority 9 if the publisher’s own callback must not run first.

Notify after a deploy

add_action( 'staticscope_post_deploy_trigger', function ( string $deployer, array $details = [] ) {
	$addresses = $details['addresses'] ?? [];
	$live      = $addresses['Production'] ?? home_url( '/' );

	wp_remote_post( 'https://hooks.slack.com/services/T000/B000/XXXX', [
		'body' => [ 'text' => 'Published: ' . $live . ' (' . $deployer . ')' ],
	] );
}, 10, 2 );

The default on $details is not decoration. Core calls this hook with one argument, and only GitHub supplies the array with summary and addresses.

Alert on a failed background job

add_action( 'staticscope_publish_failed', function ( string $message ) {
	wp_mail( 'ops@example.com', 'StaticScope failed', $message );
}, 10, 1 );

Despite the name, this fires for any failed queued stage: detection, crawl, preparation or deploy. Core also emails the completion address, so check whether your alert duplicates it.

Save a field on the Settings screen

add_action( 'staticscope_addon_ui_save_options', function () {
	$value = isset( $_POST['my_addon_setting'] )
		? sanitize_text_field( wp_unslash( $_POST['my_addon_setting'] ) )
		: '';

	update_option( 'my_addon_setting', $value );
} );

This runs after options.php has saved the core option, so you do not need to repeat the nonce or capability check. It is skipped during AJAX requests, so do not rely on it for anything other than a form save.

Next