Action uncanny-automator

automator_cache_upgrader_process_completed

Fires when the Automator cache has been successfully upgraded, indicating a completed process.

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

Description

Fires after the WordPress core upgrader has completed a process. Developers can use this hook to perform actions that depend on the upgrader finishing, such as clearing specific caches or re-initializing components. It signals the end of an update cycle.


Usage

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

Examples

<?php
/**
 * Example function to handle the 'automator_cache_upgrader_process_completed' action.
 *
 * This function demonstrates how to perform a specific action when the Automator
 * cache upgrader process has finished. In this example, we'll fetch some data
 * related to automator settings and log a message indicating the completion.
 *
 * @param int $some_id An example parameter that might be passed (though this hook doesn't pass any by default).
 * @param string $another_value An example parameter.
 */
function my_automator_cache_upgrade_completion_handler( $some_id = null, $another_value = '' ) {
    // In a real-world scenario, you might fetch specific automator settings
    // or check the status of recently completed automator tasks.
    // For this example, we'll simulate fetching some data.
    $automator_settings = get_option( 'automator_settings', array() );
    $last_upgrade_timestamp = get_option( 'automator_last_cache_upgrade', 0 );

    // Log a message for debugging or informational purposes.
    // In a production environment, you might use a more sophisticated logging system.
    error_log( sprintf(
        'Automator cache upgrader process completed. Last upgrade at: %s. Settings retrieved: %s',
        date( 'Y-m-d H:i:s', $last_upgrade_timestamp ),
        count( $automator_settings ) > 0 ? 'yes' : 'no'
    ) );

    // You could also trigger other actions here, like sending a notification,
    // clearing other caches, or updating a status in the database.
    // For example:
    // update_option( 'automator_last_cache_upgrade', time() );
}

// Add the action hook with the callback function.
// This hook is documented as not passing any parameters, so we set accepted_args to 0.
add_action( 'automator_cache_upgrader_process_completed', 'my_automator_cache_upgrade_completion_handler', 10, 0 );
?>

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/lib/helpers/class-automator-cache-handler.php:582

public function upgrader_process_completed() {
		$this->reset_integrations_directory( null, null );
		do_action( 'automator_cache_upgrader_process_completed' );
	}


Scroll to Top