C:\xampp\htdocs\landing\wp-content\plugins\wp-optimize\cache\class-wpo-detect-cache-plugins.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php

if (!defined('ABSPATH')) die('No direct access allowed');

class 
WP_Optimize_Detect_Cache_Plugins {

    private static 
$instance;

    
/**
     * WP_Optimize_Detect_Cache_Plugins constructor.
     */
    
protected function __construct() {
    }

    
/**
     * Detect list of active most popular WordPress cache plugins.
     *
     * @return array
     */
    
public function get_active_cache_plugins() {
        
// The index is the plugin's slug

        
$active_cache_plugins = array();

        foreach (
$this->get_plugins() as $plugin_slug => $plugin_title) {

            
$function_name 'is_'.str_replace('-''_'$plugin_slug).'_plugin_active';

            if (
is_callable(array($this$function_name))) {
                if (
call_user_func(array($this$function_name))) {
                    
$active_cache_plugins[$plugin_slug] = $plugin_title;
                }
            } else {
                if (
$this->is_plugin_active($plugin_slug)) {
                    
$active_cache_plugins[$plugin_slug] = $plugin_title;
                }
            }
        }

        return 
$active_cache_plugins;
    }

    
/**
     * Get the plugins list
     *
     * @return array
     */
    
protected function get_plugins() {
        return array(
            
'w3-total-cache' => 'W3 Total Cache',
            
'wp-super-cache' => 'WP Super Cache',
            
'wp-rocket' => 'WP Rocket',
            
'wp-fastest-cache' => 'WP Fastest Cache',
            
'litespeed-cache' => 'LiteSpeed Cache',
            
'cache-enabler' => 'Cache Enabler',
            
'comet-cache' => 'Comet Cache',
            
'hummingbird-performance' => 'Hummingbird',
            
'hyper-cache' => 'Hyper Cache',
        );
    }

    
/**
     * Check if W3 Total Cache active.
     *
     * @return bool
     */
    
public function is_w3_total_cache_plugin_active() {
        return 
defined('W3TC_VERSION') || $this->is_plugin_active('w3-total-cache');
    }

    
/**
     * Check if WP Rocket active.
     *
     * @return bool
     */
    
public function is_wp_rocket_plugin_active() {
        return 
defined('WP_ROCKET_VERSION') || $this->is_plugin_active('wp-rocket');
    }

    
/**
     * Check if $plugin is active.
     *
     * @param string $plugin - plugin slug
     *
     * @return bool
     */
    
private function is_plugin_active($plugin) {
        
$status WP_Optimize()->get_db_info()->get_plugin_status($plugin);

        return 
$status['active'];
    }

    
/**
     * Instance of WP_Optimize_Detect_Cache_Plugins.
     *
     * @return WP_Optimize_Detect_Cache_Plugins
     */
    
static public function instance() {
        static 
$instance;
        if (empty(
$instance)) {
            
$instance = new self();
        }

        return 
$instance;
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586