PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.5.3
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.5.3
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / includes / class-wp-optimize-404-detector-cron.php

class-wp-optimize-404-detector-cron.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 4.5.3, at includes/class-wp-optimize-404-detector-cron.php

57 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) die('No direct access allowed');
3
4 if (!class_exists('WP_Optimize_404_Detector_Cron')) :
5
6 class WP_Optimize_404_Detector_Cron {
7
8 /**
9 * Class constructor
10 */
11 private function __construct() {
12 $this->initialize();
13 }
14
15 /**
16 * Initialize the class as a singleton
17 *
18 * @return WP_Optimize_404_Detector_Cron
19 */
20 public static function get_instance() {
21 static $_instance = null;
22 if (null === $_instance) {
23 $_instance = new self();
24 }
25 return $_instance;
26 }
27
28 /**
29 * Initialize class actions
30 */
31 public function initialize() {
32 if (WP_Optimize()->get_options()->get_option('404_detector')) {
33 $this->setup_cron_event();
34 } else {
35 $this->remove_cron_event();
36 }
37 }
38
39 /**
40 * Schedule cron event
41 */
42 private function setup_cron_event() {
43 if (!wp_next_scheduled('wpo_prune_404_log')) {
44 wp_schedule_event(time(), 'wpo_daily', 'wpo_prune_404_log');
45 }
46 }
47
48 /**
49 * Remove scheduled cron event
50 */
51 private function remove_cron_event() {
52 wp_clear_scheduled_hook('wpo_prune_404_log');
53 }
54 }
55
56 endif;
57