ActionScheduler_Store::find_action
Find an action.
Note: the query ordering changes based on the passed 'status' value.
Method of the class: ActionScheduler_Store{}
No Hooks.
Returns
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() ActionScheduler Store::find action code WC 10.6.2
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];
}