| 1 |
<?php |
| 2 |
/** |
| 3 |
* Deprecated API functions for scheduling actions |
| 4 |
* |
| 5 |
* Functions with the wc prefix were deprecated to avoid confusion with |
| 6 |
* Action Scheduler being included in WooCommerce core, and it providing |
| 7 |
* a different set of APIs for working with the action queue. |
| 8 |
* |
| 9 |
* @package ActionScheduler |
| 10 |
*/ |
| 11 |
|
| 12 |
/** |
| 13 |
* Schedule an action to run one time. |
| 14 |
* |
| 15 |
* @param int $timestamp When the job will run. |
| 16 |
* @param string $hook The hook to trigger. |
| 17 |
* @param array $args Arguments to pass when the hook triggers. |
| 18 |
* @param string $group The group to assign this job to. |
| 19 |
* |
| 20 |
* @return string The job ID |
| 21 |
*/ |
| 22 |
function wc_schedule_single_action( $timestamp, $hook, $args = array(), $group = '' ) { |
| 23 |
_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_single_action()' ); |
| 24 |
return as_schedule_single_action( $timestamp, $hook, $args, $group ); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Schedule a recurring action. |
| 29 |
* |
| 30 |
* @param int $timestamp When the first instance of the job will run. |
| 31 |
* @param int $interval_in_seconds How long to wait between runs. |
| 32 |
* @param string $hook The hook to trigger. |
| 33 |
* @param array $args Arguments to pass when the hook triggers. |
| 34 |
* @param string $group The group to assign this job to. |
| 35 |
* |
| 36 |
* @deprecated 2.1.0 |
| 37 |
* |
| 38 |
* @return string The job ID |
| 39 |
*/ |
| 40 |
function wc_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) { |
| 41 |
_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_recurring_action()' ); |
| 42 |
return as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group ); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Schedule an action that recurs on a cron-like schedule. |
| 47 |
* |
| 48 |
* @param int $timestamp The schedule will start on or after this time. |
| 49 |
* @param string $schedule A cron-link schedule string. |
| 50 |
* @see http://en.wikipedia.org/wiki/Cron |
| 51 |
* * * * * * * |
| 52 |
* ┬ ┬ ┬ ┬ ┬ ┬ |
| 53 |
* | | | | | | |
| 54 |
* | | | | | + year [optional] |
| 55 |
* | | | | +----- day of week (0 - 7) (Sunday=0 or 7) |
| 56 |
* | | | +---------- month (1 - 12) |
| 57 |
* | | +--------------- day of month (1 - 31) |
| 58 |
* | +-------------------- hour (0 - 23) |
| 59 |
* +------------------------- min (0 - 59) |
| 60 |
* @param string $hook The hook to trigger. |
| 61 |
* @param array $args Arguments to pass when the hook triggers. |
| 62 |
* @param string $group The group to assign this job to. |
| 63 |
* |
| 64 |
* @deprecated 2.1.0 |
| 65 |
* |
| 66 |
* @return string The job ID |
| 67 |
*/ |
| 68 |
function wc_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '' ) { |
| 69 |
_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_cron_action()' ); |
| 70 |
return as_schedule_cron_action( $timestamp, $schedule, $hook, $args, $group ); |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Cancel the next occurrence of a job. |
| 75 |
* |
| 76 |
* @param string $hook The hook that the job will trigger. |
| 77 |
* @param array $args Args that would have been passed to the job. |
| 78 |
* @param string $group Action's group. |
| 79 |
* |
| 80 |
* @deprecated 2.1.0 |
| 81 |
*/ |
| 82 |
function wc_unschedule_action( $hook, $args = array(), $group = '' ) { |
| 83 |
_deprecated_function( __FUNCTION__, '2.1.0', 'as_unschedule_action()' ); |
| 84 |
as_unschedule_action( $hook, $args, $group ); |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* Get next scheduled action. |
| 89 |
* |
| 90 |
* @param string $hook Action's hook. |
| 91 |
* @param array $args Action's args. |
| 92 |
* @param string $group Action's group. |
| 93 |
* |
| 94 |
* @deprecated 2.1.0 |
| 95 |
* |
| 96 |
* @return int|bool The timestamp for the next occurrence, or false if nothing was found |
| 97 |
*/ |
| 98 |
function wc_next_scheduled_action( $hook, $args = null, $group = '' ) { |
| 99 |
_deprecated_function( __FUNCTION__, '2.1.0', 'as_next_scheduled_action()' ); |
| 100 |
return as_next_scheduled_action( $hook, $args, $group ); |
| 101 |
} |
| 102 |
|
| 103 |
/** |
| 104 |
* Find scheduled actions |
| 105 |
* |
| 106 |
* @param array $args Possible arguments, with their default values: |
| 107 |
* 'hook' => '' - the name of the action that will be triggered |
| 108 |
* 'args' => NULL - the args array that will be passed with the action |
| 109 |
* '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. |
| 110 |
* 'date_compare' => '<=' - operator for testing "date". accepted values are '!=', '>', '>=', '<', '<=', '=' |
| 111 |
* '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. |
| 112 |
* 'modified_compare' => '<=' - operator for testing "modified". accepted values are '!=', '>', '>=', '<', '<=', '=' |
| 113 |
* 'group' => '' - the group the action belongs to |
| 114 |
* 'status' => '' - ActionScheduler_Store::STATUS_COMPLETE or ActionScheduler_Store::STATUS_PENDING |
| 115 |
* 'claimed' => NULL - TRUE to find claimed actions, FALSE to find unclaimed actions, a string to find a specific claim ID |
| 116 |
* 'per_page' => 5 - Number of results to return |
| 117 |
* 'offset' => 0 |
| 118 |
* 'orderby' => 'date' - accepted values are 'hook', 'group', 'modified', or 'date' |
| 119 |
* 'order' => 'ASC'. |
| 120 |
* @param string $return_format OBJECT, ARRAY_A, or ids. |
| 121 |
* |
| 122 |
* @deprecated 2.1.0 |
| 123 |
* |
| 124 |
* @return array |
| 125 |
*/ |
| 126 |
function wc_get_scheduled_actions( $args = array(), $return_format = OBJECT ) { |
| 127 |
_deprecated_function( __FUNCTION__, '2.1.0', 'as_get_scheduled_actions()' ); |
| 128 |
return as_get_scheduled_actions( $args, $return_format ); |
| 129 |
} |
| 130 |
|