ActionScheduler_QueueCleaner::delete_old_actions()
Default queue cleaner process used by queue runner.
Method of the class: ActionScheduler_QueueCleaner{}
Hooks from the method
Return
Array
.
Usage
$ActionScheduler_QueueCleaner = new ActionScheduler_QueueCleaner(); $ActionScheduler_QueueCleaner->delete_old_actions();
ActionScheduler_QueueCleaner::delete_old_actions() ActionScheduler QueueCleaner::delete old actions code WC 9.4.2
public function delete_old_actions() { /** * Filter the minimum scheduled date age for action deletion. * * @param int $retention_period Minimum scheduled age in seconds of the actions to be deleted. */ $lifespan = apply_filters( 'action_scheduler_retention_period', $this->month_in_seconds ); try { $cutoff = as_get_datetime_object( $lifespan . ' seconds ago' ); } catch ( Exception $e ) { _doing_it_wrong( __METHOD__, sprintf( /* Translators: %s is the exception message. */ esc_html__( 'It was not possible to determine a valid cut-off time: %s.', 'woocommerce' ), esc_html( $e->getMessage() ) ), '3.5.5' ); return array(); } /** * Filter the statuses when cleaning the queue. * * @param string[] $default_statuses_to_purge Action statuses to clean. */ $statuses_to_purge = (array) apply_filters( 'action_scheduler_default_cleaner_statuses', $this->default_statuses_to_purge ); return $this->clean_actions( $statuses_to_purge, $cutoff, $this->get_batch_size() ); }