101 prune_super_cache ($cache_path, true); |
113 prune_super_cache ($cache_path, true); |
102 @unlink( $cache_path . '.htaccess' ); |
114 @unlink( $cache_path . '.htaccess' ); |
103 @unlink( $cache_path . 'meta' ); |
115 @unlink( $cache_path . 'meta' ); |
104 @unlink( $cache_path . 'supercache' ); |
116 @unlink( $cache_path . 'supercache' ); |
105 wp_clear_scheduled_hook( 'wp_cache_check_site_hook' ); |
117 wp_clear_scheduled_hook( 'wp_cache_check_site_hook' ); |
106 } |
118 wp_clear_scheduled_hook( 'wp_cache_gc' ); |
107 register_deactivation_hook( __FILE__, 'wpsupercache_deactivate' ); |
119 wp_clear_scheduled_hook( 'wp_cache_gc_watcher' ); |
|
120 wp_cache_disable_plugin(); |
|
121 } |
|
122 register_uninstall_hook( __FILE__, 'wpsupercache_deactivate' ); |
108 |
123 |
109 function wpsupercache_activate() { |
124 function wpsupercache_activate() { |
110 } |
125 } |
111 register_activation_hook( __FILE__, 'wpsupercache_activate' ); |
126 register_activation_hook( __FILE__, 'wpsupercache_activate' ); |
112 |
127 |
|
128 function wpsupercache_site_admin() { |
|
129 if ( function_exists( 'is_super_admin' ) ) { |
|
130 return is_super_admin(); |
|
131 } elseif ( function_exists( 'is_site_admin' ) ) { |
|
132 return is_site_admin(); |
|
133 } else { |
|
134 return true; |
|
135 } |
|
136 } |
|
137 |
113 function wp_cache_add_pages() { |
138 function wp_cache_add_pages() { |
114 if( function_exists( 'is_site_admin' ) ) { |
139 global $wpmu_version; |
115 if( is_site_admin() ) { |
140 if ( function_exists( 'is_multisite' ) && is_multisite() && wpsupercache_site_admin() ) { |
116 add_submenu_page('wpmu-admin.php', 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager'); |
141 add_submenu_page( 'ms-admin.php', 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager' ); |
117 add_options_page('WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager'); |
142 } elseif ( isset( $wpmu_version ) && wpsupercache_site_admin() ) { |
118 } |
143 add_submenu_page( 'wpmu-admin.php', 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager' ); |
119 } else { |
144 } |
120 add_options_page('WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager'); |
145 |
|
146 if ( wpsupercache_site_admin() ) { // in single or MS mode add this menu item too, but only for superadmins in MS mode. |
|
147 add_options_page( 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager'); |
121 } |
148 } |
122 } |
149 } |
123 add_action('admin_menu', 'wp_cache_add_pages'); |
150 add_action('admin_menu', 'wp_cache_add_pages'); |
|
151 |
|
152 function wp_cache_network_pages() { |
|
153 add_submenu_page('settings.php', 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager'); |
|
154 } |
|
155 add_action( 'network_admin_menu', 'wp_cache_network_pages' ); |
|
156 |
|
157 function wp_cache_manager_error_checks() { |
|
158 global $wpmu_version, $wp_cache_debug, $wp_cache_cron_check, $cache_enabled, $super_cache_enabled, $wp_cache_config_file, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers, $wp_cache_mobile_enabled, $wp_cache_mod_rewrite, $cache_path; |
|
159 global $dismiss_htaccess_warning, $dismiss_readable_warning, $dismiss_gc_warning, $wp_cache_shutdown_gc; |
|
160 |
|
161 if ( !wpsupercache_site_admin() ) |
|
162 return false; |
|
163 |
|
164 if ( version_compare( PHP_VERSION, '5.3.0', '<' ) && ( 1 == ini_get( 'safe_mode' ) || "on" == strtolower( ini_get( 'safe_mode' ) ) ) ) { |
|
165 echo '<div id="message" class="updated fade"><h3>' . __( 'Warning! PHP Safe Mode Enabled!', 'wp-super-cache' ) . '</h3><p>' . |
|
166 __( 'You may experience problems running this plugin because SAFE MODE is enabled.', 'wp-super-cache' ) . ' '; |
|
167 |
|
168 |
|
169 if( !ini_get( 'safe_mode_gid' ) ) { |
|
170 _e( 'Your server is set up to check the owner of PHP scripts before allowing them to read and write files.', 'wp-super-cache' ) . " "; |
|
171 printf( __( 'You or an administrator may be able to make it work by changing the group owner of the plugin scripts to match that of the web server user. The group owner of the %s/cache/ directory must also be changed. See the <a href="http://php.net/features.safe-mode">safe mode manual page</a> for further details.', 'wp-super-cache' ), WP_CONTENT_DIR ); |
|
172 } else { |
|
173 _e( 'You or an administrator must disable this. See the <a href="http://php.net/features.safe-mode">safe mode manual page</a> for further details. This cannot be disabled in a .htaccess file unfortunately. It must be done in the php.ini config file.', 'wp-super-cache' ); |
|
174 } |
|
175 echo '</p></div>'; |
|
176 } |
|
177 |
|
178 if ( '' == get_option( 'permalink_structure' ) ) { |
|
179 echo '<div id="message" class="updated fade"><h3>' . __( 'Permlink Structure Error', 'wp-super-cache' ) . '</h3>'; |
|
180 echo "<p>" . __( 'A custom url or permalink structure is required for this plugin to work correctly. Please go to the <a href="options-permalink.php">Permalinks Options Page</a> to configure your permalinks.' ) . "</p>"; |
|
181 echo '</div>'; |
|
182 return false; |
|
183 } |
|
184 |
|
185 if( $wp_cache_debug || !$wp_cache_cron_check ) { |
|
186 if( function_exists( "wp_remote_get" ) == false ) { |
|
187 $hostname = str_replace( 'http://', '', str_replace( 'https://', '', get_option( 'siteurl' ) ) ); |
|
188 if( strpos( $hostname, '/' ) ) |
|
189 $hostname = substr( $hostname, 0, strpos( $hostname, '/' ) ); |
|
190 $ip = gethostbyname( $hostname ); |
|
191 if( substr( $ip, 0, 3 ) == '127' || substr( $ip, 0, 7 ) == '192.168' ) { |
|
192 ?><div id="message" class="updated fade"><h3><?php printf( __( 'Warning! Your hostname "%s" resolves to %s', 'wp-super-cache' ), $hostname, $ip ); ?></h3> |
|
193 <p><?php printf( __( 'Your server thinks your hostname resolves to %s. Some services such as garbage collection by this plugin, and WordPress scheduled posts may not operate correctly.', 'wp-super-cache' ), $ip ); ?></p> |
|
194 <p><?php printf( __( 'Please see entry 16 in the <a href="%s">Troubleshooting section</a> of the readme.txt', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?></p> |
|
195 </div> |
|
196 <?php |
|
197 return false; |
|
198 } else { |
|
199 wp_cache_replace_line('^ *\$wp_cache_cron_check', "\$wp_cache_cron_check = 1;", $wp_cache_config_file); |
|
200 } |
|
201 } else { |
|
202 $cron_url = get_option( 'siteurl' ) . '/wp-cron.php?check=' . wp_hash('187425'); |
|
203 $cron = wp_remote_get($cron_url, array('timeout' => 0.01, 'blocking' => true)); |
|
204 if( is_array( $cron ) ) { |
|
205 if( $cron[ 'response' ][ 'code' ] == '404' ) { |
|
206 ?><div id="message" class="updated fade"><h3>Warning! wp-cron.php not found!</h3> |
|
207 <p><?php _e( 'Unfortunately WordPress cannot find the file wp-cron.php. This script is required for the the correct operation of garbage collection by this plugin, WordPress scheduled posts as well as other critical activities.', 'wp-super-cache' ); ?></p> |
|
208 <p><?php printf( __( 'Please see entry 16 in the <a href="%s">Troubleshooting section</a> of the readme.txt', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?></p> |
|
209 </div> |
|
210 <?php |
|
211 } else { |
|
212 wp_cache_replace_line('^ *\$wp_cache_cron_check', "\$wp_cache_cron_check = 1;", $wp_cache_config_file); |
|
213 } |
|
214 } |
|
215 } |
|
216 } |
|
217 |
|
218 if ( !wp_cache_check_link() || |
|
219 !wp_cache_verify_config_file() || |
|
220 !wp_cache_verify_cache_dir() ) { |
|
221 echo '<p>' . __( "Cannot continue... fix previous problems and retry.", 'wp-super-cache' ) . '</p>'; |
|
222 return false; |
|
223 } |
|
224 |
|
225 if (!wp_cache_check_global_config()) { |
|
226 return false; |
|
227 } |
|
228 |
|
229 if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) { |
|
230 ?><div id="message" class="updated fade"><h3><?php _e( 'Zlib Output Compression Enabled!', 'wp-super-cache' ); ?></h3> |
|
231 <p><?php _e( 'PHP is compressing the data sent to the visitors of your site. Disabling this is recommended as the plugin caches the compressed output once instead of compressing the same page over and over again. Also see #21 in the Troubleshooting section. See <a href="http://php.net/manual/en/zlib.configuration.php">this page</a> for instructions on modifying your php.ini.', 'wp-super-cache' ); ?></p></div><?php |
|
232 } |
|
233 |
|
234 if( $cache_enabled == true && $super_cache_enabled == true && $wp_cache_mod_rewrite && !got_mod_rewrite() ) { |
|
235 ?><div id="message" class="updated fade"><h3><?php _e( 'Mod rewrite may not be installed!', 'wp-super-cache' ); ?></h3> |
|
236 <p><?php _e( 'It appears that mod_rewrite is not installed. Sometimes this check isn’t 100% reliable, especially if you are not using Apache. Please verify that the mod_rewrite module is loaded. It is required for serving Super Cache static files. You will still be able to use legacy or PHP modes.', 'wp-super-cache' ); ?></p></div><?php |
|
237 } |
|
238 |
|
239 if( !is_writeable_ACLSafe( $wp_cache_config_file ) ) { |
|
240 if ( !defined( 'SUBMITDISABLED' ) ) |
|
241 define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' ); |
|
242 ?><div id="message" class="updated fade"><h3><?php _e( 'Read Only Mode. Configuration cannot be changed.', 'wp-super-cache' ); ?></h3> |
|
243 <p><?php printf( __( 'The WP Super Cache configuration file is <code>%s/wp-cache-config.php</code> and cannot be modified. That file must be writeable by the webserver to make any changes.', 'wp-super-cache' ), WP_CONTENT_DIR ); ?> |
|
244 <?php _e( 'A simple way of doing that is by changing the permissions temporarily using the CHMOD command or through your ftp client. Make sure it’s globally writeable and it should be fine.', 'wp-super-cache' ); ?></p> |
|
245 <p><?php _e( '<a href="http://codex.wordpress.org/Changing_File_Permissions">This page</a> explains how to change file permissions.', 'wp-super-cache' ); ?></p> |
|
246 <?php _e( 'Writeable:', 'wp-super-cache' ); ?> <code>chmod 666 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code> |
|
247 <?php _e( 'Readonly:', 'wp-super-cache' ); ?> <code>chmod 644 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code></p> |
|
248 </div><?php |
|
249 } elseif ( !defined( 'SUBMITDISABLED' ) ) { |
|
250 define( "SUBMITDISABLED", ' ' ); |
|
251 } |
|
252 |
|
253 $valid_nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache') : false; |
|
254 // Check that garbage collection is running |
|
255 if ( $valid_nonce && $_POST[ 'action' ] == 'dismiss_gc_warning' ) { |
|
256 wp_cache_replace_line('^ *\$dismiss_gc_warning', "\$dismiss_gc_warning = 1;", $wp_cache_config_file); |
|
257 $dismiss_gc_warning = 1; |
|
258 } elseif ( !isset( $dismiss_gc_warning ) ) { |
|
259 $dismiss_gc_warning = 0; |
|
260 } |
|
261 if ( $cache_enabled && ( !isset( $wp_cache_shutdown_gc ) || $wp_cache_shutdown_gc == 0 ) && function_exists( 'get_gc_flag' ) ) { |
|
262 $gc_flag = get_gc_flag(); |
|
263 if ( $dismiss_gc_warning == 0 ) { |
|
264 if ( false == maybe_stop_gc( $gc_flag ) && false == wp_next_scheduled( 'wp_cache_gc' ) ) { |
|
265 ?><div id="message" class="updated fade"><h3><?php _e( 'Warning! Garbage collection is not scheduled!', 'wp-super-cache' ); ?></h3> |
|
266 <p><?php _e( 'Garbage collection by this plugin clears out expired and old cached pages on a regular basis. Use <a href="#expirytime">this form</a> to enable it.', 'wp-super-cache' ); ?> </p> |
|
267 <form action="" method="POST"> |
|
268 <input type="hidden" name="action" value="dismiss_gc_warning" /> |
|
269 <input type="hidden" name="page" value="wpsupercache" /> |
|
270 <?php wp_nonce_field( 'wp-cache' ); ?> |
|
271 <input type='submit' value='<?php _e( 'Dismiss', 'wp-super-cache' ); ?>' /> |
|
272 </form> |
|
273 <br /> |
|
274 </div> |
|
275 <?php |
|
276 } |
|
277 } |
|
278 } |
|
279 |
|
280 // Server could be running as the owner of the wp-content directory. Therefore, if it's |
|
281 // writable, issue a warning only if the permissions aren't 755. |
|
282 if ( $valid_nonce && $_POST[ 'action' ] == 'dismiss_readable_warning' ) { |
|
283 wp_cache_replace_line('^ *\$dismiss_readable_warning', "\$dismiss_readable_warning = 1;", $wp_cache_config_file); |
|
284 $dismiss_readable_warning = 1; |
|
285 } elseif ( !isset( $dismiss_readable_warning ) ) { |
|
286 $dismiss_readable_warning = 0; |
|
287 } |
|
288 if( $dismiss_readable_warning == 0 && is_writeable_ACLSafe( WP_CONTENT_DIR . '/' ) ) { |
|
289 $wp_content_stat = stat(WP_CONTENT_DIR . '/'); |
|
290 $wp_content_mode = decoct( $wp_content_stat[ 'mode' ] & 0777 ); |
|
291 if( substr( $wp_content_mode, -2 ) == '77' ) { |
|
292 ?><div id="message" class="updated fade"><h3><?php printf( __( 'Warning! %s is writeable!', 'wp-super-cache' ), WP_CONTENT_DIR ); ?></h3> |
|
293 <p><?php printf( __( 'You should change the permissions on %s and make it more restrictive. Use your ftp client, or the following command to fix things:', 'wp-super-cache' ), WP_CONTENT_DIR ); ?> <code>chmod 755 <?php echo WP_CONTENT_DIR; ?>/</code></p> |
|
294 <p><?php _e( '<a href="http://codex.wordpress.org/Changing_File_Permissions">This page</a> explains how to change file permissions.', 'wp-super-cache' ); ?></p> |
|
295 <form action="" method="POST"> |
|
296 <input type="hidden" name="action" value="dismiss_readable_warning" /> |
|
297 <input type="hidden" name="page" value="wpsupercache" /> |
|
298 <?php wp_nonce_field( 'wp-cache' ); ?> |
|
299 <input type='submit' value='<?php _e( 'Dismiss', 'wp-super-cache' ); ?>' /> |
|
300 </form> |
|
301 <br /> |
|
302 </div> |
|
303 <?php |
|
304 } |
|
305 } |
|
306 |
|
307 if ( function_exists( "is_main_site" ) && true == is_main_site() ) { |
|
308 $home_path = trailingslashit( get_home_path() ); |
|
309 $scrules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WPSuperCache' ) ); |
|
310 if ( $cache_enabled && $wp_cache_mod_rewrite && !$wp_cache_mobile_enabled && strpos( $scrules, addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) ) ) { |
|
311 echo '<div id="message" class="updated fade"><h3>' . __( 'Mobile rewrite rules detected', 'wp-super-cache' ) . "</h3>"; |
|
312 echo "<p>" . __( 'For best performance you should enable "Mobile device support" or delete the mobile rewrite rules in your .htaccess. Look for the 2 lines with the text "2.0\ MMP|240x320" and delete those.', 'wp-super-cache' ) . "</p><p>" . __( 'This will have no affect on ordinary users but mobile users will see uncached pages.', 'wp-super-cache' ) . "</p></div>"; |
|
313 } elseif ( $wp_cache_mod_rewrite && $cache_enabled && $wp_cache_mobile_enabled && $scrules != '' && ( |
|
314 ( false == empty( $wp_cache_mobile_prefixes ) && false === strpos( $scrules, addcslashes( implode( '|', $wp_cache_mobile_prefixes ), ' ' ) ) ) || |
|
315 ( false == empty( $wp_cache_mobile_browsers ) && false === strpos( $scrules, addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) ) ) ) |
|
316 ) { |
|
317 ?> |
|
318 <div id="message" class="updated fade"><h3><?php _e( 'Rewrite rules must be updated', 'wp-super-cache' ); ?></h3> |
|
319 <p><?php _e( 'The rewrite rules required by this plugin have changed or are missing. ', 'wp-super-cache' ); ?> |
|
320 <?php _e( 'Mobile support requires extra rules in your .htaccess file, or you can set the plugin to legacy mode. Here are your options (in order of difficulty):', 'wp-super-cache' ); ?> |
|
321 <ol><li> <?php _e( 'Set the plugin to legacy mode and enable mobile support.', 'wp-super-cache' ); ?></li> |
|
322 <li> <?php _e( 'Scroll down the Advanced Settings page and click the <strong>Update Mod_Rewrite Rules</strong> button.', 'wp-super-cache' ); ?></li> |
|
323 <li> <?php printf( __( 'Delete the plugin mod_rewrite rules in %s.htaccess enclosed by <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code> and let the plugin regenerate them by reloading this page.', 'wp-super-cache' ), $home_path ); ?></li> |
|
324 <li> <?php printf( __( 'Add the rules yourself. Edit %s.htaccess and find the block of code enclosed by the lines <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code>. There are two sections that look very similar. Just below the line <code>%%{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$</code> add these lines: (do it twice, once for each section)', 'wp-super-cache' ), $home_path ); ?></p> |
|
325 <div style='padding: 2px; margin: 2px; border: 1px solid #333; width:400px; overflow: scroll'><pre><?php echo "RewriteCond %{HTTP_user_agent} !^.*(" . addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) . ").*\nRewriteCond %{HTTP_user_agent} !^(" . addcslashes( implode( '|', $wp_cache_mobile_prefixes ), ' ' ) . ").*"; ?></pre></div></li></ol></div><?php |
|
326 } |
|
327 |
|
328 if ( $cache_enabled && $super_cache_enabled && $wp_cache_mod_rewrite && $scrules == '' ) { |
|
329 ?><div id="message" class="updated fade"><h3><?php _e( 'Rewrite rules must be updated', 'wp-super-cache' ); ?></h3> |
|
330 <p><?php _e( 'The rewrite rules required by this plugin have changed or are missing. ', 'wp-super-cache' ); ?> |
|
331 <?php _e( 'Scroll down the Advanced Settings page and click the <strong>Update Mod_Rewrite Rules</strong> button.', 'wp-super-cache' ); ?></p></div><?php |
|
332 } |
|
333 } |
|
334 |
|
335 if ( $wp_cache_mod_rewrite && $super_cache_enabled && function_exists( 'apache_get_modules' ) ) { |
|
336 $mods = apache_get_modules(); |
|
337 $required_modules = array( 'mod_mime' => __( 'Required to serve compressed supercache files properly.', 'wp-super-cache' ), 'mod_headers' => __( 'Required to set caching information on supercache pages. IE7 users will see old pages without this module.', 'wp-super-cache' ), 'mod_expires' => __( 'Set the expiry date on supercached pages. Visitors may not see new pages when they refresh or leave comments without this module.', 'wp-super-cache' ) ); |
|
338 foreach( $required_modules as $req => $desc ) { |
|
339 if( !in_array( $req, $mods ) ) { |
|
340 $missing_mods[ $req ] = $desc; |
|
341 } |
|
342 } |
|
343 if( isset( $missing_mods) && is_array( $missing_mods ) ) { |
|
344 ?><div id="message" class="updated fade"><h3><?php _e( 'Missing Apache Modules', 'wp-super-cache' ); ?></h3> |
|
345 <p><?php __( 'The following Apache modules are missing. The plugin will work in legacy mode without them. In full Supercache mode, your visitors may see corrupted pages or out of date content however.', 'wp-super-cache' ); ?></p><?php |
|
346 echo "<ul>"; |
|
347 foreach( $missing_mods as $req => $desc ) { |
|
348 echo "<li> $req - $desc</li>"; |
|
349 } |
|
350 echo "</ul>"; |
|
351 echo "</div>"; |
|
352 } |
|
353 } |
|
354 |
|
355 if ( $valid_nonce && $_POST[ 'action' ] == 'dismiss_htaccess_warning' ) { |
|
356 wp_cache_replace_line('^ *\$dismiss_htaccess_warning', "\$dismiss_htaccess_warning = 1;", $wp_cache_config_file); |
|
357 $dismiss_htaccess_warning = 1; |
|
358 } elseif ( !isset( $dismiss_htaccess_warning ) ) { |
|
359 $dismiss_htaccess_warning = 0; |
|
360 } |
|
361 if ( $dismiss_htaccess_warning == 0 && $wp_cache_mod_rewrite && $super_cache_enabled && $disable_supercache_htaccess_warning == false && get_option( 'siteurl' ) != get_option( 'home' ) ) { |
|
362 $home_dir = str_replace( get_option( 'home' ), '', get_option( 'siteurl' ) ); |
|
363 ?><div id="message" class="updated fade"><h3><?php _e( '.htaccess file may need to be moved', 'wp-super-cache' ); ?></h3> |
|
364 <p><?php _e( 'It appears you have WordPress installed in a sub directory as described <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">here</a>. Unfortunately WordPress writes to the .htaccess in the install directory, not where your site is served from.<br />When you update the rewrite rules in this plugin you will have to copy the file to where your site is hosted. This will be fixed in the future.', 'wp-super-cache' ); ?></p> |
|
365 <form action="" method="POST"> |
|
366 <input type="hidden" name="action" value="dismiss_htaccess_warning" /> |
|
367 <input type="hidden" name="page" value="wpsupercache" /> |
|
368 <?php wp_nonce_field( 'wp-cache' ); ?> |
|
369 <input type='submit' value='<?php _e( 'Dismiss', 'wp-super-cache' ); ?>' /> |
|
370 </form> |
|
371 <br /> |
|
372 </div><?php |
|
373 } |
|
374 |
|
375 return true; |
|
376 |
|
377 } |
|
378 add_filter( 'wp_super_cache_error_checking', 'wp_cache_manager_error_checks' ); |
|
379 |
|
380 function admin_bar_delete_page() { |
|
381 // Delete cache for a specific page |
|
382 if ( function_exists('current_user_can') && false == current_user_can('delete_others_posts') ) |
|
383 return false; |
|
384 if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'delcachepage' && ( isset( $_GET[ '_wpnonce' ] ) ? wp_verify_nonce( $_REQUEST[ '_wpnonce' ], 'delete-cache' ) : false ) ) { |
|
385 $path = get_supercache_dir() . preg_replace( '/:.*$/', '', $_GET[ 'path' ] ); |
|
386 $files = get_all_supercache_filenames( $path ); |
|
387 foreach( $files as $cache_file ) |
|
388 prune_super_cache( $path . $cache_file, true ); |
|
389 |
|
390 wp_redirect( preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_GET[ 'path' ] ) ); |
|
391 die(); |
|
392 } |
|
393 } |
|
394 if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'delcachepage' ) |
|
395 add_action( 'admin_init', 'admin_bar_delete_page' ); |
|
396 |
|
397 function wp_cache_manager_updates() { |
|
398 global $wp_cache_mobile_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $wp_cache_hello_world, $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_not_logged_in, $wp_cache_make_known_anon, $cache_path, $wp_cache_object_cache, $_wp_using_ext_object_cache, $wp_cache_refresh_single_only, $cache_compression, $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks, $cache_page_secret, $wp_cache_disable_utf8, $wp_cache_no_cache_for_get; |
|
399 global $cache_schedule_type, $cache_scheduled_time, $cache_max_time, $cache_time_interval, $wp_cache_shutdown_gc; |
|
400 |
|
401 if ( !wpsupercache_site_admin() ) |
|
402 return false; |
|
403 |
|
404 if ( false == isset( $cache_page_secret ) ) { |
|
405 $cache_page_secret = md5( date( 'H:i:s' ) . mt_rand() ); |
|
406 wp_cache_replace_line('^ *\$cache_page_secret', "\$cache_page_secret = '" . $cache_page_secret . "';", $wp_cache_config_file); |
|
407 } |
|
408 |
|
409 $valid_nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache') : false; |
|
410 if ( $valid_nonce == false ) |
|
411 return false; |
|
412 |
|
413 if ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'easysetup' ) { |
|
414 $_POST[ 'action' ] = 'scupdates'; |
|
415 if( isset( $_POST[ 'wp_cache_easy_on' ] ) && $_POST[ 'wp_cache_easy_on' ] == 1 ) { |
|
416 $_POST[ 'wp_cache_mobile_enabled' ] = 1; |
|
417 $_POST[ 'wp_cache_status' ] = 'all'; |
|
418 $_POST[ 'super_cache_enabled' ] = 2; // PHP |
|
419 $_POST[ 'cache_rebuild_files' ] = 1; |
|
420 unset( $_POST[ 'cache_compression' ] ); |
|
421 // |
|
422 // set up garbage collection with some default settings |
|
423 if ( ( !isset( $wp_cache_shutdown_gc ) || $wp_cache_shutdown_gc == 0 ) && false == wp_next_scheduled( 'wp_cache_gc' ) ) { |
|
424 if ( false == isset( $cache_schedule_type ) ) { |
|
425 $cache_schedule_type = 'interval'; |
|
426 $cache_time_interval = 600; |
|
427 $cache_max_time = 1800; |
|
428 wp_cache_replace_line('^ *\$cache_schedule_type', "\$cache_schedule_type = '$cache_schedule_type';", $wp_cache_config_file); |
|
429 wp_cache_replace_line('^ *\$cache_time_interval', "\$cache_time_interval = '$cache_time_interval';", $wp_cache_config_file); |
|
430 wp_cache_replace_line('^ *\$cache_max_time', "\$cache_max_time = '$cache_max_time';", $wp_cache_config_file); |
|
431 } |
|
432 wp_schedule_single_event( time() + 600, 'wp_cache_gc' ); |
|
433 } |
|
434 |
|
435 } else { |
|
436 unset( $_POST[ 'wp_cache_status' ] ); |
|
437 $_POST[ 'super_cache_enabled' ] = 0; |
|
438 wp_clear_scheduled_hook( 'wp_cache_check_site_hook' ); |
|
439 wp_clear_scheduled_hook( 'wp_cache_gc' ); |
|
440 wp_clear_scheduled_hook( 'wp_cache_gc_watcher' ); |
|
441 } |
|
442 } |
|
443 |
|
444 if( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'scupdates' ) { |
|
445 |
|
446 if( isset( $_POST[ 'wp_super_cache_late_init' ] ) ) { |
|
447 $wp_super_cache_late_init = 1; |
|
448 } else { |
|
449 $wp_super_cache_late_init = 0; |
|
450 } |
|
451 wp_cache_replace_line('^ *\$wp_super_cache_late_init', "\$wp_super_cache_late_init = " . $wp_super_cache_late_init . ";", $wp_cache_config_file); |
|
452 |
|
453 if( isset( $_POST[ 'wp_cache_disable_utf8' ] ) ) { |
|
454 $wp_cache_disable_utf8 = 1; |
|
455 } else { |
|
456 $wp_cache_disable_utf8 = 0; |
|
457 } |
|
458 wp_cache_replace_line('^ *\$wp_cache_disable_utf8', "\$wp_cache_disable_utf8 = " . $wp_cache_disable_utf8 . ";", $wp_cache_config_file); |
|
459 |
|
460 if( isset( $_POST[ 'wp_cache_no_cache_for_get' ] ) ) { |
|
461 $wp_cache_no_cache_for_get = 1; |
|
462 } else { |
|
463 $wp_cache_no_cache_for_get = 0; |
|
464 } |
|
465 wp_cache_replace_line('^ *\$wp_cache_no_cache_for_get', "\$wp_cache_no_cache_for_get = " . $wp_cache_no_cache_for_get . ";", $wp_cache_config_file); |
|
466 |
|
467 if( isset( $_POST[ 'wp_supercache_304' ] ) ) { |
|
468 $wp_supercache_304 = 1; |
|
469 } else { |
|
470 $wp_supercache_304 = 0; |
|
471 } |
|
472 wp_cache_replace_line('^ *\$wp_supercache_304', "\$wp_supercache_304 = " . $wp_supercache_304 . ";", $wp_cache_config_file); |
|
473 |
|
474 if( isset( $_POST[ 'wp_cache_mobile_enabled' ] ) ) { |
|
475 $wp_cache_mobile_enabled = 1; |
|
476 } else { |
|
477 $wp_cache_mobile_enabled = 0; |
|
478 } |
|
479 wp_cache_replace_line('^ *\$wp_cache_mobile_enabled', "\$wp_cache_mobile_enabled = " . $wp_cache_mobile_enabled . ";", $wp_cache_config_file); |
|
480 |
|
481 if( isset( $_POST[ 'wp_cache_front_page_checks' ] ) ) { |
|
482 $wp_cache_front_page_checks = 1; |
|
483 } else { |
|
484 $wp_cache_front_page_checks = 0; |
|
485 } |
|
486 wp_cache_replace_line('^ *\$wp_cache_front_page_checks', "\$wp_cache_front_page_checks = " . $wp_cache_front_page_checks . ";", $wp_cache_config_file); |
|
487 |
|
488 if( isset( $_POST[ 'wp_supercache_cache_list' ] ) ) { |
|
489 $wp_supercache_cache_list = 1; |
|
490 } else { |
|
491 $wp_supercache_cache_list = 0; |
|
492 } |
|
493 wp_cache_replace_line('^ *\$wp_supercache_cache_list', "\$wp_supercache_cache_list = " . $wp_supercache_cache_list . ";", $wp_cache_config_file); |
|
494 |
|
495 if ( isset( $_POST[ 'wp_cache_status' ] ) ) { |
|
496 if ( $_POST[ 'wp_cache_status' ] == 'all' ) |
|
497 wp_cache_enable(); |
|
498 |
|
499 if ( isset( $_POST[ 'super_cache_enabled' ] ) ) { |
|
500 if ( $_POST[ 'super_cache_enabled' ] == 0 ) { |
|
501 wp_cache_enable(); |
|
502 wp_super_cache_disable(); |
|
503 } |
|
504 if( $_POST[ 'super_cache_enabled' ] == 1 ) { |
|
505 $wp_cache_mod_rewrite = 1; // we need this because supercached files can be served by PHP too. |
|
506 } else { |
|
507 $wp_cache_mod_rewrite = 0; |
|
508 } |
|
509 wp_cache_replace_line('^ *\$wp_cache_mod_rewrite', '$wp_cache_mod_rewrite = ' . $wp_cache_mod_rewrite . ";", $wp_cache_config_file); |
|
510 } |
|
511 } else { |
|
512 wp_cache_disable(); |
|
513 } |
|
514 |
|
515 if( isset( $_POST[ 'wp_cache_hello_world' ] ) ) { |
|
516 $wp_cache_hello_world = 1; |
|
517 } else { |
|
518 $wp_cache_hello_world = 0; |
|
519 } |
|
520 wp_cache_replace_line('^ *\$wp_cache_hello_world', '$wp_cache_hello_world = ' . $wp_cache_hello_world . ";", $wp_cache_config_file); |
|
521 |
|
522 if( isset( $_POST[ 'wp_cache_clear_on_post_edit' ] ) ) { |
|
523 $wp_cache_clear_on_post_edit = 1; |
|
524 } else { |
|
525 $wp_cache_clear_on_post_edit = 0; |
|
526 } |
|
527 wp_cache_replace_line('^ *\$wp_cache_clear_on_post_edit', "\$wp_cache_clear_on_post_edit = " . $wp_cache_clear_on_post_edit . ";", $wp_cache_config_file); |
|
528 |
|
529 if( isset( $_POST[ 'cache_rebuild_files' ] ) ) { |
|
530 $cache_rebuild_files = 1; |
|
531 } else { |
|
532 $cache_rebuild_files = 0; |
|
533 } |
|
534 wp_cache_replace_line('^ *\$cache_rebuild_files', "\$cache_rebuild_files = " . $cache_rebuild_files . ";", $wp_cache_config_file); |
|
535 |
|
536 if( isset( $_POST[ 'wp_cache_mutex_disabled' ] ) ) { |
|
537 $wp_cache_mutex_disabled = 0; |
|
538 } else { |
|
539 $wp_cache_mutex_disabled = 1; |
|
540 } |
|
541 if( defined( 'WPSC_DISABLE_LOCKING' ) ) { |
|
542 $wp_cache_mutex_disabled = 1; |
|
543 } |
|
544 wp_cache_replace_line('^ *\$wp_cache_mutex_disabled', "\$wp_cache_mutex_disabled = " . $wp_cache_mutex_disabled . ";", $wp_cache_config_file); |
|
545 |
|
546 if( isset( $_POST[ 'wp_cache_not_logged_in' ] ) ) { |
|
547 if( $wp_cache_not_logged_in == 0 && function_exists( 'prune_super_cache' ) ) |
|
548 prune_super_cache ($cache_path, true); |
|
549 $wp_cache_not_logged_in = 1; |
|
550 } else { |
|
551 $wp_cache_not_logged_in = 0; |
|
552 } |
|
553 wp_cache_replace_line('^ *\$wp_cache_not_logged_in', "\$wp_cache_not_logged_in = " . $wp_cache_not_logged_in . ";", $wp_cache_config_file); |
|
554 |
|
555 if( isset( $_POST[ 'wp_cache_make_known_anon' ] ) ) { |
|
556 if( $wp_cache_make_known_anon == 0 && function_exists( 'prune_super_cache' ) ) |
|
557 prune_super_cache ($cache_path, true); |
|
558 $wp_cache_make_known_anon = 1; |
|
559 } else { |
|
560 $wp_cache_make_known_anon = 0; |
|
561 } |
|
562 wp_cache_replace_line('^ *\$wp_cache_make_known_anon', "\$wp_cache_make_known_anon = " . $wp_cache_make_known_anon . ";", $wp_cache_config_file); |
|
563 |
|
564 if( $_wp_using_ext_object_cache && isset( $_POST[ 'wp_cache_object_cache' ] ) ) { |
|
565 if( $wp_cache_object_cache == 0 && function_exists( 'prune_super_cache' ) ) |
|
566 prune_super_cache( $cache_path, true ); |
|
567 $wp_cache_object_cache = 1; |
|
568 } else { |
|
569 $wp_cache_object_cache = 0; |
|
570 } |
|
571 wp_cache_replace_line('^ *\$wp_cache_object_cache', "\$wp_cache_object_cache = " . $wp_cache_object_cache . ";", $wp_cache_config_file); |
|
572 |
|
573 if( isset( $_POST[ 'wp_cache_refresh_single_only' ] ) ) { |
|
574 $wp_cache_refresh_single_only = 1; |
|
575 } else { |
|
576 $wp_cache_refresh_single_only = 0; |
|
577 } |
|
578 wp_cache_replace_line('^ *\$wp_cache_refresh_single_only', "\$wp_cache_refresh_single_only = '" . $wp_cache_refresh_single_only . "';", $wp_cache_config_file); |
|
579 |
|
580 if ( defined( 'WPSC_DISABLE_COMPRESSION' ) ) { |
|
581 $cache_compression = 0; |
|
582 wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file); |
|
583 } else { |
|
584 if ( isset( $_POST[ 'cache_compression' ] ) ) { |
|
585 $new_cache_compression = 1; |
|
586 } else { |
|
587 $new_cache_compression = 0; |
|
588 } |
|
589 if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) { |
|
590 echo '<div id="message" class="updated fade">' . __( "<strong>Warning!</strong> You attempted to enable compression but <code>zlib.output_compression</code> is enabled. See #21 in the Troubleshooting section of the readme file.", 'wp-super-cache' ) . '</div>'; |
|
591 } else { |
|
592 if ( $new_cache_compression != $cache_compression ) { |
|
593 $cache_compression = $new_cache_compression; |
|
594 wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file); |
|
595 if ( function_exists( 'prune_super_cache' ) ) |
|
596 prune_super_cache( $cache_path, true ); |
|
597 delete_option( 'super_cache_meta' ); |
|
598 } |
|
599 } |
|
600 } |
|
601 } |
|
602 } |
|
603 if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wpsupercache' ) |
|
604 add_action( 'admin_init', 'wp_cache_manager_updates' ); |
124 |
605 |
125 function wp_cache_manager() { |
606 function wp_cache_manager() { |
126 global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled, $wp_cache_hello_world; |
607 global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled, $wp_cache_hello_world; |
127 global $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_mobile_enabled, $wp_cache_mobile_whitelist, $wp_cache_mobile_browsers; |
608 global $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_no_cache_for_get; |
128 global $wp_cache_cron_check, $wp_cache_debug, $wp_cache_hide_donation, $wp_cache_not_logged_in, $wp_supercache_cache_list; |
609 global $wp_cache_cron_check, $wp_cache_debug, $wp_cache_not_logged_in, $wp_cache_make_known_anon, $wp_supercache_cache_list, $cache_page_secret, $cache_home_path; |
129 global $wp_super_cache_front_page_check; |
610 global $wp_super_cache_front_page_check, $wp_cache_object_cache, $_wp_using_ext_object_cache, $wp_cache_refresh_single_only, $wp_cache_mobile_prefixes; |
130 |
611 global $wpmu_version, $cache_max_time, $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks, $wp_cache_disable_utf8; |
131 if( function_exists( 'is_site_admin' ) ) |
612 |
132 if( !is_site_admin() ) |
613 if ( !wpsupercache_site_admin() ) |
133 return; |
614 return false; |
134 |
615 |
135 $supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]); |
616 // used by mod_rewrite rules and config file |
|
617 if ( function_exists( "cfmobi_default_browsers" ) ) { |
|
618 $wp_cache_mobile_browsers = cfmobi_default_browsers( "mobile" ); |
|
619 $wp_cache_mobile_browsers = array_merge( $wp_cache_mobile_browsers, cfmobi_default_browsers( "touch" ) ); |
|
620 } elseif ( function_exists( 'lite_detection_ua_contains' ) ) { |
|
621 $wp_cache_mobile_browsers = explode( '|', lite_detection_ua_contains() ); |
|
622 } else { |
|
623 $wp_cache_mobile_browsers = array( '2.0 MMP', '240x320', '400X240', 'AvantGo', 'BlackBerry', 'Blazer', 'Cellphone', 'Danger', 'DoCoMo', 'Elaine/3.0', 'EudoraWeb', 'Googlebot-Mobile', 'hiptop', 'IEMobile', 'KYOCERA/WX310K', 'LG/U990', 'MIDP-2.', 'MMEF20', 'MOT-V', 'NetFront', 'Newt', 'Nintendo Wii', 'Nitro', 'Nokia', 'Opera Mini', 'Palm', 'PlayStation Portable', 'portalmmm', 'Proxinet', 'ProxiNet', 'SHARP-TQ-GX10', 'SHG-i900', 'Small', 'SonyEricsson', 'Symbian OS', 'SymbianOS', 'TS21i-10', 'UP.Browser', 'UP.Link', 'webOS', 'Windows CE', 'WinWAP', 'YahooSeeker/M1A1-R2D2', 'iPhone', 'iPod', 'Android', 'BlackBerry9530', 'LG-TU915 Obigo', 'LGE VX', 'webOS', 'Nokia5800' ); |
|
624 } |
|
625 if ( function_exists( "lite_detection_ua_prefixes" ) ) { |
|
626 $wp_cache_mobile_prefixes = lite_detection_ua_prefixes(); |
|
627 } else { |
|
628 $wp_cache_mobile_prefixes = array( 'w3c ', 'w3c-', 'acs-', 'alav', 'alca', 'amoi', 'audi', 'avan', 'benq', 'bird', 'blac', 'blaz', 'brew', 'cell', 'cldc', 'cmd-', 'dang', 'doco', 'eric', 'hipt', 'htc_', 'inno', 'ipaq', 'ipod', 'jigs', 'kddi', 'keji', 'leno', 'lg-c', 'lg-d', 'lg-g', 'lge-', 'lg/u', 'maui', 'maxo', 'midp', 'mits', 'mmef', 'mobi', 'mot-', 'moto', 'mwbp', 'nec-', 'newt', 'noki', 'palm', 'pana', 'pant', 'phil', 'play', 'port', 'prox', 'qwap', 'sage', 'sams', 'sany', 'sch-', 'sec-', 'send', 'seri', 'sgh-', 'shar', 'sie-', 'siem', 'smal', 'smar', 'sony', 'sph-', 'symb', 't-mo', 'teli', 'tim-', 'tosh', 'tsm-', 'upg1', 'upsi', 'vk-v', 'voda', 'wap-', 'wapa', 'wapi', 'wapp', 'wapr', 'webc', 'winw', 'winw', 'xda ', 'xda-' ); // from http://svn.wp-plugins.org/wordpress-mobile-pack/trunk/plugins/wpmp_switcher/lite_detection.php |
|
629 } |
|
630 $wp_cache_mobile_browsers = apply_filters( 'cached_mobile_browsers', $wp_cache_mobile_browsers ); // Allow mobile plugins access to modify the mobile UA list |
|
631 $wp_cache_mobile_prefixes = apply_filters( 'cached_mobile_prefixes', $wp_cache_mobile_prefixes ); // Allow mobile plugins access to modify the mobile UA prefix list |
|
632 if ( function_exists( 'do_cacheaction' ) ) { |
|
633 $wp_cache_mobile_browsers = do_cacheaction( 'wp_super_cache_mobile_browsers', $wp_cache_mobile_browsers ); |
|
634 $wp_cache_mobile_prefixes = do_cacheaction( 'wp_super_cache_mobile_prefixes', $wp_cache_mobile_prefixes ); |
|
635 } |
|
636 $mobile_groups = apply_filters( 'cached_mobile_groups', array() ); // Group mobile user agents by capabilities. Lump them all together by default |
|
637 // mobile_groups = array( 'apple' => array( 'ipod', 'iphone' ), 'nokia' => array( 'nokia5800', 'symbianos' ) ); |
|
638 |
|
639 if ( false == apply_filters( 'wp_super_cache_error_checking', true ) ) |
|
640 return false; |
|
641 |
|
642 if ( function_exists( 'get_supercache_dir' ) ) |
|
643 $supercachedir = get_supercache_dir(); |
136 if( get_option( 'gzipcompression' ) == 1 ) |
644 if( get_option( 'gzipcompression' ) == 1 ) |
137 update_option( 'gzipcompression', 0 ); |
645 update_option( 'gzipcompression', 0 ); |
138 if( !isset( $cache_rebuild_files ) ) |
646 if( !isset( $cache_rebuild_files ) ) |
139 $cache_rebuild_files = 0; |
647 $cache_rebuild_files = 0; |
140 |
648 |
187 if(isset($_REQUEST['wp_restore_config']) && $valid_nonce) { |
709 if(isset($_REQUEST['wp_restore_config']) && $valid_nonce) { |
188 unlink($wp_cache_config_file); |
710 unlink($wp_cache_config_file); |
189 echo '<strong>' . __( 'Configuration file changed, some values might be wrong. Load the page again from the "Settings" menu to reset them.', 'wp-super-cache' ) . '</strong>'; |
711 echo '<strong>' . __( 'Configuration file changed, some values might be wrong. Load the page again from the "Settings" menu to reset them.', 'wp-super-cache' ) . '</strong>'; |
190 } |
712 } |
191 |
713 |
192 if ( !wp_cache_check_link() || |
714 if ( substr( get_option( 'permalink_structure' ), -1 ) == '/' ) { |
193 !wp_cache_verify_config_file() || |
715 wp_cache_replace_line('^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 1;", $wp_cache_config_file); |
194 !wp_cache_verify_cache_dir() ) { |
716 } else { |
195 echo '<p>' . __( "Cannot continue... fix previous problems and retry.", 'wp-super-cache' ) . '</p>'; |
717 wp_cache_replace_line('^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 0;", $wp_cache_config_file); |
196 echo "</div>\n"; |
718 } |
197 return; |
719 $home_path = parse_url( site_url() ); |
198 } |
720 $home_path = trailingslashit( array_key_exists( 'path', $home_path ) ? $home_path[ 'path' ] : '' ); |
199 |
721 if (! isset( $wp_cache_home_path ) ) |
200 if (!wp_cache_check_global_config()) { |
722 $wp_cache_home_path = '/'; |
201 echo "</div>\n"; |
723 if ( "$home_path" != "$wp_cache_home_path" ) |
202 return; |
724 wp_cache_replace_line('^ *\$wp_cache_home_path', "\$wp_cache_home_path = '$home_path';", $wp_cache_config_file); |
203 } |
725 |
204 if( $wp_cache_debug || !$wp_cache_cron_check ) { |
726 |
205 if( function_exists( "wp_remote_get" ) == false ) { |
727 if( $wp_cache_mobile_enabled == 1 ) { |
206 $hostname = str_replace( 'http://', '', str_replace( 'https://', '', get_option( 'siteurl' ) ) ); |
728 update_cached_mobile_ua_list( $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $mobile_groups ); |
207 if( strpos( $hostname, '/' ) ) |
729 } |
208 $hostname = substr( $hostname, 0, strpos( $hostname, '/' ) ); |
730 |
209 $ip = gethostbyname( $hostname ); |
731 ?> <table><td valign='top'><?php |
210 if( substr( $ip, 0, 3 ) == '127' || substr( $ip, 0, 7 ) == '192.168' ) { |
732 switch( $_GET[ 'tab' ] ) { |
211 ?><h3><?php printf( __( 'Warning! Your hostname "%s" resolves to %s', 'wp-super-cache' ), $hostname, $ip ); ?></h3> |
733 case "cdn": |
212 <div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'> |
734 scossdl_off_options(); |
213 <p><?php printf( __( 'Your server thinks your hostname resolves to %s. Some services such as garbage collection by this plugin, and WordPress scheduled posts may not operate correctly.', 'wp-super-cache' ), $ip ); ?></p> |
735 break; |
214 <p><?php printf( __( 'Please see entry 16 in the <a href="%s">Troubleshooting section</a> of the readme.txt', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?></p> |
736 case "tester": |
215 </div> |
737 case "contents": |
|
738 echo '<a name="test"></a>'; |
|
739 wp_cache_files(); |
|
740 break; |
|
741 case "preload": |
|
742 if ( !$cache_enabled ) |
|
743 wp_die( __( 'Caching must be enabled to use this feature', 'wp-super-cache' ) ); |
|
744 echo '<a name="preload"></a>'; |
|
745 if ( $super_cache_enabled == true && false == defined( 'DISABLESUPERCACHEPRELOADING' ) ) { |
|
746 global $wp_cache_preload_interval, $wp_cache_preload_on, $wp_cache_preload_taxonomies, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $wp_cache_preload_posts, $wpdb; |
|
747 $count = $wpdb->get_var( "SELECT count(*) FROM {$wpdb->posts} WHERE post_status = 'publish'" ); |
|
748 if ( $count > 1000 ) { |
|
749 $min_refresh_interval = 720; |
|
750 } else { |
|
751 $min_refresh_interval = 30; |
|
752 } |
|
753 if ( array_key_exists('action', $_POST) && $_POST[ 'action' ] == 'preload' && $valid_nonce ) { |
|
754 if ( $_POST[ 'posts_to_cache' ] == 'all' ) { |
|
755 $wp_cache_preload_posts = 'all'; |
|
756 } else { |
|
757 $wp_cache_preload_posts = (int)$_POST[ 'posts_to_cache' ]; |
|
758 } |
|
759 wp_cache_replace_line('^ *\$wp_cache_preload_posts', "\$wp_cache_preload_posts = '$wp_cache_preload_posts';", $wp_cache_config_file); |
|
760 |
|
761 if ( isset( $_POST[ 'preload' ] ) && $_POST[ 'preload' ] == __( 'Cancel Cache Preload', 'wp-super-cache' ) ) { |
|
762 $next_preload = wp_next_scheduled( 'wp_cache_preload_hook' ); |
|
763 if ( $next_preload ) { |
|
764 update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); |
|
765 wp_unschedule_event( $next_preload, 'wp_cache_preload_hook' ); |
|
766 } |
|
767 $fp = @fopen( $cache_path . "stop_preload.txt", 'w' ); |
|
768 @fclose( $fp ); |
|
769 echo "<p><strong>" . __( 'Scheduled preloading of cache almost cancelled. It may take up to a minute for it to cancel completely.', 'wp-super-cache' ) . "</strong></p>"; |
|
770 } elseif ( isset( $_POST[ 'custom_preload_interval' ] ) && ( $_POST[ 'custom_preload_interval' ] == 0 || $_POST[ 'custom_preload_interval' ] >= $min_refresh_interval ) ) { |
|
771 // if preload interval changes than unschedule any preload jobs and schedule any new one. |
|
772 $_POST[ 'custom_preload_interval' ] = (int)$_POST[ 'custom_preload_interval' ]; |
|
773 if ( $wp_cache_preload_interval != $_POST[ 'custom_preload_interval' ] ) { |
|
774 $next_preload = wp_next_scheduled( 'wp_cache_full_preload_hook' ); |
|
775 if ( $next_preload ) { |
|
776 update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); |
|
777 add_option( 'preload_cache_stop', 1 ); |
|
778 wp_unschedule_event( $next_preload, 'wp_cache_full_preload_hook' ); |
|
779 if ( $wp_cache_preload_interval == 0 ) { |
|
780 echo "<p><strong>" . __( 'Scheduled preloading of cache cancelled.', 'wp-super-cache' ) . "</strong></p>"; |
|
781 } |
|
782 } |
|
783 if ( $_POST[ 'custom_preload_interval' ] != 0 ) |
|
784 wp_schedule_single_event( time() + ( $_POST[ 'custom_preload_interval' ] * 60 ), 'wp_cache_full_preload_hook' ); |
|
785 } |
|
786 $wp_cache_preload_interval = (int)$_POST[ 'custom_preload_interval' ]; |
|
787 wp_cache_replace_line('^ *\$wp_cache_preload_interval', "\$wp_cache_preload_interval = $wp_cache_preload_interval;", $wp_cache_config_file); |
|
788 if ( isset( $_POST[ 'preload_email_me' ] ) ) { |
|
789 $wp_cache_preload_email_me = 1; |
|
790 } else { |
|
791 $wp_cache_preload_email_me = 0; |
|
792 } |
|
793 wp_cache_replace_line('^ *\$wp_cache_preload_email_me', "\$wp_cache_preload_email_me = $wp_cache_preload_email_me;", $wp_cache_config_file); |
|
794 if ( isset( $_POST[ 'wp_cache_preload_email_volume' ] ) && in_array( $_POST[ 'wp_cache_preload_email_volume' ], array( 'less', 'medium', 'many' ) ) ) { |
|
795 $wp_cache_preload_email_volume = $_POST[ 'wp_cache_preload_email_volume' ]; |
|
796 } else { |
|
797 $wp_cache_preload_email_volume = 'medium'; |
|
798 } |
|
799 wp_cache_replace_line('^ *\$wp_cache_preload_email_volume', "\$wp_cache_preload_email_volume = '$wp_cache_preload_email_volume';", $wp_cache_config_file); |
|
800 if ( isset( $_POST[ 'preload_taxonomies' ] ) ) { |
|
801 $wp_cache_preload_taxonomies = 1; |
|
802 } else { |
|
803 $wp_cache_preload_taxonomies = 0; |
|
804 } |
|
805 wp_cache_replace_line('^ *\$wp_cache_preload_taxonomies', "\$wp_cache_preload_taxonomies = $wp_cache_preload_taxonomies;", $wp_cache_config_file); |
|
806 if ( isset( $_POST[ 'preload_on' ] ) ) { |
|
807 $wp_cache_preload_on = 1; |
|
808 } else { |
|
809 $wp_cache_preload_on = 0; |
|
810 } |
|
811 wp_cache_replace_line('^ *\$wp_cache_preload_on', "\$wp_cache_preload_on = $wp_cache_preload_on;", $wp_cache_config_file); |
|
812 if ( isset( $_POST[ 'preload' ] ) && $_POST[ 'preload' ] == __( 'Preload Cache Now', 'wp-super-cache' ) ) { |
|
813 @unlink( $cache_path . "preload_mutex.tmp" ); |
|
814 update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); |
|
815 wp_schedule_single_event( time() + 10, 'wp_cache_preload_hook' ); |
|
816 echo "<p><strong>" . __( 'Scheduled preloading of cache in 10 seconds.' ) . "</strong></p>"; |
|
817 } elseif ( (int)$_POST[ 'custom_preload_interval' ] ) { |
|
818 @unlink( $cache_path . "preload_mutex.tmp" ); |
|
819 update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); |
|
820 wp_schedule_single_event( time() + ( (int)$_POST[ 'custom_preload_interval' ] * 60 ), 'wp_cache_full_preload_hook' ); |
|
821 echo "<p><strong>" . sprintf( __( 'Scheduled preloading of cache in %d minutes', 'wp-super-cache' ), (int)$_POST[ 'custom_preload_interval' ] ) . "</strong></p>"; |
|
822 } |
|
823 } |
|
824 } |
|
825 echo '<p>' . __( 'This will cache every published post and page on your site. It will create supercache static files so unknown visitors (including bots) will hit a cached page. This will probably help your Google ranking as they are using speed as a metric when judging websites now.', 'wp-super-cache' ) . '</p>'; |
|
826 echo '<p>' . __( 'Preloading creates lots of files however. Caching is done from the newest post to the oldest so please consider only caching the newest if you have lots (10,000+) of posts. This is especially important on shared hosting.', 'wp-super-cache' ) . '</p>'; |
|
827 echo '<p>' . __( 'In ’Preload Mode’ regular garbage collection will only clean out old legacy files for known users, not the preloaded supercache files. This is a recommended setting when the cache is preloaded.', 'wp-super-cache' ) . '</p>'; |
|
828 echo '<form name="cache_filler" action="" method="POST">'; |
|
829 echo '<input type="hidden" name="action" value="preload" />'; |
|
830 echo '<input type="hidden" name="page" value="wpsupercache" />'; |
|
831 echo '<p>' . sprintf( __( 'Refresh preloaded cache files every %s minutes. (0 to disable, minimum %d minutes.)', 'wp-super-cache' ), "<input type='text' size=4 name='custom_preload_interval' value='" . (int)$wp_cache_preload_interval . "' />", $min_refresh_interval ) . '</p>'; |
|
832 if ( $count > 100 ) { |
|
833 $step = (int)( $count / 10 ); |
|
834 |
|
835 $select = "<select name='posts_to_cache' size=1>"; |
|
836 $select .= "<option value='all' "; |
|
837 if ( !isset( $wp_cache_preload_posts ) || $wp_cache_preload_posts == 'all' ) { |
|
838 $checked = 'selectect=1 '; |
|
839 $best = 'all'; |
|
840 } else { |
|
841 $checked = ' '; |
|
842 $best = $wp_cache_preload_posts; |
|
843 } |
|
844 $select .= "{$checked}>" . __( 'all', 'wp-super-cache' ) . "</option>"; |
|
845 |
|
846 for( $c = $step; $c < $count; $c += $step ) { |
|
847 $checked = ' '; |
|
848 if ( $best == $c ) |
|
849 $checked = 'selected=1 '; |
|
850 $select .= "<option value='$c'{$checked}>$c</option>"; |
|
851 } |
|
852 $checked = ' '; |
|
853 if ( $best == $count ) |
|
854 $checked = 'selected=1 '; |
|
855 $select .= "<option value='$count'{$checked}>$count</option>"; |
|
856 $select .= "</select>"; |
|
857 echo '<p>' . sprintf( __( 'Preload %s posts.', 'wp-super-cache' ), $select ) . '</p>'; |
|
858 } else { |
|
859 echo '<input type="hidden" name="posts_to_cache" value="' . $count . '" />'; |
|
860 } |
|
861 |
|
862 echo '<input type="checkbox" name="preload_on" value="1" '; |
|
863 echo $wp_cache_preload_on == 1 ? 'checked=1' : ''; |
|
864 echo ' /> ' . __( 'Preload mode (garbage collection only on legacy cache files. Recommended.)', 'wp-super-cache' ) . '<br />'; |
|
865 echo '<input type="checkbox" name="preload_taxonomies" value="1" '; |
|
866 echo $wp_cache_preload_taxonomies == 1 ? 'checked=1' : ''; |
|
867 echo ' /> ' . __( 'Preload tags, categories and other taxonomies.', 'wp-super-cache' ) . '<br />'; |
|
868 echo '<input type="checkbox" name="preload_email_me" value="1" '; |
|
869 echo $wp_cache_preload_email_me == 1 ? 'checked=1' : ''; |
|
870 echo ' /> ' . __( 'Send me status emails when files are refreshed.', 'wp-super-cache' ) . '<br />'; |
|
871 if ( !isset( $wp_cache_preload_email_volume ) ) |
|
872 $wp_cache_preload_email_volume = 'many'; |
|
873 echo ' <input name="wp_cache_preload_email_volume" type="radio" value="many" class="tog" '; |
|
874 checked( 'many', $wp_cache_preload_email_volume ); |
|
875 echo '/> ' . __( 'Many emails, 2 emails per 100 posts.', 'wp-super-cache' ) . '<br >'; |
|
876 echo ' <input name="wp_cache_preload_email_volume" type="radio" value="medium" class="tog" '; |
|
877 checked( 'medium', $wp_cache_preload_email_volume ); |
|
878 echo '/> ' . __( 'Medium, 1 email per 100 posts.', 'wp-super-cache' ) . '<br >'; |
|
879 echo ' <input name="wp_cache_preload_email_volume" type="radio" value="less" class="tog" '; |
|
880 checked( 'less', $wp_cache_preload_email_volume ); |
|
881 echo '/> ' . __( 'Less emails, 1 at the start and 1 at the end of preloading all posts.', 'wp-super-cache' ) . '<br >'; |
|
882 |
|
883 $currently_preloading = false; |
|
884 |
|
885 next_preload_message( 'wp_cache_preload_hook', __( 'Refresh of cache in %d hours %d minutes and %d seconds.', 'wp-super-cache' ), 60 ); |
|
886 next_preload_message( 'wp_cache_full_preload_hook', __( 'Full refresh of cache in %d hours %d minutes and %d seconds.', 'wp-super-cache' ) ); |
|
887 |
|
888 $preload_counter = get_option( 'preload_cache_counter' ); |
|
889 if ( isset( $preload_counter[ 'first' ] ) ) // converted from int to array |
|
890 update_option( 'preload_cache_counter', array( 'c' => $preload_counter[ 'c' ], 't' => time() ) ); |
|
891 if ( is_array( $preload_counter ) && $preload_counter[ 'c' ] > 0 ) { |
|
892 echo '<p><strong>' . sprintf( __( 'Currently caching from post %d to %d.', 'wp-super-cache' ), ( $preload_counter[ 'c' ] - 100 ), $preload_counter[ 'c' ] ) . '</strong></p>'; |
|
893 $currently_preloading = true; |
|
894 if ( @file_exists( $cache_path . "preload_permalink.txt" ) ) { |
|
895 $url = file_get_contents( $cache_path . "preload_permalink.txt" ); |
|
896 echo "<p>" . sprintf( __( "<strong>Page last cached:</strong> %s", 'wp-super-cache' ), $url ) . "</p>"; |
|
897 } |
|
898 } |
|
899 echo '<div class="submit"><input type="submit" name="preload" value="' . __( 'Update Settings', 'wp-super-cache' ) . '" /> <input type="submit" name="preload" value="' . __( 'Preload Cache Now', 'wp-super-cache' ) . '" />'; |
|
900 if ( $currently_preloading ) { |
|
901 echo ' <input type="submit" name="preload" value="' . __( 'Cancel Cache Preload', 'wp-super-cache' ) . '" />'; |
|
902 } |
|
903 echo '</div>'; |
|
904 wp_nonce_field('wp-cache'); |
|
905 echo '</form>'; |
|
906 } else { |
|
907 echo '<p>' . __( 'Preloading of cache disabled. Please disable legacy page caching or talk to your host administrator.', 'wp-super-cache' ) . '</p>'; |
|
908 } |
|
909 break; |
|
910 case 'plugins': |
|
911 wpsc_plugins_tab(); |
|
912 break; |
|
913 case 'debug': |
|
914 wp_cache_debug_settings(); |
|
915 break; |
|
916 case 'settings': |
|
917 if ( isset( $wp_cache_front_page_checks ) == false ) |
|
918 $wp_cache_front_page_checks = true; |
|
919 echo '<form name="wp_manager" action="' . add_query_arg( array( 'page' => 'wpsupercache', 'tab' => 'settings' ) ) . '" method="post">'; |
|
920 wp_nonce_field('wp-cache'); |
|
921 echo '<input type="hidden" name="action" value="scupdates" />'; |
|
922 ?><table class="form-table"> |
|
923 <tr valign="top"> |
|
924 <th scope="row"><label for="wp_cache_status"><?php _e( 'Caching', 'wp-super-cache' ); ?></label></th> |
|
925 <td> |
|
926 <fieldset> |
|
927 <legend class="hidden">Caching</legend> |
|
928 <label><input type='checkbox' name='wp_cache_status' value='all' <?php if ( $cache_enabled == true ) { echo 'checked=checked'; } ?>> <?php _e( 'Cache hits to this website for quick access.', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br /><br /> |
|
929 <label><input type='radio' name='super_cache_enabled' <?php if( $super_cache_enabled ) echo "checked"; ?> value='1'> <?php printf( __( 'Use mod_rewrite to serve cache files.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wordpress-mobile-edition/' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br /> |
|
930 <label><input type='radio' name='super_cache_enabled' <?php if( $wp_cache_mod_rewrite == 0 ) echo "checked"; ?> value='2'> <?php printf( __( 'Use PHP to serve cache files.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wordpress-mobile-edition/' ); ?></label><br /> |
|
931 <label><input type='radio' name='super_cache_enabled' <?php if( $super_cache_enabled == false ) echo "checked"; ?> value='0'> <?php _e( 'Legacy page caching.', 'wp-super-cache' ); ?></label><br /> |
|
932 <em><?php _e( 'Mod_rewrite is fastest, PHP is almost as fast and easier to get working, while legacy caching is slower again, but more flexible and also easy to get working. New users should use PHP caching.', 'wp-super-cache' ); ?></em><br /> |
|
933 </legend> |
|
934 </fieldset> |
|
935 </td> |
|
936 </tr> |
|
937 <tr valign="top"> |
|
938 <th scope="row"><label for="wp_cache_status"><?php _e( 'Miscellaneous', 'wp-super-cache' ); ?></label></th> |
|
939 <td> |
|
940 <fieldset> |
|
941 <legend class="hidden">Miscellaneous</legend> |
|
942 <?php if ( false == defined( 'WPSC_DISABLE_COMPRESSION' ) ) { ?> |
|
943 <?php if ( false == function_exists( 'gzencode' ) ) { ?> |
|
944 <em><?php _e( 'Warning! Compression is disabled as gzencode() function not found.', 'wp-super-cache' ); ?></em><br /> |
|
945 <?php } else { ?> |
|
946 <label><input type='checkbox' name='cache_compression' <?php if( $cache_compression ) echo "checked"; ?> value='1'> <?php _e( 'Compress pages so they’re served more quickly to visitors.', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br /> |
|
947 <em><?php _e( 'Compression is disabled by default because some hosts have problems with compressed files. Switching it on and off clears the cache.', 'wp-super-cache' ); ?></em><br /> |
|
948 <?php } |
|
949 } |
|
950 $disable_304 = true; |
|
951 if ( 0 == $wp_cache_mod_rewrite ) |
|
952 $disable_304 = false; |
|
953 if ( $disable_304 ) |
|
954 echo "<strike>"; |
|
955 ?><label><input <?php if ( $disable_304 ) { echo "disabled"; } ?> type='checkbox' name='wp_supercache_304' <?php if( $wp_supercache_304 ) echo "checked"; ?> value='1'> <?php _e( '304 Not Modified browser caching. Indicate when a page has not been modified since last requested.', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br /><?php |
|
956 if ( $disable_304 ) { |
|
957 echo "</strike>"; |
|
958 echo "<p><strong>" . __( 'Warning! 304 browser caching is only supported when not using mod_rewrite caching.', 'wp-super-cache' ) . "</strong></p>"; |
|
959 } else { |
|
960 ?><em><?php _e( '304 support is disabled by default because in the past GoDaddy had problems with some of the headers used.', 'wp-super-cache' ); ?></em><br /><?php |
|
961 } |
|
962 ?><label><input type='checkbox' name='wp_cache_not_logged_in' <?php if( $wp_cache_not_logged_in ) echo "checked"; ?> value='1'> <?php _e( 'Don’t cache pages for <acronym title="Logged in users and those that comment">known users</acronym>.', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br /> |
|
963 <label><input type='checkbox' name='wp_cache_no_cache_for_get' <?php if( $wp_cache_no_cache_for_get ) echo "checked"; ?> value='1'> <?php _e( 'Don’t cache pages with GET parameters. (?x=y at the end of a url)', 'wp-super-cache' ); ?></label><br /> |
|
964 <label><input type='checkbox' name='wp_cache_make_known_anon' <?php if( $wp_cache_make_known_anon ) echo "checked"; ?> value='1'> <?php _e( 'Make known users anonymous so they’re served supercached static files.', 'wp-super-cache' ); ?></label><br /> |
|
965 <label><input type='checkbox' name='cache_rebuild_files' <?php if( $cache_rebuild_files ) echo "checked"; ?> value='1'> <?php _e( 'Cache rebuild. Serve a supercache file to anonymous users while a new file is being generated.', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br /> |
|
966 <label><input type='checkbox' name='wp_cache_hello_world' <?php if( $wp_cache_hello_world ) echo "checked"; ?> value='1'> <?php printf( __( 'Proudly tell the world your server is <a href="%s">Stephen Fry proof</a>! (places a message in your blog’s footer)', 'wp-super-cache' ), 'https://twitter.com/#!/HibbsLupusTrust/statuses/136429993059291136' ); ?></label><br /> |
|
967 </legend> |
|
968 </fieldset> |
|
969 </td> |
|
970 </tr> |
|
971 <tr valign="top"> |
|
972 <th scope="row"><label for="wp_cache_status"><?php _e( 'Advanced', 'wp-super-cache' ); ?></label></th> |
|
973 <td> |
|
974 <fieldset> |
|
975 <legend class="hidden">Advanced</legend> |
|
976 <label><input type='checkbox' name='wp_cache_mobile_enabled' <?php if( $wp_cache_mobile_enabled ) echo "checked"; ?> value='1'> <?php _e( 'Mobile device support. (External plugin or theme required. See the <a href="http://wordpress.org/extend/plugins/wp-super-cache/faq/">FAQ</a> for further details.)', 'wp-super-cache' ); ?></label><br /> |
|
977 <?php if ( $wp_cache_mobile_enabled ) { |
|
978 echo '<blockquote><h4>' . __( 'Mobile Browsers', 'wp-super-cache' ) . '</h4>' . implode( ', ', $wp_cache_mobile_browsers ) . "<br /><h4>" . __( 'Mobile Prefixes', 'wp-super-cache' ) . "</h4>" . implode( ', ', $wp_cache_mobile_prefixes ) . "<br /></blockquote>"; |
|
979 } ?> |
|
980 <label><input type='checkbox' name='wp_cache_disable_utf8' <?php if( $wp_cache_disable_utf8 ) echo "checked"; ?> value='1'> <?php _e( 'Remove UTF8/blog charset support from .htaccess file. Only necessary if you see odd characters or punctuation looks incorrect. Requires rewrite rules update.', 'wp-super-cache' ); ?></label><br /> |
|
981 <label><input type='checkbox' name='wp_cache_clear_on_post_edit' <?php if( $wp_cache_clear_on_post_edit ) echo "checked"; ?> value='1'> <?php _e( 'Clear all cache files when a post or page is published or updated.', 'wp-super-cache' ); ?></label><br /> |
|
982 <label><input type='checkbox' name='wp_cache_front_page_checks' <?php if( $wp_cache_front_page_checks ) echo "checked"; ?> value='1'> <?php _e( 'Extra homepage checks. (Very occasionally stops homepage caching)', 'wp-super-cache' ); ?></label><?php echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?><br /> |
|
983 <label><input type='checkbox' name='wp_cache_refresh_single_only' <?php if( $wp_cache_refresh_single_only ) echo "checked"; ?> value='1'> <?php _e( 'Only refresh current page when comments made.', 'wp-super-cache' ); ?></label><br /> |
|
984 <label><input type='checkbox' name='wp_supercache_cache_list' <?php if( $wp_supercache_cache_list ) echo "checked"; ?> value='1'> <?php _e( 'List the newest cached pages on this page.', 'wp-super-cache' ); ?></label><br /> |
|
985 <?php if( false == defined( 'WPSC_DISABLE_LOCKING' ) ) { ?> |
|
986 <label><input type='checkbox' name='wp_cache_mutex_disabled' <?php if( !$wp_cache_mutex_disabled ) echo "checked"; ?> value='0'> <?php _e( 'Coarse file locking. You probably don’t need this but it may help if your server is underpowered. Warning! <em>May cause your server to lock up in very rare cases!</em>', 'wp-super-cache' ); ?></label><br /> |
|
987 <?php } ?> |
|
988 <label><input type='checkbox' name='wp_super_cache_late_init' <?php if( $wp_super_cache_late_init ) echo "checked"; ?> value='1'> <?php _e( 'Late init. Display cached files after WordPress has loaded. Most useful in legacy mode.', 'wp-super-cache' ); ?></label><br /> |
|
989 <?php if ( $_wp_using_ext_object_cache ) { |
|
990 ?><label><input type='checkbox' name='wp_cache_object_cache' <?php if( $wp_cache_object_cache ) echo "checked"; ?> value='1'> <?php echo __( 'Use object cache to store cached files.', 'wp-super-cache' ) . ' ' . __( '(Experimental)', 'wp-super-cache' ); ?></label><?php |
|
991 }?> |
|
992 <?php printf( __( '<strong>DO NOT CACHE PAGE</strong> secret key: <a href="%s">%s</a>', 'wp-super-cache' ), trailingslashit( get_bloginfo( 'url' ) ) . "?donotcachepage={$cache_page_secret}", $cache_page_secret ); ?> |
|
993 </legend> |
|
994 </fieldset> |
|
995 </td> |
|
996 </tr> |
|
997 </table> |
|
998 <h3><?php _e( 'Note:', 'wp-super-cache' ); ?></h3> |
|
999 <ol> |
|
1000 <li><?php _e( 'Uninstall this plugin on the plugins page. It will automatically clean up after itself. If manual intervention is required then simple instructions are provided.', 'wp-super-cache' ); ?></li> |
|
1001 <li><?php printf( __( 'If uninstalling this plugin, make sure the directory <em>%s</em> is writeable by the webserver so the files <em>advanced-cache.php</em> and <em>cache-config.php</em> can be deleted automatically. (Making sure those files are writeable too is probably a good idea!)', 'wp-super-cache' ), WP_CONTENT_DIR ); ?></li> |
|
1002 <li><?php printf( __( 'Please see the <a href="%1$s/wp-super-cache/readme.txt">readme.txt</a> for instructions on uninstalling this script. Look for the heading, "How to uninstall WP Super Cache".', 'wp-super-cache' ), WP_PLUGIN_URL ); ?></li><?php |
|
1003 echo "<li><em>" . sprintf( __( 'Need help? Check the <a href="%1$s">Super Cache readme file</a>. It includes installation documentation, a FAQ and Troubleshooting tips. The <a href="%2$s">support forum</a> is also available. Your question may already have been answered.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/', 'http://wordpress.org/tags/wp-super-cache?forum_id=10' ) . "</em></li>"; |
|
1004 echo "</ol>"; |
|
1005 |
|
1006 echo "<div class='submit'><input class='button-primary' type='submit' " . SUBMITDISABLED . " value='" . __( 'Update Status', 'wp-super-cache' ) . " »' /></div>"; |
|
1007 wp_nonce_field('wp-cache'); |
|
1008 ?> </form> <?php |
|
1009 wsc_mod_rewrite(); |
|
1010 |
|
1011 wp_cache_edit_max_time(); |
|
1012 |
|
1013 echo '<a name="files"></a><fieldset class="options"><h3>' . __( 'Accepted Filenames & Rejected URIs', 'wp-super-cache' ) . '</h3>'; |
|
1014 wp_cache_edit_rejected_pages(); |
|
1015 echo "\n"; |
|
1016 wp_cache_edit_rejected(); |
|
1017 echo "\n"; |
|
1018 wp_cache_edit_accepted(); |
|
1019 echo '</fieldset>'; |
|
1020 |
|
1021 wp_cache_edit_rejected_ua(); |
|
1022 |
|
1023 wp_lock_down(); |
|
1024 |
|
1025 wp_cache_restore(); |
|
1026 |
|
1027 break; |
|
1028 case "easy": |
|
1029 default: |
|
1030 echo '<form name="wp_manager" action="" method="post">'; |
|
1031 echo '<input type="hidden" name="action" value="easysetup" />'; |
|
1032 wp_nonce_field('wp-cache'); |
|
1033 ?><table class="form-table"> |
|
1034 <tr valign="top"> |
|
1035 <th scope="row"><label for="wp_cache_status"><?php _e( 'Caching', 'wp-super-cache' ); ?></label></th> |
|
1036 <td> |
|
1037 <fieldset> |
|
1038 <label><input type='radio' name='wp_cache_easy_on' value='1' <?php if ( $cache_enabled == true ) { echo 'checked=checked'; } ?>> <?php _e( 'Caching On', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br /> |
|
1039 <label><input type='radio' name='wp_cache_easy_on' value='0' <?php if ( $cache_enabled == false ) { echo 'checked=checked'; } ?>> <?php _e( 'Caching Off', 'wp-super-cache' ); ?></label><br /> |
|
1040 <em><?php _e( 'Note: enables PHP caching, cache rebuild, and mobile support', 'wp-super-cache' ); ?></em><br /> |
|
1041 </legend> |
|
1042 </fieldset> |
|
1043 </td> |
|
1044 </tr> |
|
1045 </table> |
216 <?php |
1046 <?php |
217 } else { |
1047 if ( $cache_enabled && !$wp_cache_mod_rewrite ) { |
218 wp_cache_replace_line('^ *\$wp_cache_cron_check', "\$wp_cache_cron_check = 1;", $wp_cache_config_file); |
1048 $scrules = trim( implode( "\n", extract_from_markers( trailingslashit( get_home_path() ) . '.htaccess', 'WPSuperCache' ) ) ); |
219 } |
1049 if ( $scrules != '' ) { |
220 } else { |
1050 echo "<p><strong>" . __( 'Notice: PHP caching enabled but Supercache mod_rewrite rules detected. Cached files will be served using those rules. If your site is working ok please ignore this message or you can edit the .htaccess file in the root of your install and remove the SuperCache rules.', 'wp-super-cache' ) . '</strong></p>'; |
221 $cron_url = get_option( 'siteurl' ) . '/wp-cron.php?check=' . wp_hash('187425'); |
1051 } |
222 $cron = wp_remote_get($cron_url, array('timeout' => 0.01, 'blocking' => true)); |
1052 } |
223 if( is_array( $cron ) ) { |
1053 echo "<div class='submit'><input class='button-primary' type='submit' " . SUBMITDISABLED . " value='" . __( 'Update Status', 'wp-super-cache' ) . " »' /></div></form>"; |
224 if( $cron[ 'response' ][ 'code' ] == '404' ) { |
1054 if ( $cache_enabled ) { |
225 ?><h3>Warning! wp-cron.php not found!</h3> |
1055 echo "<h3>" . __( 'Cache Tester', 'wp-super-cache' ) . "</h3>"; |
226 <div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'> |
1056 echo '<p>' . __( 'Test your cached website by clicking the test button below.', 'wp-super-cache' ) . '</p>'; |
227 <p><?php _e( 'Unfortunately WordPress cannot find the file wp-cron.php. This script is required for the the correct operation of garbage collection by this plugin, WordPress scheduled posts as well as other critical activities.', 'wp-super-cache' ); ?></p> |
1057 if ( array_key_exists('action', $_POST) && $_POST[ 'action' ] == 'test' && $valid_nonce ) { |
228 <p><?php printf( __( 'Please see entry 16 in the <a href="%s">Troubleshooting section</a> of the readme.txt', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?></p> |
1058 $url = trailingslashit( get_bloginfo( 'url' ) ); |
229 </div> |
1059 if ( isset( $_POST[ 'httponly' ] ) ) |
230 <?php |
1060 $url = str_replace( 'https://', 'http://', $url ); |
231 } else { |
1061 // Prime the cache |
232 wp_cache_replace_line('^ *\$wp_cache_cron_check', "\$wp_cache_cron_check = 1;", $wp_cache_config_file); |
1062 echo "<p>" . sprintf( __( 'Fetching %s to prime cache: ', 'wp-super-cache' ), $url ); |
233 } |
1063 $page = wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) ); |
234 } |
1064 echo '<span style="color: #0a0; font-weight: bold;">' . __( 'OK', 'wp-super-cache' ) . '</strong></p>'; |
235 } |
1065 sleep( 1 ); |
236 } |
1066 // Get the first copy |
237 |
1067 echo "<p>" . sprintf( __( 'Fetching first copy of %s: ', 'wp-super-cache' ), $url ); |
238 if( $cache_enabled == true && $super_cache_enabled == true && !got_mod_rewrite() ) { |
1068 $page = wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) ); |
239 ?><h4 style='color: #a00'><?php _e( 'Mod rewrite may not be installed!', 'wp-super-cache' ); ?></h4> |
1069 if ( !is_wp_error( $page ) ) { |
240 <p><?php _e( 'It appears that mod_rewrite is not installed. Sometimes this check isn’t 100% reliable, especially if you are not using Apache. Please verify that the mod_rewrite module is loaded. It is required for serving Super Cache static files. You will still be able to use half-on mode.', 'wp-super-cache' ); ?></p><?php |
1070 $fp = fopen( $cache_path . "1.html", "w" ); |
241 } |
1071 fwrite( $fp, $page[ 'body' ] ); |
242 |
1072 fclose( $fp ); |
243 if( !is_writeable_ACLSafe($wp_cache_config_file) ) { |
1073 echo '<span style="color: #0a0; font-weight: bold;">' . __( 'OK', 'wp-super-cache' ) . "</span> (<a href='" . WP_CONTENT_URL . "/cache/1.html'>1.html</a>)</p>"; |
244 define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' ); |
1074 sleep( 1 ); |
245 ?><h4 style='text-align:center; color: #a00'><?php _e( 'Read Only Mode. Configuration cannot be changed.', 'wp-super-cache' ); ?> <a href="javascript:toggleLayer('readonlywarning');" title="<?php _e( 'Why your configuration may not be changed', 'wp-super-cache' ); ?>"><?php _e( 'Why', 'wp-super-cache' ); ?></a></h4> |
1075 } else { |
246 <div id='readonlywarning' style='border: 1px solid #aaa; margin: 2px; padding: 2px; display: none;'> |
1076 echo '<span style="color: #a00; font-weight: bold;">' . __( 'FAILED', 'wp-super-cache' ) . "</span></p>"; |
247 <p><?php printf( __( 'The WP Super Cache configuration file is <code>%s/wp-cache-config.php</code> and cannot be modified. That file must be writeable by the webserver to make any changes.', 'wp-super-cache' ), WP_CONTENT_DIR ); ?> |
1077 } |
248 <?php _e( 'A simple way of doing that is by changing the permissions temporarily using the CHMOD command or through your ftp client. Make sure it’s globally writeable and it should be fine.', 'wp-super-cache' ); ?></p> |
1078 // Get the second copy |
249 <?php _e( 'Writeable:', 'wp-super-cache' ); ?> <code>chmod 666 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code> |
1079 echo "<p>" . sprintf( __( 'Fetching second copy of %s: ', 'wp-super-cache' ), $url ); |
250 <?php _e( 'Readonly:', 'wp-super-cache' ); ?> <code>chmod 644 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code></p> |
1080 $page2 = wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) ); |
251 </div><?php |
1081 if ( !is_wp_error( $page2 ) ) { |
252 } else { |
1082 $fp = fopen( $cache_path . "2.html", "w" ); |
253 define( "SUBMITDISABLED", ' ' ); |
1083 fwrite( $fp, $page2[ 'body' ] ); |
254 } |
1084 fclose( $fp ); |
255 |
1085 echo '<span style="color: #0a0; font-weight: bold;">' . __( 'OK', 'wp-super-cache' ) . "</span> (<a href='" . WP_CONTENT_URL . "/cache/2.html'>2.html</a>)</p>"; |
256 // Server could be running as the owner of the wp-content directory. Therefore, if it's |
1086 } else { |
257 // writable, issue a warning only if the permissions aren't 755. |
1087 echo '<span style="color: #a00; font-weight: bold;">' . __( 'FAILED', 'wp-super-cache' ) . "</span></p>"; |
258 if( is_writeable_ACLSafe( WP_CONTENT_DIR . '/' ) ) { |
1088 } |
259 $wp_content_stat = stat(WP_CONTENT_DIR . '/'); |
1089 |
260 $wp_content_mode = ($wp_content_stat['mode'] & 0777); |
1090 if ( is_wp_error( $page ) || is_wp_error( $page2 ) || $page[ 'response' ][ 'code' ] != 200 || $page2[ 'response' ][ 'code' ] != 200 ) { |
261 if( $wp_content_mode != 0755 ) { |
1091 echo '<p><span style="color: #a00; font-weight: bold;">' . __( 'One or more page requests failed:', 'wp-super-cache' ) . '</span></p>'; |
262 ?><h4 style='text-align:center; color: #a00'><?php printf( __( 'Warning! %s is writeable!', 'wp-super-cache' ), WP_CONTENT_DIR ); ?></h4> |
1092 $error = false; |
263 <p><?php printf( __( 'You should change the permissions on %s and make it more restrictive. Use your ftp client, or the following command to fix things:', 'wp-super-cache' ), WP_CONTENT_DIR ); ?><code>chmod 755 <?php echo WP_CONTENT_DIR; ?>/</code></p><?php |
1093 if ( is_wp_error( $page ) ) { |
264 } |
1094 $error = $page; |
265 } |
1095 } elseif ( is_wp_error( $page2 ) ) { |
266 |
1096 $error = $page2; |
267 if ( $valid_nonce ) { |
1097 } |
268 if( isset( $_POST[ 'wp_cache_status' ] ) ) { |
1098 if ( $error ) { |
269 if( isset( $_POST[ 'wp_cache_mobile_enabled' ] ) ) { |
1099 $errors = ''; |
270 $wp_cache_mobile_enabled = 1; |
1100 $messages = ''; |
271 } else { |
1101 foreach ( $error->get_error_codes() as $code ) { |
272 $wp_cache_mobile_enabled = 0; |
1102 $severity = $error->get_error_data($code); |
273 } |
1103 foreach ( $error->get_error_messages( $code ) as $err ) { |
274 if( $wp_cache_mobile_enabled == 1 ) { |
1104 $errors .= ' ' . $err . "<br />\n"; |
275 if( !isset( $wp_cache_mobile_whitelist ) ) |
1105 } |
276 wp_cache_replace_line('^ *\$wp_cache_mobile_whitelist', "\$wp_cache_mobile_whitelist = 'Stand Alone/QNws';", $wp_cache_config_file); |
1106 } |
277 if( false == isset( $wp_cache_mobile_browsers ) ) |
1107 if ( !empty($err) ) |
278 wp_cache_replace_line('^ *\$wp_cache_mobile_browsers', "\$wp_cache_mobile_browsers = 'Android, 2.0 MMP, 240x320, AvantGo, BlackBerry, Blazer, Cellphone, Danger, DoCoMo, Elaine/3.0, EudoraWeb, hiptop, IEMobile, iPhone, iPod, KYOCERA/WX310K, LG/U990, MIDP-2.0, MMEF20, MOT-V, NetFront, Newt, Nintendo Wii, Nitro, Nokia, Opera Mini, Palm, Playstation Portable, portalmmm, Proxinet, ProxiNet, SHARP-TQ-GX10, Small, SonyEricsson, Symbian OS, SymbianOS, TS21i-10, UP.Browser, UP.Link, Windows CE, WinWAP';", $wp_cache_config_file); |
1108 echo '<div class="updated fade">' . $errors . "</div>\n"; |
279 } |
1109 } else { |
280 wp_cache_replace_line('^ *\$wp_cache_mobile_enabled', "\$wp_cache_mobile_enabled = " . $wp_cache_mobile_enabled . ";", $wp_cache_config_file); |
1110 echo '<ul><li>' . sprintf( __( 'Page %d: %d (%s)', 'wp-super-cache' ), 1, $page[ 'response' ][ 'code' ], $page[ 'response' ][ 'message' ] ) . '</li>'; |
281 |
1111 echo '<li>' . sprintf( __( 'Page %d: %d (%s)', 'wp-super-cache' ), 2, $page2[ 'response' ][ 'code' ], $page2[ 'response' ][ 'message' ] ) . '</li></ul>'; |
282 $wp_supercache_cache_list = $_POST[ 'wp_supercache_cache_list' ] == 1 ? 1 : 0; |
1112 } |
283 wp_cache_replace_line('^ *\$wp_supercache_cache_list', "\$wp_supercache_cache_list = " . $wp_supercache_cache_list . ";", $wp_cache_config_file); |
1113 } |
284 |
1114 |
285 switch( $_POST[ 'wp_cache_status' ] ) { |
1115 if ( ( !is_wp_error( $page ) && !is_wp_error( $page2 ) ) && preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[ 'body' ], $matches1 ) && |
286 case 'all': |
1116 preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page2[ 'body' ], $matches2 ) && $matches1[2] == $matches2[2] ) { |
287 wp_cache_enable(); |
1117 echo '<p>' . sprintf( __( 'Page 1: %s', 'wp-super-cache' ), $matches1[ 2 ] ) . '</p>'; |
288 break; |
1118 echo '<p>' . sprintf( __( 'Page 2: %s', 'wp-super-cache' ), $matches2[ 2 ] ) . '</p>'; |
289 case 'none': |
1119 echo '<p><span style="color: #0a0; font-weight: bold;">' . __( 'The timestamps on both pages match!', 'wp-super-cache' ) . '</span></p>'; |
290 wp_cache_disable(); |
1120 } else { |
291 break; |
1121 echo '<p><strong>' . __( 'The pages do not match! Timestamps differ or were not found!', 'wp-super-cache' ) . '</strong></p>'; |
292 case 'wpcache': |
1122 echo '<p>' . __( 'Things you can do:', 'wp-super-cache' ) . '</p>'; |
293 wp_cache_enable(); |
1123 echo '<ol><li>' . __( 'Load your homepage in a logged out browser, check the timestamp at the end of the html source. Load the page again and compare the timestamp. Caching is working if the timestamps match.', 'wp-super-cache' ) . '</li>'; |
294 wp_super_cache_disable(); |
1124 echo '<li>' . __( 'Enable logging on the Debug page here. That should help you track down the problem.', 'wp-super-cache' ) . '</li>'; |
295 break; |
1125 echo '<li>' . __( 'You should check Page 1 and Page 2 above for errors. Your local server configuration may not allow your website to access itself.', 'wp-super-cache' ) . '</li>'; |
296 } |
1126 echo "</ol>"; |
297 if( isset( $_POST[ 'wp_cache_hello_world' ] ) ) { |
1127 |
298 $wp_cache_hello_world = 1; |
1128 } |
299 } else { |
1129 } |
300 $wp_cache_hello_world = 0; |
1130 echo '<form name="cache_tester" action="" method="post">'; |
301 } |
1131 echo '<input type="hidden" name="action" value="test" />'; |
302 wp_cache_replace_line('^ *\$wp_cache_hello_world', '$wp_cache_hello_world = ' . (int)$wp_cache_hello_world . ";", $wp_cache_config_file); |
1132 if ( isset( $_SERVER['HTTPS' ] ) && 'on' == strtolower( $_SERVER['HTTPS' ] ) ) |
303 if( isset( $_POST[ 'wp_cache_clear_on_post_edit' ] ) ) { |
1133 echo "<input type='checkbox' name='httponly' checked='checked' value='1' /> " . __( 'Send non-secure (non https) request for homepage', 'wp-super-cache' ); |
304 $wp_cache_clear_on_post_edit = 1; |
1134 echo '<div class="submit"><input type="submit" name="test" value="' . __( 'Test Cache', 'wp-super-cache' ) . '" /></div>'; |
305 } else { |
1135 wp_nonce_field('wp-cache'); |
306 $wp_cache_clear_on_post_edit = 0; |
1136 echo '</form>'; |
307 } |
1137 } |
308 wp_cache_replace_line('^ *\$wp_cache_clear_on_post_edit', "\$wp_cache_clear_on_post_edit = " . $wp_cache_clear_on_post_edit . ";", $wp_cache_config_file); |
1138 echo "<h3>" . __( "Delete Cached Pages", 'wp-super-cache' ) . "</h3>"; |
309 if( isset( $_POST[ 'cache_rebuild_files' ] ) ) { |
1139 echo "<p>" . __( "Cached pages are stored on your server as html and PHP files. If you need to delete them use the button below.", 'wp-super-cache' ) . "</p>"; |
310 $cache_rebuild_files = 1; |
1140 echo '<form name="wp_cache_content_delete" action="?page=wpsupercache&tab=contents" method="post">'; |
311 } else { |
1141 echo '<input type="hidden" name="wp_delete_cache" />'; |
312 $cache_rebuild_files = 0; |
1142 echo '<div class="submit" style="float:left;margin-left:10px"><input id="deletepost" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache', 'wp-super-cache' ) . ' »" /></div>'; |
313 } |
1143 wp_nonce_field('wp-cache'); |
314 wp_cache_replace_line('^ *\$cache_rebuild_files', "\$cache_rebuild_files = " . $cache_rebuild_files . ";", $wp_cache_config_file); |
1144 echo "</form>\n"; |
315 if( isset( $_POST[ 'wp_cache_mutex_disabled' ] ) ) { |
1145 |
316 $wp_cache_mutex_disabled = 0; |
1146 if ( ( defined( 'VHOST' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) && wpsupercache_site_admin() ) { |
317 } else { |
1147 echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">'; |
318 $wp_cache_mutex_disabled = 1; |
1148 echo '<input type="hidden" name="wp_delete_all_cache" />'; |
319 } |
1149 echo '<div class="submit" style="float:left;margin-left:10px"><input id="deleteallpost" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache On All Blogs', 'wp-super-cache' ) . ' »" />'; |
320 if( defined( 'WPSC_DISABLE_LOCKING' ) ) { |
1150 wp_nonce_field('wp-cache'); |
321 $wp_cache_mutex_disabled = 1; |
1151 echo "</form><br />\n"; |
322 } |
1152 } |
323 wp_cache_replace_line('^ *\$wp_cache_mutex_disabled', "\$wp_cache_mutex_disabled = " . $wp_cache_mutex_disabled . ";", $wp_cache_config_file); |
1153 ?> |
324 if( isset( $_POST[ 'wp_cache_not_logged_in' ] ) ) { |
1154 <h3><?php _e( 'Recommended Links and Plugins', 'wp-super-cache' ); ?></h3> |
325 if( $wp_cache_not_logged_in == 0 && function_exists( 'prune_super_cache' ) ) |
1155 <p><?php _e( 'Caching is only one part of making a website faster. Here are some other plugins that will help:', 'wp-super-cache' ); ?></p> |
326 prune_super_cache ($cache_path, true); |
1156 <ol><li><?php printf( __( '<a href="%s">WPSCMin</a>, a Supercache plugin that minifies cached pages by removing whitespaces and extra characters ', 'wp-super-cache' ), 'http://lyncd.com/wpscmin/' ); ?></li> |
327 $wp_cache_not_logged_in = 1; |
1157 <li><?php printf( __( '<a href="%s">Yahoo! Yslow</a> is an extension for the Firefox add-on Firebug. It analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages. Also try the performance tools online at <a href="%s">GTMetrix</a>.', 'wp-super-cache' ), 'http://developer.yahoo.com/yslow/', 'http://gtmetrix.com/' ); ?></li> |
328 } else { |
1158 <li><?php printf( __( '<a href="%s">Use Google Libraries</a> allows you to load some commonly used Javascript libraries from Google webservers. Ironically it may reduce your Yslow score.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/use-google-libraries/' ); ?></li> |
329 $wp_cache_not_logged_in = 0; |
1159 <li><?php printf( __( 'The <a href="%1$s">CDN Sync Tool</a> plugin will help upload files to Amazon S3/Cloudfront if you would rather not depend on origin pull. See the <a href="%2$s">plugin support forum</a> if you have any queries about this plugin.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/cdn-sync-tool/', 'http://wordpress.org/tags/cdn-sync-tool?forum_id=10' ); ?></li> |
330 } |
1160 <li><?php printf( __( '<strong>Advanced users only:</strong> <a href="%s">Speed up your site with Caching and cache-control</a> explains how to make your site more cacheable with .htaccess rules.', 'wp-super-cache' ), 'http://www.askapache.com/htaccess/speed-up-your-site-with-caching-and-cache-control.html' ); ?></li> |
331 wp_cache_replace_line('^ *\$wp_cache_not_logged_in', "\$wp_cache_not_logged_in = " . $wp_cache_not_logged_in . ";", $wp_cache_config_file); |
1161 <li><?php printf( __( '<strong>Advanced users only:</strong> Install an object cache. Choose from <a href="%s">Memcached</a>, <a href="%s">XCache</a>, <a href="%s">eAcccelerator</a> and others.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/memcached/', 'http://neosmart.net/dl.php?id=12', 'http://neosmart.net/dl.php?id=13' ); ?></li> |
332 } |
1162 <li><?php printf( __( '<a href="%s">Cron View</a> is a useful plugin to use when trying to debug garbage collection and preload problems.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/cron-view/' ); ?></li> |
333 if( defined( 'WPSC_DISABLE_COMPRESSION' ) ) { |
1163 </ol> |
334 $cache_compression_changed = false; |
1164 |
335 $cache_compression = 0; |
1165 <?php |
336 wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file); |
1166 break; |
337 } elseif( isset( $_POST[ 'cache_compression' ] ) && $_POST[ 'cache_compression' ] != $cache_compression ) { |
1167 } |
338 $cache_compression_changed = true; |
1168 |
339 $cache_compression = intval( $_POST[ 'cache_compression' ] ); |
|
340 wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file); |
|
341 if( function_exists( 'prune_super_cache' ) ) |
|
342 prune_super_cache ($cache_path, true); |
|
343 delete_option( 'super_cache_meta' ); |
|
344 } |
|
345 if( isset( $_POST[ 'wp_cache_hide_donation' ] ) && $_POST[ 'wp_cache_hide_donation' ] != $wp_cache_hide_donation ) { |
|
346 $wp_cache_hide_donation = intval( $_POST[ 'wp_cache_hide_donation' ] ); |
|
347 wp_cache_replace_line('^ *\$wp_cache_hide_donation', "\$wp_cache_hide_donation = " . $wp_cache_hide_donation . ";", $wp_cache_config_file); |
|
348 } |
|
349 } |
|
350 |
|
351 echo '<a name="top"></a>'; |
|
352 ?> |
|
353 <table><td><fieldset class="options" id="show-this-fieldset"> |
|
354 <h3><?php _e( 'WP Super Cache Status', 'wp-super-cache' ); ?></h3><?php |
|
355 echo '<form name="wp_manager" action="#top" method="post">'; |
|
356 ?> |
|
357 <label><input type='radio' name='wp_cache_status' value='all' <?php if( $cache_enabled == true && $super_cache_enabled == true ) { echo 'checked=checked'; } ?>> <strong><?php _e( 'ON', 'wp-super-cache' ); ?></strong> <span class="setting-description"><?php _e( 'WP Cache and Super Cache enabled', 'wp-super-cache' ); ?></span></label><br /> |
|
358 <label><input type='radio' name='wp_cache_status' value='wpcache' <?php if( $cache_enabled == true && $super_cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong><?php _e( 'HALF ON', 'wp-super-cache' ); ?></strong> <span class="setting-description"><?php _e( 'Super Cache Disabled, only legacy WP-Cache caching.', 'wp-super-cache' ); ?></span></label><br /> |
|
359 <label><input type='radio' name='wp_cache_status' value='none' <?php if( $cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong><?php _e( 'OFF', 'wp-super-cache' ); ?></strong> <span class="setting-description"><?php _e( 'WP Cache and Super Cache disabled', 'wp-super-cache' ); ?></span></label><br /> |
|
360 <p><label><input type='checkbox' name='wp_cache_not_logged_in' <?php if( $wp_cache_not_logged_in ) echo "checked"; ?> value='1'> <?php _e( 'Don’t cache pages for logged in users.', 'wp-super-cache' ); ?></label></p> |
|
361 <p><label><input type='checkbox' name='wp_cache_hello_world' <?php if( $wp_cache_hello_world ) echo "checked"; ?> value='1'> <?php _e( 'Proudly tell the world your server is Digg proof! (places a message in your blog’s footer)', 'wp-super-cache' ); ?></label></p> |
|
362 <p><label><input type='checkbox' name='wp_cache_clear_on_post_edit' <?php if( $wp_cache_clear_on_post_edit ) echo "checked"; ?> value='1'> <?php _e( 'Clear all cache files when a post or page is published. (This may significantly slow down saving of posts.)', 'wp-super-cache' ); ?></label></p> |
|
363 <p><label><input type='checkbox' name='cache_rebuild_files' <?php if( $cache_rebuild_files ) echo "checked"; ?> value='1'> <?php _e( 'Cache rebuild. Serve a supercache file to anonymous users while a new file is being generated. Recommended for <em>very</em> busy websites with lots of comments. Makes "directly cached pages" and "Lockdown mode" obsolete.', 'wp-super-cache' ); ?></label></p> |
|
364 <?php if( false == defined( 'WPSC_DISABLE_LOCKING' ) ) { ?> |
|
365 <p><label><input type='checkbox' name='wp_cache_mutex_disabled' <?php if( !$wp_cache_mutex_disabled ) echo "checked"; ?> value='0'> <?php _e( 'Coarse file locking. You probably don’t need this but it may help if your server is underpowered. Warning! <em>May cause your server to lock up in very rare cases!</em>', 'wp-super-cache' ); ?></label></p> |
|
366 <?php } ?> |
|
367 <p><label><input type='checkbox' name='wp_supercache_cache_list' <?php if( $wp_supercache_cache_list ) echo "checked"; ?> value='1'> <?php _e( 'List the newest cached pages (may be expensive to run on busy sites, use with caution.)', 'wp-super-cache' ); ?></label> |
|
368 <p><label><input type='checkbox' name='wp_cache_mobile_enabled' <?php if( $wp_cache_mobile_enabled ) echo "checked"; ?> value='1'> <?php _e( 'Mobile device support.', 'wp-super-cache' ); ?></label> |
|
369 <?php |
|
370 $home_path = trailingslashit( get_home_path() ); |
|
371 $scrules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WPSuperCache' ) ); |
|
372 if ( !$wp_cache_mobile_enabled && strpos( $scrules, '240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo' ) ) { |
|
373 echo "<blockquote style='background-color:#feefb3; padding: 5px; margin: 5px;'><h4>" . __( 'Mobile rewrite rules detected', 'wp-super-cache' ) . "</h4>"; |
|
374 echo "<p>" . __( 'For best performance you should enable "Mobile device support" or delete the mobile rewrite rules in your .htaccess. Look for the 2 lines with the text "Android|2.0\ MMP|240x320|AvantGo|BlackBerry|Blazer|Cellphone" and delete those.', 'wp-super-cache' ) . "</p><p>" . __( 'This will have no affect on ordinary users but mobile users will see uncached pages.', 'wp-super-cache' ) . "</p></blockquote>"; |
|
375 } elseif ( $wp_cache_mobile_enabled && $scrules != '' && false === strpos( $scrules, '240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo' ) ) { |
|
376 ?> |
|
377 <blockquote style='background-color:#fefeb3; padding: 5px; margin: 5px;'><p><?php _e( 'Mobile support requires extra rules in your .htaccess file, or you can set the plugin to half-on mode. Here are your options (in order of difficulty):', 'wp-super-cache' ); ?> |
|
378 <ol><li> 1. <?php _e( 'Set the plugin to half on mode and enable mobile support.', 'wp-super-cache' ); ?></li> |
|
379 <li> 2. <?php printf( __( 'Delete the plugin mod_rewrite rules in %s.htaccess enclosed by <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code> and let the plugin regenerate them by reloading this page.', 'wp-super-cache' ), $home_path ); ?></li> |
|
380 <li> 3. <?php printf( __( 'Add the rules yourself. Edit %s.htaccess and find the block of code enclosed by the lines <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code>. There are two sections that look very similar. Just below the line <code>%{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$</code> add this line: (do it twice, once for each section)', 'wp-super-cache' ), $home_path ); ?></p> |
|
381 <div style='padding: 2px; margin: 2px; border: 1px solid #333; width:400px; overflow: scroll'><pre>RewriteCond %{HTTP_user_agent} !^.*(Android|2.0\ MMP|240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|hiptop|IEMobile|iPhone|iPod|KYOCERA/WX310K|LG/U990|MIDP-2.0|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|Playstation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|Windows\ CE|WinWAP).*</pre></div></li></ol></blockquote> |
|
382 <?php } ?> |
|
383 <p><strong><?php _e( 'Note:', 'wp-super-cache' ); ?></strong> <?php printf( __( 'If uninstalling this plugin, make sure the directory <em>%s</em> is writeable by the webserver so the files <em>advanced-cache.php</em> and <em>cache-config.php</em> can be deleted automatically. (Making sure those files are writeable too is probably a good idea!)', 'wp-super-cache' ), WP_CONTENT_DIR ); ?></p> |
|
384 <p><?php printf( __( 'Uninstall using the <a href="%1$s/wp-super-cache/uninstall.php">uninstall script</a> to remove files and directories created by the plugin. (Please see <a href="%1$s/wp-super-cache/readme.txt">readme.txt</a> for instructions on uninstalling this script.)', 'wp-super-cache' ), WP_PLUGIN_URL ); ?></p> |
|
385 <?php |
|
386 echo "<div class='submit'><input type='submit' " . SUBMITDISABLED . " value='" . __( 'Update Status', 'wp-super-cache' ) . " »' /></div>"; |
|
387 wp_nonce_field('wp-cache'); |
|
388 ?> |
|
389 </form> |
|
390 <?php |
|
391 if( $super_cache_enabled && function_exists( 'apache_get_modules' ) ) { |
|
392 $mods = apache_get_modules(); |
|
393 $required_modules = array( 'mod_mime' => __( 'Required to serve compressed supercache files properly.', 'wp-super-cache' ), 'mod_headers' => __( 'Required to set caching information on supercache pages. IE7 users will see old pages without this module.', 'wp-super-cache' ), 'mod_expires' => __( 'Set the expiry date on supercached pages. Visitors may not see new pages when they refresh or leave comments without this module.', 'wp-super-cache' ) ); |
|
394 foreach( $required_modules as $req => $desc ) { |
|
395 if( !in_array( $req, $mods ) ) { |
|
396 $missing_mods[ $req ] = $desc; |
|
397 } |
|
398 } |
|
399 if( isset( $missing_mods) && is_array( $missing_mods ) ) { |
|
400 echo "<h3>" . __( 'Missing Apache Modules', 'wp-super-cache' ) . "</h3>"; |
|
401 echo "<p>" . __( 'The following Apache modules are missing. The plugin will work in half-on mode without them. In full Supercache mode, your visitors may see corrupted pages or out of date content however.', 'wp-super-cache' ) . "</p>"; |
|
402 echo "<ul>"; |
|
403 foreach( $missing_mods as $req => $desc ) { |
|
404 echo "<li> $req - $desc</li>"; |
|
405 } |
|
406 echo "</ul>"; |
|
407 } |
|
408 } |
|
409 ?> |
1169 ?> |
410 </fieldset> |
1170 </fieldset> |
411 </td><td valign='top'> |
1171 </td><td valign='top' style='width: 300px'> |
412 <div style='background: #ffc; border: 1px solid #333; margin: 2px; padding: 5px'> |
1172 <div style='background: #ffc; border: 1px solid #333; margin: 2px; padding: 5px'> |
413 <h3 align='center'><?php _e( 'Make WordPress Faster', 'wp-super-cache' ); ?></h3> |
1173 <h3 align='center'><?php _e( 'Make WordPress Faster', 'wp-super-cache' ); ?></h3> |
414 <?php if( $wp_cache_hide_donation != 1 ) { ?> |
1174 <p><?php printf( __( '%1$s is maintained and developed by %2$s with contributions from many others.', 'wp-super-cache' ), '<a href="http://ocaoimh.ie/y/34">WP Super Cache</a>', '<a href="http://ocaoimh.ie/y/35">Donncha O Caoimh</a>' ); ?></p> |
415 <p><?php printf( __( '%1$s really makes your blog go faster. Make it go faster<sup>*</sup> by buying me an <a href="%2$s">Amazon gift card</a>! Make it out to "%3$s" for whatever amount you want. Every penny helps!', 'wp-super-cache' ), '<a href="http://ocaoimh.ie/wp-super-cache/?r=wpsc">WP Super Cache</a>', 'http://ocaoimh.ie/agc', 'donncha@ocaoimh.ie' ) ?>;</p> |
1175 <p><?php printf( __( 'He blogs at %1$s and posts photos at %2$s.', 'wp-super-cache' ), '<a href="http://ocaoimh.ie/y/35">Holy Shmoly</a>', '<a href="http://ocaoimh.ie/y/2m">In Photos.org</a>' ); ?></p> |
416 <p><?php printf( __( 'If Amazon isn’t your thing, there’s also PayPal. Click the "Donate" button below or take a quick peek at my <a href="%s">wishlist</a>.', 'wp-super-cache' ), 'http://ocaoimh.ie/wish' ); ?></p> |
|
417 <p><?php _e( 'Thanks in advance!', 'wp-super-cache' ); ?><br />Donncha<br /> |
|
418 <small>* <?php _e( 'Ok, it won’t go any faster but you’ll make this plugin author very happy!', 'wp-super-cache' ); ?></small></p> |
|
419 <div align='center'> |
|
420 <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> |
|
421 <input type="hidden" name="cmd" value="_s-xclick"/> |
|
422 <input type="hidden" name="hosted_button_id" value="3244504"/> |
|
423 <input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" border="0" name="submit" alt=""/> |
|
424 <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"/><br /> |
|
425 </form> |
|
426 <p><?php _e( 'Don’t show me this again.', 'wp-super-cache' ); ?> <form action="#top" method="post"><input type='hidden' name='wp_cache_hide_donation' value='1' /><input type='submit' value='<?php _e( 'Hide', 'wp-super-cache' ); ?>' /><?php wp_nonce_field('wp-cache'); ?></form></p> |
|
427 </div> |
|
428 <?php } else { ?> |
|
429 <p><?php printf( __( '%1$s is maintained and developed by %2$s with contributions from many others.', 'wp-super-cache' ), '<a href="http://ocaoimh.ie/wp-super-cache/?r=supercache">WP Super Cache</a>', '<a href="http://ocaoimh.ie/?r=supercache">Donncha O Caoimh</a>' ); ?></p> |
|
430 <p><?php printf( __( 'He blogs at %1$s, posts photos at %2$s and <a href="%3$s">wishes</a> he had more time to read and relax.', 'wp-super-cache' ), '<a href="http://ocaoimh.ie/?r=supercache">Holy Shmoly</a>', '<a href="http://inphotos.org/?r=supercache">In Photos.org</a>', 'http://ocaoimh.ie/gad' ); ?></p> |
|
431 <p><?php printf( __( 'Please say hi to him on %s too!', 'wp-super-cache' ), '<a href="http://twitter.com/donncha/">Twitter</a>' ); ?></p> |
1176 <p><?php printf( __( 'Please say hi to him on %s too!', 'wp-super-cache' ), '<a href="http://twitter.com/donncha/">Twitter</a>' ); ?></p> |
|
1177 <h3 align='center'><?php _e( 'Need Help?', 'wp-super-cache' ); ?></h3> |
|
1178 <ol> |
|
1179 <li><?php _e( 'Use the debug system in the Debug tab above. It will tell you what the plugin is doing.', 'wp-super-cache' ); ?></li> |
|
1180 <li><?php printf( __( '<a href="%1$s">Installation Help</a>', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/installation/' ); ?></li> |
|
1181 <li><?php printf( __( '<a href="%1$s">Frequently Asked Questions</a>', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?></li> |
|
1182 <li><?php printf( __( '<a href="%1$s">Support Forum</a>', 'wp-super-cache' ), 'http://wordpress.org/tags/wp-super-cache' ); ?></li> |
|
1183 <li><?php printf( __( '<a href="%1$s">Development Version</a>', 'wp-super-cache' ), 'http://ocaoimh.ie/y/2o' ); ?></li> |
|
1184 </ol> |
|
1185 <h3 align='center'><?php _e( 'Rate This Plugin!', 'wp-super-cache' ); ?></h3> |
|
1186 <p><?php printf( __( 'Please <a href="%s">rate</a> this plugin and tell me if it works for you or not. It really helps development.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/' ); ?></p> |
|
1187 |
432 <?php |
1188 <?php |
433 } |
|
434 if ( isset( $wp_supercache_cache_list ) && $wp_supercache_cache_list ) { |
1189 if ( isset( $wp_supercache_cache_list ) && $wp_supercache_cache_list ) { |
435 $start_date = get_option( 'wpsupercache_start' ); |
1190 $start_date = get_option( 'wpsupercache_start' ); |
436 if ( !$start_date ) { |
1191 if ( !$start_date ) { |
437 $start_date = time(); |
1192 $start_date = time(); |
438 } |
1193 } |
440 <p><?php printf( __( 'Cached pages since %1$s : <strong>%2$s</strong>', 'wp-super-cache' ), date( 'M j, Y', $start_date ), number_format( get_option( 'wpsupercache_count' ) ) ); ?></p> |
1195 <p><?php printf( __( 'Cached pages since %1$s : <strong>%2$s</strong>', 'wp-super-cache' ), date( 'M j, Y', $start_date ), number_format( get_option( 'wpsupercache_count' ) ) ); ?></p> |
441 <p><?php _e( 'Newest Cached Pages:', 'wp-super-cache' ); ?><ol> |
1196 <p><?php _e( 'Newest Cached Pages:', 'wp-super-cache' ); ?><ol> |
442 <?php |
1197 <?php |
443 foreach( array_reverse( (array)get_option( 'supercache_last_cached' ) ) as $url ) { |
1198 foreach( array_reverse( (array)get_option( 'supercache_last_cached' ) ) as $url ) { |
444 $since = time() - strtotime( $url[ 'date' ] ); |
1199 $since = time() - strtotime( $url[ 'date' ] ); |
445 echo "<li><a title='" . sprintf( __( 'Cached %s seconds ago', 'wp-super-cache' ), $since ) . "' href='" . site_url( $url[ 'url' ] ) . "'>{$url[ 'url' ]}</a></li>\n"; |
1200 echo "<li><a title='" . sprintf( __( 'Cached %s seconds ago', 'wp-super-cache' ), $since ) . "' href='" . site_url( $url[ 'url' ] ) . "'>" . substr( $url[ 'url' ], 0, 20 ) . "</a></li>\n"; |
446 } |
1201 } |
447 ?></ol> |
1202 ?></ol> |
448 <small><?php _e( '(may not always be accurate on busy sites)', 'wp-super-cache' ); ?></small> |
1203 <small><?php _e( '(may not always be accurate on busy sites)', 'wp-super-cache' ); ?></small> |
449 </p><?php |
1204 </p><?php |
450 } else { |
1205 } elseif ( false == get_option( 'wpsupercache_start' ) ) { |
451 $start_date = get_option( 'wpsupercache_start' ); |
1206 update_option( 'wpsupercache_start', time() ); |
452 if ( $start_date ) { |
|
453 update_option( 'wpsupercache_start', $start_date ); |
|
454 update_option( 'wpsupercache_count', 0 ); |
1207 update_option( 'wpsupercache_count', 0 ); |
455 } |
|
456 } |
1208 } |
457 ?> |
1209 ?> |
458 </div> |
1210 </div> |
459 |
|
460 </td></table> |
1211 </td></table> |
|
1212 |
461 <?php |
1213 <?php |
462 |
1214 |
463 wp_cache_files(); |
1215 echo "</div>\n"; |
464 |
1216 } |
465 wsc_mod_rewrite(); |
1217 |
466 |
1218 function wpsc_plugins_tab() { |
467 wp_cache_edit_max_time(); |
1219 echo '<p>' . __( 'Cache plugins are PHP scripts that live in a plugins folder inside the wp-super-cache folder. They are loaded when Supercache loads, much sooner than regular WordPress plugins.', 'wp-super-cache' ) . '</p>'; |
468 |
1220 echo '<p>' . __( 'This is strictly an advanced feature only and knowledge of both PHP and WordPress actions is required to create them.', 'wp-super-cache' ) . '</p>'; |
469 echo '<a name="files"></a><fieldset class="options"><h3>' . __( 'Accepted Filenames & Rejected URIs', 'wp-super-cache' ) . '</h3>'; |
1221 echo '<p>' . __( '<strong>Warning</strong>! Due to the way WordPress upgrades plugins the plugins you upload to wp-super-cache/plugins/ will be deleted when you upgrade WP Super Cache. You can avoid this by loading the plugins from elsewhere. Set <strong>$wp_cache_plugins_dir</strong> to the new location in wp-config.php and WP Super Cache will look there instead.<br />More info available in the <a href="http://ocaoimh.ie/wp-super-cache-developers/">developer documentation</a>.', 'wp-super-cache' ) . '</p>'; |
470 wp_cache_edit_rejected_pages(); |
|
471 echo "\n"; |
|
472 wp_cache_edit_rejected(); |
|
473 echo "\n"; |
|
474 wp_cache_edit_accepted(); |
|
475 echo '</fieldset>'; |
|
476 |
|
477 wp_cache_edit_rejected_ua(); |
|
478 |
|
479 wp_cache_debug_settings(); |
|
480 |
|
481 wp_lock_down(); |
|
482 |
|
483 wp_cache_restore(); |
|
484 |
|
485 ob_start(); |
1222 ob_start(); |
486 if( defined( 'WP_CACHE' ) ) { |
1223 if( defined( 'WP_CACHE' ) ) { |
487 if( function_exists( 'do_cacheaction' ) ) { |
1224 if( function_exists( 'do_cacheaction' ) ) { |
488 do_cacheaction( 'cache_admin_page' ); |
1225 do_cacheaction( 'cache_admin_page' ); |
489 } |
1226 } |
490 } |
1227 } |
491 $out = ob_get_contents(); |
1228 $out = ob_get_contents(); |
492 ob_end_clean(); |
1229 ob_end_clean(); |
493 if( SUBMITDISABLED == ' ' && $out != '' ) { |
1230 if( SUBMITDISABLED == ' ' && $out != '' ) { |
494 echo '<fieldset class="options"><h3>' . __( 'Cache Plugins', 'wp-super-cache' ) . '</h3>'; |
1231 echo '<h3>' . __( 'Available Plugins', 'wp-super-cache' ) . '</h3>'; |
|
1232 echo "<ol>"; |
495 echo $out; |
1233 echo $out; |
496 echo '</fieldset>'; |
1234 echo "</ol>"; |
497 } |
1235 } |
498 |
1236 |
499 echo "</div>\n"; |
1237 } |
|
1238 |
|
1239 function wpsc_admin_tabs( $current = 0 ) { |
|
1240 global $wp_db_version; |
|
1241 if ( $current == 0 ) { |
|
1242 if ( isset( $_GET[ 'tab' ] ) ) { |
|
1243 $current = $_GET[ 'tab' ]; |
|
1244 } else { |
|
1245 $current = 'easy'; |
|
1246 } |
|
1247 } |
|
1248 $tabs = array( 'easy' => __( 'Easy', 'wp-super-cache' ), 'settings' => __( 'Advanced', 'wp-super-cache' ), 'cdn' => __( 'CDN', 'wp-super-cache' ), 'contents' => __( 'Contents', 'wp-super-cache' ), 'preload' => __( 'Preload', 'wp-super-cache' ), 'plugins' => __( 'Plugins', 'wp-super-cache' ), 'debug' => __( 'Debug', 'wp-super-cache' ) ); |
|
1249 $links = array(); |
|
1250 foreach( $tabs as $tab => $name ) { |
|
1251 if ( $current == $tab ) { |
|
1252 $links[] = "<a class='nav-tab nav-tab-active' href='?page=wpsupercache&tab=$tab'>$name</a>"; |
|
1253 } else { |
|
1254 $links[] = "<a class='nav-tab' href='?page=wpsupercache&tab=$tab'>$name</a>"; |
|
1255 } |
|
1256 } |
|
1257 if ( $wp_db_version >= 15477 ) { |
|
1258 echo '<div id="nav"><h2 class="themes-php">'; |
|
1259 echo implode( "", $links ); |
|
1260 echo '</h2></div>'; |
|
1261 } else { |
|
1262 echo implode( " | ", $links ); |
|
1263 } |
500 } |
1264 } |
501 |
1265 |
502 function wsc_mod_rewrite() { |
1266 function wsc_mod_rewrite() { |
503 global $cache_enabled, $super_cache_enabled, $cache_compression, $cache_compression_changed, $valid_nonce, $cache_path; |
1267 global $cache_enabled, $super_cache_enabled, $valid_nonce, $cache_path, $wp_cache_mod_rewrite, $wpmu_version; |
504 if( $super_cache_enabled == false && $cache_enabled == true ) { |
1268 |
505 ?><h3><?php _e( 'Super Cache Compression', 'wp-super-cache' ); ?></h3> |
1269 if ( !$wp_cache_mod_rewrite ) |
506 <p><?php _e( 'Compression is enabled by default when in <em>HALF ON</em> mode.', 'wp-super-cache' ); ?></p> |
1270 return false; |
507 <?php |
1271 |
508 return; |
1272 if ( isset( $wpmu_version ) || function_exists( 'is_multisite' ) && is_multisite() ) { |
509 } elseif ( $super_cache_enabled == false ) { |
1273 if ( false == wpsupercache_site_admin() ) |
510 return; |
1274 return false; |
511 } |
1275 if ( function_exists( "is_main_site" ) && false == is_main_site() ) { |
512 if( false == defined( 'WPSC_DISABLE_COMPRESSION' ) ) { |
1276 global $current_site; |
|
1277 $protocol = ( 'on' == strtolower( $_SERVER['HTTPS' ] ) ) ? 'https://' : 'http://'; |
|
1278 if ( isset( $wpmu_version ) ) { |
|
1279 $link_to_admin = admin_url( "wpmu-admin.php?page=wpsupercache" ); |
|
1280 } else { |
|
1281 $link_to_admin = admin_url( "ms-admin.php?page=wpsupercache" ); |
|
1282 } |
|
1283 echo '<div id="message" class="updated fade"><p>' . sprintf( __( 'Notice: WP Super Cache mod_rewrite rule checks disabled unless running on <a href="%s">the main site</a> of this network.', 'wp-super-cache' ), $link_to_admin ) . '</p></div>'; |
|
1284 return false; |
|
1285 } |
|
1286 } |
|
1287 |
|
1288 if ( function_exists( "is_main_site" ) && false == is_main_site() ) |
|
1289 return true; |
513 ?> |
1290 ?> |
514 <a name='rewrite'></a> |
|
515 <fieldset class="options"> |
|
516 <h3><?php _e( 'Super Cache Compression', 'wp-super-cache' ); ?></h3> |
|
517 <form name="wp_manager" action="#rewrite" method="post"> |
|
518 <label><input type="radio" name="cache_compression" value="1" <?php if( $cache_compression ) { echo "checked=checked"; } ?>> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label> |
|
519 <label><input type="radio" name="cache_compression" value="0" <?php if( !$cache_compression ) { echo "checked=checked"; } ?>> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label> |
|
520 <p><?php _e( 'Compression is disabled by default because some hosts have problems with compressed files. Switching this on and off clears the cache.', 'wp-super-cache' ); ?></p> |
|
521 <?php |
|
522 if( isset( $cache_compression_changed ) && isset( $_POST[ 'cache_compression' ] ) && !$cache_compression ) { |
|
523 ?><p><strong><?php _e( 'Super Cache compression is now disabled.', 'wp-super-cache' ); ?></strong></p> <?php |
|
524 } elseif( isset( $cache_compression_changed ) && isset( $_POST[ 'cache_compression' ] ) && $cache_compression ) { |
|
525 ?><p><strong><?php _e( 'Super Cache compression is now enabled.', 'wps-uper-cache' ); ?></strong></p><?php |
|
526 } |
|
527 echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update Compression', 'wp-super-cache' ) . ' »" /></div>'; |
|
528 wp_nonce_field('wp-cache'); |
|
529 echo "</form>\n"; |
|
530 ?></fieldset> |
|
531 <?php } ?> |
|
532 |
|
533 <a name="modrewrite"></a><fieldset class="options"> |
1291 <a name="modrewrite"></a><fieldset class="options"> |
534 <h3><?php _e( 'Mod Rewrite Rules', 'wp-super-cache' ); ?></h3><?php |
1292 <h3><?php _e( 'Mod Rewrite Rules', 'wp-super-cache' ); ?></h3><?php |
535 if ( isset( $_SERVER[ "PHP_DOCUMENT_ROOT" ] ) ) { |
1293 |
536 $document_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ]; |
1294 extract( wpsc_get_htaccess_info() ); |
537 $apache_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ]; |
|
538 } else { |
|
539 $document_root = $_SERVER[ "DOCUMENT_ROOT" ]; |
|
540 $apache_root = '%{DOCUMENT_ROOT}'; |
|
541 } |
|
542 $home_path = get_home_path(); |
|
543 $home_root = parse_url(get_bloginfo('url')); |
|
544 $home_root = isset( $home_root['path'] ) ? trailingslashit( $home_root['path'] ) : '/'; |
|
545 $inst_root = str_replace( '//', '/', '/' . trailingslashit( str_replace( $document_root, '', str_replace( '\\', '/', WP_CONTENT_DIR ) ) ) ); |
|
546 $wprules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WordPress' ) ); |
|
547 $wprules = str_replace( "RewriteEngine On\n", '', $wprules ); |
|
548 $wprules = str_replace( "RewriteBase $home_root\n", '', $wprules ); |
|
549 $scrules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WPSuperCache' ) ); |
|
550 |
|
551 if( substr( get_option( 'permalink_structure' ), -1 ) == '/' ) { |
|
552 $condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*[^/]$"; |
|
553 $condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*//.*$"; |
|
554 } |
|
555 $condition_rules[] = "RewriteCond %{REQUEST_METHOD} !POST"; |
|
556 $condition_rules[] = "RewriteCond %{QUERY_STRING} !.*=.*"; |
|
557 $condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$"; |
|
558 $condition_rules[] = "RewriteCond %{HTTP_USER_AGENT} !^.*(Android|2.0\\ MMP|240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|hiptop|IEMobile|iPhone|iPod|KYOCERA/WX310K|LG/U990|MIDP-2.0|MMEF20|MOT-V|NetFront|Newt|Nintendo\\ Wii|Nitro|Nokia|Opera\\ Mini|Palm|Playstation\\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|Small|SonyEricsson|Symbian\\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|Windows\\ CE|WinWAP).*"; |
|
559 $condition_rules = apply_filters( 'supercacherewriteconditions', $condition_rules ); |
|
560 |
|
561 $rules = "<IfModule mod_rewrite.c>\n"; |
|
562 $rules .= "RewriteEngine On\n"; |
|
563 $rules .= "RewriteBase $home_root\n"; // props Chris Messina |
|
564 $charset = get_option('blog_charset') == '' ? 'UTF-8' : get_option('blog_charset'); |
|
565 $rules .= "AddDefaultCharset {$charset}\n"; |
|
566 $rules .= "CONDITION_RULES"; |
|
567 $rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n"; |
|
568 $rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz -f\n"; |
|
569 $rules .= "RewriteRule ^(.*) {$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz [L]\n\n"; |
|
570 |
|
571 $rules .= "CONDITION_RULES"; |
|
572 $rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html -f\n"; |
|
573 $rules .= "RewriteRule ^(.*) {$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html [L]\n"; |
|
574 $rules .= "</IfModule>\n"; |
|
575 $rules = apply_filters( 'supercacherewriterules', $rules ); |
|
576 |
|
577 $rules = str_replace( "CONDITION_RULES", implode( "\n", $condition_rules ) . "\n", $rules ); |
|
578 |
|
579 $dohtaccess = true; |
1295 $dohtaccess = true; |
580 if( function_exists( 'is_site_admin' ) ) { |
1296 global $wpmu_version; |
|
1297 if( isset( $wpmu_version ) ) { |
581 echo "<h4 style='color: #a00'>" . __( 'WordPress MU Detected', 'wp-super-cache' ) . "</h4><p>" . __( "Unfortunately the rewrite rules cannot be updated automatically when running WordPress MU. Please open your .htaccess and add the following mod_rewrite rules above any other rules in that file.", 'wp-super-cache' ) . "</p>"; |
1298 echo "<h4 style='color: #a00'>" . __( 'WordPress MU Detected', 'wp-super-cache' ) . "</h4><p>" . __( "Unfortunately the rewrite rules cannot be updated automatically when running WordPress MU. Please open your .htaccess and add the following mod_rewrite rules above any other rules in that file.", 'wp-super-cache' ) . "</p>"; |
582 } elseif( !$wprules || $wprules == '' ) { |
1299 } elseif( !$wprules || $wprules == '' ) { |
583 echo "<h4 style='color: #a00'>" . __( 'Mod Rewrite rules cannot be updated!', 'wp-super-cache' ) . "</h4>"; |
1300 echo "<h4 style='color: #a00'>" . __( 'Mod Rewrite rules cannot be updated!', 'wp-super-cache' ) . "</h4>"; |
584 echo "<p>" . sprintf( __( "You must have <strong>BEGIN</strong> and <strong>END</strong> markers in %s.htaccess for the auto update to work. They look like this and surround the main WordPress mod_rewrite rules:", 'wp-super-cache' ), $home_path ); |
1301 echo "<p>" . sprintf( __( "You must have <strong>BEGIN</strong> and <strong>END</strong> markers in %s.htaccess for the auto update to work. They look like this and surround the main WordPress mod_rewrite rules:", 'wp-super-cache' ), $home_path ); |
585 echo "<blockquote><pre><em># BEGIN WordPress</em>\n RewriteCond %{REQUEST_FILENAME} !-f\n RewriteCond %{REQUEST_FILENAME} !-d\n RewriteRule . /index.php [L]\n <em># END WordPress</em></pre></blockquote>"; |
1302 echo "<blockquote><pre><em># BEGIN WordPress</em>\n RewriteCond %{REQUEST_FILENAME} !-f\n RewriteCond %{REQUEST_FILENAME} !-d\n RewriteRule . /index.php [L]\n <em># END WordPress</em></pre></blockquote>"; |
586 _e( 'Refresh this page when you have updated your .htaccess file.', 'wp-super-cache' ); |
1303 _e( 'Refresh this page when you have updated your .htaccess file.', 'wp-super-cache' ); |
587 echo "</fieldset></div>"; |
1304 echo "</fieldset>"; |
588 return; |
1305 $dohtaccess = false; |
589 } elseif( strpos( $wprules, 'wordpressuser' ) ) { // Need to clear out old mod_rewrite rules |
1306 } elseif( strpos( $wprules, 'wordpressuser' ) ) { // Need to clear out old mod_rewrite rules |
590 echo "<p><strong>" . __( 'Thank you for upgrading.', 'wp-super-cache' ) . "</strong> " . sprintf( __( 'The mod_rewrite rules changed since you last installed this plugin. Unfortunately you must remove the old supercache rules before the new ones are updated. Refresh this page when you have edited your .htaccess file. If you wish to manually upgrade, change the following line: %1$s so it looks like this: %2$s The only changes are "HTTP_COOKIE" becomes "HTTP:Cookie" and "wordpressuser" becomes "wordpress". This is a WordPress 2.5 change but it’s backwards compatible with older versions if you’re brave enough to use them.', 'wp-super-cache' ), '<blockquote><code>RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$</code></blockquote>', '<blockquote><code>RewriteCond %{HTTP:Cookie} !^.*wordpress.*$</code></blockquote>' ) . "</p>"; |
1307 echo "<p><strong>" . __( 'Thank you for upgrading.', 'wp-super-cache' ) . "</strong> " . sprintf( __( 'The mod_rewrite rules changed since you last installed this plugin. Unfortunately you must remove the old supercache rules before the new ones are updated. Refresh this page when you have edited your .htaccess file. If you wish to manually upgrade, change the following line: %1$s so it looks like this: %2$s The only changes are "HTTP_COOKIE" becomes "HTTP:Cookie" and "wordpressuser" becomes "wordpress". This is a WordPress 2.5 change but it’s backwards compatible with older versions if you’re brave enough to use them.', 'wp-super-cache' ), '<blockquote><code>RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$</code></blockquote>', '<blockquote><code>RewriteCond %{HTTP:Cookie} !^.*wordpress.*$</code></blockquote>' ) . "</p>"; |
591 echo "</fieldset></div>"; |
1308 echo "</fieldset></div>"; |
592 return; |
1309 return; |
593 } elseif( $scrules != '' && strpos( $scrules, '%{REQUEST_URI} !^.*[^/]$' ) === false && substr( get_option( 'permalink_structure' ), -1 ) == '/' ) { // permalink structure has a trailing slash, need slash check in rules. |
1310 } elseif( $scrules != '' && strpos( $scrules, '%{REQUEST_URI} !^.*[^/]$' ) === false && substr( get_option( 'permalink_structure' ), -1 ) == '/' ) { // permalink structure has a trailing slash, need slash check in rules. |
838 return FALSE; |
1543 return FALSE; |
839 } |
1544 } |
840 } |
1545 } |
841 |
1546 |
842 function wp_cache_edit_max_time () { |
1547 function wp_cache_edit_max_time () { |
843 global $cache_max_time, $wp_cache_config_file, $valid_nonce, $cache_enabled, $super_cache_enabled; |
1548 global $cache_max_time, $wp_cache_config_file, $valid_nonce, $cache_enabled, $super_cache_enabled, $cache_schedule_type, $cache_scheduled_time, $cache_schedule_interval, $cache_time_interval, $cache_gc_email_me, $wp_cache_preload_on; |
844 |
1549 |
845 if( !isset( $cache_max_time ) ) |
1550 $timezone_format = _x('Y-m-d G:i:s', 'timezone date format'); |
|
1551 |
|
1552 if( !isset( $cache_schedule_type ) ) { |
|
1553 $cache_schedule_type = 'interval'; |
|
1554 wp_cache_replace_line('^ *\$cache_schedule_type', "\$cache_schedule_type = '$cache_schedule_type';", $wp_cache_config_file); |
|
1555 } |
|
1556 |
|
1557 if( !isset( $cache_scheduled_time ) ) { |
|
1558 $cache_scheduled_time = '00:00'; |
|
1559 wp_cache_replace_line('^ *\$cache_scheduled_time', "\$cache_scheduled_time = '$cache_scheduled_time';", $wp_cache_config_file); |
|
1560 } |
|
1561 |
|
1562 if( !isset( $cache_max_time ) ) { |
846 $cache_max_time = 3600; |
1563 $cache_max_time = 3600; |
847 |
1564 wp_cache_replace_line('^ *\$cache_max_time', "\$cache_max_time = $cache_max_time;", $wp_cache_config_file); |
848 if(isset($_POST['wp_max_time']) && $valid_nonce) { |
1565 } |
849 $max_time = (int)$_POST['wp_max_time']; |
1566 |
850 if ($max_time > 0) { |
1567 if ( !isset( $cache_time_interval ) ) { |
851 $cache_max_time = $max_time; |
1568 $cache_time_interval = $cache_max_time; |
852 wp_cache_replace_line('^ *\$cache_max_time', "\$cache_max_time = $cache_max_time;", $wp_cache_config_file); |
1569 wp_cache_replace_line('^ *\$cache_time_interval', "\$cache_time_interval = '$cache_time_interval';", $wp_cache_config_file); |
853 } |
1570 } |
|
1571 |
|
1572 if ( isset( $_POST['wp_max_time'] ) && $valid_nonce ) { |
|
1573 $cache_max_time = (int)$_POST['wp_max_time']; |
|
1574 wp_cache_replace_line('^ *\$cache_max_time', "\$cache_max_time = $cache_max_time;", $wp_cache_config_file); |
|
1575 // schedule gc watcher |
|
1576 if ( false == wp_next_scheduled( 'wp_cache_gc_watcher' ) ) |
|
1577 wp_schedule_event( time()+600, 'hourly', 'wp_cache_gc_watcher' ); |
|
1578 } |
|
1579 |
|
1580 if ( isset( $_POST[ 'cache_gc_email_me' ] ) && $valid_nonce ) { |
|
1581 $cache_gc_email_me = 1; |
|
1582 wp_cache_replace_line('^ *\$cache_gc_email_me', "\$cache_gc_email_me = $cache_gc_email_me;", $wp_cache_config_file); |
|
1583 } elseif ( $valid_nonce ) { |
|
1584 $cache_gc_email_me = 0; |
|
1585 wp_cache_replace_line('^ *\$cache_gc_email_me', "\$cache_gc_email_me = $cache_gc_email_me;", $wp_cache_config_file); |
|
1586 } |
|
1587 if ( isset( $_POST[ 'cache_schedule_type' ] ) && $_POST[ 'cache_schedule_type' ] == 'interval' && isset( $_POST['cache_time_interval'] ) && $valid_nonce ) { |
|
1588 wp_clear_scheduled_hook( 'wp_cache_gc' ); |
|
1589 $cache_schedule_type = 'interval'; |
|
1590 if ( (int)$_POST[ 'cache_time_interval' ] == 0 ) |
|
1591 $_POST[ 'cache_time_interval' ] = 600; |
|
1592 $cache_time_interval = (int)$_POST[ 'cache_time_interval' ]; |
|
1593 wp_schedule_single_event( time() + $cache_time_interval, 'wp_cache_gc' ); |
|
1594 wp_cache_replace_line('^ *\$cache_schedule_type', "\$cache_schedule_type = '$cache_schedule_type';", $wp_cache_config_file); |
|
1595 wp_cache_replace_line('^ *\$cache_time_interval', "\$cache_time_interval = '$cache_time_interval';", $wp_cache_config_file); |
|
1596 } elseif ( $valid_nonce ) { // clock |
|
1597 wp_clear_scheduled_hook( 'wp_cache_gc' ); |
|
1598 $cache_schedule_type = 'time'; |
|
1599 if ( $_POST[ 'cache_scheduled_time' ] == '' ) |
|
1600 $_POST[ 'cache_scheduled_time' ] = '00:00'; |
|
1601 $cache_scheduled_time = $_POST[ 'cache_scheduled_time' ]; |
|
1602 $schedules = wp_get_schedules(); |
|
1603 if ( isset( $schedules[ $_POST[ 'cache_schedule_interval' ] ] ) ) |
|
1604 $cache_schedule_interval = $_POST[ 'cache_schedule_interval' ]; |
|
1605 wp_cache_replace_line('^ *\$cache_schedule_type', "\$cache_schedule_type = '$cache_schedule_type';", $wp_cache_config_file); |
|
1606 wp_cache_replace_line('^ *\$cache_schedule_interval', "\$cache_schedule_interval = '{$cache_schedule_interval}';", $wp_cache_config_file); |
|
1607 wp_cache_replace_line('^ *\$cache_scheduled_time', "\$cache_scheduled_time = '$cache_scheduled_time';", $wp_cache_config_file); |
|
1608 wp_schedule_event( strtotime( $cache_scheduled_time ), $cache_schedule_interval, 'wp_cache_gc' ); |
854 } |
1609 } |
855 ?><fieldset class="options"> |
1610 ?><fieldset class="options"> |
856 <a name='expirytime'></a> |
1611 <a name='expirytime'></a> |
857 <h3><?php _e( 'Expiry Time & Garbage Collection', 'wp-super-cache' ); ?></h3><?php |
1612 <h3><?php _e( 'Expiry Time & Garbage Collection', 'wp-super-cache' ); ?></h3><?php |
|
1613 |
|
1614 ?><span id="utc-time"><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n($timezone_format, false, 'gmt')); ?></span><?php |
|
1615 $current_offset = get_option('gmt_offset'); |
|
1616 if ( get_option('timezone_string') || !empty($current_offset) ) { |
|
1617 ?><span id="local-time"><?php printf(__('Local time is <code>%1$s</code>'), date_i18n($timezone_format)); ?></span><?php |
|
1618 } |
|
1619 $next_gc = wp_next_scheduled( 'wp_cache_gc' ); |
|
1620 if ( $next_gc ) |
|
1621 echo "<p>" . sprintf( __( 'Next scheduled garbage collection will be at <strong>%s UTC</strong>', 'wp-super-cache' ), date_i18n( $timezone_format, $next_gc, 'gmt' ) ) . "</p>"; |
|
1622 |
|
1623 |
|
1624 if ( $wp_cache_preload_on ) |
|
1625 echo "<p>" . __( 'Warning! <strong>PRELOAD MODE</strong> activated. Supercache files will not be deleted regardless of age.' ) . "</p>"; |
|
1626 |
|
1627 echo "<script type='text/javascript'>"; |
|
1628 echo "jQuery(function () { |
|
1629 jQuery('#cache_interval_time').click(function () { |
|
1630 jQuery('#schedule_interval').attr('checked', true); |
|
1631 }); |
|
1632 jQuery('#cache_scheduled_time').click(function () { |
|
1633 jQuery('#schedule_time').attr('checked', true); |
|
1634 }); |
|
1635 jQuery('#cache_scheduled_select').click(function () { |
|
1636 jQuery('#schedule_time').attr('checked', true); |
|
1637 }); |
|
1638 });"; |
|
1639 echo "</script>"; |
858 echo '<form name="wp_edit_max_time" action="#expirytime" method="post">'; |
1640 echo '<form name="wp_edit_max_time" action="#expirytime" method="post">'; |
859 echo '<label for="wp_max_time">' . __( 'Expire time:', 'wp-super-cache' ) . '</label> '; |
1641 echo '<table class="form-table">'; |
860 echo "<input type=\"text\" size=6 name=\"wp_max_time\" value=\"$cache_max_time\" /> " . __( "seconds", 'wp-super-cache' ); |
1642 echo '<tr><td><label for="wp_max_time"><strong>' . __( 'Cache Timeout', 'wp-super-cache' ) . '</strong></label></td>'; |
861 echo "<h4>" . __( 'Garbage Collection', 'wp-super-cache' ) . "</h4><p>" . __( 'If expiry time is more than 1800 seconds (half an hour), garbage collection will be done every 10 minutes, otherwise it will happen 10 seconds after the expiry time above.', 'wp-super-cache' ) . "</p>"; |
1643 echo "<td><input type='text' id='wp_max_time' size=6 name='wp_max_time' value='$cache_max_time' /> " . __( "seconds", 'wp-super-cache' ) . "</td></tr>\n"; |
862 echo "<p>" . __( 'Checking for and deleting expired files is expensive, but it’s expensive leaving them there too. On a very busy site you should set the expiry time to <em>300 seconds</em>. Experiment with different values and visit this page to see how many expired files remain at different times during the day. Aim to have less than 500 cached files if possible.', 'wp-super-cache' ) . "</p>"; |
1644 echo "<tr><td></td><td>" . __( 'How long should cached pages remain fresh? Set to 0 to disable garbage collection. A good starting point is 3600 seconds.', 'wp-super-cache' ) . "</td></tr>\n"; |
|
1645 echo '<tr><td valign="top"><strong>' . __( 'Scheduler', 'wp-super-cache' ) . '</strong></td><td><table cellpadding=0 cellspacing=0><tr><td valign="top"><input type="radio" id="schedule_interval" name="cache_schedule_type" value="interval" ' . checked( 'interval', $cache_schedule_type, false ) . ' /></td><td valign="top"><label for="cache_interval_time">' . __( 'Timer:', 'wp-super-cache' ) . '</label></td>'; |
|
1646 echo "<td><input type='text' id='cache_interval_time' size=6 name='cache_time_interval' value='$cache_time_interval' /> " . __( "seconds", 'wp-super-cache' ) . '<br />' . __( 'Check for stale cached files every <em>interval</em> seconds.', 'wp-super-cache' ) . "</td></tr>"; |
|
1647 echo '<tr><td valign="top"><input type="radio" id="schedule_time" name="cache_schedule_type" value="time" ' . checked( 'time', $cache_schedule_type, false ) . ' /></td><td valign="top"><label for="schedule_time">' . __( 'Clock:', 'wp-super-cache' ) . '</label></td>'; |
|
1648 echo "<td><input type=\"text\" size=5 id='cache_scheduled_time' name='cache_scheduled_time' value=\"$cache_scheduled_time\" /> " . __( "HH:MM", 'wp-super-cache' ) . "<br />" . __( 'Check for stale cached files at this time <strong>(UTC)</strong> or starting at this time every <em>interval</em> below.', 'wp-super-cache' ) . "</td></tr>"; |
|
1649 $schedules = wp_get_schedules(); |
|
1650 echo "<tr><td><br /></td><td><label for='cache_scheduled_select'>" . __( 'Interval:', 'wp-super-cache' ) . "</label></td><td><select id='cache_scheduled_select' name='cache_schedule_interval' size=1>"; |
|
1651 foreach( $schedules as $desc => $details ) { |
|
1652 echo "<option value='$desc' " . selected( $desc, $cache_schedule_interval, false ) . " /> {$details[ 'display' ]}</option>"; |
|
1653 } |
|
1654 echo "</select></td></tr>"; |
|
1655 echo '</table></td></tr>'; |
|
1656 echo '<tr><td><label for="cache_gc_email_me"><strong>' . __( 'Notification Emails', 'wp-super-cache' ) . '</strong></label></td>'; |
|
1657 echo "<td><input type='checkbox' id='cache_gc_email_me' name='cache_gc_email_me' " . checked( $cache_gc_email_me, 1, false ) . " /> " . __( 'Email me when the garbage collection runs.', 'wp-super-cache' ) . "</td></tr>\n"; |
|
1658 echo "</table>\n"; |
|
1659 echo "<h4>" . __( 'Garbage Collection', 'wp-super-cache' ) . "</h4>"; |
|
1660 echo "<ol><li>" . __( '<em>Garbage collection</em> is the simple act of throwing out your garbage. For this plugin that would be old or <em>stale</em> cached files that may be out of date. New cached files are described as <em>fresh</em>.', 'wp-super-cache' ) . "</li>\n"; |
|
1661 echo "<li>" . __( 'Cached files are fresh for a limited length of time. You can set that time in the <em>Cache Timeout</em> text box on this page.', 'wp-super-cache' ) . "</li>\n"; |
|
1662 echo "<li>" . __( 'Stale cached files are not removed as soon as they become stale. They have to be removed by the garbage collecter. That is why you have to tell the plugin when the garbage collector should run.', 'wp-super-cache' ) . "</li>\n"; |
|
1663 echo "<li>" . __( 'Use the <em>Timer</em> or <em>Clock</em> schedulers to define when the garbage collector should run.', 'wp-super-cache' ) . "</li>\n"; |
|
1664 echo "<li>" . __( 'The <em>Timer</em> scheduler tells the plugin to run the garbage collector at regular intervals. When one garbage collection is done, the next run is scheduled.', 'wp-super-cache' ) . "</li>\n"; |
|
1665 echo "<li>" . __( 'Or, the <em>Clock</em> scheduler allows the garbage collection to run at specific times. If set to run hourly or twicedaily the garbage collector will be first scheduled for the time you enter here. It will then run again at the indicated interval. If set to run daily it will run once a day at the time specified.', 'wp-super-cache' ) . "</li>\n"; |
|
1666 echo "</ol>"; |
|
1667 echo "<p>" . __( 'There are no best garbage collection settings but here are a few scenarios. Garbage collection is separate to other actions that clear our cached files like leaving a comment or publishing a post.', 'wp-super-cache' ) . "</p>\n"; |
|
1668 echo "<ol>"; |
|
1669 echo "<li>" . __( 'Sites that want to serve lots of newly generated data should set the <em>Cache Timeout</em> to 60 and use the <em>Timer</em> scheduler set to 90 seconds.', 'wp-super-cache' ) . "</li>\n"; |
|
1670 echo "<li>" . __( 'Sites with widgets and rss feeds in their sidebar should probably use a timeout of 3600 seconds and set the timer to 600 seconds. Stale files will be caught within 10 minutes of going stale.', 'wp-super-cache' ) . "</li>\n"; |
|
1671 echo "<li>" . __( 'Sites with lots of static content, no widgets or rss feeds in their sidebar can use a timeout of 86400 seconds or even more and set the timer to something equally long.', 'wp-super-cache' ) . "</li>\n"; |
|
1672 echo "<li>" . __( 'Sites where an external data source updates at a particular time every day should set the timeout to 86400 seconds and use the Clock scheduler set appropriately.', 'wp-super-cache' ) . "</li>\n"; |
|
1673 echo "</ol>"; |
|
1674 echo "<p>" . __( 'Checking for and deleting expired files is expensive, but it’s expensive leaving them there too. On a very busy site you should set the expiry time to <em>600 seconds</em>. Experiment with different values and visit this page to see how many expired files remain at different times during the day. If you are using legacy caching aim to have less than 500 cached files if possible. You can have many times more cached files when using mod_rewrite or PHP caching.', 'wp-super-cache' ) . "</p>"; |
|
1675 echo "<p>" . __( 'Set the expiry time to 0 seconds to disable garbage collection.', 'wp-super-cache' ) . "</p>"; |
863 echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Change Expiration', 'wp-super-cache' ) . ' »" /></div>'; |
1676 echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Change Expiration', 'wp-super-cache' ) . ' »" /></div>'; |
864 wp_nonce_field('wp-cache'); |
1677 wp_nonce_field('wp-cache'); |
865 echo "</form>\n"; |
1678 echo "</form>\n"; |
866 ?></fieldset><?php |
1679 ?></fieldset><?php |
867 } |
1680 } |
868 |
1681 |
869 function wp_cache_sanitize_value($text, & $array) { |
1682 function wp_cache_sanitize_value($text, & $array) { |
870 $text = wp_specialchars(strip_tags($text)); |
1683 $text = esc_html(strip_tags($text)); |
871 $array = preg_split("/[\s,]+/", chop($text)); |
1684 $array = preg_split("/[\s,]+/", chop($text)); |
872 $text = var_export($array, true); |
1685 $text = var_export($array, true); |
873 $text = preg_replace('/[\s]+/', ' ', $text); |
1686 $text = preg_replace('/[\s]+/', ' ', $text); |
874 return $text; |
1687 return $text; |
875 } |
1688 } |
1413 } elseif( $wp_cache_fsize != 0 ) { |
2252 } elseif( $wp_cache_fsize != 0 ) { |
1414 $wp_cache_fsize = number_format( $wp_cache_fsize, 2 ) . "KB"; |
2253 $wp_cache_fsize = number_format( $wp_cache_fsize, 2 ) . "KB"; |
1415 } else { |
2254 } else { |
1416 $wp_cache_fsize = '0KB'; |
2255 $wp_cache_fsize = '0KB'; |
1417 } |
2256 } |
1418 if( $cache_enabled == true && $super_cache_enabled == true ) { |
2257 |
1419 $now = time(); |
2258 // Supercache files |
1420 $sizes = array( 'expired' => 0, 'expired_list' => array(), 'cached' => 0, 'cached_list' => array(), 'ts' => 0 ); |
2259 $now = time(); |
1421 |
2260 $sizes = array( 'expired' => 0, 'expired_list' => array(), 'cached' => 0, 'cached_list' => array(), 'ts' => 0 ); |
1422 if (is_dir($supercachedir)) { |
2261 |
1423 if( $dh = opendir( $supercachedir ) ) { |
2262 if (is_dir($supercachedir)) { |
1424 while( ( $entry = readdir( $dh ) ) !== false ) { |
2263 if( $dh = opendir( $supercachedir ) ) { |
1425 if ($entry != '.' && $entry != '..') { |
2264 while( ( $entry = readdir( $dh ) ) !== false ) { |
1426 $sizes = wpsc_dirsize( trailingslashit( $supercachedir ) . $entry, $sizes ); |
2265 if ($entry != '.' && $entry != '..') { |
1427 } |
2266 $sizes = wpsc_dirsize( trailingslashit( $supercachedir ) . $entry, $sizes ); |
1428 } |
2267 } |
1429 closedir($dh); |
2268 } |
1430 } |
2269 closedir($dh); |
1431 } else { |
2270 } |
1432 $filem = @filemtime( $supercachedir ); |
2271 } else { |
1433 if(is_file($supercachedir) && $filem + $cache_max_time <= $now ) { |
2272 $filem = @filemtime( $supercachedir ); |
1434 $sizes[ 'expired' ] ++; |
2273 if ( false == $wp_cache_preload_on && is_file( $supercachedir ) && $cache_max_time > 0 && $filem + $cache_max_time <= $now ) { |
1435 if ( $valid_nonce && $_GET[ 'listfiles' ] ) |
2274 $sizes[ 'expired' ] ++; |
1436 $sizes[ 'expired_list' ][ str_replace( $cache_path . 'supercache/' , '', $supercachedir ) ] = $now - $filem; |
2275 if ( $valid_nonce && $_GET[ 'listfiles' ] ) |
1437 } else { |
2276 $sizes[ 'expired_list' ][ str_replace( $cache_path . 'supercache/' , '', $supercachedir ) ] = $now - $filem; |
1438 if ( $valid_nonce && $_GET[ 'listfiles' ] && $filem ) |
2277 } else { |
1439 $sizes[ 'cached_list' ][ str_replace( $cache_path . 'supercache/' , '', $supercachedir ) ] = $now - $filem; |
2278 if ( $valid_nonce && $_GET[ 'listfiles' ] && $filem ) |
1440 } |
2279 $sizes[ 'cached_list' ][ str_replace( $cache_path . 'supercache/' , '', $supercachedir ) ] = $now - $filem; |
1441 } |
2280 } |
1442 $sizes[ 'ts' ] = time(); |
2281 } |
1443 } |
2282 $sizes[ 'ts' ] = time(); |
1444 |
2283 $cache_stats = array( 'generated' => time(), 'supercache' => $sizes, 'wpcache' => array( 'cached' => $count, 'expired' => $expired, 'fsize' => $wp_cache_fsize ) ); |
1445 echo "<p><strong>" . __( 'WP-Cache', 'wp-super-cache' ) . " ({$wp_cache_fsize})</strong></p>"; |
2284 update_option( 'supercache_stats', $cache_stats ); |
1446 echo "<ul><li>" . sprintf( __( '%s Cached Pages', 'wp-super-cache' ), $count ) . "</li>"; |
2285 } else { |
1447 echo "<li>" . sprintf( __( '%s Expired Pages', 'wp-super-cache' ), $expired ) . "</li></ul>"; |
2286 echo "<p>" . __( 'Cache stats are not automatically generated. You must click the link below to regenerate the stats on this page.', 'wp-super-cache' ) . "</p>"; |
1448 if( $cache_enabled == true && $super_cache_enabled == true ) { |
2287 echo "<a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'tab' => 'contents', 'action' => 'regenerate_cache_stats' ) ), 'wp-cache' ) . "'>" . __( 'Regenerate cache stats', 'wp-super-cache' ) . "</a>"; |
1449 $fsize = $sizes[ 'fsize' ] / 1024; |
2288 if ( is_array( $cache_stats ) ) { |
|
2289 echo "<p>" . sprintf( __( 'Cache stats last generated: %s minutes ago.', 'wp-super-cache' ), number_format( ( time() - $cache_stats[ 'generated' ] ) / 60 ) ) . "</p>"; |
|
2290 } |
|
2291 $cache_stats = get_option( 'supercache_stats' ); |
|
2292 }// regerate stats cache |
|
2293 |
|
2294 if ( is_array( $cache_stats ) ) { |
|
2295 echo "<p><strong>" . __( 'WP-Cache', 'wp-super-cache' ) . " ({$cache_stats[ 'wpcache' ][ 'fsize' ]})</strong></p>"; |
|
2296 echo "<ul><li>" . sprintf( __( '%s Cached Pages', 'wp-super-cache' ), $cache_stats[ 'wpcache' ][ 'cached' ] ) . "</li>"; |
|
2297 echo "<li>" . sprintf( __( '%s Expired Pages', 'wp-super-cache' ), $cache_stats[ 'wpcache' ][ 'expired' ] ) . "</li></ul>"; |
|
2298 $divisor = $cache_compression == 1 ? 2 : 1; |
|
2299 if ( array_key_exists('fsize', (array)$cache_stats[ 'supercache' ]) ) |
|
2300 $fsize = $cache_stats[ 'supercache' ][ 'fsize' ] / 1024; |
|
2301 else |
|
2302 $fsize = 0; |
1450 if( $fsize > 1024 ) { |
2303 if( $fsize > 1024 ) { |
1451 $fsize = number_format( $fsize / 1024, 2 ) . "MB"; |
2304 $fsize = number_format( $fsize / 1024, 2 ) . "MB"; |
1452 } elseif( $fsize != 0 ) { |
2305 } elseif( $fsize != 0 ) { |
1453 $fsize = number_format( $fsize, 2 ) . "KB"; |
2306 $fsize = number_format( $fsize, 2 ) . "KB"; |
1454 } else { |
2307 } else { |
1455 $fsize = "0KB"; |
2308 $fsize = "0KB"; |
1456 } |
2309 } |
1457 $divisor = $cache_compression == 1 ? 2 : 1; |
|
1458 echo "<p><strong>" . __( 'WP-Super-Cache', 'wp-super-cache' ) . " ({$fsize})</strong></p>"; |
2310 echo "<p><strong>" . __( 'WP-Super-Cache', 'wp-super-cache' ) . " ({$fsize})</strong></p>"; |
1459 echo "<ul><li>" . sprintf( __( '%s Cached Pages', 'wp-super-cache' ), intval( $sizes[ 'cached' ] / $divisor ) ) . "</li>"; |
2311 echo "<ul><li>" . sprintf( __( '%s Cached Pages', 'wp-super-cache' ), intval( $cache_stats[ 'supercache' ][ 'cached' ] / $divisor ) ) . "</li>"; |
1460 $age = intval(($now - $sizes['ts'])/60); |
2312 if (isset($now) && isset($sizes)) |
1461 echo "<li>" . sprintf( __( '%s Expired Pages', 'wp-super-cache' ), intval( $sizes[ 'expired' ] / $divisor ) ) . "</li></ul>"; |
2313 $age = intval(($now - $sizes['ts'])/60); |
1462 } |
2314 else |
1463 if ( $valid_nonce && $_GET[ 'listfiles' ] ) { |
2315 $age = 0; |
1464 echo "<div style='padding: 10px; border: 1px solid #333; height: 400px; width: 70%; overflow: auto'>"; |
2316 echo "<li>" . sprintf( __( '%s Expired Pages', 'wp-super-cache' ), intval( $cache_stats[ 'supercache' ][ 'expired' ] / $divisor ) ) . "</li></ul>"; |
1465 if ( is_array( $cached_list ) && !empty( $cached_list ) ) { |
2317 if ( $valid_nonce && array_key_exists('listfiles', $_GET) && $_GET[ 'listfiles' ] ) { |
1466 echo "<h4>" . __( 'Fresh WP-Cached Files', 'wp-super-cache' ) . "</h4>"; |
2318 echo "<div style='padding: 10px; border: 1px solid #333; height: 400px; width: 90%; overflow: auto'>"; |
1467 echo "<table class='widefat'><tr><th>#</th><th>" . __( 'URI', 'wp-super-cache' ) . "</th><th>" . __( 'Key', 'wp-super-cache' ) . "</th><th>" . __( 'Age', 'wp-super-cache' ) . "</th><th>" . __( 'Delete', 'wp-super-cache' ) . "</th></tr>"; |
2319 if ( is_array( $cached_list ) && !empty( $cached_list ) ) { |
1468 $c = 1; |
2320 echo "<h4>" . __( 'Fresh WP-Cached Files', 'wp-super-cache' ) . "</h4>"; |
1469 $flip = 1; |
2321 echo "<table class='widefat'><tr><th>#</th><th>" . __( 'URI', 'wp-super-cache' ) . "</th><th>" . __( 'Key', 'wp-super-cache' ) . "</th><th>" . __( 'Age', 'wp-super-cache' ) . "</th><th>" . __( 'Delete', 'wp-super-cache' ) . "</th></tr>"; |
1470 ksort( $cached_list ); |
2322 $c = 1; |
1471 foreach( $cached_list as $age => $d ) { |
2323 $flip = 1; |
1472 foreach( $d as $details ) { |
2324 ksort( $cached_list ); |
1473 $bg = $flip ? 'style="background: #EAEAEA;"' : ''; |
2325 foreach( $cached_list as $age => $d ) { |
1474 echo "<tr $bg><td>$c</td><td> <a href='http://{$details[ 'uri' ]}'>" . $details[ 'uri' ] . "</a></td><td> " . str_replace( $details[ 'uri' ], '', $details[ 'key' ] ) . "</td><td> {$age}</td><td><a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'action' => 'deletewpcache', 'uri' => base64_encode( $details[ 'uri' ] ) ) ), 'wp-cache' ) . "#listfiles'>X</a></td></tr>\n"; |
2326 foreach( $d as $details ) { |
1475 $flip = !$flip; |
2327 $bg = $flip ? 'style="background: #EAEAEA;"' : ''; |
1476 $c++; |
2328 echo "<tr $bg><td>$c</td><td> <a href='http://{$details[ 'uri' ]}'>" . $details[ 'uri' ] . "</a></td><td> " . str_replace( $details[ 'uri' ], '', $details[ 'key' ] ) . "</td><td> {$age}</td><td><a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'action' => 'deletewpcache', 'uri' => base64_encode( $details[ 'uri' ] ) ) ), 'wp-cache' ) . "#listfiles'>X</a></td></tr>\n"; |
|
2329 $flip = !$flip; |
|
2330 $c++; |
|
2331 } |
1477 } |
2332 } |
1478 } |
2333 echo "</table>"; |
1479 echo "</table>"; |
2334 } |
1480 } |
2335 if ( is_array( $expired_list ) && !empty( $expired_list ) ) { |
1481 if ( is_array( $expired_list ) && !empty( $expired_list ) ) { |
2336 echo "<h4>" . __( 'Stale WP-Cached Files', 'wp-super-cache' ) . "</h4>"; |
1482 echo "<h4>" . __( 'Stale WP-Cached Files', 'wp-super-cache' ) . "</h4>"; |
2337 echo "<table class='widefat'><tr><th>#</th><th>" . __( 'URI', 'wp-super-cache' ) . "</th><th>" . __( 'Key', 'wp-super-cache' ) . "</th><th>" . __( 'Age', 'wp-super-cache' ) . "</th><th>" . __( 'Delete', 'wp-super-cache' ) . "</th></tr>"; |
1483 echo "<table class='widefat'><tr><th>#</th><th>" . __( 'URI', 'wp-super-cache' ) . "</th><th>" . __( 'Key', 'wp-super-cache' ) . "</th><th>" . __( 'Age', 'wp-super-cache' ) . "</th><th>" . __( 'Delete', 'wp-super-cache' ) . "</th></tr>"; |
2338 $c = 1; |
1484 $c = 1; |
2339 $flip = 1; |
1485 $flip = 1; |
2340 ksort( $expired_list ); |
1486 ksort( $expired_list ); |
2341 foreach( $expired_list as $age => $d ) { |
1487 foreach( $expired_list as $age => $d ) { |
2342 foreach( $d as $details ) { |
1488 foreach( $d as $details ) { |
2343 $bg = $flip ? 'style="background: #EAEAEA;"' : ''; |
1489 $bg = $flip ? 'style="background: #EAEAEA;"' : ''; |
2344 echo "<tr $bg><td>$c</td><td> <a href='http://{$details[ 'uri' ]}'>" . $details[ 'uri' ] . "</a></td><td> " . str_replace( $details[ 'uri' ], '', $details[ 'key' ] ) . "</td><td> {$age}</td><td><a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'action' => 'deletewpcache', 'uri' => base64_encode( $details[ 'uri' ] ) ) ), 'wp-cache' ) . "#listfiles'>X</a></td></tr>\n"; |
1490 echo "<tr $bg><td>$c</td><td> <a href='http://{$details[ 'uri' ]}'>" . $details[ 'uri' ] . "</a></td><td> " . str_replace( $details[ 'uri' ], '', $details[ 'key' ] ) . "</td><td> {$age}</td><td><a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'action' => 'deletewpcache', 'uri' => base64_encode( $details[ 'uri' ] ) ) ), 'wp-cache' ) . "#listfiles'>X</a></td></tr>\n"; |
2345 $flip = !$flip; |
1491 $flip = !$flip; |
2346 $c++; |
1492 $c++; |
2347 } |
1493 } |
2348 } |
1494 } |
2349 echo "</table>"; |
1495 echo "</table>"; |
2350 } |
1496 } |
2351 if ( is_array( $sizes[ 'cached_list' ] ) & !empty( $sizes[ 'cached_list' ] ) ) { |
1497 if ( is_array( $sizes[ 'cached_list' ] ) & !empty( $sizes[ 'cached_list' ] ) ) { |
2352 echo "<h4>" . __( 'Fresh Super Cached Files', 'wp-super-cache' ) . "</h4>"; |
1498 echo "<h4>" . __( 'Fresh Super Cached Files', 'wp-super-cache' ) . "</h4>"; |
2353 echo "<table class='widefat'><tr><th>#</th><th>" . __( 'URI', 'wp-super-cache' ) . "</th><th>" . __( 'Age', 'wp-super-cache' ) . "</th><th>" . __( 'Delete', 'wp-super-cache' ) . "</th></tr>"; |
1499 echo "<table class='widefat'><tr><th>#</th><th>" . __( 'URI', 'wp-super-cache' ) . "</th><th>" . __( 'Age', 'wp-super-cache' ) . "</th><th>" . __( 'Delete', 'wp-super-cache' ) . "</th></tr>"; |
2354 $c = 1; |
1500 $c = 1; |
2355 $flip = 1; |
1501 $flip = 1; |
2356 ksort( $sizes[ 'cached_list' ] ); |
1502 ksort( $sizes[ 'cached_list' ] ); |
2357 foreach( $sizes[ 'cached_list' ] as $age => $d ) { |
1503 foreach( $sizes[ 'cached_list' ] as $age => $d ) { |
2358 foreach( $d as $uri => $n ) { |
1504 foreach( $d as $uri => $n ) { |
2359 $bg = $flip ? 'style="background: #EAEAEA;"' : ''; |
1505 $bg = $flip ? 'style="background: #EAEAEA;"' : ''; |
2360 echo "<tr $bg><td>$c</td><td> <a href='http://{$uri}'>" . $uri . "</a></td><td>$age</td><td><a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'action' => 'deletesupercache', 'uri' => base64_encode( $uri ) ) ), 'wp-cache' ) . "#listfiles'>X</a></td></tr>\n"; |
1506 echo "<tr $bg><td>$c</td><td> <a href='http://{$uri}'>" . $uri . "</a></td><td>$age</td><td><a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'action' => 'deletesupercache', 'uri' => base64_encode( $uri ) ) ), 'wp-cache' ) . "#listfiles'>X</a></td></tr>\n"; |
2361 $flip = !$flip; |
1507 $flip = !$flip; |
2362 $c++; |
1508 $c++; |
2363 } |
1509 } |
2364 } |
1510 } |
2365 echo "</table>"; |
1511 echo "</table>"; |
2366 } |
1512 } |
2367 if ( is_array( $sizes[ 'expired_list' ] ) && !empty( $sizes[ 'expired_list' ] ) ) { |
1513 if ( is_array( $sizes[ 'expired_list' ] ) && !empty( $sizes[ 'expired_list' ] ) ) { |
2368 echo "<h4>" . __( 'Stale Super Cached Files', 'wp-super-cache' ) . "</h4>"; |
1514 echo "<h4>" . __( 'Stale Super Cached Files', 'wp-super-cache' ) . "</h4>"; |
2369 echo "<table class='widefat'><tr><th>#</th><th>" . __( 'URI', 'wp-super-cache' ) . "</th><th>" . __( 'Age', 'wp-super-cache' ) . "</th><th>" . __( 'Delete', 'wp-super-cache' ) . "</th></tr>"; |
1515 echo "<table class='widefat'><tr><th>#</th><th>" . __( 'URI', 'wp-super-cache' ) . "</th><th>" . __( 'Age', 'wp-super-cache' ) . "</th><th>" . __( 'Delete', 'wp-super-cache' ) . "</th></tr>"; |
2370 $c = 1; |
1516 $c = 1; |
2371 $flip = 1; |
1517 $flip = 1; |
2372 ksort( $sizes[ 'expired_list' ] ); |
1518 ksort( $sizes[ 'expired_list' ] ); |
2373 foreach( $sizes[ 'expired_list' ] as $age => $d ) { |
1519 foreach( $sizes[ 'expired_list' ] as $age => $d ) { |
2374 foreach( $d as $uri => $n ) { |
1520 foreach( $d as $uri => $n ) { |
2375 $bg = $flip ? 'style="background: #EAEAEA;"' : ''; |
1521 $bg = $flip ? 'style="background: #EAEAEA;"' : ''; |
2376 echo "<tr $bg><td>$c</td><td> <a href='http://{$uri}'>" . $uri . "</a></td><td>$age</td><td><a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'action' => 'deletesupercache', 'uri' => base64_encode( $uri ) ) ), 'wp-cache' ) . "#listfiles'>X</a></td></tr>\n"; |
1522 echo "<tr $bg><td>$c</td><td> <a href='http://{$uri}'>" . $uri . "</a></td><td>$age</td><td><a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'action' => 'deletesupercache', 'uri' => base64_encode( $uri ) ) ), 'wp-cache' ) . "#listfiles'>X</a></td></tr>\n"; |
2377 $flip = !$flip; |
1523 $flip = !$flip; |
2378 $c++; |
1524 $c++; |
2379 } |
1525 } |
2380 } |
1526 } |
2381 echo "</table>"; |
1527 echo "</table>"; |
2382 } |
1528 } |
2383 echo "</div>"; |
1529 echo "</div>"; |
2384 echo "<p><a href='?page=wpsupercache&tab=contents#top'>" . __( 'Hide file list', 'wp-super-cache' ) . "</a></p>"; |
1530 echo "<p><a href='?page=wpsupercache#top'>" . __( 'Hide file list', 'wp-super-cache' ) . "</a></p>"; |
2385 } elseif ( $cache_stats[ 'supercache' ][ 'cached' ] > 500 || $cache_stats[ 'supercache' ][ 'expired' ] > 500 || ( $cache_stats[ 'wpcache' ][ 'cached' ] / $divisor ) > 500 || ( $cache_stats[ 'wpcache' ][ 'expired' ] / $divisor) > 500 ) { |
1531 } else { |
2386 echo "<p><em>" . __( 'Too many cached files, no listing possible.', 'wp-super-cache' ) . "</em></p>"; |
1532 echo "<p><a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'listfiles' => '1' ) ), 'wp-cache' ) . "#listfiles'>" . __( 'List all cached files', 'wp-super-cache' ) . "</a></p>"; |
2387 } else { |
1533 } |
2388 echo "<p><a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'listfiles' => '1' ) ), 'wp-cache' ) . "#listfiles'>" . __( 'List all cached files', 'wp-super-cache' ) . "</a></p>"; |
1534 $last_gc = get_option( "wpsupercache_gc_time" ); |
2389 } |
1535 if( $last_gc ) { |
2390 if ( $cache_max_time > 0 ) |
1536 $next_gc = $cache_max_time < 1800 ? $cache_max_time : 600; |
2391 echo "<p>" . sprintf( __( 'Expired files are files older than %s seconds. They are still used by the plugin and are deleted periodically.', 'wp-super-cache' ), $cache_max_time ) . "</p>"; |
1537 $next_gc_mins = ( time() - $last_gc ); |
2392 } // cache_stats |
1538 echo "<p>" . sprintf( __( '<strong>Garbage Collection</strong><br />Last GC was <strong>%s</strong> minutes ago<br />', 'wp-super-cache' ), date( 'i:s', $next_gc_mins ) ); |
2393 wp_cache_delete_buttons(); |
1539 printf( __( "Next GC in <strong>%s</strong> minutes", 'wp-super-cache' ), date( 'i:s', $next_gc - $next_gc_mins ) ) . "</p>"; |
2394 |
1540 } |
2395 echo '</fieldset>'; |
1541 |
2396 } |
1542 echo "<p>" . sprintf( __( 'Expired files are files older than %s seconds. They are still used by the plugin and are deleted periodically.', 'wp-super-cache' ), $cache_max_time ) . "</p>"; |
2397 |
|
2398 function wp_cache_delete_buttons() { |
|
2399 |
1543 echo '<form name="wp_cache_content_expired" action="#listfiles" method="post">'; |
2400 echo '<form name="wp_cache_content_expired" action="#listfiles" method="post">'; |
1544 echo '<input type="hidden" name="wp_delete_expired" />'; |
2401 echo '<input type="hidden" name="wp_delete_expired" />'; |
1545 echo '<div class="submit" style="float:left"><input type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Expired', 'wp-super-cache' ) . ' »" /></div>'; |
2402 echo '<div class="submit" style="float:left"><input type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Expired', 'wp-super-cache' ) . ' »" /></div>'; |
1546 wp_nonce_field('wp-cache'); |
2403 wp_nonce_field('wp-cache'); |
1547 echo "</form>\n"; |
2404 echo "</form>\n"; |
1787 wp_schedule_single_event( time() + 360 , 'wp_cache_check_site_hook' ); |
2667 wp_schedule_single_event( time() + 360 , 'wp_cache_check_site_hook' ); |
1788 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'scheduled wp_cache_check_site_hook for 360 seconds time.', 2 ); |
2668 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'scheduled wp_cache_check_site_hook for 360 seconds time.', 2 ); |
1789 } |
2669 } |
1790 } |
2670 } |
1791 add_action( 'wp_cache_check_site_hook', 'wp_cache_check_site' ); |
2671 add_action( 'wp_cache_check_site_hook', 'wp_cache_check_site' ); |
|
2672 |
|
2673 function update_cached_mobile_ua_list( $mobile_browsers, $mobile_prefixes = 0, $mobile_groups = 0 ) { |
|
2674 global $wp_cache_config_file, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $wp_cache_mobile_groups; |
|
2675 if ( is_array( $mobile_browsers ) ) { |
|
2676 $wp_cache_mobile_browsers = $mobile_browsers; |
|
2677 wp_cache_replace_line('^ *\$wp_cache_mobile_browsers', "\$wp_cache_mobile_browsers = '" . implode( ', ', $mobile_browsers ) . "';", $wp_cache_config_file); |
|
2678 } |
|
2679 if ( is_array( $mobile_prefixes ) ) { |
|
2680 $wp_cache_mobile_prefixes = $mobile_prefixes; |
|
2681 wp_cache_replace_line('^ *\$wp_cache_mobile_prefixes', "\$wp_cache_mobile_prefixes = '" . implode( ', ', $mobile_prefixes ) . "';", $wp_cache_config_file); |
|
2682 } |
|
2683 if ( is_array( $mobile_groups ) ) { |
|
2684 $wp_cache_mobile_groups = $mobile_groups; |
|
2685 wp_cache_replace_line('^ *\$wp_cache_mobile_groups', "\$wp_cache_mobile_groups = '" . implode( ', ', $mobile_groups ) . "';", $wp_cache_config_file); |
|
2686 } |
|
2687 |
|
2688 return true; |
|
2689 } |
|
2690 |
|
2691 function wpsc_update_htaccess() { |
|
2692 extract( wpsc_get_htaccess_info() ); |
|
2693 wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top |
|
2694 if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) { |
|
2695 return true; |
|
2696 } else { |
|
2697 return false; |
|
2698 } |
|
2699 } |
|
2700 |
|
2701 function wpsc_update_htaccess_form( $short_form = true ) { |
|
2702 global $wpmu_version; |
|
2703 |
|
2704 extract( wpsc_get_htaccess_info() ); |
|
2705 if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) { |
|
2706 echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h4>" . __( 'Cannot update .htaccess', 'wp-super-cache' ) . "</h4><p>" . sprintf( __( 'The file <code>%s.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.', 'wp-super-cache' ), $home_path ) . "</p><p>" . __( 'Refresh this page when the file permissions have been modified.' ) . "</p><p>" . sprintf( __( 'Alternatively, you can edit your <code>%s.htaccess</code> file manually and add the following code (before any WordPress rules):', 'wp-super-cache' ), $home_path ) . "</p>"; |
|
2707 echo "<p><pre># BEGIN WPSuperCache\n" . esc_html( $rules ) . "# END WPSuperCache</pre></p></div>"; |
|
2708 } else { |
|
2709 if ( $short_form == false ) { |
|
2710 echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><p>" . sprintf( __( 'To serve static html files your server must have the correct mod_rewrite rules added to a file called <code>%s.htaccess</code>', 'wp-super-cache' ), $home_path ) . " "; |
|
2711 _e( "You can edit the file yourself add the following rules.", 'wp-super-cache' ); |
|
2712 echo __( " Make sure they appear before any existing WordPress rules. ", 'wp-super-cache' ) . "</p>"; |
|
2713 echo "<pre># BEGIN WPSuperCache\n" . esc_html( $rules ) . "# END WPSuperCache</pre></p>"; |
|
2714 echo "<p>" . sprintf( __( 'Rules must be added to %s too:', 'wp-super-cache' ), WP_CONTENT_DIR . "/cache/.htaccess" ) . "</p>"; |
|
2715 echo "<pre># BEGIN supercache\n" . esc_html( $gziprules ) . "# END supercache</pre></p>"; |
|
2716 } |
|
2717 if ( !isset( $wpmu_version ) || $wpmu_version == '' ) { |
|
2718 echo '<form name="updatehtaccess" action="#modrewrite" method="post">'; |
|
2719 echo '<input type="hidden" name="updatehtaccess" value="1" />'; |
|
2720 echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="' . __( 'Update Mod_Rewrite Rules', 'wp-super-cache' ) . ' »" /></div>'; |
|
2721 wp_nonce_field('wp-cache'); |
|
2722 echo "</form></div>\n"; |
|
2723 } |
|
2724 } |
|
2725 } |
|
2726 |
|
2727 function wpsc_get_htaccess_info() { |
|
2728 global $wp_cache_mobile_enabled, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers, $wp_cache_disable_utf8; |
|
2729 if ( isset( $_SERVER[ "PHP_DOCUMENT_ROOT" ] ) ) { |
|
2730 $document_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ]; |
|
2731 $apache_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ]; |
|
2732 } else { |
|
2733 $document_root = $_SERVER[ "DOCUMENT_ROOT" ]; |
|
2734 $apache_root = '%{DOCUMENT_ROOT}'; |
|
2735 } |
|
2736 $content_dir_root = $document_root; |
|
2737 if ( strpos( $document_root, '/kunden/' ) === 0 ) { |
|
2738 // http://wordpress.org/support/topic/plugin-wp-super-cache-how-to-get-mod_rewrite-working-on-1and1-shared-hosting?replies=1 |
|
2739 // On 1and1, PHP's directory structure starts with '/homepages'. The |
|
2740 // Apache directory structure has an extra '/kunden' before it. |
|
2741 // Also 1and1 does not support the %{DOCUMENT_ROOT} variable in |
|
2742 // .htaccess files. |
|
2743 // This prevents the $inst_root from being calculated correctly and |
|
2744 // means that the $apache_root is wrong. |
|
2745 // |
|
2746 // e.g. This is an example of how Apache and PHP see the directory |
|
2747 // structure on 1and1: |
|
2748 // Apache: /kunden/homepages/xx/dxxxxxxxx/htdocs/site1/index.html |
|
2749 // PHP: /homepages/xx/dxxxxxxxx/htdocs/site1/index.html |
|
2750 // Here we fix up the paths to make mode_rewrite work on 1and1 shared hosting. |
|
2751 $content_dir_root = substr( $content_dir_root, 7 ); |
|
2752 $apache_root = $document_root; |
|
2753 } |
|
2754 $home_path = get_home_path(); |
|
2755 $home_root = parse_url(get_bloginfo('url')); |
|
2756 $home_root = isset( $home_root['path'] ) ? trailingslashit( $home_root['path'] ) : '/'; |
|
2757 $home_root_lc = str_replace( '//', '/', strtolower( $home_root ) ); |
|
2758 $inst_root = str_replace( '//', '/', '/' . trailingslashit( str_replace( $content_dir_root, '', str_replace( '\\', '/', WP_CONTENT_DIR ) ) ) ); |
|
2759 $wprules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WordPress' ) ); |
|
2760 $wprules = str_replace( "RewriteEngine On\n", '', $wprules ); |
|
2761 $wprules = str_replace( "RewriteBase $home_root\n", '', $wprules ); |
|
2762 $scrules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WPSuperCache' ) ); |
|
2763 |
|
2764 if( substr( get_option( 'permalink_structure' ), -1 ) == '/' ) { |
|
2765 $condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*[^/]$"; |
|
2766 $condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*//.*$"; |
|
2767 } |
|
2768 $condition_rules[] = "RewriteCond %{REQUEST_METHOD} !POST"; |
|
2769 $condition_rules[] = "RewriteCond %{QUERY_STRING} !.*=.*"; |
|
2770 $condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$"; |
|
2771 $condition_rules[] = "RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\\\"]+ [NC]"; |
|
2772 $condition_rules[] = "RewriteCond %{HTTP:Profile} !^[a-z0-9\\\"]+ [NC]"; |
|
2773 if ( $wp_cache_mobile_enabled ) { |
|
2774 if ( false == empty( $wp_cache_mobile_browsers ) ) |
|
2775 $condition_rules[] = "RewriteCond %{HTTP_USER_AGENT} !^.*(" . addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) . ").* [NC]"; |
|
2776 if ( false == empty( $wp_cache_mobile_prefixes ) ) |
|
2777 $condition_rules[] = "RewriteCond %{HTTP_user_agent} !^(" . addcslashes( implode( '|', $wp_cache_mobile_prefixes ), ' ' ) . ").* [NC]"; |
|
2778 } |
|
2779 $condition_rules = apply_filters( 'supercacherewriteconditions', $condition_rules ); |
|
2780 |
|
2781 $rules = "<IfModule mod_rewrite.c>\n"; |
|
2782 $rules .= "RewriteEngine On\n"; |
|
2783 $rules .= "RewriteBase $home_root\n"; // props Chris Messina |
|
2784 $rules .= "#If you serve pages from behind a proxy you may want to change 'RewriteCond %{HTTPS} on' to something more sensible\n"; |
|
2785 if ( isset( $wp_cache_disable_utf8 ) == false || $wp_cache_disable_utf8 == 0 ) { |
|
2786 $charset = get_option('blog_charset') == '' ? 'UTF-8' : get_option('blog_charset'); |
|
2787 $rules .= "AddDefaultCharset {$charset}\n"; |
|
2788 } |
|
2789 |
|
2790 $rules .= "CONDITION_RULES"; |
|
2791 $rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n"; |
|
2792 $rules .= "RewriteCond %{HTTPS} on\n"; |
|
2793 $rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index-https.html.gz -f\n"; |
|
2794 $rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index-https.html.gz\" [L]\n\n"; |
|
2795 |
|
2796 $rules .= "CONDITION_RULES"; |
|
2797 $rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n"; |
|
2798 $rules .= "RewriteCond %{HTTPS} !on\n"; |
|
2799 $rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index.html.gz -f\n"; |
|
2800 $rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index.html.gz\" [L]\n\n"; |
|
2801 |
|
2802 $rules .= "CONDITION_RULES"; |
|
2803 $rules .= "RewriteCond %{HTTPS} on\n"; |
|
2804 $rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index-https.html -f\n"; |
|
2805 $rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index-https.html\" [L]\n\n"; |
|
2806 |
|
2807 $rules .= "CONDITION_RULES"; |
|
2808 $rules .= "RewriteCond %{HTTPS} !on\n"; |
|
2809 $rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index.html -f\n"; |
|
2810 $rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index.html\" [L]\n"; |
|
2811 $rules .= "</IfModule>\n"; |
|
2812 $rules = apply_filters( 'supercacherewriterules', $rules ); |
|
2813 |
|
2814 $rules = str_replace( "CONDITION_RULES", implode( "\n", $condition_rules ) . "\n", $rules ); |
|
2815 |
|
2816 $gziprules = "<IfModule mod_mime.c>\n <FilesMatch \"\\.html\\.gz\$\">\n ForceType text/html\n FileETag None\n </FilesMatch>\n AddEncoding gzip .gz\n AddType text/html .gz\n</IfModule>\n"; |
|
2817 $gziprules .= "<IfModule mod_deflate.c>\n SetEnvIfNoCase Request_URI \.gz$ no-gzip\n</IfModule>\n"; |
|
2818 $gziprules .= "<IfModule mod_headers.c>\n Header set Vary \"Accept-Encoding, Cookie\"\n Header set Cache-Control 'max-age=3, must-revalidate'\n</IfModule>\n"; |
|
2819 $gziprules .= "<IfModule mod_expires.c>\n ExpiresActive On\n ExpiresByType text/html A3\n</IfModule>\n"; |
|
2820 return array( "document_root" => $document_root, "apache_root" => $apache_root, "home_path" => $home_path, "home_root" => $home_root, "home_root_lc" => $home_root_lc, "inst_root" => $inst_root, "wprules" => $wprules, "scrules" => $scrules, "condition_rules" => $condition_rules, "rules" => $rules, "gziprules" => $gziprules ); |
|
2821 } |
|
2822 |
|
2823 function clear_post_supercache( $post_id ) { |
|
2824 $dir = get_current_url_supercache_dir( $post_id ); |
|
2825 if ( false == @is_dir( $dir ) ) |
|
2826 return false; |
|
2827 |
|
2828 if ( !function_exists( 'prune_super_cache' ) ) |
|
2829 include_once( 'wp-cache-phase2.php' ); |
|
2830 |
|
2831 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "clear_post_supercache: deleting $dir/index*.html files", 2 ); |
|
2832 $files_to_check = get_all_supercache_filenames( $dir ); |
|
2833 foreach( $files_to_check as $cache_file ) { |
|
2834 prune_super_cache( $dir . $cache_file, true ); |
|
2835 } |
|
2836 } |
|
2837 |
|
2838 function wp_cron_preload_cache() { |
|
2839 global $wpdb, $wp_cache_preload_interval, $wp_cache_preload_posts, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $cache_path, $wp_cache_preload_taxonomies; |
|
2840 global $WPSC_HTTP_HOST; |
|
2841 |
|
2842 if ( get_option( 'preload_cache_stop' ) ) { |
|
2843 delete_option( 'preload_cache_stop' ); |
|
2844 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: preload cancelled", 1 ); |
|
2845 return true; |
|
2846 } |
|
2847 $mutex = $cache_path . "preload_mutex.tmp"; |
|
2848 sleep( 3 + mt_rand( 1, 5 ) ); |
|
2849 if ( @file_exists( $mutex ) ) { |
|
2850 if ( @filemtime( $mutex ) > ( time() - 600 ) ) { |
|
2851 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: preload mutex found and less than 600 seconds old. Aborting preload.", 1 ); |
|
2852 return true; |
|
2853 } else { |
|
2854 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: old preload mutex found and deleted. Preload continues.", 1 ); |
|
2855 @unlink( $mutex ); |
|
2856 } |
|
2857 } |
|
2858 $fp = @fopen( $mutex, 'w' ); |
|
2859 @fclose( $fp ); |
|
2860 |
|
2861 $counter = get_option( 'preload_cache_counter' ); |
|
2862 if ( is_array( $counter ) == false ) { |
|
2863 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: setting up preload for the first time!", 5 ); |
|
2864 $counter = array( 'c' => 0, 't' => time() ); |
|
2865 update_option( 'preload_cache_counter', $counter ); |
|
2866 } |
|
2867 $c = $counter[ 'c' ]; |
|
2868 |
|
2869 update_option( 'preload_cache_counter', array( 'c' => ( $c + 100 ), 't' => time() ) ); |
|
2870 |
|
2871 if ( $wp_cache_preload_email_me && $c == 0 ) |
|
2872 wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] Cache Preload Started', 'wp-super-cache' ), site_url(), '' ), ' ' ); |
|
2873 |
|
2874 if ( $wp_cache_preload_posts == 'all' || $c < $wp_cache_preload_posts ) { |
|
2875 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: doing taxonomy preload.", 5 ); |
|
2876 $permalink_counter_msg = $cache_path . "preload_permalink.txt"; |
|
2877 if ( isset( $wp_cache_preload_taxonomies ) && $wp_cache_preload_taxonomies ) { |
|
2878 $taxonomies = apply_filters( 'wp_cache_preload_taxonomies', array( 'post_tag' => 'tag', 'category' => 'category' ) ); |
|
2879 foreach( $taxonomies as $taxonomy => $path ) { |
|
2880 $taxonomy_filename = $cache_path . "taxonomy_" . $taxonomy . ".txt"; |
|
2881 if ( $c == 0 ) |
|
2882 @unlink( $taxonomy_filename ); |
|
2883 |
|
2884 if ( false == @file_exists( $taxonomy_filename ) ) { |
|
2885 $out = ''; |
|
2886 $records = get_terms( $taxonomy ); |
|
2887 foreach( $records as $term ) { |
|
2888 $out .= get_term_link( $term ). "\n"; |
|
2889 } |
|
2890 $fp = fopen( $taxonomy_filename, 'w' ); |
|
2891 if ( $fp ) { |
|
2892 fwrite( $fp, $out ); |
|
2893 fclose( $fp ); |
|
2894 } |
|
2895 $details = explode( "\n", $out ); |
|
2896 } else { |
|
2897 $details = explode( "\n", file_get_contents( $taxonomy_filename ) ); |
|
2898 } |
|
2899 if ( count( $details ) != 1 && $details[ 0 ] != '' ) { |
|
2900 $rows = array_splice( $details, 0, 50 ); |
|
2901 if ( $wp_cache_preload_email_me && $wp_cache_preload_email_volume == 'many' ) |
|
2902 wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] Refreshing %2$s taxonomy from %3$d to %4$d', 'wp-super-cache' ), site_url(), $taxonomy, $c, ($c+100) ), 'Refreshing: ' . print_r( $rows, 1 ) ); |
|
2903 foreach( (array)$rows as $url ) { |
|
2904 set_time_limit( 60 ); |
|
2905 if ( $url == '' ) |
|
2906 continue; |
|
2907 $url_info = parse_url( $url ); |
|
2908 $dir = get_supercache_dir() . $url_info[ 'path' ]; |
|
2909 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: delete $dir", 5 ); |
|
2910 prune_super_cache( $dir ); |
|
2911 $fp = @fopen( $permalink_counter_msg, 'w' ); |
|
2912 if ( $fp ) { |
|
2913 @fwrite( $fp, "$taxonomy: $url" ); |
|
2914 @fclose( $fp ); |
|
2915 } |
|
2916 wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) ); |
|
2917 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: fetched $url", 5 ); |
|
2918 sleep( 1 ); |
|
2919 } |
|
2920 $fp = fopen( $taxonomy_filename, 'w' ); |
|
2921 if ( $fp ) { |
|
2922 fwrite( $fp, implode( "\n", $details ) ); |
|
2923 fclose( $fp ); |
|
2924 } |
|
2925 } |
|
2926 } |
|
2927 } |
|
2928 } |
|
2929 |
|
2930 if ( $wp_cache_preload_posts == 'all' || $c < $wp_cache_preload_posts ) { |
|
2931 $posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE ( post_type != 'revision' AND post_type != 'nav_menu_item' ) AND post_status = 'publish' ORDER BY ID ASC LIMIT $c, 100" ); |
|
2932 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: got 100 posts from position $c.", 5 ); |
|
2933 } else { |
|
2934 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: no more posts to get. Limit ($wp_cache_preload_posts) reached.", 5 ); |
|
2935 $posts = false; |
|
2936 } |
|
2937 if ( !isset( $wp_cache_preload_email_volume ) ) |
|
2938 $wp_cache_preload_email_volume = 'medium'; |
|
2939 |
|
2940 if ( $posts ) { |
|
2941 if ( get_option( 'show_on_front' ) == 'page' ) { |
|
2942 $page_on_front = get_option( 'page_on_front' ); |
|
2943 $page_for_posts = get_option( 'page_for_posts' ); |
|
2944 } else { |
|
2945 $page_on_front = $page_for_posts = 0; |
|
2946 } |
|
2947 if ( $wp_cache_preload_email_me && $wp_cache_preload_email_volume == 'many' ) |
|
2948 wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] Refreshing posts from %2$d to %3$d', 'wp-super-cache' ), site_url(), $c, ($c+100) ), ' ' ); |
|
2949 $msg = ''; |
|
2950 $count = $c + 1; |
|
2951 $permalink_counter_msg = $cache_path . "preload_permalink.txt"; |
|
2952 foreach( $posts as $post_id ) { |
|
2953 set_time_limit( 60 ); |
|
2954 if ( $page_on_front != 0 && ( $post_id == $page_on_front || $post_id == $page_for_posts ) ) |
|
2955 continue; |
|
2956 clear_post_supercache( $post_id ); |
|
2957 $url = get_permalink( $post_id ); |
|
2958 $fp = @fopen( $permalink_counter_msg, 'w' ); |
|
2959 if ( $fp ) { |
|
2960 @fwrite( $fp, $count . " " . $url ); |
|
2961 @fclose( $fp ); |
|
2962 } |
|
2963 if ( @file_exists( $cache_path . "stop_preload.txt" ) ) { |
|
2964 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: cancelling preload. stop_preload.txt found.", 5 ); |
|
2965 @unlink( $mutex ); |
|
2966 @unlink( $cache_path . "stop_preload.txt" ); |
|
2967 update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); |
|
2968 if ( $wp_cache_preload_email_me ) |
|
2969 wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] Cache Preload Stopped', 'wp-super-cache' ), site_url(), '' ), ' ' ); |
|
2970 return true; |
|
2971 } |
|
2972 $msg .= "$url\n"; |
|
2973 wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) ); |
|
2974 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: fetched $url", 5 ); |
|
2975 sleep( 1 ); |
|
2976 $count++; |
|
2977 } |
|
2978 if ( $wp_cache_preload_email_me && $wp_cache_preload_email_volume != 'less' ) |
|
2979 wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] %2$d posts refreshed', 'wp-super-cache' ), $WPSC_HTTP_HOST, ($c+100) ), __( "Refreshed the following posts:", 'wp-super-cache' ) . "\n$msg" ); |
|
2980 if ( defined( 'DOING_CRON' ) ) { |
|
2981 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: scheduling the next preload in 30 seconds.", 5 ); |
|
2982 wp_schedule_single_event( time() + 30, 'wp_cache_preload_hook' ); |
|
2983 } |
|
2984 } else { |
|
2985 $msg = ''; |
|
2986 update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); |
|
2987 if ( (int)$wp_cache_preload_interval && defined( 'DOING_CRON' ) ) { |
|
2988 if ( $wp_cache_preload_email_me ) |
|
2989 $msg = sprintf( __( 'Scheduling next preload refresh in %d minutes.', 'wp-super-cache' ), (int)$wp_cache_preload_interval ); |
|
2990 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: no more posts. scheduling next preload in $wp_cache_preload_interval minutes.", 5 ); |
|
2991 wp_schedule_single_event( time() + ( (int)$wp_cache_preload_interval * 60 ), 'wp_cache_full_preload_hook' ); |
|
2992 } |
|
2993 global $file_prefix, $cache_max_time; |
|
2994 if ( $wp_cache_preload_interval > 0 ) { |
|
2995 $cache_max_time = (int)$wp_cache_preload_interval * 60; // fool the GC into expiring really old files |
|
2996 } else { |
|
2997 $cache_max_time = 86400; // fool the GC into expiring really old files |
|
2998 } |
|
2999 if ( $wp_cache_preload_email_me ) |
|
3000 wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Cache Preload Completed', 'wp-super-cache' ), site_url() ), __( "Cleaning up old supercache files.", 'wp-super-cache' ) . "\n" . $msg ); |
|
3001 if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: clean expired cache files older than $cache_max_time seconds.", 5 ); |
|
3002 wp_cache_phase2_clean_expired( $file_prefix, true ); // force cleanup of old files. |
|
3003 } |
|
3004 @unlink( $mutex ); |
|
3005 } |
|
3006 add_action( 'wp_cache_preload_hook', 'wp_cron_preload_cache' ); |
|
3007 add_action( 'wp_cache_full_preload_hook', 'wp_cron_preload_cache' ); |
|
3008 |
|
3009 function next_preload_message( $hook, $text, $limit = 0 ) { |
|
3010 global $currently_preloading, $wp_cache_preload_interval; |
|
3011 if ( $next_preload = wp_next_scheduled( $hook ) ) { |
|
3012 $next_time = $next_preload - time(); |
|
3013 if ( $limit != 0 && $next_time > $limit ) |
|
3014 return false; |
|
3015 $h = $m = $s = 0; |
|
3016 if ( $next_time > 0 ) { |
|
3017 // http://bytes.com/topic/php/answers/3917-seconds-converted-hh-mm-ss |
|
3018 $m = (int)($next_time / 60); |
|
3019 $s = $next_time % 60; |
|
3020 $h = (int)($m / 60); $m = $m % 60; |
|
3021 } |
|
3022 if ( $next_time > 0 && $next_time < ( 60 * $wp_cache_preload_interval ) ) |
|
3023 echo '<p><strong>' . sprintf( $text, $h, $m, $s ) . '</strong></p>'; |
|
3024 if ( ( $next_preload - time() ) <= 60 ) |
|
3025 $currently_preloading = true; |
|
3026 } |
|
3027 } |
|
3028 |
|
3029 function option_preload_cache_counter( $value ) { |
|
3030 if ( false == is_array( $value ) ) { |
|
3031 $ret = array( 'c' => $value, 't' => time(), 'first' => 1 ); |
|
3032 return $ret; |
|
3033 } |
|
3034 |
|
3035 return $value; |
|
3036 } |
|
3037 add_filter( 'option_preload_cache_counter', 'option_preload_cache_counter' ); |
|
3038 |
|
3039 function check_up_on_preloading() { |
|
3040 $value = get_option( 'preload_cache_counter' ); |
|
3041 if ( $value[ 'c' ] > 0 && ( time() - $value[ 't' ] ) > 3600 && false == wp_next_scheduled( 'wp_cache_preload_hook' ) ) { |
|
3042 if ( is_admin() ) |
|
3043 wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Preload may have stalled.', 'wp-super-cache' ), get_bloginfo( 'url' ) ), sprintf( __( "Preload has been restarted.\n%s", 'wp-super-cache' ), admin_url( "options-general.php?page=wpsupercache" ) ) ); |
|
3044 wp_schedule_single_event( time() + 30, 'wp_cache_preload_hook' ); |
|
3045 } |
|
3046 } |
|
3047 add_action( 'init', 'check_up_on_preloading' ); // sometimes preloading stops working. Kickstart it. |
|
3048 |
|
3049 function wp_cache_disable_plugin() { |
|
3050 global $wp_cache_config_file, $wp_rewrite; |
|
3051 if ( file_exists( ABSPATH . 'wp-config.php') ) { |
|
3052 $global_config_file = ABSPATH . 'wp-config.php'; |
|
3053 } else { |
|
3054 $global_config_file = dirname(ABSPATH) . '/wp-config.php'; |
|
3055 } |
|
3056 $line = 'define(\'WP_CACHE\', true);'; |
|
3057 if ( strpos( file_get_contents( $global_config_file ), $line ) && ( !is_writeable_ACLSafe( $global_config_file ) || !wp_cache_replace_line( 'define *\( *\'WP_CACHE\'', '//' . $line, $global_config_file ) ) ) |
|
3058 wp_die( "Could not remove WP_CACHE define from $global_config_file. Please edit that file and remove the line containing the text 'WP_CACHE'. Then refresh this page." ); |
|
3059 |
|
3060 uninstall_supercache( WP_CONTENT_DIR . '/cache' ); |
|
3061 $file_not_deleted = false; |
|
3062 if ( @file_exists( WP_CONTENT_DIR . "/advanced-cache.php" ) ) { |
|
3063 if ( false == @unlink( WP_CONTENT_DIR . "/advanced-cache.php" ) ) |
|
3064 $file_not_deleted[] = 'advanced-cache.php'; |
|
3065 } |
|
3066 if ( @file_exists( WP_CONTENT_DIR . "/wp-cache-config.php" ) ) { |
|
3067 if ( false == unlink( WP_CONTENT_DIR . "/wp-cache-config.php" ) ) |
|
3068 $file_not_deleted[] = 'wp-cache-config.php'; |
|
3069 } |
|
3070 if ( $file_not_deleted ) { |
|
3071 $msg = "<p>One or more files could not be deleted. These files and directories must be made writeable:</p>\n <ol><li>" . WP_CONTENT_DIR . "</li>\n"; |
|
3072 $code = "<ul>\n"; |
|
3073 foreach( (array)$file_not_deleted as $filename ) { |
|
3074 $msg .= "<li>" . WP_CONTENT_DIR . "/{$filename}</li>"; |
|
3075 $code .= "<li><code>chmod 666 " . WP_CONTENT_DIR . "/{$filename}</code></li>\n"; |
|
3076 } |
|
3077 $code .= "</ul>\n"; |
|
3078 |
|
3079 $msg .= "</ol>\n<p>First try fixing the directory permissions with this command and refresh this page:<br /><br /><code>chmod 777 " . WP_CONTENT_DIR . "</code><br /><br />If you still see this error, you have to fix the permissions on the files themselves and refresh this page again:</p> {$code}\n<p>Don't forgot to fix things later:<br /><code>chmod 755 " . WP_CONTENT_DIR . "</code></p><p>If you don't know what <strong>chmod</strong> is use <a href='http://www.google.ie/search?hl=en&q=ftp+chmod+777'>this Google search</a> to find out all about it.</p><p>Please refresh this page when the permissions have been modified.</p>"; |
|
3080 wp_die( $msg ); |
|
3081 } |
|
3082 extract( wpsc_get_htaccess_info() ); |
|
3083 if ( $scrules != '' && insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', array() ) ) { |
|
3084 $wp_rewrite->flush_rules(); |
|
3085 } elseif( $scrules != '' ) { |
|
3086 wp_mail( get_option( 'admin_email' ), __( 'Supercache Uninstall Problems', 'wp-super-cache' ), sprintf( __( "Dear User,\n\nWP Super Cache was removed from your blog but the mod_rewrite rules\nin your .htaccess were not.\n\nPlease edit the following file and remove the code\nbetween 'BEGIN WPSuperCache' and 'END WPSuperCache'. Please backup the file first!\n\n%s\n\nRegards,\nWP Super Cache Plugin\nhttp://wordpress.org/extend/plugins/wp-super-cache/", 'wp-super-cache' ), ABSPATH . '/.htaccess' ) ); |
|
3087 } |
|
3088 } |
|
3089 |
|
3090 function uninstall_supercache( $folderPath ) { // from http://www.php.net/manual/en/function.rmdir.php |
|
3091 if ( trailingslashit( constant( 'ABSPATH' ) ) == trailingslashit( $folderPath ) ) |
|
3092 return false; |
|
3093 if ( @is_dir ( $folderPath ) ) { |
|
3094 $dh = @opendir($folderPath); |
|
3095 while( false !== ( $value = @readdir( $dh ) ) ) { |
|
3096 if ( $value != "." && $value != ".." ) { |
|
3097 $value = $folderPath . "/" . $value; |
|
3098 if ( @is_dir ( $value ) ) { |
|
3099 uninstall_supercache( $value ); |
|
3100 } else { |
|
3101 @unlink( $value ); |
|
3102 } |
|
3103 } |
|
3104 } |
|
3105 return @rmdir( $folderPath ); |
|
3106 } else { |
|
3107 return false; |
|
3108 } |
|
3109 } |
|
3110 |
|
3111 function supercache_admin_bar_render() { |
|
3112 global $wp_admin_bar, $wp_cache_not_logged_in; |
|
3113 if ( !is_user_logged_in() || !$wp_cache_not_logged_in ) |
|
3114 return false; |
|
3115 |
|
3116 if ( function_exists('current_user_can') && false == current_user_can('delete_others_posts') ) |
|
3117 return false; |
|
3118 |
|
3119 $wp_admin_bar->add_menu( array( |
|
3120 'parent' => '', |
|
3121 'id' => 'delete-cache', |
|
3122 'title' => __( 'Delete Cache', 'wp-super-cache' ), |
|
3123 'meta' => array( 'title' => __( 'Delete cache of the current page', 'wp-super-cache' ) ), |
|
3124 'href' => wp_nonce_url( admin_url( 'index.php?action=delcachepage&path=' . urlencode( $_SERVER[ 'REQUEST_URI' ] ) ), 'delete-cache' ) |
|
3125 ) ); |
|
3126 } |
|
3127 add_action( 'wp_before_admin_bar_render', 'supercache_admin_bar_render' ); |
|
3128 |
1792 ?> |
3129 ?> |