Action uncanny-automator

automator_after_admin_init

Fires after the WordPress admin initialization process is complete, allowing for last-minute adjustments or custom admin features.

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

Description

Fires after core Automator admin classes are loaded but before custom post types are registered. Use this hook to enqueue scripts, add admin notices, or perform other actions that require the Automator admin environment to be ready.


Usage

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

Examples

<?php
/**
 * Example function hooked into the 'automator_after_admin_init' action.
 * This function demonstrates how to register a new admin menu page
 * or perform other admin-related tasks after the core Automator admin
 * initialization has occurred.
 */
function my_automator_custom_admin_features() {
    // Check if we are in the admin area.
    if ( is_admin() ) {
        // Example: Add a custom settings sub-menu page under the main Automator menu.
        // Assuming Automator has a main menu slug like 'automator'.
        // You would need to know the actual main menu slug used by Automator.
        // For demonstration, let's assume it's 'automator'.
        $parent_slug = 'automator';
        $page_title  = 'My Custom Settings';
        $menu_title  = 'Custom Settings';
        $capability  = 'manage_options'; // The capability required to access this page.
        $menu_slug   = 'my-automator-custom-settings';
        $callback    = 'my_automator_custom_settings_page_callback'; // Function to render the page content.

        add_submenu_page(
            $parent_slug,
            $page_title,
            $menu_title,
            $capability,
            $menu_slug,
            $callback
        );
    }
}
add_action( 'automator_after_admin_init', 'my_automator_custom_admin_features', 10, 0 );

/**
 * Callback function to render the content for the custom admin settings page.
 * This function would typically contain HTML, forms, and logic for saving settings.
 */
function my_automator_custom_settings_page_callback() {
    ?>
    <div class="wrap">
        <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
        <p>This is a custom settings page for Automator. You can add your own configuration options here.</p>
        <form method="post" action="options.php">
            <?php
            // Example: If you had registered settings using register_setting() and add_settings_section(),
            // you would output them here. For simplicity, this is a placeholder.
            // settings_fields( 'my_automator_settings_group' );
            // do_settings_sections( 'my-automator-custom-settings' );
            ?>
            <p>
                <?php submit_button( 'Save Settings' ); ?>
            </p>
        </form>
    </div>
    <?php
}

/**
 * If this were a filter hook, the example would look like this:
 *
 * function my_automator_filter_example( $value ) {
 *     // Modify the $value here.
 *     $modified_value = $value . ' - modified by my plugin';
 *     return $modified_value;
 * }
 * add_filter( 'automator_some_filter_hook', 'my_automator_filter_example', 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:663

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