Actions Reference
Every action hook in the plugin, with when it fires.
On this page
- Lifecycle
- hydrogen_seo_activated
- hydrogen_seo_deactivated
- hydrogen_seo_modules_loaded
- Frontend output
- hydrogen_seo_print_meta
- hydrogen_seo_print_schemas
- Metabox saves
- hydrogen_seo_metabox_save_post
- hydrogen_seo_metabox_save_term
- hydrogen_seo_metabox_post_data_saved
- hydrogen_seo_metabox_term_data_saved
- REST
- hydrogen_seo_register_rest_routes
- Module initialization
- hydrogen_seo_metabox_init
- hydrogen_seo_schema_markup_init
- hydrogen_seo_seo_analysis_init
- hydrogen_seo_rank_analysis_init
- Schema events
- hydrogen_seo_schema_error
- Daily tasks
- hydrogen_seo_before_daily_tasks
- hydrogen_seo_after_daily_tasks
- hydrogen_seo_cleanup_old_data
- Sitemap events
- hydrogen_seo_sitemap_cache_cleared
- Robots and llms.txt events
- hydrogen_seo_robots_editor_updated
- hydrogen_seo_robots_editor_reset
- hydrogen_seo_robots_editor_validation_warning
- hydrogen_seo_llms_txt_updated
- hydrogen_seo_llms_txt_reset
- Related reading
This is the complete reference for every public action hook in the Hydrogen SEO WordPress plugin (Beta). Actions fire at meaningful moments — activation, frontend output, metabox saves, REST registration, module boot, daily maintenance — so your code can react without modifying the plugin. Every hook name and signature below was verified against the plugin source. If you want to change values rather than react to events, you need the Filters Reference instead.
When an action passes arguments, remember to declare the argument count as the fourth parameter of add_action().
Lifecycle
hydrogen_seo_activated
Fires once when the plugin is activated, after activation routines complete. No arguments.
add_action( 'hydrogen_seo_activated', function () {
error_log( 'Hydrogen SEO activated on ' . home_url() );
} );
hydrogen_seo_deactivated
Fires when the plugin is deactivated. No arguments. Use it to clean up anything your integration created.
add_action( 'hydrogen_seo_deactivated', function () {
wp_clear_scheduled_hook( 'my_hydrogen_companion_cron' );
} );
hydrogen_seo_modules_loaded
Fires after the module loader has instantiated all enabled modules. One argument: $modules (array of loaded module instances keyed by module ID). This is the safest point to interact with Hydrogen SEO internals, because you know every module exists.
add_action( 'hydrogen_seo_modules_loaded', function ( $modules ) {
if ( isset( $modules['sitemap'] ) ) {
// The sitemap module is active — safe to wire up sitemap integrations.
}
}, 10, 1 );
Frontend output
Hydrogen SEO prints all of its head output server-side from a single wp_head callback (there is no front-end JavaScript). Inside that block it fires two actions.
hydrogen_seo_print_meta
Fires inside the Hydrogen SEO output block in <head>, where the title, description, robots, canonical and social tags print. No arguments. Anything you echo here lands inside the plugin's commented output section.
// Add a custom verification tag inside the Hydrogen SEO head block.
add_action( 'hydrogen_seo_print_meta', function () {
echo '<meta name="my-verification" content="abc123" />' . "\n";
}, 20 );
The plugin's own components (description, robots, Open Graph and so on) attach to this hook at priority 10, so use a higher priority number to print after them.
hydrogen_seo_print_schemas
Fires immediately after hydrogen_seo_print_meta, where JSON-LD schema blocks are printed. No arguments. To modify schema data rather than print extra markup, prefer the hydrogen_seo_schemas or hydrogen_seo_schema_markup filters (see schema markup overview).
Metabox saves
Two families of hooks exist. The classic save_* pair fires during WordPress saves after the plugin's nonce, autosave and capability checks pass. The *_data_saved pair fires after SEO data has actually been written through the plugin's REST API (or by Hydrogen AI's abilities) — in practice the editor saves via REST, so these are usually the ones you want.
hydrogen_seo_metabox_save_post
Fires during save_post once Hydrogen SEO's nonce, autosave and permission checks pass. Arguments: $post_id (int), $post (WP_Post).
hydrogen_seo_metabox_save_term
Fires when a term with SEO fields is created or edited, after checks pass. Arguments: $term_id (int), $taxonomy (string).
hydrogen_seo_metabox_post_data_saved
Fires after per-post SEO data has been persisted via the REST API or an AI ability. Arguments: $object_id (int), $data (array — the saved SEO fields).
// Bust an external cache whenever a post's SEO data changes.
add_action( 'hydrogen_seo_metabox_post_data_saved', function ( $post_id, $data ) {
if ( function_exists( 'my_cdn_purge' ) ) {
my_cdn_purge( get_permalink( $post_id ) );
}
}, 10, 2 );
hydrogen_seo_metabox_term_data_saved
The term equivalent. Arguments: $term_id (int), $data (array).
REST
hydrogen_seo_register_rest_routes
Fires while the plugin registers its REST routes, so your code can add endpoints under the same namespace. One argument: $namespace (string — hydrogen-seo/v1). See The Plugin REST API for the full route catalogue.
add_action( 'hydrogen_seo_register_rest_routes', function ( $namespace ) {
register_rest_route( $namespace, '/my-integration/status', [
'methods' => 'GET',
'callback' => function () {
return rest_ensure_response( [ 'ok' => true ] );
},
'permission_callback' => function () {
return current_user_can( 'manage_options' );
},
] );
}, 10, 1 );
Module initialization
Each of these fires when its module boots, with no arguments. They are useful for conditionally wiring code that should only run when a specific feature is active.
hydrogen_seo_metabox_init
Fires when the metabox module initializes.
hydrogen_seo_schema_markup_init
Fires when the schema markup module initializes.
hydrogen_seo_seo_analysis_init
Fires when the on-page SEO analysis module initializes — see on-page SEO analysis.
hydrogen_seo_rank_analysis_init
Fires when the rank analysis module initializes.
add_action( 'hydrogen_seo_schema_markup_init', function () {
// Schema module is live: safe to register schema-related filters.
add_filter( 'hydrogen_seo_schema_markup_post_types', function ( $types ) {
$types[] = 'event';
return $types;
} );
} );
Schema events
hydrogen_seo_schema_error
Fires when schema generation or validation hits a problem on the frontend. Arguments: $schema_type (string), $message (string), $context (mixed — additional error context).
add_action( 'hydrogen_seo_schema_error', function ( $schema_type, $message, $context ) {
error_log( sprintf( '[Hydrogen SEO] %s schema error: %s', $schema_type, $message ) );
}, 10, 3 );
Daily tasks
The plugin schedules a daily cron for maintenance and brackets it with hooks, so you can piggyback your own scheduled work without registering a separate cron event.
hydrogen_seo_before_daily_tasks
Fires before the plugin's daily maintenance runs. No arguments.
hydrogen_seo_after_daily_tasks
Fires after daily maintenance completes. No arguments.
// Run your own housekeeping right after Hydrogen SEO's daily tasks.
add_action( 'hydrogen_seo_after_daily_tasks', function () {
delete_transient( 'my_seo_report_cache' );
} );
hydrogen_seo_cleanup_old_data
Fires during the daily cleanup phase, as an extension point for removing your own stale data. No arguments.
Sitemap events
hydrogen_seo_sitemap_cache_cleared
Fires whenever the sitemap cache is cleared (from the dashboard or the REST endpoint). No arguments. Useful for pinging downstream systems that mirror your XML sitemaps.
add_action( 'hydrogen_seo_sitemap_cache_cleared', function () {
error_log( 'Hydrogen SEO sitemap cache cleared at ' . gmdate( 'c' ) );
} );
Robots and llms.txt events
hydrogen_seo_robots_editor_updated
Fires after custom robots.txt content is saved from the robots.txt editor. One argument: $content (string — the sanitized content).
hydrogen_seo_robots_editor_reset
Fires after the robots.txt editor content is reset to defaults. No arguments.
hydrogen_seo_robots_editor_validation_warning
Fires when the editor's validation detects a non-fatal issue, such as content without a User-agent line. One argument: a warning code (string, for example missing_user_agent).
add_action( 'hydrogen_seo_robots_editor_validation_warning', function ( $code ) {
error_log( 'robots.txt validation warning: ' . $code );
} );
hydrogen_seo_llms_txt_updated
Fires after llms.txt content is saved from the llms.txt editor. One argument: $content (string).
hydrogen_seo_llms_txt_reset
Fires after llms.txt content is reset to the default. No arguments.
// Keep an audit trail of llms.txt changes.
add_action( 'hydrogen_seo_llms_txt_updated', function ( $content ) {
update_option( 'my_llms_txt_last_changed', [
'time' => time(),
'hash' => md5( $content ),
] );
} );