Action Since 7.2 uncanny-automator

automator_addon_registered

Fires after an addon has been registered with the loading pipeline. Fires after an addon is successfully registered with the loading pipeline, providing its configuration.

add_action( 'automator_addon_registered', $callback, 10, 1 );

Description

Fires after an add-on is successfully registered and added to the core loading pipeline. Developers can hook into this action to perform tasks that require knowledge of registered add-ons, such as initializing add-on specific functionalities or modifying their configurations before they are fully loaded.


Usage

add_action( 'automator_addon_registered', 'your_function_name', 10, 1 );

Parameters

$config (array)
The addon configuration.

Examples

add_action( 'automator_addon_registered', 'my_custom_automator_addon_handler', 10, 1 );

/**
 * Logs the details of a newly registered Automator addon.
 *
 * This function demonstrates how to hook into the 'automator_addon_registered'
 * action to perform custom logic when an addon is loaded by the Automator plugin.
 * In this example, we'll simply log the addon's configuration to the WordPress
 * debug log.
 *
 * @param array $config The addon configuration array.
 */
function my_custom_automator_addon_handler( $config ) {
    // Ensure WP_DEBUG and WP_DEBUG_LOG are enabled for this to appear in the log.
    if ( defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
        error_log( 'Automator Addon Registered: ' . print_r( $config, true ) );
    }

    // You could also perform other actions here, like:
    // - Storing addon-specific settings in the WordPress options table.
    // - Registering custom post types or taxonomies related to the addon.
    // - Enqueuing scripts or styles if the addon requires them.

    // Since this is an action hook and not a filter, no return value is strictly necessary.
    // However, if you were to modify data, you would do it before this point.
}

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/core/integration-loader/class-addon-registry.php:105

public function register( array $config ) {

		$config = wp_parse_args(
			$config,
			array(
				'integrations_path' => '',
				'namespace'         => '',
				'integrations'      => array(),
				'item_map_file'     => '',
				'filemap_file'      => '',
			)
		);

		if ( empty( $config['integrations'] ) || empty( $config['namespace'] ) ) {
			return false;
		}

		$this->merge_integrations( $config['integrations'], $config['integrations_path'], $config['namespace'] );

		// Hook the item map BEFORE loading framework integrations so that
		// addon constructors calling get_item_map() see the merged map.
		$this->hook_item_map( $config['item_map_file'] );
		Recipe_Manifest::get_instance()->invalidate_item_map();

		$this->load_framework_integrations( $config['filemap_file'] );

		/**
		 * Fires after an addon has been registered with the loading pipeline.
		 *
		 * @since 7.2
		 *
		 * @param array $config The addon configuration.
		 */
		do_action( 'automator_addon_registered', $config );

		return true;
	}

Scroll to Top