Action uncanny-automator

automator_after_traits

Fires after traits have been processed and their logic has been executed within the Automator integration.

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

Description

Fires after all core Automator traits are loaded and available. Developers can use this hook to register custom Automator traits, modify existing trait behavior, or perform actions that depend on the availability of Automator's core functionalities. Ensure your callback function is loaded after Automator's core classes.


Usage

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

Examples

<?php
/**
 * Example function to hook into 'automator_after_traits'.
 * This example demonstrates how you might register a new Automator recipe type
 * after all core traits have been loaded, ensuring all necessary dependencies are available.
 *
 * @since 1.0.0
 */
function my_automator_register_custom_recipe_type() {
	// Assume a custom class exists for our new recipe type.
	// This check ensures that the class is available, which is likely the point
	// of hooking after traits are loaded.
	if ( class_exists( 'My_Custom_Automator_Recipe' ) ) {
		// Register the custom recipe type using a hypothetical Automator API function.
		// This function would likely take the recipe type class name as an argument.
		automator_register_recipe_type( 'my_custom_recipe', 'My_Custom_Automator_Recipe' );

		// You could also potentially add settings or other configurations here
		// that depend on the loaded traits.
		// For example:
		// automator_add_recipe_setting( 'my_custom_recipe', 'enable_feature_x', true );
	}
}
add_action( 'automator_after_traits', 'my_automator_register_custom_recipe_type', 10, 0 ); // 10 is the default priority, 0 is the number of accepted arguments.

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/class-automator-load.php:865

public function load_traits() {
		// All trait, abstract, and helper files under src/core/lib/recipe-parts/ and
		// src/core/lib/settings/ are covered by the "classmap": ["src/"] entry in
		// composer.json. Composer loads each file on first use — no require_once needed.
		do_action( 'automator_before_traits' );
		do_action( 'automator_after_traits' );
	}


Scroll to Top