PluginProbe
Patchstack – WordPress & Plugins Security / 2.2.5
Patchstack – WordPress & Plugins Security v2.2.5
2.3.7 trunk 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.17 2.1.18 2.1.19 2.1.2 2.1.20 2.1.21 2.1.22 2.1.23 2.1.24 2.1.25 2.1.3 2.1.4 2.1.5 2.1.6 All 49 releases
← All changes | includes/cron.php +19 -19 2.1.172.2.5 View file →
@@ -17,10 +17,10 @@
17 17 * @return void
18 18 */
19 19 public function __construct( $core ) {
20 20 parent::__construct( $core );
21 - add_action( 'init', array( $this, 'schedule_events' ) );
22 - add_filter( 'cron_schedules', array( $this, 'cron_schedules' ) );
21 + add_action( 'init', [ $this, 'schedule_events' ] );
22 + add_filter( 'cron_schedules', [ $this, 'cron_schedules' ] );
23 23 }
24 24
25 25 /**
26 26 * Define our own custom cron schedules.
@@ -29,32 +29,32 @@
29 29 * @return array
30 30 */
31 31 public function cron_schedules( $schedules ) {
32 32 // Define the scheduled tasks.
33 - $schedules['patchstack_15minute'] = array(
33 + $schedules['patchstack_15minute'] = [
34 34 'interval' => ( 60 * 15 ),
35 35 'display' => __( 'Every 15 Minutes' ),
36 - );
36 + ];
37 37
38 - $schedules['patchstack_hourly'] = array(
38 + $schedules['patchstack_hourly'] = [
39 39 'interval' => ( 60 * 60 ),
40 40 'display' => __( 'Every Hour' ),
41 - );
41 + ];
42 42
43 - $schedules['patchstack_trihourly'] = array(
43 + $schedules['patchstack_trihourly'] = [
44 44 'interval' => ( 60 * 60 * 3 ),
45 45 'display' => __( 'Every 3 Hours' ),
46 - );
46 + ];
47 47
48 - $schedules['patchstack_twicedaily'] = array(
48 + $schedules['patchstack_twicedaily'] = [
49 49 'interval' => ( 60 * 60 * 12 ),
50 50 'display' => __( '2 Times Daily' ),
51 - );
51 + ];
52 52
53 - $schedules['patchstack_daily'] = array(
53 + $schedules['patchstack_daily'] = [
54 54 'interval' => ( 60 * 60 * 24 ),
55 55 'display' => __( '1 Time Daily' ),
56 - );
56 + ];
57 57
58 58 return $schedules;
59 59 }
60 60
@@ -66,38 +66,38 @@
66 66 public function schedule_events() {
67 67 // Random time throughout the day to make sure not all sites synchronize at the same time.
68 68 $crons = get_option( 'patchstack_cron_offset', false );
69 69 if ( ! $crons || ! isset ( $crons['patchstack_daily'] ) ) {
70 - $crons = array(
70 + $crons = [
71 71 'patchstack_daily' => strtotime( 'today' ) + mt_rand( 0, 86399 ),
72 72 'patchstack_hourly' => strtotime( 'today' ) + mt_rand( 0, 3600 ),
73 73 'patchstack_trihourly' => strtotime( 'today' ) + mt_rand( 0, 9599 ),
74 74 'patchstack_twicedaily' => strtotime( 'today' ) + mt_rand( 0, 43199 ),
75 75 'patchstack_15minute' => strtotime( 'today' ) + mt_rand( 0, 899 ),
76 - );
76 + ];
77 77 update_option( 'patchstack_cron_offset', $crons );
78 78
79 79 // Clear existing scheduled events so we can use the new timestamps.
80 - foreach ( array( 'patchstack_send_software_data', 'patchstack_send_hacker_logs', 'patchstack_post_firewall_rules', 'patchstack_post_firewall_htaccess_rules', 'patchstack_post_dynamic_firewall_rules', 'patchstack_update_license_status', 'patchstack_send_event_logs', 'patchstack_update_plugins', 'patchstack_send_ping' ) as $event ) {
80 + foreach ( [ 'patchstack_send_software_data', 'patchstack_send_hacker_logs', 'patchstack_post_firewall_rules', 'patchstack_post_firewall_htaccess_rules', 'patchstack_post_dynamic_firewall_rules', 'patchstack_update_license_status', 'patchstack_send_event_logs', 'patchstack_update_plugins', 'patchstack_send_ping' ] as $event ) {
81 81 wp_clear_scheduled_hook( $event );
82 82 }
83 83 }
84 84
85 85 // List of the different events.
86 - $free = array(
86 + $free = [
87 87 'patchstack_send_software_data' => 'patchstack_twicedaily',
88 88 'patchstack_update_license_status' => 'patchstack_twicedaily',
89 89 'patchstack_send_ping' => 'patchstack_trihourly',
90 90 'patchstack_update_plugins' => 'patchstack_15minute'
91 - );
91 + ];
92 92
93 - $premium = array(
93 + $premium = [
94 94 'patchstack_send_hacker_logs' => 'patchstack_15minute',
95 95 'patchstack_post_firewall_rules' => 'patchstack_twicedaily',
96 96 'patchstack_post_firewall_htaccess_rules' => 'patchstack_trihourly',
97 97 'patchstack_post_dynamic_firewall_rules' => 'patchstack_hourly',
98 98 'patchstack_send_event_logs' => 'patchstack_15minute'
99 - );
99 + ];
100 100
101 101 // Schedule the events if they are not scheduled yet.
102 102 foreach ( $free as $event => $interval ) {
103 103 if ( ! wp_next_scheduled( $event ) ) {