PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.7.0
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.7.0
1.7.2 1.7.1 1.7.0 1.6.0 1.5.9 1.5.8 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 trunk 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6
hostinger-reach / vendor / woocommerce / action-scheduler / classes / ActionScheduler_RecurringActionScheduler.php
hostinger-reach / vendor / woocommerce / action-scheduler / classes Last commit date
WP_CLI 9 months ago abstracts 9 months ago actions 9 months ago data-stores 9 months ago migration 9 months ago schedules 9 months ago schema 9 months ago ActionScheduler_ActionClaim.php 9 months ago ActionScheduler_ActionFactory.php 9 months ago ActionScheduler_AdminView.php 9 months ago ActionScheduler_AsyncRequest_QueueRunner.php 9 months ago ActionScheduler_Compatibility.php 9 months ago ActionScheduler_DataController.php 9 months ago ActionScheduler_DateTime.php 9 months ago ActionScheduler_Exception.php 9 months ago ActionScheduler_FatalErrorMonitor.php 9 months ago ActionScheduler_InvalidActionException.php 9 months ago ActionScheduler_ListTable.php 9 months ago ActionScheduler_LogEntry.php 9 months ago ActionScheduler_NullLogEntry.php 9 months ago ActionScheduler_OptionLock.php 9 months ago ActionScheduler_QueueCleaner.php 9 months ago ActionScheduler_QueueRunner.php 9 months ago ActionScheduler_RecurringActionScheduler.php 9 months ago ActionScheduler_SystemInformation.php 9 months ago ActionScheduler_Versions.php 9 months ago ActionScheduler_WPCommentCleaner.php 9 months ago ActionScheduler_wcSystemStatus.php 9 months ago
ActionScheduler_RecurringActionScheduler.php
82 lines
1 <?php
2
3 /**
4 * Class ActionScheduler_RecurringActionScheduler
5 *
6 * This class ensures that the `action_scheduler_ensure_recurring_actions` hook is triggered on a daily interval. This
7 * simplifies the process for other plugins to register their recurring actions without requiring each plugin to query
8 * or schedule actions independently on every request.
9 */
10 class ActionScheduler_RecurringActionScheduler {
11
12 /**
13 * @var string The hook of the scheduled recurring action that is run to trigger the
14 * `action_scheduler_ensure_recurring_actions` hook that plugins should use. We can't directly have the
15 * scheduled action hook be the hook plugins should use because the actions will show as failed if no plugin
16 * was actively hooked into it.
17 */
18 private const RUN_SCHEDULED_RECURRING_ACTIONS_HOOK = 'action_scheduler_run_recurring_actions_schedule_hook';
19
20 /**
21 * Initialize the instance. Should only be run on a single instance per request.
22 *
23 * @return void
24 */
25 public function init(): void {
26 add_action( self::RUN_SCHEDULED_RECURRING_ACTIONS_HOOK, array( $this, 'run_recurring_scheduler_hook' ) );
27 if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
28 add_action( 'action_scheduler_init', array( $this, 'schedule_recurring_scheduler_hook' ) );
29 }
30 }
31
32 /**
33 * Schedule the recurring `action_scheduler_ensure_recurring_actions` action if not already scheduled.
34 *
35 * @return void
36 */
37 public function schedule_recurring_scheduler_hook(): void {
38 if ( false === wp_cache_get( 'as_is_ensure_recurring_actions_scheduled' ) ) {
39 if ( ! as_has_scheduled_action( self::RUN_SCHEDULED_RECURRING_ACTIONS_HOOK ) ) {
40 as_schedule_recurring_action(
41 time(),
42 DAY_IN_SECONDS,
43 self::RUN_SCHEDULED_RECURRING_ACTIONS_HOOK,
44 [],
45 'ActionScheduler',
46 true,
47 20
48 );
49 }
50 wp_cache_set( 'as_is_ensure_recurring_actions_scheduled', true, HOUR_IN_SECONDS );
51 }
52 }
53
54 /**
55 * Trigger the hook to allow other plugins to schedule their recurring actions.
56 *
57 * @return void
58 */
59 public function run_recurring_scheduler_hook(): void {
60 /**
61 * Fires to allow extensions to verify and ensure their recurring actions are scheduled.
62 *
63 * This action is scheduled to trigger once every 24 hrs for the purpose of having 3rd party plugins verify that
64 * any previously scheduled recurring actions are still scheduled. Because recurring actions could stop getting
65 * rescheduled by default due to excessive failures, database issues, or other interruptions, extensions can use
66 * this hook to check for the existence of their recurring actions and reschedule them if necessary.
67 *
68 * Example usage:
69 *
70 * add_action('action_scheduler_ensure_recurring_actions', function() {
71 * // Check if the recurring action is scheduled, and reschedule if missing.
72 * if ( ! as_has_scheduled_action('my_recurring_action') ) {
73 * as_schedule_recurring_action( time(), HOUR_IN_SECONDS, 'my_recurring_action' );
74 * }
75 * });
76 *
77 * @since 3.9.3
78 */
79 do_action( 'action_scheduler_ensure_recurring_actions' );
80 }
81 }
82