Filter
uncanny-automator
automator_status_removable
Filters the list of automator statuses that can be removed from the system.
add_filter( 'automator_status_removable', $callback, 10, 1 );
Description
Filters the array of action statuses considered removable. Developers can use this hook to add or remove statuses from the list of those that can be safely deleted, allowing for custom status management. This hook fires before the list of removable statuses is returned.
Usage
add_filter( 'automator_status_removable', 'your_function_name', 10, 1 );
Parameters
-
$removable_statuses(mixed) - This parameter contains an array of action statuses that are considered removable by default.
Return Value
The filtered value.
Examples
add_filter( 'automator_status_removable', 'my_custom_automator_removable_statuses', 10, 1 );
/**
* Make custom automator statuses removable.
*
* By default, only certain statuses are considered removable. This filter allows
* us to add our own custom statuses to the list of removable statuses, for example,
* if we've introduced a new status for a specific automation workflow.
*
* @param array $removable_statuses An array of statuses that are currently considered removable.
*
* @return array The modified array of removable statuses, including any custom ones.
*/
function my_custom_automator_removable_statuses( $removable_statuses ) {
// Define a custom status that we want to make removable.
// This would typically be a constant defined elsewhere in your plugin.
// For demonstration purposes, let's assume 'MY_CUSTOM_PENDING' is a status.
$custom_pending_status = 'MY_CUSTOM_PENDING';
// Add the custom status to the array of removable statuses.
// We only add it if it's not already present to avoid duplicates.
if ( ! in_array( $custom_pending_status, $removable_statuses, true ) ) {
$removable_statuses[] = $custom_pending_status;
}
// You could also potentially remove statuses if needed, though less common.
// Example: removing 'COMPLETED_WITH_NOTICE' if it's no longer relevant for removal.
/*
$key_to_remove = array_search( 'COMPLETED_WITH_NOTICE', $removable_statuses, true );
if ( false !== $key_to_remove ) {
unset( $removable_statuses[ $key_to_remove ] );
}
*/
return $removable_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:142
public static function get_removable_statuses() {
$removable_statuses = array(
self::COMPLETED,
self::CANCELLED,
self::SKIPPED,
self::DID_NOTHING,
self::COMPLETED_WITH_NOTICE,
self::FAILED,
);
return apply_filters( 'automator_status_removable', $removable_statuses );
}