Action
uncanny-automator
automator_after_automator_post_types_init
Fires after the Automator plugin has initialized its custom post types.
add_action( 'automator_after_automator_post_types_init', $callback, 10, 1 );
Description
Fires after Automator's custom post types (Recipes, Triggers, Actions) are initialized. Developers can use this hook to programmatically register additional post types, modify existing ones, or perform actions related to these core components after they've been set up.
Usage
add_action( 'automator_after_automator_post_types_init', 'your_function_name', 10, 1 );
Examples
<?php
/**
* Example function to hook into automator_after_automator_post_types_init.
* This function demonstrates how to potentially interact with or modify
* the loaded post type classes after they have been initialized by the Automator plugin.
* In a real-world scenario, you might use this to:
* - Register custom meta boxes for specific post types.
* - Modify the behavior of existing post type classes.
* - Log information about the initialized post types.
*
* For demonstration purposes, this example will simply log the names of the
* post type classes that have been loaded.
*/
function my_automator_post_types_initialized_handler( $loaded_classes ) {
// Check if $loaded_classes is an array and not empty.
if ( is_array( $loaded_classes ) && ! empty( $loaded_classes ) ) {
// Log the names of the post type classes that were just initialized.
error_log( 'Automator post types initialization complete. Loaded classes: ' . implode( ', ', array_keys( $loaded_classes ) ) );
// Example: If you wanted to conditionally load or modify something based on a specific class.
// For instance, if 'Triggers_Post_Type' class exists and you need to add a custom action to it.
if ( isset( $loaded_classes['Triggers_Post_Type'] ) ) {
// In a real scenario, you would likely instantiate the class and call a method,
// or perhaps directly hook into methods of that class if it supports it.
// Example: Maybe the Triggers_Post_Type class has a method to register custom trigger types.
// If Triggers_Post_Type has a public method `register_custom_trigger_type()`
// You would need to ensure the class is properly loaded and instantiated first.
// Assuming $loaded_classes['Triggers_Post_Type'] contains the path to the class file.
// require_once $loaded_classes['Triggers_Post_Type'];
// $trigger_instance = new Triggers_Post_Type();
// $trigger_instance->register_custom_trigger_type( 'my_custom_trigger' );
error_log( 'Detected Triggers_Post_Type. Further custom trigger registration could occur here.' );
}
} else {
error_log( 'Automator post types initialization detected, but no classes were provided.' );
}
}
// Add the action hook.
// The 'automator_after_automator_post_types_init' hook typically receives an array of loaded class paths.
// We accept 1 argument, which is the array of $classes.
add_action( 'automator_after_automator_post_types_init', 'my_automator_post_types_initialized_handler', 10, 1 );
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:704
public function custom_post_types_classes( $classes = array() ) {
do_action( 'automator_before_automator_post_types_init' );
$classes['Recipe_Post_Type'] = UA_ABSPATH . 'src/core/automator-post-types/uo-recipe/class-recipe-post-type.php';
$classes['Recipe_Post_Metabox'] = UA_ABSPATH . 'src/core/automator-post-types/uo-recipe/class-recipe-post-metabox.php';
$classes['Recipe_Post_Utilities'] = UA_ABSPATH . 'src/core/automator-post-types/uo-recipe/class-recipe-post-utilities.php';
$classes['Triggers_Post_Type'] = UA_ABSPATH . 'src/core/automator-post-types/uo-trigger/class-triggers-post-type.php';
$classes['Actions_Post_Type'] = UA_ABSPATH . 'src/core/automator-post-types/uo-action/class-actions-post-type.php';
$classes['Closures_Post_Type'] = UA_ABSPATH . 'src/core/automator-post-types/uo-closure/class-closures-post-type.php';
$classes['Automator_Taxonomies'] = UA_ABSPATH . 'src/core/automator-post-types/uo-taxonomies/class-automator-taxonomies.php';
do_action( 'automator_after_automator_post_types_init' );
return $classes;
}