Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wpforms-.../vendor/woocomme.../action-s...
File: functions.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* General API functions for scheduling actions
[2] Fix | Delete
*
[3] Fix | Delete
* @package ActionScheduler.
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Enqueue an action to run one time, as soon as possible
[8] Fix | Delete
*
[9] Fix | Delete
* @param string $hook The hook to trigger.
[10] Fix | Delete
* @param array $args Arguments to pass when the hook triggers.
[11] Fix | Delete
* @param string $group The group to assign this job to.
[12] Fix | Delete
* @param bool $unique Whether the action should be unique.
[13] Fix | Delete
* @param int $priority Lower values take precedence over higher values. Defaults to 10, with acceptable values falling in the range 0-255.
[14] Fix | Delete
*
[15] Fix | Delete
* @return int The action ID. Zero if there was an error scheduling the action.
[16] Fix | Delete
*/
[17] Fix | Delete
function as_enqueue_async_action( $hook, $args = array(), $group = '', $unique = false, $priority = 10 ) {
[18] Fix | Delete
if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
[19] Fix | Delete
return 0;
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Provides an opportunity to short-circuit the default process for enqueuing async
[24] Fix | Delete
* actions.
[25] Fix | Delete
*
[26] Fix | Delete
* Returning a value other than null from the filter will short-circuit the normal
[27] Fix | Delete
* process. The expectation in such a scenario is that callbacks will return an integer
[28] Fix | Delete
* representing the enqueued action ID (enqueued using some alternative process) or else
[29] Fix | Delete
* zero.
[30] Fix | Delete
*
[31] Fix | Delete
* @param int|null $pre_option The value to return instead of the option value.
[32] Fix | Delete
* @param string $hook Action hook.
[33] Fix | Delete
* @param array $args Action arguments.
[34] Fix | Delete
* @param string $group Action group.
[35] Fix | Delete
* @param int $priority Action priority.
[36] Fix | Delete
*/
[37] Fix | Delete
$pre = apply_filters( 'pre_as_enqueue_async_action', null, $hook, $args, $group, $priority );
[38] Fix | Delete
if ( null !== $pre ) {
[39] Fix | Delete
return is_int( $pre ) ? $pre : 0;
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
return ActionScheduler::factory()->create(
[43] Fix | Delete
array(
[44] Fix | Delete
'type' => 'async',
[45] Fix | Delete
'hook' => $hook,
[46] Fix | Delete
'arguments' => $args,
[47] Fix | Delete
'group' => $group,
[48] Fix | Delete
'unique' => $unique,
[49] Fix | Delete
'priority' => $priority,
[50] Fix | Delete
)
[51] Fix | Delete
);
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Schedule an action to run one time
[56] Fix | Delete
*
[57] Fix | Delete
* @param int $timestamp When the job will run.
[58] Fix | Delete
* @param string $hook The hook to trigger.
[59] Fix | Delete
* @param array $args Arguments to pass when the hook triggers.
[60] Fix | Delete
* @param string $group The group to assign this job to.
[61] Fix | Delete
* @param bool $unique Whether the action should be unique.
[62] Fix | Delete
* @param int $priority Lower values take precedence over higher values. Defaults to 10, with acceptable values falling in the range 0-255.
[63] Fix | Delete
*
[64] Fix | Delete
* @return int The action ID. Zero if there was an error scheduling the action.
[65] Fix | Delete
*/
[66] Fix | Delete
function as_schedule_single_action( $timestamp, $hook, $args = array(), $group = '', $unique = false, $priority = 10 ) {
[67] Fix | Delete
if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
[68] Fix | Delete
return 0;
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* Provides an opportunity to short-circuit the default process for enqueuing single
[73] Fix | Delete
* actions.
[74] Fix | Delete
*
[75] Fix | Delete
* Returning a value other than null from the filter will short-circuit the normal
[76] Fix | Delete
* process. The expectation in such a scenario is that callbacks will return an integer
[77] Fix | Delete
* representing the scheduled action ID (scheduled using some alternative process) or else
[78] Fix | Delete
* zero.
[79] Fix | Delete
*
[80] Fix | Delete
* @param int|null $pre_option The value to return instead of the option value.
[81] Fix | Delete
* @param int $timestamp When the action will run.
[82] Fix | Delete
* @param string $hook Action hook.
[83] Fix | Delete
* @param array $args Action arguments.
[84] Fix | Delete
* @param string $group Action group.
[85] Fix | Delete
* @param int $priorities Action priority.
[86] Fix | Delete
*/
[87] Fix | Delete
$pre = apply_filters( 'pre_as_schedule_single_action', null, $timestamp, $hook, $args, $group, $priority );
[88] Fix | Delete
if ( null !== $pre ) {
[89] Fix | Delete
return is_int( $pre ) ? $pre : 0;
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
return ActionScheduler::factory()->create(
[93] Fix | Delete
array(
[94] Fix | Delete
'type' => 'single',
[95] Fix | Delete
'hook' => $hook,
[96] Fix | Delete
'arguments' => $args,
[97] Fix | Delete
'when' => $timestamp,
[98] Fix | Delete
'group' => $group,
[99] Fix | Delete
'unique' => $unique,
[100] Fix | Delete
'priority' => $priority,
[101] Fix | Delete
)
[102] Fix | Delete
);
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
/**
[106] Fix | Delete
* Schedule a recurring action
[107] Fix | Delete
*
[108] Fix | Delete
* @param int $timestamp When the first instance of the job will run.
[109] Fix | Delete
* @param int $interval_in_seconds How long to wait between runs.
[110] Fix | Delete
* @param string $hook The hook to trigger.
[111] Fix | Delete
* @param array $args Arguments to pass when the hook triggers.
[112] Fix | Delete
* @param string $group The group to assign this job to.
[113] Fix | Delete
* @param bool $unique Whether the action should be unique.
[114] Fix | Delete
* @param int $priority Lower values take precedence over higher values. Defaults to 10, with acceptable values falling in the range 0-255.
[115] Fix | Delete
*
[116] Fix | Delete
* @return int The action ID. Zero if there was an error scheduling the action.
[117] Fix | Delete
*/
[118] Fix | Delete
function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '', $unique = false, $priority = 10 ) {
[119] Fix | Delete
if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
[120] Fix | Delete
return 0;
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
$interval = (int) $interval_in_seconds;
[124] Fix | Delete
[125] Fix | Delete
// We expect an integer and allow it to be passed using float and string types, but otherwise
[126] Fix | Delete
// should reject unexpected values.
[127] Fix | Delete
if ( ! is_numeric( $interval_in_seconds ) || $interval_in_seconds != $interval ) {
[128] Fix | Delete
_doing_it_wrong(
[129] Fix | Delete
__METHOD__,
[130] Fix | Delete
sprintf(
[131] Fix | Delete
/* translators: 1: provided value 2: provided type. */
[132] Fix | Delete
esc_html__( 'An integer was expected but "%1$s" (%2$s) was received.', 'action-scheduler' ),
[133] Fix | Delete
esc_html( $interval_in_seconds ),
[134] Fix | Delete
esc_html( gettype( $interval_in_seconds ) )
[135] Fix | Delete
),
[136] Fix | Delete
'3.6.0'
[137] Fix | Delete
);
[138] Fix | Delete
[139] Fix | Delete
return 0;
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
/**
[143] Fix | Delete
* Provides an opportunity to short-circuit the default process for enqueuing recurring
[144] Fix | Delete
* actions.
[145] Fix | Delete
*
[146] Fix | Delete
* Returning a value other than null from the filter will short-circuit the normal
[147] Fix | Delete
* process. The expectation in such a scenario is that callbacks will return an integer
[148] Fix | Delete
* representing the scheduled action ID (scheduled using some alternative process) or else
[149] Fix | Delete
* zero.
[150] Fix | Delete
*
[151] Fix | Delete
* @param int|null $pre_option The value to return instead of the option value.
[152] Fix | Delete
* @param int $timestamp When the action will run.
[153] Fix | Delete
* @param int $interval_in_seconds How long to wait between runs.
[154] Fix | Delete
* @param string $hook Action hook.
[155] Fix | Delete
* @param array $args Action arguments.
[156] Fix | Delete
* @param string $group Action group.
[157] Fix | Delete
* @param int $priority Action priority.
[158] Fix | Delete
*/
[159] Fix | Delete
$pre = apply_filters( 'pre_as_schedule_recurring_action', null, $timestamp, $interval_in_seconds, $hook, $args, $group, $priority );
[160] Fix | Delete
if ( null !== $pre ) {
[161] Fix | Delete
return is_int( $pre ) ? $pre : 0;
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
return ActionScheduler::factory()->create(
[165] Fix | Delete
array(
[166] Fix | Delete
'type' => 'recurring',
[167] Fix | Delete
'hook' => $hook,
[168] Fix | Delete
'arguments' => $args,
[169] Fix | Delete
'when' => $timestamp,
[170] Fix | Delete
'pattern' => $interval_in_seconds,
[171] Fix | Delete
'group' => $group,
[172] Fix | Delete
'unique' => $unique,
[173] Fix | Delete
'priority' => $priority,
[174] Fix | Delete
)
[175] Fix | Delete
);
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
/**
[179] Fix | Delete
* Schedule an action that recurs on a cron-like schedule.
[180] Fix | Delete
*
[181] Fix | Delete
* @param int $timestamp The first instance of the action will be scheduled
[182] Fix | Delete
* to run at a time calculated after this timestamp matching the cron
[183] Fix | Delete
* expression. This can be used to delay the first instance of the action.
[184] Fix | Delete
* @param string $schedule A cron-link schedule string.
[185] Fix | Delete
* @see http://en.wikipedia.org/wiki/Cron
[186] Fix | Delete
* * * * * * *
[187] Fix | Delete
* ┬ ┬ ┬ ┬ ┬ ┬
[188] Fix | Delete
* | | | | | |
[189] Fix | Delete
* | | | | | + year [optional]
[190] Fix | Delete
* | | | | +----- day of week (0 - 7) (Sunday=0 or 7)
[191] Fix | Delete
* | | | +---------- month (1 - 12)
[192] Fix | Delete
* | | +--------------- day of month (1 - 31)
[193] Fix | Delete
* | +-------------------- hour (0 - 23)
[194] Fix | Delete
* +------------------------- min (0 - 59)
[195] Fix | Delete
* @param string $hook The hook to trigger.
[196] Fix | Delete
* @param array $args Arguments to pass when the hook triggers.
[197] Fix | Delete
* @param string $group The group to assign this job to.
[198] Fix | Delete
* @param bool $unique Whether the action should be unique.
[199] Fix | Delete
* @param int $priority Lower values take precedence over higher values. Defaults to 10, with acceptable values falling in the range 0-255.
[200] Fix | Delete
*
[201] Fix | Delete
* @return int The action ID. Zero if there was an error scheduling the action.
[202] Fix | Delete
*/
[203] Fix | Delete
function as_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '', $unique = false, $priority = 10 ) {
[204] Fix | Delete
if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
[205] Fix | Delete
return 0;
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
/**
[209] Fix | Delete
* Provides an opportunity to short-circuit the default process for enqueuing cron
[210] Fix | Delete
* actions.
[211] Fix | Delete
*
[212] Fix | Delete
* Returning a value other than null from the filter will short-circuit the normal
[213] Fix | Delete
* process. The expectation in such a scenario is that callbacks will return an integer
[214] Fix | Delete
* representing the scheduled action ID (scheduled using some alternative process) or else
[215] Fix | Delete
* zero.
[216] Fix | Delete
*
[217] Fix | Delete
* @param int|null $pre_option The value to return instead of the option value.
[218] Fix | Delete
* @param int $timestamp When the action will run.
[219] Fix | Delete
* @param string $schedule Cron-like schedule string.
[220] Fix | Delete
* @param string $hook Action hook.
[221] Fix | Delete
* @param array $args Action arguments.
[222] Fix | Delete
* @param string $group Action group.
[223] Fix | Delete
* @param int $priority Action priority.
[224] Fix | Delete
*/
[225] Fix | Delete
$pre = apply_filters( 'pre_as_schedule_cron_action', null, $timestamp, $schedule, $hook, $args, $group, $priority );
[226] Fix | Delete
if ( null !== $pre ) {
[227] Fix | Delete
return is_int( $pre ) ? $pre : 0;
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
return ActionScheduler::factory()->create(
[231] Fix | Delete
array(
[232] Fix | Delete
'type' => 'cron',
[233] Fix | Delete
'hook' => $hook,
[234] Fix | Delete
'arguments' => $args,
[235] Fix | Delete
'when' => $timestamp,
[236] Fix | Delete
'pattern' => $schedule,
[237] Fix | Delete
'group' => $group,
[238] Fix | Delete
'unique' => $unique,
[239] Fix | Delete
'priority' => $priority,
[240] Fix | Delete
)
[241] Fix | Delete
);
[242] Fix | Delete
}
[243] Fix | Delete
[244] Fix | Delete
/**
[245] Fix | Delete
* Cancel the next occurrence of a scheduled action.
[246] Fix | Delete
*
[247] Fix | Delete
* While only the next instance of a recurring or cron action is unscheduled by this method, that will also prevent
[248] Fix | Delete
* all future instances of that recurring or cron action from being run. Recurring and cron actions are scheduled in
[249] Fix | Delete
* a sequence instead of all being scheduled at once. Each successive occurrence of a recurring action is scheduled
[250] Fix | Delete
* only after the former action is run. If the next instance is never run, because it's unscheduled by this function,
[251] Fix | Delete
* then the following instance will never be scheduled (or exist), which is effectively the same as being unscheduled
[252] Fix | Delete
* by this method also.
[253] Fix | Delete
*
[254] Fix | Delete
* @param string $hook The hook that the job will trigger.
[255] Fix | Delete
* @param array $args Args that would have been passed to the job.
[256] Fix | Delete
* @param string $group The group the job is assigned to.
[257] Fix | Delete
*
[258] Fix | Delete
* @return int|null The scheduled action ID if a scheduled action was found, or null if no matching action found.
[259] Fix | Delete
*/
[260] Fix | Delete
function as_unschedule_action( $hook, $args = array(), $group = '' ) {
[261] Fix | Delete
if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
[262] Fix | Delete
return 0;
[263] Fix | Delete
}
[264] Fix | Delete
$params = array(
[265] Fix | Delete
'hook' => $hook,
[266] Fix | Delete
'status' => ActionScheduler_Store::STATUS_PENDING,
[267] Fix | Delete
'orderby' => 'date',
[268] Fix | Delete
'order' => 'ASC',
[269] Fix | Delete
'group' => $group,
[270] Fix | Delete
);
[271] Fix | Delete
if ( is_array( $args ) ) {
[272] Fix | Delete
$params['args'] = $args;
[273] Fix | Delete
}
[274] Fix | Delete
[275] Fix | Delete
$action_id = ActionScheduler::store()->query_action( $params );
[276] Fix | Delete
[277] Fix | Delete
if ( $action_id ) {
[278] Fix | Delete
try {
[279] Fix | Delete
ActionScheduler::store()->cancel_action( $action_id );
[280] Fix | Delete
} catch ( Exception $exception ) {
[281] Fix | Delete
ActionScheduler::logger()->log(
[282] Fix | Delete
$action_id,
[283] Fix | Delete
sprintf(
[284] Fix | Delete
/* translators: %1$s is the name of the hook to be cancelled, %2$s is the exception message. */
[285] Fix | Delete
__( 'Caught exception while cancelling action "%1$s": %2$s', 'action-scheduler' ),
[286] Fix | Delete
$hook,
[287] Fix | Delete
$exception->getMessage()
[288] Fix | Delete
)
[289] Fix | Delete
);
[290] Fix | Delete
[291] Fix | Delete
$action_id = null;
[292] Fix | Delete
}
[293] Fix | Delete
}
[294] Fix | Delete
[295] Fix | Delete
return $action_id;
[296] Fix | Delete
}
[297] Fix | Delete
[298] Fix | Delete
/**
[299] Fix | Delete
* Cancel all occurrences of a scheduled action.
[300] Fix | Delete
*
[301] Fix | Delete
* @param string $hook The hook that the job will trigger.
[302] Fix | Delete
* @param array $args Args that would have been passed to the job.
[303] Fix | Delete
* @param string $group The group the job is assigned to.
[304] Fix | Delete
*/
[305] Fix | Delete
function as_unschedule_all_actions( $hook, $args = array(), $group = '' ) {
[306] Fix | Delete
if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
[307] Fix | Delete
return;
[308] Fix | Delete
}
[309] Fix | Delete
if ( empty( $args ) ) {
[310] Fix | Delete
if ( ! empty( $hook ) && empty( $group ) ) {
[311] Fix | Delete
ActionScheduler_Store::instance()->cancel_actions_by_hook( $hook );
[312] Fix | Delete
return;
[313] Fix | Delete
}
[314] Fix | Delete
if ( ! empty( $group ) && empty( $hook ) ) {
[315] Fix | Delete
ActionScheduler_Store::instance()->cancel_actions_by_group( $group );
[316] Fix | Delete
return;
[317] Fix | Delete
}
[318] Fix | Delete
}
[319] Fix | Delete
do {
[320] Fix | Delete
$unscheduled_action = as_unschedule_action( $hook, $args, $group );
[321] Fix | Delete
} while ( ! empty( $unscheduled_action ) );
[322] Fix | Delete
}
[323] Fix | Delete
[324] Fix | Delete
/**
[325] Fix | Delete
* Check if there is an existing action in the queue with a given hook, args and group combination.
[326] Fix | Delete
*
[327] Fix | Delete
* An action in the queue could be pending, in-progress or async. If the is pending for a time in
[328] Fix | Delete
* future, its scheduled date will be returned as a timestamp. If it is currently being run, or an
[329] Fix | Delete
* async action sitting in the queue waiting to be processed, in which case boolean true will be
[330] Fix | Delete
* returned. Or there may be no async, in-progress or pending action for this hook, in which case,
[331] Fix | Delete
* boolean false will be the return value.
[332] Fix | Delete
*
[333] Fix | Delete
* @param string $hook Name of the hook to search for.
[334] Fix | Delete
* @param array $args Arguments of the action to be searched.
[335] Fix | Delete
* @param string $group Group of the action to be searched.
[336] Fix | Delete
*
[337] Fix | Delete
* @return int|bool The timestamp for the next occurrence of a pending scheduled action, true for an async or in-progress action or false if there is no matching action.
[338] Fix | Delete
*/
[339] Fix | Delete
function as_next_scheduled_action( $hook, $args = null, $group = '' ) {
[340] Fix | Delete
if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
[341] Fix | Delete
return false;
[342] Fix | Delete
}
[343] Fix | Delete
[344] Fix | Delete
$params = array(
[345] Fix | Delete
'hook' => $hook,
[346] Fix | Delete
'orderby' => 'date',
[347] Fix | Delete
'order' => 'ASC',
[348] Fix | Delete
'group' => $group,
[349] Fix | Delete
);
[350] Fix | Delete
[351] Fix | Delete
if ( is_array( $args ) ) {
[352] Fix | Delete
$params['args'] = $args;
[353] Fix | Delete
}
[354] Fix | Delete
[355] Fix | Delete
$params['status'] = ActionScheduler_Store::STATUS_RUNNING;
[356] Fix | Delete
$action_id = ActionScheduler::store()->query_action( $params );
[357] Fix | Delete
if ( $action_id ) {
[358] Fix | Delete
return true;
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
$params['status'] = ActionScheduler_Store::STATUS_PENDING;
[362] Fix | Delete
$action_id = ActionScheduler::store()->query_action( $params );
[363] Fix | Delete
if ( null === $action_id ) {
[364] Fix | Delete
return false;
[365] Fix | Delete
}
[366] Fix | Delete
[367] Fix | Delete
$action = ActionScheduler::store()->fetch_action( $action_id );
[368] Fix | Delete
$scheduled_date = $action->get_schedule()->get_date();
[369] Fix | Delete
if ( $scheduled_date ) {
[370] Fix | Delete
return (int) $scheduled_date->format( 'U' );
[371] Fix | Delete
} elseif ( null === $scheduled_date ) { // pending async action with NullSchedule.
[372] Fix | Delete
return true;
[373] Fix | Delete
}
[374] Fix | Delete
[375] Fix | Delete
return false;
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
/**
[379] Fix | Delete
* Check if there is a scheduled action in the queue but more efficiently than as_next_scheduled_action().
[380] Fix | Delete
*
[381] Fix | Delete
* It's recommended to use this function when you need to know whether a specific action is currently scheduled
[382] Fix | Delete
* (pending or in-progress).
[383] Fix | Delete
*
[384] Fix | Delete
* @since 3.3.0
[385] Fix | Delete
*
[386] Fix | Delete
* @param string $hook The hook of the action.
[387] Fix | Delete
* @param array $args Args that have been passed to the action. Null will matches any args.
[388] Fix | Delete
* @param string $group The group the job is assigned to.
[389] Fix | Delete
*
[390] Fix | Delete
* @return bool True if a matching action is pending or in-progress, false otherwise.
[391] Fix | Delete
*/
[392] Fix | Delete
function as_has_scheduled_action( $hook, $args = null, $group = '' ) {
[393] Fix | Delete
if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
[394] Fix | Delete
return false;
[395] Fix | Delete
}
[396] Fix | Delete
[397] Fix | Delete
$query_args = array(
[398] Fix | Delete
'hook' => $hook,
[399] Fix | Delete
'status' => array( ActionScheduler_Store::STATUS_RUNNING, ActionScheduler_Store::STATUS_PENDING ),
[400] Fix | Delete
'group' => $group,
[401] Fix | Delete
'orderby' => 'none',
[402] Fix | Delete
);
[403] Fix | Delete
[404] Fix | Delete
if ( null !== $args ) {
[405] Fix | Delete
$query_args['args'] = $args;
[406] Fix | Delete
}
[407] Fix | Delete
[408] Fix | Delete
$action_id = ActionScheduler::store()->query_action( $query_args );
[409] Fix | Delete
[410] Fix | Delete
return null !== $action_id;
[411] Fix | Delete
}
[412] Fix | Delete
[413] Fix | Delete
/**
[414] Fix | Delete
* Find scheduled actions
[415] Fix | Delete
*
[416] Fix | Delete
* @param array $args Possible arguments, with their default values.
[417] Fix | Delete
* 'hook' => '' - the name of the action that will be triggered.
[418] Fix | Delete
* 'args' => NULL - the args array that will be passed with the action.
[419] Fix | Delete
* 'date' => NULL - the scheduled date of the action. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime(). Used in UTC timezone.
[420] Fix | Delete
* 'date_compare' => '<=' - operator for testing "date". accepted values are '!=', '>', '>=', '<', '<=', '='.
[421] Fix | Delete
* 'modified' => NULL - the date the action was last updated. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime(). Used in UTC timezone.
[422] Fix | Delete
* 'modified_compare' => '<=' - operator for testing "modified". accepted values are '!=', '>', '>=', '<', '<=', '='.
[423] Fix | Delete
* 'group' => '' - the group the action belongs to.
[424] Fix | Delete
* 'status' => '' - ActionScheduler_Store::STATUS_COMPLETE or ActionScheduler_Store::STATUS_PENDING.
[425] Fix | Delete
* 'claimed' => NULL - TRUE to find claimed actions, FALSE to find unclaimed actions, a string to find a specific claim ID.
[426] Fix | Delete
* 'per_page' => 5 - Number of results to return.
[427] Fix | Delete
* 'offset' => 0.
[428] Fix | Delete
* 'orderby' => 'date' - accepted values are 'hook', 'group', 'modified', 'date' or 'none'.
[429] Fix | Delete
* 'order' => 'ASC'.
[430] Fix | Delete
*
[431] Fix | Delete
* @param string $return_format OBJECT, ARRAY_A, or ids.
[432] Fix | Delete
*
[433] Fix | Delete
* @return array
[434] Fix | Delete
*/
[435] Fix | Delete
function as_get_scheduled_actions( $args = array(), $return_format = OBJECT ) {
[436] Fix | Delete
if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) {
[437] Fix | Delete
return array();
[438] Fix | Delete
}
[439] Fix | Delete
$store = ActionScheduler::store();
[440] Fix | Delete
foreach ( array( 'date', 'modified' ) as $key ) {
[441] Fix | Delete
if ( isset( $args[ $key ] ) ) {
[442] Fix | Delete
$args[ $key ] = as_get_datetime_object( $args[ $key ] );
[443] Fix | Delete
}
[444] Fix | Delete
}
[445] Fix | Delete
$ids = $store->query_actions( $args );
[446] Fix | Delete
[447] Fix | Delete
if ( 'ids' === $return_format || 'int' === $return_format ) {
[448] Fix | Delete
return $ids;
[449] Fix | Delete
}
[450] Fix | Delete
[451] Fix | Delete
$actions = array();
[452] Fix | Delete
foreach ( $ids as $action_id ) {
[453] Fix | Delete
$actions[ $action_id ] = $store->fetch_action( $action_id );
[454] Fix | Delete
}
[455] Fix | Delete
[456] Fix | Delete
if ( ARRAY_A == $return_format ) {
[457] Fix | Delete
foreach ( $actions as $action_id => $action_object ) {
[458] Fix | Delete
$actions[ $action_id ] = get_object_vars( $action_object );
[459] Fix | Delete
}
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
return $actions;
[463] Fix | Delete
}
[464] Fix | Delete
[465] Fix | Delete
/**
[466] Fix | Delete
* Helper function to create an instance of DateTime based on a given
[467] Fix | Delete
* string and timezone. By default, will return the current date/time
[468] Fix | Delete
* in the UTC timezone.
[469] Fix | Delete
*
[470] Fix | Delete
* Needed because new DateTime() called without an explicit timezone
[471] Fix | Delete
* will create a date/time in PHP's timezone, but we need to have
[472] Fix | Delete
* assurance that a date/time uses the right timezone (which we almost
[473] Fix | Delete
* always want to be UTC), which means we need to always include the
[474] Fix | Delete
* timezone when instantiating datetimes rather than leaving it up to
[475] Fix | Delete
* the PHP default.
[476] Fix | Delete
*
[477] Fix | Delete
* @param mixed $date_string A date/time string. Valid formats are explained in http://php.net/manual/en/datetime.formats.php.
[478] Fix | Delete
* @param string $timezone A timezone identifier, like UTC or Europe/Lisbon. The list of valid identifiers is available http://php.net/manual/en/timezones.php.
[479] Fix | Delete
*
[480] Fix | Delete
* @return ActionScheduler_DateTime
[481] Fix | Delete
*/
[482] Fix | Delete
function as_get_datetime_object( $date_string = null, $timezone = 'UTC' ) {
[483] Fix | Delete
if ( is_object( $date_string ) && $date_string instanceof DateTime ) {
[484] Fix | Delete
$date = new ActionScheduler_DateTime( $date_string->format( 'Y-m-d H:i:s' ), new DateTimeZone( $timezone ) );
[485] Fix | Delete
} elseif ( is_numeric( $date_string ) ) {
[486] Fix | Delete
$date = new ActionScheduler_DateTime( '@' . $date_string, new DateTimeZone( $timezone ) );
[487] Fix | Delete
} else {
[488] Fix | Delete
$date = new ActionScheduler_DateTime( null === $date_string ? 'now' : $date_string, new DateTimeZone( $timezone ) );
[489] Fix | Delete
}
[490] Fix | Delete
return $date;
[491] Fix | Delete
}
[492] Fix | Delete
[493] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function