Cache.php
1.46 KB
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
<?php
namespace AIOSEO\Plugin\Common\ThirdParty\Cache;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Handles third-party caching plugins.
*
* @since 4.2.5
*/
class Cache {
/**
* The third-party plugins we have rules for.
*
* @since 4.2.5
*
* @var string[] The key contains the class name prefixed with its namespace.
* The value contains the "{plugin_folder}/{plugin_main_file}".
*/
private $plugins = [
'AIOSEO\Plugin\Common\ThirdParty\Cache\WpFastestCache' => 'wp-fastest-cache/wpFastestCache.php'
];
/**
* List of active plugins and their instances.
*
* @since 4.2.7
*
* @var array[Object]
*/
private $activePlugins = [];
/**
* Class constructor.
*
* @since 4.2.5
*/
public function __construct() {
if ( ! function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$this->activePlugins = [];
foreach ( $this->plugins as $class => $relativeFilePath ) {
if ( is_plugin_active( $relativeFilePath ) ) {
$this->activePlugins[] = new $class( $relativeFilePath );
}
}
}
/**
* Takes a request URI, e.g. "sitemap.xml", and prevent it from being cached.
*
* @since 4.2.5
*
* @param string $uri Request URI.
* @return void
*/
public function excludeUri( $uri ) {
foreach ( $this->activePlugins as $activePlugin ) {
if ( method_exists( $activePlugin, 'excludeUri' ) ) {
$activePlugin->excludeUri( $uri );
}
}
}
}