ActionScheduler_QueueCleaner::delete_actionsprivateWC 1.0

Delete actions.

Метод класса: ActionScheduler_QueueCleaner{}

Возвращает

Массив. Deleted action IDs.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->delete_actions( $actions_to_delete, $lifespan, $context );
$actions_to_delete(int[]) (обязательный)
List of action IDs to delete.
$lifespan(int)
Minimum scheduled age in seconds of the actions being deleted.
По умолчанию: null
$context(строка)
Context of the delete request.
По умолчанию: 'old'

Код ActionScheduler_QueueCleaner::delete_actions() WC 10.0.2

private function delete_actions( array $actions_to_delete, $lifespan = null, $context = 'old' ) {
	$deleted_actions = array();

	if ( is_null( $lifespan ) ) {
		$lifespan = $this->month_in_seconds;
	}

	foreach ( $actions_to_delete as $action_id ) {
		try {
			$this->store->delete_action( $action_id );
			$deleted_actions[] = $action_id;
		} catch ( Exception $e ) {
			/**
			 * Notify 3rd party code of exceptions when deleting a completed action older than the retention period
			 *
			 * This hook provides a way for 3rd party code to log or otherwise handle exceptions relating to their
			 * actions.
			 *
			 * @param int $action_id The scheduled actions ID in the data store
			 * @param Exception $e The exception thrown when attempting to delete the action from the data store
			 * @param int $lifespan The retention period, in seconds, for old actions
			 * @param int $count_of_actions_to_delete The number of old actions being deleted in this batch
			 * @since 2.0.0
			 */
			do_action( "action_scheduler_failed_{$context}_action_deletion", $action_id, $e, $lifespan, count( $actions_to_delete ) );
		}
	}
	return $deleted_actions;
}