Hooks Filters

Supercharger exposes WordPress action hooks and filters that allow developers to customize its behavior without modifying plugin files.

Filters

supercharger_indexable_post_types

Modifies the list of post types that Supercharger will index and process.

Parameters:

  • $post_types _(array)_ — Array of post type slugs.

Example — Add a custom post type:

php
add_filter( 'supercharger_indexable_post_types', function( $post_types ) {
  $post_types[] = 'my_custom_type';
  return $post_types;
} );

supercharger_recommendations_query_results

Filters the list of posts returned by a semantic recommendations query before they are displayed.

Parameters:

  • $posts _(array)_ — Array of WP_Post objects or post IDs.
  • $current_post_id _(int)_ — The ID of the post being viewed.

Example — Exclude posts from a specific category:

php
add_filter( 'supercharger_recommendations_query_results', function( $posts, $current_post_id ) {
  return array_filter( $posts, function( $post ) {
    return ! has_term( 'sponsored', 'category', $post );
  } );
}, 10, 2 );

supercharger_available_style_presets

Modifies the available style presets for modules that support preset-based styling (e.g., Quote Puller).

Parameters:

  • $presets _(array)_ — Associative array of preset slug => label.

Example — Add a custom preset:

php
add_filter( 'supercharger_available_style_presets', function( $presets ) {
  $presets['my_brand'] = 'My Brand Style';
  return $presets;
} );

supercharger_module_setting_value

Filters the value of any module setting before it is used. Allows dynamic override of module configuration.

Parameters:

  • $value _(mixed)_ — The current setting value.
  • $setting_name _(string)_ — The setting key.
  • $module_slug _(string)_ — The slug of the module.

Example — Force recommendations limit to 3 for a specific post type:

php
add_filter( 'supercharger_module_setting_value', function( $value, $setting_name, $module_slug ) {
  if ( $module_slug === 'ai-recommendations' && $setting_name === 'default_limit' && is_singular( 'page' ) ) {
    return 3;
  }
  return $value;
}, 10, 3 );

Actions

supercharger_plugin_initialized

Fired after all Supercharger core components (database, settings, modules, REST API) have been initialized.

Example:

php
add_action( 'supercharger_plugin_initialized', function() {
  // Supercharger is fully loaded. Safe to access its APIs.
} );

supercharger_settings_saved

Fired after plugin settings are successfully saved via the REST API.

Parameters:

  • $new_settings _(array)_ — The updated settings array.

Example:

php
add_action( 'supercharger_settings_saved', function( $new_settings ) {
  // React to settings changes, e.g., flush caches.
} );

supercharger_modules_loading

Fired before modules are instantiated. Use this to register custom modules or modify the modules list before they are initialized.

Example:

php
add_action( 'supercharger_modules_loading', function() {
  // Register a custom module here.
} );