rebase code on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:51:46 -04:00
parent b16ad94b69
commit 8f1a2c3a66
2197 changed files with 184921 additions and 35568 deletions

View File

@@ -12,11 +12,10 @@
* @param array $args Arguments to pass when the hook triggers.
* @param string $group The group to assign this job to.
* @param bool $unique Whether the action should be unique.
* @param int $priority Lower values take precedence over higher values. Defaults to 10, with acceptable values falling in the range 0-255.
*
* @return int The action ID.
*/
function as_enqueue_async_action( $hook, $args = array(), $group = '', $unique = false, $priority = 10 ) {
function as_enqueue_async_action( $hook, $args = array(), $group = '', $unique = false ) {
if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
return 0;
}
@@ -34,23 +33,13 @@ function as_enqueue_async_action( $hook, $args = array(), $group = '', $unique =
* @param string $hook Action hook.
* @param array $args Action arguments.
* @param string $group Action group.
* @param int $priority Action priority.
*/
$pre = apply_filters( 'pre_as_enqueue_async_action', null, $hook, $args, $group, $priority );
$pre = apply_filters( 'pre_as_enqueue_async_action', null, $hook, $args, $group );
if ( null !== $pre ) {
return is_int( $pre ) ? $pre : 0;
}
return ActionScheduler::factory()->create(
array(
'type' => 'async',
'hook' => $hook,
'arguments' => $args,
'group' => $group,
'unique' => $unique,
'priority' => $priority,
)
);
return ActionScheduler::factory()->async_unique( $hook, $args, $group, $unique );
}
/**
@@ -61,11 +50,10 @@ function as_enqueue_async_action( $hook, $args = array(), $group = '', $unique =
* @param array $args Arguments to pass when the hook triggers.
* @param string $group The group to assign this job to.
* @param bool $unique Whether the action should be unique.
* @param int $priority Lower values take precedence over higher values. Defaults to 10, with acceptable values falling in the range 0-255.
*
* @return int The action ID.
*/
function as_schedule_single_action( $timestamp, $hook, $args = array(), $group = '', $unique = false, $priority = 10 ) {
function as_schedule_single_action( $timestamp, $hook, $args = array(), $group = '', $unique = false ) {
if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
return 0;
}
@@ -84,24 +72,13 @@ function as_schedule_single_action( $timestamp, $hook, $args = array(), $group =
* @param string $hook Action hook.
* @param array $args Action arguments.
* @param string $group Action group.
* @param int $priorities Action priority.
*/
$pre = apply_filters( 'pre_as_schedule_single_action', null, $timestamp, $hook, $args, $group, $priority );
$pre = apply_filters( 'pre_as_schedule_single_action', null, $timestamp, $hook, $args, $group );
if ( null !== $pre ) {
return is_int( $pre ) ? $pre : 0;
}
return ActionScheduler::factory()->create(
array(
'type' => 'single',
'hook' => $hook,
'arguments' => $args,
'when' => $timestamp,
'group' => $group,
'unique' => $unique,
'priority' => $priority,
)
);
return ActionScheduler::factory()->single_unique( $hook, $args, $timestamp, $group, $unique );
}
/**
@@ -113,34 +90,14 @@ function as_schedule_single_action( $timestamp, $hook, $args = array(), $group =
* @param array $args Arguments to pass when the hook triggers.
* @param string $group The group to assign this job to.
* @param bool $unique Whether the action should be unique.
* @param int $priority Lower values take precedence over higher values. Defaults to 10, with acceptable values falling in the range 0-255.
*
* @return int The action ID.
*/
function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '', $unique = false, $priority = 10 ) {
function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '', $unique = false ) {
if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
return 0;
}
$interval = (int) $interval_in_seconds;
// We expect an integer and allow it to be passed using float and string types, but otherwise
// should reject unexpected values.
if ( ! is_numeric( $interval_in_seconds ) || $interval_in_seconds != $interval ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: 1: provided value 2: provided type. */
esc_html__( 'An integer was expected but "%1$s" (%2$s) was received.', 'action-scheduler' ),
esc_html( $interval_in_seconds ),
esc_html( gettype( $interval_in_seconds ) )
),
'3.6.0'
);
return 0;
}
/**
* Provides an opportunity to short-circuit the default process for enqueuing recurring
* actions.
@@ -156,25 +113,13 @@ function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook,
* @param string $hook Action hook.
* @param array $args Action arguments.
* @param string $group Action group.
* @param int $priority Action priority.
*/
$pre = apply_filters( 'pre_as_schedule_recurring_action', null, $timestamp, $interval_in_seconds, $hook, $args, $group, $priority );
$pre = apply_filters( 'pre_as_schedule_recurring_action', null, $timestamp, $interval_in_seconds, $hook, $args, $group );
if ( null !== $pre ) {
return is_int( $pre ) ? $pre : 0;
}
return ActionScheduler::factory()->create(
array(
'type' => 'recurring',
'hook' => $hook,
'arguments' => $args,
'when' => $timestamp,
'pattern' => $interval_in_seconds,
'group' => $group,
'unique' => $unique,
'priority' => $priority,
)
);
return ActionScheduler::factory()->recurring_unique( $hook, $args, $timestamp, $interval_in_seconds, $group, $unique );
}
/**
@@ -198,11 +143,10 @@ function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook,
* @param array $args Arguments to pass when the hook triggers.
* @param string $group The group to assign this job to.
* @param bool $unique Whether the action should be unique.
* @param int $priority Lower values take precedence over higher values. Defaults to 10, with acceptable values falling in the range 0-255.
*
* @return int The action ID.
*/
function as_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '', $unique = false, $priority = 10 ) {
function as_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '', $unique = false ) {
if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
return 0;
}
@@ -222,25 +166,13 @@ function as_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(),
* @param string $hook Action hook.
* @param array $args Action arguments.
* @param string $group Action group.
* @param int $priority Action priority.
*/
$pre = apply_filters( 'pre_as_schedule_cron_action', null, $timestamp, $schedule, $hook, $args, $group, $priority );
$pre = apply_filters( 'pre_as_schedule_cron_action', null, $timestamp, $schedule, $hook, $args, $group );
if ( null !== $pre ) {
return is_int( $pre ) ? $pre : 0;
}
return ActionScheduler::factory()->create(
array(
'type' => 'cron',
'hook' => $hook,
'arguments' => $args,
'when' => $timestamp,
'pattern' => $schedule,
'group' => $group,
'unique' => $unique,
'priority' => $priority,
)
);
return ActionScheduler::factory()->cron_unique( $hook, $args, $timestamp, $schedule, $group, $unique );
}
/**