PluginProbe
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score / 1.2.4
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score v1.2.4
trunk 1.0 1.0.1 1.1 1.1.1 1.1.2 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1 2.1.1 2.1.2 2.2 2.2.1 All 69 releases
powered-cache / includes / admin / notices.php

notices.php in Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score 1.2.4, at includes/admin/notices.php

243 lines 8.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 add_action( 'admin_notices', 'powered_cache_flash_messages' );
8
9 /**
10 * Display flash messages
11 *
12 * @since 1.0
13 */
14 function powered_cache_flash_messages() {
15 Powered_Cache_Admin_Helper::get_flash_message();
16 }
17
18
19 add_action( 'admin_notices', 'powered_cache_plugin_compatability_notices' );
20
21 /**
22 * Display incompatible plugins
23 *
24 * @since 1.0
25 */
26 function powered_cache_plugin_compatability_notices() {
27
28 $plugins = array(
29 'w3-total-cache' => 'w3-total-cache/w3-total-cache.php',
30 'wp-super-cache' => 'wp-super-cache/wp-cache.php',
31 'quick-cache' => 'quick-cache/quick-cache.php',
32 'hyper-cache' => 'hyper-cache/plugin.php',
33 'hyper-cache-extended' => 'hyper-cache-extended/plugin.php',
34 'wp-fast-cache' => 'wp-fast-cache/wp-fast-cache.php',
35 'flexicache' => 'flexicache/wp-plugin.php',
36 'wp-fastest-cache' => 'wp-fastest-cache/wpFastestCache.php',
37 'lite-cache' => 'lite-cache/plugin.php',
38 'gator-cache' => 'gator-cache/gator-cache.php',
39 'wp-http-compression' => 'wp-http-compression/wp-http-compression.php',
40 'wordpress-gzip-compression' => 'wordpress-gzip-compression/ezgz.php',
41 'gzip-ninja-speed-compression' => 'gzip-ninja-speed-compression/gzip-ninja-speed.php',
42 'speed-booster-pack' => 'speed-booster-pack/speed-booster-pack.php',
43 'wp-performance-score-booster' => 'wp-performance-score-booster/wp-performance-score-booster.php',
44 'remove-query-strings-from-static-resources' => 'remove-query-strings-from-static-resources/remove-query-strings.php',
45 'query-strings-remover' => 'query-strings-remover/query-strings-remover.php',
46 'wp-ffpc' => 'wp-ffpc/wp-ffpc.php',
47 'far-future-expiry-header' => 'far-future-expiry-header/far-future-expiration.php',
48 'combine-css' => 'combine-css/combine-css.php',
49 'super-static-cache' => 'super-static-cache/super-static-cache.php',
50 'wpcompressor' => 'wpcompressor/wpcompressor.php',
51 'check-and-enable-gzip-compression' => 'check-and-enable-gzip-compression/richards-toolbox.php',
52 'leverage-browser-caching-ninjas' => 'leverage-browser-caching-ninjas/leverage-browser-caching-ninja.php',
53 'force-gzip' => 'force-gzip/force-gzip.php'
54 );
55
56
57 $plugins = array_filter( $plugins, 'is_plugin_active' );
58
59 if ( count( $plugins ) > 0 && current_user_can( apply_filters( 'powered_cache_cap', 'manage_options' ) ) ) { ?>
60 <div class="error">
61 <h2><?php _e( 'Powered Cache', 'powered-cache' ); ?></h2>
62
63 <p><?php printf( __( 'The following plugins are not compatible with <b>%s</b> and will cause unintended results:', 'powered-cache' ), __( 'Powered Cache', 'powered-cache' ) ); ?></p>
64 <ul class="incompatible-plugin-list">
65 <?php
66 foreach ( $plugins as $plugin ) {
67 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $plugin );
68 echo '<li>' . $plugin_data['Name'] . '</span> <a href="' . wp_nonce_url( admin_url( 'admin-post.php?action=deactivate_plugin&plugin=' . urlencode( $plugin ) ), 'deactivate_plugin' ) . '" class="button-secondary">' . __( 'Deactivate', 'powered-cache' ) . '</a></li>';
69 }
70 ?>
71 </ul>
72 </div>
73 <?php
74 }
75 }
76
77 add_action( 'admin_notices', 'powered_cache_advanced_cache_notices' );
78
79 /**
80 * Show notices about page cache
81 *
82 * @since 1.0
83 */
84 function powered_cache_advanced_cache_notices() {
85
86 /**
87 * Users might want to control this notice.
88 * eg: Varnish users don't need to turning on page cache.
89 * Yeah! they can use remove_action as well
90 *
91 * @since 1.2
92 */
93 if ( apply_filters( 'powered_cache_disable_advanced_cache_notices', false ) ) {
94 return;
95 }
96
97 if ( powered_cache_is_saving_options() ) {
98 return;
99 }
100
101
102 if ( true !== powered_cache_get_option( 'enable_page_caching' ) ) {
103 ?>
104 <div class="notice notice-warning"><p>
105 <?php echo sprintf( __( '<strong>Important:</strong> please enable page caching on the Powered Cache <a href="%s">settings page</a>', 'powered-cache' ), admin_url( 'admin.php?page=powered-cache' ) ); ?>
106 </p>
107 </div>
108 <?php
109 return;
110 }
111
112 $err = array();
113
114 if ( ! defined( 'WP_CACHE' ) || true !== WP_CACHE ) {
115 $err['wp_cache'] = sprintf( __( '<code>%s</code> is not in wp-config.php.', 'powered-cache' ), 'define("WP_CACHE", true);' );
116 }
117
118 if ( ! defined( 'POWERED_CACHE_PAGE_CACHING' ) || true !== POWERED_CACHE_PAGE_CACHING ) {
119 $err['powered_cache_page_cache'] = sprintf( __( '<code>%s</code> file was edited or deleted. You can re-create correct configuration files by saving settings.', 'powered-cache' ), basename( WP_CONTENT_DIR ) . '/advanced-cache.php' );
120 }
121
122
123 if ( defined( 'POWERED_CACHE_PAGE_CACHING_HAS_PROBLEM' ) && true === POWERED_CACHE_PAGE_CACHING_HAS_PROBLEM ) {
124 $err['powered_cache_page_cache_has_problem'] = sprintf( __( 'Powered Cache could not access dropin. Please check <code>%s</code> exist and accessible on your server.', 'powered-cache' ), POWERED_CACHE_DROPIN_DIR . 'page-cache.php' );
125 }
126
127 // everything ok
128 if ( empty( $err ) ) {
129 return;
130 }
131
132 if ( ! current_user_can( apply_filters( 'powered_cache_cap', 'manage_options' ) ) ) {
133 return;
134 }
135 ?>
136 <div class="error">
137 <h2><?php _e( 'Powered Cache', 'powered-cache' ); ?></h2>
138 <strong><?php echo __( 'Page Caching feature could not work because:', 'powered-cache' ); ?></strong>
139
140 <?php foreach ( $err as $error_msg ): ?>
141 <p><?php echo $error_msg; ?></p>
142 <?php endforeach; ?>
143 </div>
144 <?php
145
146
147 }
148
149 add_action( 'admin_notices', 'powered_cache_object_cache_notices' );
150
151 /**
152 * Display object cache broken msg
153 *
154 * @since 1.0
155 */
156 function powered_cache_object_cache_notices() {
157 $object_cache_backends = Powered_Cache_Admin_Helper::object_cache_dropins();
158 $object_cache_driver = powered_cache_get_option( 'object_cache' );
159 $object_cache_dropin = untrailingslashit( WP_CONTENT_DIR ) . '/object-cache.php';
160
161
162 if ( ! current_user_can( apply_filters( 'powered_cache_cap', 'manage_options' ) ) ) {
163 return;
164 }
165
166 // first check object cache file exist
167 if ( isset( $object_cache_backends[ $object_cache_driver ] ) && ! file_exists( $object_cache_dropin ) ) {
168 $message = sprintf( __( 'Phew! It looks your object cache file missing. Please check <code>%s</code> exist, writable and accessible on your server.', 'powered-cache' ), $object_cache_dropin );
169 ?>
170 <div class="error">
171 <p><strong><?php echo __( 'Powered Cache:', 'powered-cache' ); ?></strong>
172 <?php echo $message; ?>
173 </p>
174 </div>
175 <?php
176 return;
177 }
178
179
180
181 if ( defined( 'POWERED_OBJECT_CACHE_HAS_PROBLEM' ) && true === POWERED_OBJECT_CACHE_HAS_PROBLEM ) {
182 if ( isset( $object_cache_backends[ $object_cache_driver] ) ) {
183 $broken_file = $object_cache_backends[ $object_cache_driver ];
184 }
185
186 $message = sprintf( __( 'Powered Cache could not access object cache backend. Please check <code>%s</code> exist and accessible on your server.', 'powered-cache' ), $broken_file );
187 ?>
188 <div class="error">
189 <p><strong><?php echo __( 'Powered Cache:', 'powered-cache' ); ?></strong>
190 <?php echo $message; ?>
191 </p>
192 </div>
193 <?php
194 }
195
196 }
197
198 add_action( 'admin_notices', 'powered_cache_maybe_htaccess_warning' );
199
200 /**
201 * Notices for the .htaccess
202 *
203 * @since 1.2
204 */
205 function powered_cache_maybe_htaccess_warning() {
206 global $is_apache;
207
208 if ( true !== powered_cache_get_option( 'configure_htaccess' ) ) {
209 return;
210 }
211
212 if ( ! $is_apache ) {
213 return;
214 }
215
216 if ( ! current_user_can( apply_filters( 'powered_cache_cap', 'manage_options' ) ) ) {
217 return;
218 }
219
220 $htaccess_file = get_home_path() . '.htaccess';
221 $message = '';
222 if ( ! file_exists( $htaccess_file ) ) {
223 $message = sprintf( __( 'We can\'t find <code>%s</code> file on your server. Please create a new <code>.htaccess</code> file. <a href="%s">Codex</a> might help!.', 'powered-cache' ), '.htaccess', 'https://codex.wordpress.org/htaccess' );
224 } elseif ( ! is_writeable( $htaccess_file ) ) {
225 $message = sprintf( __( 'Oh no! It looks your <code>%s</code> file is not writable. Please make sure it is writable by the web server. Your website will much more faster when configured for Powered Cache.', 'powered-cache' ), '.htaccess' );
226 }
227
228 if ( empty( $message ) ) {
229 return;
230 }
231
232 ?>
233
234 <div class="error">
235 <p><strong><?php echo __( 'Powered Cache:', 'powered-cache' ); ?></strong>
236 <?php echo $message; ?>
237 </p>
238 </div>
239
240 <?php
241
242 }
243