Action uncanny-automator

automator_before_init

Fires before the Automator core is initialized, allowing for early customization and setup.

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

Description

Fires after core Automator functionality is loaded but before plugin initialization begins. Developers can hook into this action to perform custom setup, modify core Automator behavior, or add their own integrations before the plugin is fully active. No parameters are passed.


Usage

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

Examples

<?php
/**
 * Example function to run custom logic before Automator core initialization.
 *
 * This function could be used to set up custom configurations,
 * load necessary helper functions, or perform checks before Automator
 * starts its main initialization process.
 */
add_action( 'automator_before_init', function() {

	// Check if a specific custom plugin or feature is active.
	if ( class_exists( 'My_Custom_Automator_Extension' ) ) {
		// If the custom extension is active, maybe we need to pass some custom arguments
		// or modify how Automator loads its core files.
		// For instance, let's say our custom extension adds its own set of core files.

		// This is a hypothetical example of how you might interact with
		// a filter that's applied later, to influence Automator's core loading.
		// In a real scenario, this might involve modifying global variables,
		// hooking into other actions, or preparing data for later filters.

		// As a simple demonstration, let's log a message to the debug log.
		error_log( 'My Custom Automator Extension is active. Preparing for Automator initialization.' );

		// You could also potentially register custom post types or taxonomies here
		// if Automator depends on them for its core functionality.
		// For example:
		// register_automator_custom_types();

	} else {
		// If the custom extension is not active, proceed with default logic.
		error_log( 'Automator core initialization is about to begin. No custom extension detected.' );
	}

	// Potentially, you might add other actions or filters here to prepare
	// the environment for Automator's core initialization.

}, 10, 0 ); // Priority 10, accepts 0 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:569

public function initialize_core_automator() {
		do_action( 'automator_before_init' );

		$classes = apply_filters( 'automator_core_files', array() );

		if ( empty( $classes ) ) {
			return;
		}

		// only load if it's admin
		$this->load_traits();

		foreach ( $classes as $class_name => $file ) {
			if ( ! is_file( $file ) ) {
				continue;
			}
			require_once $file;
			$class                                 = __NAMESPACE__ . '\' . $class_name;
			self::$core_class_inits[ $class_name ] = new $class();
		}

		do_action( 'automator_after_init' );
	}


Scroll to Top