Action uncanny-automator

automator_activation_before

Fires before the Automator plugin is activated.

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

Description

Fires before the Automator plugin's core activation processes begin. Developers can use this hook to perform custom setup or logic immediately prior to plugin installation tasks, such as adding default options or modifying core settings. This hook executes early in the activation lifecycle.


Usage

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

Examples

// Example of using the 'automator_activation_before' action hook
// This function will run right before the plugin performs its initial database setup on activation.
// It's a good place to set default options or perform pre-activation checks.
function my_automator_activation_setup( $plugin_file_path ) {

    // Ensure we're dealing with the correct plugin activation if multiple automator plugins exist.
    // (This is a hypothetical scenario, real logic might be more specific).
    $target_plugin_slug = 'my-custom-automator'; // Replace with the actual slug of your custom automator plugin.

    // Check if the activation is related to our specific plugin.
    if ( strpos( $plugin_file_path, $target_plugin_slug ) !== false ) {

        // Set a default value for a custom option that our plugin might use.
        // This ensures the option exists with a sensible default from the start.
        $default_workflow_limit = 10;
        if ( get_option( 'my_automator_workflow_limit' ) === false ) {
            update_option( 'my_automator_workflow_limit', $default_workflow_limit );
        }

        // Log a message to the debug log for verification purposes.
        error_log( 'My Custom Automator activation pre-setup complete.' );
    }
}

// Add the action hook.
// The 'automator_activation_before' hook does not explicitly pass arguments in the provided source.
// However, it's common for activation hooks to implicitly pass the main plugin file path.
// We'll assume it passes one argument for demonstration, and set accepted args to 1.
add_action( 'automator_activation_before', 'my_automator_activation_setup', 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/core/class-automator-db.php:327

public static function activation() {

		do_action( 'automator_activation_before' );

		automator_update_option( 'automator_over_time', array( 'installed_date' => time() ) );

		$db_version = automator_get_option( 'uap_database_version', null );

		self::async_wp_options_migration();

		if ( null !== $db_version && (string) AUTOMATOR_DATABASE_VERSION === (string) $db_version ) {
			// bail. No db upgrade needed!
			return;
		}

		self::create_tables();

		do_action( 'automator_activation_after' );
	}


Internal Usage

Found in src/core/classes/class-background-actions.php:56:

add_action( 'automator_activation_before', array( $this, 'add_option' ) );
Scroll to Top