PluginProbe
SlimStat Analytics / trunk
SlimStat Analytics vtrunk
5.5.0 5.4.12 4.7.4 4.7.4.1 4.7.5 4.7.5.1 4.7.5.2 4.7.5.3 4.7.6 4.7.6.1 4.7.7 4.7.8 4.7.8.1 4.7.8.2 4.7.8.3 4.7.9 4.7.9.1 4.8 4.8.1 4.8.2 4.8.3 4.8.4 4.8.4.1 4.8.5 4.8.5.1 All 212 releases
wp-slimstat / src / Components / Event.php

Event.php in SlimStat Analytics trunk, at src/Components/Event.php

36 lines 746 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SlimStat\Components;
4
5 class Event
6 {
7 /**
8 * Schedule a cron event
9 *
10 * @param string $hook
11 * @param int $timestamp
12 * @param string $recurrence
13 * @param callable $callback
14 */
15 public static function schedule($hook, $timestamp, $recurrence, $callback)
16 {
17 if (!wp_next_scheduled($hook)) {
18 wp_schedule_event($timestamp, $recurrence, $hook);
19 }
20
21 add_action($hook, $callback);
22 }
23
24 /**
25 * Unschedule a cron event
26 *
27 * @param string $hook
28 */
29 public static function unschedule($hook)
30 {
31 $timestamp = wp_next_scheduled($hook);
32 if ($timestamp) {
33 wp_unschedule_event($timestamp, $hook);
34 }
35 }
36 }