ActionScheduler_Store::find_action()publicWC 1.0

Find an action.

Note: the query ordering changes based on the passed 'status' value.

Method of the class: ActionScheduler_Store{}

No Hooks.

Return

String|null. ID of the next action matching the criteria or NULL if not found.

Usage

$ActionScheduler_Store = new ActionScheduler_Store();
$ActionScheduler_Store->find_action( $hook, $params );
$hook(string) (required)
Action hook.
$params(array)
Parameters of the action to find.
Default: array()

ActionScheduler_Store::find_action() code WC 8.6.1

public function find_action( $hook, $params = array() ) {
	$params = wp_parse_args(
		$params,
		array(
			'args'   => null,
			'status' => self::STATUS_PENDING,
			'group'  => '',
		)
	);

	// These params are fixed for this method.
	$params['hook']     = $hook;
	$params['orderby']  = 'date';
	$params['per_page'] = 1;

	if ( ! empty( $params['status'] ) ) {
		if ( self::STATUS_PENDING === $params['status'] ) {
			$params['order'] = 'ASC'; // Find the next action that matches.
		} else {
			$params['order'] = 'DESC'; // Find the most recent action that matches.
		}
	}

	$results = $this->query_actions( $params );

	return empty( $results ) ? null : $results[0];
}