as_enqueue_async_action()WC 1.0

Enqueue an action to run one time, as soon as possible

Хуки из функции


int. The action ID.


as_enqueue_async_action( $hook, $args, $group, $unique );
$hook(строка) (обязательный)
The hook to trigger.
Arguments to pass when the hook triggers.
По умолчанию: array()
The group to assign this job to.
По умолчанию: ''
Whether the action should be unique.
По умолчанию: false

Код as_enqueue_async_action() WC 7.7.0

function as_enqueue_async_action( $hook, $args = array(), $group = '', $unique = false ) {
	if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
		return 0;

	 * Provides an opportunity to short-circuit the default process for enqueuing async
	 * actions.
	 * Returning a value other than null from the filter will short-circuit the normal
	 * process. The expectation in such a scenario is that callbacks will return an integer
	 * representing the enqueued action ID (enqueued using some alternative process) or else
	 * zero.
	 * @param int|null $pre_option The value to return instead of the option value.
	 * @param string   $hook       Action hook.
	 * @param array    $args       Action arguments.
	 * @param string   $group      Action group.
	$pre = apply_filters( 'pre_as_enqueue_async_action', null, $hook, $args, $group );
	if ( null !== $pre ) {
		return is_int( $pre ) ? $pre : 0;

	return ActionScheduler::factory()->async_unique( $hook, $args, $group, $unique );