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 1 month ago core 1 month ago languages 1 month ago lets-encrypt 1 month ago lib 1 month ago mailer 1 month ago modal 1 month ago placeholders 1 month ago progress 1 month ago security 1 month ago settings 1 month ago testssl 1 month ago upgrade 1 month ago .wp-env.json 1 month ago SECURITY.md 1 month ago class-admin.php 1 month ago class-cache.php 1 month ago class-certificate.php 1 month ago class-front-end.php 1 month ago class-installer.php 1 month ago class-mixed-content-fixer.php 1 month ago class-multisite.php 1 month ago class-server.php 1 month ago class-site-health.php 1 month ago class-wp-cli.php 1 month ago compatibility.php 1 month ago force-deactivate.txt 1 month ago functions.php 1 month ago index.php 1 month ago readme.txt 1 month ago rector.php 1 month ago rlrsssl-really-simple-ssl.php 1 month ago rsssl-auto-loader.php 1 month ago sbom.json.gz 1 month ago ssl-test-page.php 1 month ago system-status.php 1 month ago uninstall.php 1 month ago upgrade.php 1 month 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