PluginProbe ʕ •ᴥ•ʔ
Really Simple Security – Simple and Performant Security (formerly Really Simple SSL) / 9.5.11
Really Simple Security – Simple and Performant Security (formerly Really Simple SSL) v9.5.11
9.5.11 9.5.10.1 9.5.10 trunk 9.4.0 9.4.1 9.4.2 9.4.3 9.5.0 9.5.0.1 9.5.0.2 9.5.1 9.5.2 9.5.2.2 9.5.2.3 9.5.3 9.5.3.1 9.5.3.2 9.5.4 9.5.5 9.5.6 9.5.7 9.5.8 9.5.9
really-simple-ssl / class-cache.php
really-simple-ssl Last commit date
assets 4 weeks ago core 4 weeks ago languages 4 weeks ago lets-encrypt 4 weeks ago lib 4 weeks ago mailer 4 weeks ago modal 4 weeks ago placeholders 4 weeks ago progress 4 weeks ago security 4 weeks ago settings 4 weeks ago testssl 4 weeks ago upgrade 4 weeks ago .wp-env.json 4 weeks ago SECURITY.md 4 weeks ago class-admin.php 4 weeks ago class-cache.php 4 weeks ago class-certificate.php 4 weeks ago class-front-end.php 4 weeks ago class-installer.php 4 weeks ago class-mixed-content-fixer.php 4 weeks ago class-multisite.php 4 weeks ago class-server.php 4 weeks ago class-site-health.php 4 weeks ago class-wp-cli.php 4 weeks ago compatibility.php 4 weeks ago force-deactivate.txt 4 weeks ago functions.php 4 weeks ago index.php 4 weeks ago readme.txt 4 weeks ago rector.php 4 weeks ago rlrsssl-really-simple-ssl.php 4 weeks ago rsssl-auto-loader.php 4 weeks ago sbom.json.gz 4 weeks ago ssl-test-page.php 4 weeks ago system-status.php 4 weeks ago uninstall.php 4 weeks ago upgrade.php 4 weeks ago
class-cache.php
160 lines
1 <?php
2 defined( 'ABSPATH' ) or die( );
3 if ( ! class_exists( 'rsssl_cache' ) ) {
4 class rsssl_cache {
5 private static $_this;
6
7 public function __construct() {
8 if ( isset( self::$_this ) ) {
9 wp_die( 'you cannot create a second instance.' );
10 }
11
12 self::$_this = $this;
13 }
14
15 public static function this() {
16 return self::$_this;
17 }
18
19 /**
20 * Flushes the cache for popular caching plugins to prevent mixed content errors
21 * When .htaccess is changed, all traffic should flow over https, so clear cache when possible.
22 * Supported: W3TC, WP Optimize, LiteSpeed, Hummingbird, WP Fastest Cache,
23 * Autoptimize, WP Rocket, Cache Enabler, WP Super Cache, Cloudflare
24 *
25 * @since 2.0
26 *
27 * @access public
28 *
29 */
30
31 public function flush() {
32 if ( ! rsssl_user_can_manage() ) {
33 return;
34 }
35
36 add_action( 'admin_head', array( $this, 'maybe_flush_w3tc_cache' ) );
37 add_action( 'admin_head', array( $this, 'maybe_flush_wp_optimize_cache' ) );
38 add_action( 'admin_head', array( $this, 'maybe_flush_litespeed_cache' ) );
39 add_action( 'admin_head', array( $this, 'maybe_flush_hummingbird_cache' ) );
40 add_action( 'admin_head', array( $this, 'maybe_flush_fastest_cache' ) );
41 add_action( 'admin_head', array( $this, 'maybe_flush_autoptimize_cache' ) );
42 add_action( 'admin_head', array( $this, 'maybe_flush_wp_rocket' ) );
43 add_action( 'admin_head', array( $this, 'maybe_flush_cache_enabler' ) );
44 add_action( 'admin_head', array( $this, 'maybe_flush_wp_super_cache' ) );
45 add_action( 'admin_head', array( $this, 'maybe_flush_cloudflare_cache' ) );
46 }
47
48 public function maybe_flush_w3tc_cache() {
49 if ( ! rsssl_user_can_manage() ) {
50 return;
51 }
52
53 if ( function_exists( 'w3tc_flush_all' ) ) {
54 w3tc_flush_all();
55 }
56 }
57
58 public function maybe_flush_wp_optimize_cache() {
59 if ( ! rsssl_user_can_manage() ) {
60 return;
61 }
62
63 if ( function_exists( 'wpo_cache_flush' ) ) {
64 wpo_cache_flush();
65 }
66 }
67
68 public function maybe_flush_litespeed_cache() {
69 if ( ! rsssl_user_can_manage() ) {
70 return;
71 }
72
73 if ( class_exists( 'LiteSpeed' ) ) {
74 Litespeed\Purge::purge_all();
75 }
76 }
77
78 public function maybe_flush_hummingbird_cache() {
79 if ( ! rsssl_user_can_manage() ) {
80 return;
81 }
82
83 if ( is_callable( array( 'Hummingbird\WP_Hummingbird', 'flush_cache' ) ) ) {
84 Hummingbird\WP_Hummingbird::flush_cache();
85 }
86 }
87
88 public function maybe_flush_fastest_cache() {
89 if ( ! rsssl_user_can_manage() ) {
90 return;
91 }
92
93 if ( class_exists( 'WpFastestCache' ) ) {
94 // Non-static cannot be called statically ::
95 ( new WpFastestCache() )->deleteCache();
96 }
97 }
98
99 public function maybe_flush_autoptimize_cache() {
100 if ( ! rsssl_user_can_manage() ) {
101 return;
102 }
103
104 if ( class_exists( 'autoptimizeCache' ) ) {
105 autoptimizeCache::clearall();
106 }
107 }
108
109 public function maybe_flush_wp_rocket() {
110 if ( ! rsssl_user_can_manage() ) {
111 return;
112 }
113
114 if ( function_exists( 'rocket_clean_domain' ) ) {
115 rocket_clean_domain();
116 }
117 }
118
119 public function maybe_flush_cache_enabler() {
120 if ( ! rsssl_user_can_manage() ) {
121 return;
122 }
123
124 if ( class_exists( 'Cache_Enabler' ) ) {
125 Cache_Enabler::clear_complete_cache();
126 }
127 }
128
129 public function maybe_flush_wp_super_cache() {
130 if ( ! rsssl_user_can_manage() ) {
131 return;
132 }
133
134 if ( function_exists( 'wp_cache_clear_cache' ) ) {
135 wp_cache_clear_cache();
136 }
137 }
138
139 /**
140 * Flush Cloudflare cache if the Cloudflare plugin is active.
141 *
142 * @see https://github.com/cloudflare/Cloudflare-WordPress
143 */
144 public function maybe_flush_cloudflare_cache() {
145 if ( ! rsssl_user_can_manage() ) {
146 return;
147 }
148
149 if ( defined( 'CLOUDFLARE_PLUGIN_DIR' ) && class_exists( '\Cloudflare\APO\WordPress\Hooks' ) ) {
150 try {
151 $cloudflare_hooks = new \Cloudflare\APO\WordPress\Hooks();
152 $cloudflare_hooks->purgeCacheEverything();
153 } catch ( \Throwable $e ) {
154 // Silently fail if Cloudflare API is not configured.
155 }
156 }
157 }
158 }//class closure
159 }
160