PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.21
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.21
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 / webp / class-wpo-webp-cron-scheduler.php

class-wpo-webp-cron-scheduler.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.21, at webp/class-wpo-webp-cron-scheduler.php

48 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('WPO_VERSION')) die('No direct access allowed');
4
5 if (!class_exists('WPO_WebP_Cron_Scheduler')) :
6
7 class WPO_WebP_Cron_Scheduler {
8
9 /**
10 * Constructor
11 */
12 private function __construct() {
13 $this->setup_cron_event();
14 add_action('wpo_reset_webp_conversion_test_result', array($this, 'reset_webp_conversion_flags'));
15 }
16
17 /**
18 * Returns singleton instance of this class
19 *
20 * @return WPO_WebP_Cron_Scheduler Singleton Instance
21 */
22 public static function get_instance() {
23 static $instance = null;
24 if (null === $instance) {
25 $instance = new self();
26 }
27 return $instance;
28 }
29
30 /**
31 * Setup cron event to reset webp conversion test result
32 */
33 private function setup_cron_event() {
34 if (!wp_next_scheduled('wpo_reset_webp_conversion_test_result')) {
35 wp_schedule_event(time(), 'wpo_daily', 'wpo_reset_webp_conversion_test_result');
36 }
37 }
38
39 /**
40 * Reset all webp conversion flags
41 */
42 public function reset_webp_conversion_flags() {
43 WP_Optimize()->get_webp_instance()->reset_webp_serving_method();
44 }
45 }
46
47 endif;
48