Bez popisu

functions.php 5.0KB

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