PluginProbe
Patchstack – WordPress & Plugins Security / 2.2.11
Patchstack – WordPress & Plugins Security v2.2.11
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 +29 -30 2.1.62.2.11 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 - 'display' => __( 'Every 15 Minutes' ),
36 - );
35 + 'display' => esc_attr__( 'Every 15 Minutes' ),
36 + ];
37 37
38 - $schedules['patchstack_hourly'] = array(
38 + $schedules['patchstack_hourly'] = [
39 39 'interval' => ( 60 * 60 ),
40 - 'display' => __( 'Every Hour' ),
41 - );
40 + 'display' => esc_attr__( 'Every Hour' ),
41 + ];
42 42
43 - $schedules['patchstack_trihourly'] = array(
43 + $schedules['patchstack_trihourly'] = [
44 44 'interval' => ( 60 * 60 * 3 ),
45 - 'display' => __( 'Every 3 Hours' ),
46 - );
45 + 'display' => esc_attr__( 'Every 3 Hours' ),
46 + ];
47 47
48 - $schedules['patchstack_twicedaily'] = array(
48 + $schedules['patchstack_twicedaily'] = [
49 49 'interval' => ( 60 * 60 * 12 ),
50 - 'display' => __( '2 Times Daily' ),
51 - );
50 + 'display' => esc_attr__( '2 Times Daily' ),
51 + ];
52 52
53 - $schedules['patchstack_daily'] = array(
53 + $schedules['patchstack_daily'] = [
54 54 'interval' => ( 60 * 60 * 24 ),
55 - 'display' => __( '1 Time Daily' ),
56 - );
55 + 'display' => esc_attr__( '1 Time Daily' ),
56 + ];
57 57
58 58 return $schedules;
59 59 }
60 60
@@ -64,41 +64,40 @@
64 64 * @return void
65 65 */
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 - if ( ! get_option( 'patchstack_cron_offset' ) ) {
69 - $crons = array(
68 + $crons = get_option( 'patchstack_cron_offset', false );
69 + if ( ! $crons || ! isset ( $crons['patchstack_daily'] ) ) {
70 + $crons = [
70 71 'patchstack_daily' => strtotime( 'today' ) + mt_rand( 0, 86399 ),
71 72 'patchstack_hourly' => strtotime( 'today' ) + mt_rand( 0, 3600 ),
72 73 'patchstack_trihourly' => strtotime( 'today' ) + mt_rand( 0, 9599 ),
73 74 'patchstack_twicedaily' => strtotime( 'today' ) + mt_rand( 0, 43199 ),
74 75 'patchstack_15minute' => strtotime( 'today' ) + mt_rand( 0, 899 ),
75 - );
76 + ];
76 77 update_option( 'patchstack_cron_offset', $crons );
77 78
78 79 // Clear existing scheduled events so we can use the new timestamps.
79 - 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 ) {
80 81 wp_clear_scheduled_hook( $event );
81 82 }
82 - } else {
83 - $crons = get_option( 'patchstack_cron_offset' );
84 83 }
85 84
86 85 // List of the different events.
87 - $free = array(
88 - 'patchstack_send_software_data' => 'patchstack_hourly',
86 + $free = [
87 + 'patchstack_send_software_data' => 'patchstack_twicedaily',
89 88 'patchstack_update_license_status' => 'patchstack_twicedaily',
90 89 'patchstack_send_ping' => 'patchstack_trihourly',
91 - 'patchstack_update_plugins' => 'patchstack_15minute',
92 - );
90 + 'patchstack_update_plugins' => 'patchstack_15minute'
91 + ];
93 92
94 - $premium = array(
93 + $premium = [
95 94 'patchstack_send_hacker_logs' => 'patchstack_15minute',
96 95 'patchstack_post_firewall_rules' => 'patchstack_twicedaily',
97 96 'patchstack_post_firewall_htaccess_rules' => 'patchstack_trihourly',
98 97 'patchstack_post_dynamic_firewall_rules' => 'patchstack_hourly',
99 - 'patchstack_send_event_logs' => 'patchstack_15minute',
100 - );
98 + 'patchstack_send_event_logs' => 'patchstack_15minute'
99 + ];
101 100
102 101 // Schedule the events if they are not scheduled yet.
103 102 foreach ( $free as $event => $interval ) {
104 103 if ( ! wp_next_scheduled( $event ) ) {