Action
uncanny-automator
automator_before_autoloader
Class autoloader. Fires before the autoloader is initialized, allowing modifications to class loading behavior.
add_action( 'automator_before_autoloader', $callback, 10, 1 );
Description
Fires before the Automator class autoloader registers core classes. Developers can use this hook to add custom class mappings or modify the default autoloader configuration before essential Automator classes are loaded.
Usage
add_action( 'automator_before_autoloader', 'your_function_name', 10, 1 );
Examples
/**
* Example: Add custom logging before the main Automator autoloader runs.
*
* This hook is useful for performing actions or modifications just before
* the plugin's core classes are registered with the autoloader.
*/
add_action( 'automator_before_autoloader', 'my_custom_automator_logging', 10, 0 );
/**
* Logs a message indicating that the Automator autoloader is about to start.
*
* This function demonstrates how to hook into `automator_before_autoloader`
* to perform custom actions.
*
* @since 1.0.0
*/
function my_custom_automator_logging() {
// In a real-world scenario, you might want to log this to a file or
// a custom database table for debugging purposes.
error_log( 'Automator autoloader is about to be initialized.' );
// You could also potentially modify the $classes array if this hook allowed it,
// but this specific hook is designed for actions, not filters that modify the array.
// If you needed to modify the classes, you would look for a filter hook that
// exposes the $classes array for modification.
}
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:751
public function global_classes( $classes = array() ) {
/**
* Class autoloader.
*/
do_action( 'automator_before_autoloader' );
// Webhooks
$classes['Automator_Send_Webhook_Ajax_Handler'] = UA_ABSPATH . 'src/core/lib/webhooks/class-automator-send-webhook-ajax-handler.php';
$classes['Recipe_Post_Rest_Api'] = UA_ABSPATH . 'src/core/automator-post-types/uo-recipe/class-recipe-post-rest-api.php';
$classes['Background_Actions'] = UA_ABSPATH . 'src/core/classes/class-background-actions.php';
$classes['Calculation_Token'] = UA_ABSPATH . 'src/core/classes/class-calculation-token.php';
$classes['Copy_Recipe_Parts'] = UA_ABSPATH . 'src/core/admin/class-copy-recipe-parts.php';
$classes['Export_Recipe'] = UA_ABSPATH . 'src/core/admin/class-export-recipe.php';
$classes['Import_Recipe'] = UA_ABSPATH . 'src/core/admin/class-import-recipe.php';
$classes['Pricing_Plan_Resolver'] = UA_ABSPATH . 'src/core/admin/class-pricing-plan-resolver.php';
// Load migrations
$this->load_migrations();
// Load migrations that uses hooks.
$this->load_migrations_hooks();
// Only initialize classes if there're any active recipes OR if user is editing recipe
$classes = $this->maybe_initialize_automator( $classes );
do_action( 'automator_after_autoloader' );
return $classes;
}