Extension hooks
Use these hooks when you are adding a reusable integration or changing one of Staatic’s extension points. If you only need a conditional crawl or URL rewrite decision, start with URL processing hooks instead.
Add crawl URL providers
staatic_crawl_url_providers
Filters the collection of crawl URL providers used to produce the initial crawl queue.
Use a provider when URLs need to be discovered from custom data, external APIs, plugin records, or another source that does not fit the Additional URLs setting.
Arguments:
| Argument | Type |
|---|---|
$providers |
Staatic\Crawler\CrawlUrlProvider\CrawlUrlProviderCollection |
$publication |
Staatic\WordPress\Publication\Publication |
Example:
use Staatic\Crawler\CrawlUrlProvider\AdditionalUrlCrawlUrlProvider;
use Staatic\Crawler\CrawlUrlProvider\AdditionalUrlCrawlUrlProvider\AdditionalUrl;
use Staatic\Crawler\CrawlUrlProvider\CrawlUrlProviderCollection;
use Staatic\WordPress\Publication\Publication;
add_filter( 'staatic_crawl_url_providers', function ( CrawlUrlProviderCollection $providers, Publication $publication ) {
$providers->addProvider( new AdditionalUrlCrawlUrlProvider(
[ new AdditionalUrl( 'https://www.example.com/special-page/' ) ],
$publication->build()->entryUrl()
) );
return $providers;
}, 10, 2 );
Add transformers
staatic_transformers
Filters the list of result transformers used while publication results are processed.
Transformers operate during result processing. Use them for systematic changes to generated resources, not for one-off URL decisions that can be handled by staatic_should_transform_url.
Arguments:
| Argument | Type |
|---|---|
$transformers |
Staatic\Framework\Transformer\TransformerInterface[] |
$publication |
Staatic\WordPress\Publication\Publication |
Example shape:
add_filter( 'staatic_transformers', function ( array $transformers, $publication ) {
// $transformers[] = new MyCustomTransformer();
return $transformers;
}, 10, 2 );
Add post-processors
staatic_post_processors
Filters the list of post-processors that run after crawling has finished.
Post-processors are a good fit for final build changes such as generated config files, redirects, duplicate cleanup, or deployment-target-specific files.
Arguments:
| Argument | Type |
|---|---|
$postProcessors |
Staatic\Framework\PostProcessor\PostProcessorInterface[] |
$publication |
Staatic\WordPress\Publication\Publication |
Example shape:
add_filter( 'staatic_post_processors', function ( array $postProcessors, $publication ) {
// $postProcessors[] = new MyCustomPostProcessor();
return $postProcessors;
}, 10, 2 );
Register deployment methods
Custom deployment methods usually need three pieces:
For the complete workflow, including settings, validation, strategy lifecycle, preview support, and no-deploy methods, see Custom deployment methods.
| Hook | Purpose |
|---|---|
staatic_deployment_methods |
Adds the method to the Deployment Method setting. |
staatic_deployment_strategy |
Returns the active deploy strategy when the custom method is selected. |
staatic_deployment_strategy_validate |
Returns validation errors that should block publication. |
Preview support can be enabled with staatic_deployment_strategy_supports_preview.
staatic_deployment_methods
Arguments:
| Argument | Type |
|---|---|
$deploymentMethods |
array |
Example:
add_filter( 'staatic_deployment_methods', function ( array $deploymentMethods ) {
$deploymentMethods['custom'] = 'Custom';
return $deploymentMethods;
} );
staatic_deployment_strategy
Arguments:
| Argument | Type |
|---|---|
$deployStrategy |
Staatic\Framework\DeployStrategy\DeployStrategyInterface|null|false |
$publication |
Staatic\WordPress\Publication\Publication |
Return false only when deployment tasks are intentionally inactive. Otherwise return an object implementing Staatic\Framework\DeployStrategy\DeployStrategyInterface for the selected deployment method.
Example shape:
use Staatic\WordPress\Publication\Publication;
add_filter( 'staatic_deployment_strategy', function ( $deployStrategy, Publication $publication ) {
if ( get_option( 'staatic_deployment_method' ) !== 'custom' ) {
return $deployStrategy;
}
// return new MyCustomDeployStrategy( $publication );
return $deployStrategy;
}, 10, 2 );
staatic_deployment_strategy_validate
Arguments:
| Argument | Type |
|---|---|
$errors |
string[] |
$publication |
Staatic\WordPress\Publication\Publication |
Example:
add_filter( 'staatic_deployment_strategy_validate', function ( array $errors, $publication ) {
if ( get_option( 'staatic_deployment_method' ) === 'custom' && ! get_option( 'staatic_custom_token' ) ) {
$errors[] = 'Custom deployment token is missing.';
}
return $errors;
}, 10, 2 );
staatic_deployment_strategy_supports_preview
Arguments:
| Argument | Type |
|---|---|
$supportsPreview |
bool |
Register settings
staatic_settings
Filters the registered settings grouped by setting group name.
Arguments:
| Argument | Type |
|---|---|
$settings |
array<string, Staatic\WordPress\Setting\SettingInterface[]> |
Example shape:
add_filter( 'staatic_settings', function ( array $settings ) {
// $settings['staatic-deployment'][] = new MyCustomSetting();
return $settings;
} );
staatic_setting_groups
Filters the registered settings groups.
Arguments:
| Argument | Type |
|---|---|
$settingGroups |
Staatic\WordPress\SettingGroup\SettingGroup[] |
Deployment-specific helpers
These hooks are most useful when extending or tuning built-in deployment targets.
| Hook | Use it for |
|---|---|
staatic_aws_retain_paths |
Retain remote paths during Amazon S3 or compatible deployments. |
staatic_github_retain_paths |
Retain remote paths during GitHub deployments. |
staatic_filesystem_retain_paths |
Retain local filesystem deployment paths. |
staatic_filesystem_html_as_directories |
Control whether filesystem deployment writes HTML as directories. |
staatic_netlify_config_extra |
Add content to the generated netlify.toml file. |
staatic_meta_redirect_template |
Override the meta refresh redirect template used by applicable deployers. |
Other extension hooks
| Hook | Use it for |
|---|---|
staatic_debug |
Enable Staatic debug mode and more detailed publication logs. |
staatic_compress_resources |
Control compression for the filesystem resource repository. |
staatic_get_template |
Override resolved template paths used by Staatic partial rendering. |
staatic_test_request_enabled |
Enable or disable Staatic’s internal test request. |
staatic_premium |
Override premium feature availability. |
Example debug toggle:
add_filter( 'staatic_debug', '__return_true' );