Action uncanny-automator

automator_after_classes_init

Fires after all Automator core classes have been initialized, allowing for late modifications.

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

Description

Fires after core Automator classes have been defined but before they are instantiated. Developers can use this hook to hook into the class loading process, potentially adding custom class mappings or performing actions after core classes are ready.


Usage

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

Examples

add_action( 'automator_after_classes_init', 'my_automator_custom_class_loading', 10, 1 );

/**
 * Custom function to dynamically load an additional Automator class after core classes are initialized.
 *
 * This example demonstrates how to hook into 'automator_after_classes_init' to include
 * a custom class file that might be needed for specific automation workflows.
 *
 * @param array $classes An array of class file paths that have been initialized.
 * @return array Modified array of class file paths.
 */
function my_automator_custom_class_loading( $classes ) {
    // Assuming 'my-custom-automator-dir' is a directory within your WordPress plugins or theme
    // where you've placed your custom Automator class file.
    $custom_class_path = plugin_dir_path( __FILE__ ) . 'includes/automator/class-my-custom-automation-handler.php';

    // Check if the custom class file exists before trying to include it.
    if ( file_exists( $custom_class_path ) ) {
        // Add our custom class to the list of classes that Automator will manage.
        // The key 'My_Custom_Automation_Handler' should match the actual class name.
        $classes['My_Custom_Automation_Handler'] = $custom_class_path;
        error_log( 'My Automator Custom Class loaded: ' . $custom_class_path );
    } else {
        error_log( 'My Automator Custom Class not found at: ' . $custom_class_path );
    }

    // It's good practice to return the modified array, even though the hook is an action.
    // This allows for potential future modifications or chaining of similar hooks.
    return $classes;
}

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:682

public function admin_only_classes( $classes = array() ) {
		/**
		 * Admin.
		 */
		if ( ! self::$is_admin_sect && ! Automator()->helpers->recipe->is_automator_ajax() ) {
			return $classes;
		}

		do_action( 'automator_before_admin_init' );

		$classes['Admin_Menu']                     = UA_ABSPATH . 'src/core/admin/class-admin-menu.php';
		$classes['Prune_Logs']                     = UA_ABSPATH . 'src/core/admin/class-prune-logs.php';
		$classes['Admin_Logs']                     = UA_ABSPATH . 'src/core/admin/admin-logs/admin-logs.php';
		$classes['Admin_Tools']                    = UA_ABSPATH . 'src/core/admin/admin-tools/admin-tools.php';
		$classes['Admin_Settings']                 = UA_ABSPATH . 'src/core/admin/admin-settings/admin-settings.php';
		$classes['Pro_Upsell']                     = UA_ABSPATH . 'src/core/admin/pro-upgrade/class-pro-upsell.php';
		$classes['Addons']                         = UA_ABSPATH . 'src/core/admin/addons/class-addons.php';
		$classes['Automator_Review']               = UA_ABSPATH . 'src/core/admin/class-automator-review.php';
		$classes['Automator_Notifications']        = UA_ABSPATH . 'src/core/admin/notifications/notifications.php';
		$classes['Automator_Tooltip_Notification'] = UA_ABSPATH . 'src/core/admin/tooltip-notification/class-tooltip-notification.php';
		$classes['Automator_Tooltip_48hr']         = UA_ABSPATH . 'src/core/admin/tooltip-notification/tooltips/class-create-recipe-reminder.php';
		$classes['Admin_Template_Library']         = UA_ABSPATH . 'src/core/admin/class-admin-template-library.php';

		$classes['Api_Log'] = UA_ABSPATH . 'src/core/admin/api-log/class-api-log.php';

		$classes['Add_User_Recipe_Type'] = UA_ABSPATH . 'src/core/classes/class-add-user-recipe-type.php';
		if ( ! defined( 'AUTOMATOR_PRO_FILE' ) ) {
			$classes['Add_Anon_Recipe_Type'] = UA_ABSPATH . 'src/core/anon/class-add-anon-recipe-type.php';
		}
		do_action( 'automator_after_admin_init' );

		/**
		 * Automator Custom Post Types.
		 */
		//$classes = $this->custom_post_types_classes( $classes );

		/**
		 * Activity Stream / Logs.
		 */
		$classes = $this->activity_stream_classes( $classes );

		/**
		 * Classes.
		 */
		do_action( 'automator_before_classes_init' );

		$classes['Populate_From_Query'] = UA_ABSPATH . 'src/core/classes/class-populate-from-query.php';

		do_action( 'automator_after_classes_init' );

		return $classes;
	}


Scroll to Top