PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.3.3
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.3.3
3.3.3 3.3.2 3.3.1 3.3.0 3.2.14 3.2.13 3.2.12 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 trunk 0.2.5.5 0.2.5.6 0.2.5.7 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 All 158 releases
← All changes | includes/Admin/Cron.php +18 -0 3.2.12 → 3.3.3 View file →
@@ -31,8 +31,18 @@
31 31 }
32 32
33 33 /**
34 34 * Schedule cron jobs.
35 + *
36 + * Callers that run before `init` (migrations and upgrade routines hooked to
37 + * `plugins_loaded`, for instance) are deferred rather than refused:
38 + * wp_schedule_event() -> wp_get_schedules() fires the `cron_schedules`
39 + * filter, and its callbacks -- ours, NX Pro's, WooCommerce's -- translate
40 + * their interval labels, which before `init` trips WordPress'
41 + * _load_textdomain_just_in_time "called too early" notice (WP 6.7+).
42 + * Guarding here rather than at each call site keeps the whole class of bug
43 + * closed, whatever hooks a future caller happens to run on.
44 + *
35 45 * @param int $post_id
36 46 * @param string $cache_key
37 47 */
38 48 public function set_cron($post_id, $cache_key = 'nx_cache_interval') {
@@ -38,8 +48,16 @@
38 48 public function set_cron($post_id, $cache_key = 'nx_cache_interval') {
39 49 if (!$post_id || empty($post_id)) {
40 50 return;
41 51 }
52 +
53 + if (!did_action('init')) {
54 + add_action('init', function () use ($post_id, $cache_key) {
55 + $this->set_cron($post_id, $cache_key);
56 + }, 20);
57 + return;
58 + }
59 +
42 60 // First clear previously scheduled cron hook.
43 61 $this->clear_schedule((int) $post_id);
44 62
45 63 // If there is no next event, start cron now.