Filter
uncanny-automator
automator_status_finished
Filters the list of statuses considered finished for automator actions.
add_filter( 'automator_status_finished', $callback, 10, 1 );
Description
Filters the array of statuses considered "finished" for automator actions. Developers can use this hook to customize which statuses are treated as complete, skipped, or failed, influencing how automator processes and reports are displayed.
Usage
add_filter( 'automator_status_finished', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to hook into the 'automator_status_finished' filter to
* add a custom 'PAUSED' status to the list of finished statuses.
*
* This would typically be done in your theme's functions.php file or a custom plugin.
*/
add_filter( 'automator_status_finished', 'my_custom_automator_finished_statuses', 10, 1 );
/**
* Adds a custom status to the list of finished automator statuses.
*
* @param array $finished_statuses The original array of finished statuses.
* @return array The modified array of finished statuses, including the custom one.
*/
function my_custom_automator_finished_statuses( $finished_statuses ) {
// Assuming you have a defined constant for your custom status, e.g.,
// defined( 'MY_CUSTOM_AUTOMATOR_PAUSED' ) or similar.
// For this example, let's simulate adding a new status code.
// In a real scenario, this would likely be an integer constant defined elsewhere.
$custom_paused_status_code = 99; // Replace with your actual custom status code
// Check if the custom status is not already in the list to avoid duplicates.
if ( ! in_array( $custom_paused_status_code, $finished_statuses, true ) ) {
$finished_statuses[] = $custom_paused_status_code;
}
return $finished_statuses;
}
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/process/class-automator-action-status.php:125
public static function get_finished_statuses() {
$finished_statuses = array(
self::COMPLETED,
self::COMPLETED_WITH_ERRORS,
self::CANCELLED,
self::SKIPPED,
self::DID_NOTHING,
self::COMPLETED_WITH_NOTICE,
self::FAILED,
);
return apply_filters( 'automator_status_finished', $finished_statuses );
}