PageRenderTime 63ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/blog/wp-content/plugins/wp-super-cache/wp-cache.php

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 2672 lines | 2441 code | 184 blank | 47 comment | 580 complexity | a322a5105875b120438ac8ba6f2c872d MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. Plugin Name: WP Super Cache
  4. Plugin URI: http://ocaoimh.ie/wp-super-cache/
  5. Description: Very fast caching plugin for WordPress.
  6. Version: 0.9.9.8
  7. Author: Donncha O Caoimh
  8. Author URI: http://ocaoimh.ie/
  9. */
  10. /* Copyright 2005-2006 Ricardo Galli Granada (email : gallir@uib.es)
  11. Copyright 2007-2011 Donncha O Caoimh (http://ocaoimh.ie/) and many others.
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. GNU General Public License for more details.
  20. You should have received a copy of the GNU General Public License
  21. along with this program; if not, write to the Free Software
  22. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. // Pre-2.6 compatibility
  25. if( !defined('WP_CONTENT_URL') )
  26. define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
  27. if( !defined('WP_CONTENT_DIR') )
  28. define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
  29. $wp_cache_config_file = WP_CONTENT_DIR . '/wp-cache-config.php';
  30. if( !@include($wp_cache_config_file) ) {
  31. get_wpcachehome();
  32. $wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
  33. @include($wp_cache_config_file_sample);
  34. } else {
  35. get_wpcachehome();
  36. }
  37. $wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
  38. $wp_cache_link = WP_CONTENT_DIR . '/advanced-cache.php';
  39. $wp_cache_file = WPCACHEHOME . 'advanced-cache.php';
  40. if( !defined( 'WP_CACHE' ) || ( defined( 'WP_CACHE' ) && constant( 'WP_CACHE' ) == false ) ) {
  41. $wp_cache_check_wp_config = true;
  42. }
  43. include(WPCACHEHOME . 'wp-cache-base.php');
  44. function wp_super_cache_text_domain() {
  45. load_plugin_textdomain( 'wp-super-cache', WPCACHEHOME . 'languages', basename( dirname( __FILE__ ) ) . '/languages' );
  46. }
  47. add_action( 'init', 'wp_super_cache_text_domain' );
  48. function wp_cache_set_home() {
  49. global $wp_cache_is_home;
  50. $wp_cache_is_home = ( is_front_page() || is_home() );
  51. if ( $wp_cache_is_home && is_paged() )
  52. $wp_cache_is_home = false;
  53. }
  54. add_action( 'template_redirect', 'wp_cache_set_home' );
  55. // OSSDL CDN plugin (http://wordpress.org/extend/plugins/ossdl-cdn-off-linker/)
  56. include_once( WPCACHEHOME . 'ossdl-cdn.php' );
  57. // from legolas558 d0t users dot sf dot net at http://www.php.net/is_writable
  58. function is_writeable_ACLSafe($path) {
  59. // PHP's is_writable does not work with Win32 NTFS
  60. if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
  61. return is_writeable_ACLSafe($path.uniqid(mt_rand()).'.tmp');
  62. else if (is_dir($path))
  63. return is_writeable_ACLSafe($path.'/'.uniqid(mt_rand()).'.tmp');
  64. // check tmp file for read/write capabilities
  65. $rm = file_exists($path);
  66. $f = @fopen($path, 'a');
  67. if ($f===false)
  68. return false;
  69. fclose($f);
  70. if (!$rm)
  71. unlink($path);
  72. return true;
  73. }
  74. function get_wpcachehome() {
  75. if( defined( 'WPCACHEHOME' ) == false ) {
  76. if( is_file( dirname(__FILE__) . '/wp-cache-config-sample.php' ) ) {
  77. define( 'WPCACHEHOME', trailingslashit( dirname(__FILE__) ) );
  78. } elseif( is_file( dirname(__FILE__) . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
  79. define( 'WPCACHEHOME', dirname(__FILE__) . '/wp-super-cache/' );
  80. } else {
  81. die( sprintf( __( 'Please create %s /wp-cache-config.php from wp-super-cache/wp-cache-config-sample.php', 'wp-super-cache' ), WP_CONTENT_DIR ) );
  82. }
  83. }
  84. }
  85. function wpsupercache_deactivate() {
  86. global $wp_cache_config_file, $wp_cache_link, $cache_path;
  87. $files = array( $wp_cache_config_file, $wp_cache_link );
  88. foreach( $files as $file ) {
  89. if( file_exists( $file ) )
  90. unlink( $file );
  91. }
  92. if( !function_exists( 'prune_super_cache' ) )
  93. include_once( 'wp-cache-phase2.php' );
  94. prune_super_cache ($cache_path, true);
  95. @unlink( $cache_path . '.htaccess' );
  96. @unlink( $cache_path . 'meta' );
  97. @unlink( $cache_path . 'supercache' );
  98. wp_clear_scheduled_hook( 'wp_cache_check_site_hook' );
  99. wp_cache_disable_plugin();
  100. }
  101. register_deactivation_hook( __FILE__, 'wpsupercache_deactivate' );
  102. function wpsupercache_activate() {
  103. }
  104. register_activation_hook( __FILE__, 'wpsupercache_activate' );
  105. function wpsupercache_site_admin() {
  106. if ( function_exists( 'is_super_admin' ) ) {
  107. return is_super_admin();
  108. } elseif ( function_exists( 'is_site_admin' ) ) {
  109. return is_site_admin();
  110. } else {
  111. return true;
  112. }
  113. }
  114. function wp_cache_add_pages() {
  115. global $wpmu_version;
  116. if ( function_exists( 'is_multisite' ) && is_multisite() && wpsupercache_site_admin() ) {
  117. add_submenu_page( 'ms-admin.php', 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager' );
  118. } elseif ( isset( $wpmu_version ) && wpsupercache_site_admin() ) {
  119. add_submenu_page( 'wpmu-admin.php', 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager' );
  120. }
  121. if ( wpsupercache_site_admin() ) { // in single or MS mode add this menu item too, but only for superadmins in MS mode.
  122. add_options_page( 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager');
  123. }
  124. }
  125. add_action('admin_menu', 'wp_cache_add_pages');
  126. function wp_cache_network_pages() {
  127. add_submenu_page('settings.php', 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager');
  128. }
  129. add_action( 'network_admin_menu', 'wp_cache_network_pages' );
  130. function wp_cache_manager_error_checks() {
  131. 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;
  132. if ( !wpsupercache_site_admin() )
  133. return false;
  134. if ( 1 == ini_get( 'safe_mode' ) || "on" == strtolower( ini_get( 'safe_mode' ) ) ) {
  135. echo '<div id="message" class="updated fade"><h3>' . __( 'Warning! PHP Safe Mode Enabled!', 'wp-super-cache' ) . '</h3><p>' .
  136. __( 'You may experience problems running this plugin because SAFE MODE is enabled.', 'wp-super-cache' ) . ' ';
  137. if( !ini_get( 'safe_mode_gid' ) ) {
  138. _e( 'Your server is set up to check the owner of PHP scripts before allowing them to read and write files.', 'wp-super-cache' ) . " ";
  139. 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 );
  140. } else {
  141. _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' );
  142. }
  143. echo '</p></div>';
  144. }
  145. if ( '' == get_option( 'permalink_structure' ) ) {
  146. echo '<div id="message" class="updated fade"><h3>' . __( 'Permlink Structure Error', 'wp-super-cache' ) . '</h3>';
  147. 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>";
  148. echo '</div>';
  149. return false;
  150. }
  151. if( $wp_cache_debug || !$wp_cache_cron_check ) {
  152. if( function_exists( "wp_remote_get" ) == false ) {
  153. $hostname = str_replace( 'http://', '', str_replace( 'https://', '', get_option( 'siteurl' ) ) );
  154. if( strpos( $hostname, '/' ) )
  155. $hostname = substr( $hostname, 0, strpos( $hostname, '/' ) );
  156. $ip = gethostbyname( $hostname );
  157. if( substr( $ip, 0, 3 ) == '127' || substr( $ip, 0, 7 ) == '192.168' ) {
  158. ?><div id="message" class="updated fade"><h3><?php printf( __( 'Warning! Your hostname "%s" resolves to %s', 'wp-super-cache' ), $hostname, $ip ); ?></h3>
  159. <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>
  160. <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>
  161. </div>
  162. <?php
  163. return false;
  164. } else {
  165. wp_cache_replace_line('^ *\$wp_cache_cron_check', "\$wp_cache_cron_check = 1;", $wp_cache_config_file);
  166. }
  167. } else {
  168. $cron_url = get_option( 'siteurl' ) . '/wp-cron.php?check=' . wp_hash('187425');
  169. $cron = wp_remote_get($cron_url, array('timeout' => 0.01, 'blocking' => true));
  170. if( is_array( $cron ) ) {
  171. if( $cron[ 'response' ][ 'code' ] == '404' ) {
  172. ?><div id="message" class="updated fade"><h3>Warning! wp-cron.php not found!</h3>
  173. <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>
  174. <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>
  175. </div>
  176. <?php
  177. return false;
  178. } else {
  179. wp_cache_replace_line('^ *\$wp_cache_cron_check', "\$wp_cache_cron_check = 1;", $wp_cache_config_file);
  180. }
  181. }
  182. }
  183. }
  184. if ( !wp_cache_check_link() ||
  185. !wp_cache_verify_config_file() ||
  186. !wp_cache_verify_cache_dir() ) {
  187. echo '<p>' . __( "Cannot continue... fix previous problems and retry.", 'wp-super-cache' ) . '</p>';
  188. return false;
  189. }
  190. if (!wp_cache_check_global_config()) {
  191. return false;
  192. }
  193. if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) {
  194. ?><div id="message" class="updated fade"><h3><?php _e( 'Zlib Output Compression Enabled!', 'wp-super-cache' ); ?></h3>
  195. <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
  196. }
  197. if( $cache_enabled == true && $super_cache_enabled == true && $wp_cache_mod_rewrite && !got_mod_rewrite() ) {
  198. ?><div id="message" class="updated fade"><h3><?php _e( 'Mod rewrite may not be installed!', 'wp-super-cache' ); ?></h3>
  199. <p><?php _e( 'It appears that mod_rewrite is not installed. Sometimes this check isn&#8217;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
  200. }
  201. if( !is_writeable_ACLSafe( $wp_cache_config_file ) ) {
  202. define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' );
  203. ?><div id="message" class="updated fade"><h3><?php _e( 'Read Only Mode. Configuration cannot be changed.', 'wp-super-cache' ); ?></h3>
  204. <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 ); ?>
  205. <?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&#8217;s globally writeable and it should be fine.', 'wp-super-cache' ); ?></p>
  206. <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>
  207. <?php _e( 'Writeable:', 'wp-super-cache' ); ?> <code>chmod 666 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code>
  208. <?php _e( 'Readonly:', 'wp-super-cache' ); ?> <code>chmod 644 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code></p>
  209. </div><?php
  210. } else {
  211. define( "SUBMITDISABLED", ' ' );
  212. }
  213. // Server could be running as the owner of the wp-content directory. Therefore, if it's
  214. // writable, issue a warning only if the permissions aren't 755.
  215. if( is_writeable_ACLSafe( WP_CONTENT_DIR . '/' ) ) {
  216. $wp_content_stat = stat(WP_CONTENT_DIR . '/');
  217. $wp_content_mode = ( $wp_content_stat[ 'mode' ] & 0777 );
  218. if( $wp_content_mode != 0755 ) {
  219. ?><div id="message" class="updated fade"><h3><?php printf( __( 'Warning! %s is writeable!', 'wp-super-cache' ), WP_CONTENT_DIR ); ?></h3>
  220. <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>
  221. <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></div>
  222. <?php
  223. }
  224. }
  225. if ( function_exists( "is_main_site" ) && true == is_main_site() || function_exists( 'is_main_blog' ) && true == is_main_blog() ) {
  226. $home_path = trailingslashit( get_home_path() );
  227. $scrules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WPSuperCache' ) );
  228. if ( $cache_enabled && $wp_cache_mod_rewrite && !$wp_cache_mobile_enabled && strpos( $scrules, addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) ) ) {
  229. echo '<div id="message" class="updated fade"><h3>' . __( 'Mobile rewrite rules detected', 'wp-super-cache' ) . "</h3>";
  230. 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>";
  231. } elseif ( $wp_cache_mod_rewrite && $cache_enabled && $wp_cache_mobile_enabled && $scrules != '' && (
  232. false === strpos( $scrules, addcslashes( implode( '|', $wp_cache_mobile_prefixes ), ' ' ) ) ||
  233. false === strpos( $scrules, addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) ) )
  234. ) {
  235. ?>
  236. <div id="message" class="updated fade"><h3><?php _e( 'Rewrite rules must be updated', 'wp-super-cache' ); ?></h3>
  237. <p><?php _e( 'The rewrite rules required by this plugin have changed or are missing. ', 'wp-super-cache' ); ?>
  238. <?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' ); ?>
  239. <ol><li> <?php _e( 'Set the plugin to legacy mode and enable mobile support.', 'wp-super-cache' ); ?></li>
  240. <li> <?php _e( 'Scroll down the Advanced Settings page and click the <strong>Update Mod_Rewrite Rules</strong> button.', 'wp-super-cache' ); ?></li>
  241. <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>
  242. <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>
  243. <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
  244. }
  245. if ( $cache_enabled && $super_cache_enabled && $wp_cache_mod_rewrite && $scrules == '' ) {
  246. ?><div id="message" class="updated fade"><h3><?php _e( 'Rewrite rules must be updated', 'wp-super-cache' ); ?></h3>
  247. <p><?php _e( 'The rewrite rules required by this plugin have changed or are missing. ', 'wp-super-cache' ); ?>
  248. <?php _e( 'Scroll down the Advanced Settings page and click the <strong>Update Mod_Rewrite Rules</strong> button.', 'wp-super-cache' ); ?></p></div><?php
  249. }
  250. }
  251. if ( $wp_cache_mod_rewrite && $super_cache_enabled && function_exists( 'apache_get_modules' ) ) {
  252. $mods = apache_get_modules();
  253. $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' ) );
  254. foreach( $required_modules as $req => $desc ) {
  255. if( !in_array( $req, $mods ) ) {
  256. $missing_mods[ $req ] = $desc;
  257. }
  258. }
  259. if( isset( $missing_mods) && is_array( $missing_mods ) ) {
  260. ?><div id="message" class="updated fade"><h3><?php _e( 'Missing Apache Modules', 'wp-super-cache' ); ?></h3>
  261. <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
  262. echo "<ul>";
  263. foreach( $missing_mods as $req => $desc ) {
  264. echo "<li> $req - $desc</li>";
  265. }
  266. echo "</ul>";
  267. echo "</div>";
  268. }
  269. }
  270. return true;
  271. }
  272. add_filter( 'wp_super_cache_error_checking', 'wp_cache_manager_error_checks' );
  273. function wp_cache_manager_updates() {
  274. 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, $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;
  275. if ( !wpsupercache_site_admin() )
  276. return false;
  277. $valid_nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache') : false;
  278. if ( $valid_nonce == false )
  279. return false;
  280. if ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'easysetup' ) {
  281. $_POST[ 'action' ] = 'scupdates';
  282. if( isset( $_POST[ 'wp_cache_easy_on' ] ) && $_POST[ 'wp_cache_easy_on' ] == 1 ) {
  283. $_POST[ 'wp_cache_mobile_enabled' ] = 1;
  284. $_POST[ 'wp_cache_status' ] = 'all';
  285. $_POST[ 'super_cache_enabled' ] = 2; // PHP
  286. $_POST[ 'cache_rebuild_files' ] = 1;
  287. unset( $_POST[ 'cache_compression' ] );
  288. } else {
  289. unset( $_POST[ 'wp_cache_status' ] );
  290. $_POST[ 'super_cache_enabled' ] = 0;
  291. }
  292. }
  293. if( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'scupdates' ) {
  294. if( isset( $_POST[ 'wp_super_cache_late_init' ] ) ) {
  295. $wp_super_cache_late_init = 1;
  296. } else {
  297. $wp_super_cache_late_init = 0;
  298. }
  299. wp_cache_replace_line('^ *\$wp_super_cache_late_init', "\$wp_super_cache_late_init = " . $wp_super_cache_late_init . ";", $wp_cache_config_file);
  300. if( isset( $_POST[ 'wp_supercache_304' ] ) ) {
  301. $wp_supercache_304 = 1;
  302. } else {
  303. $wp_supercache_304 = 0;
  304. }
  305. wp_cache_replace_line('^ *\$wp_supercache_304', "\$wp_supercache_304 = " . $wp_supercache_304 . ";", $wp_cache_config_file);
  306. if( isset( $_POST[ 'wp_cache_mobile_enabled' ] ) ) {
  307. $wp_cache_mobile_enabled = 1;
  308. } else {
  309. $wp_cache_mobile_enabled = 0;
  310. }
  311. wp_cache_replace_line('^ *\$wp_cache_mobile_enabled', "\$wp_cache_mobile_enabled = " . $wp_cache_mobile_enabled . ";", $wp_cache_config_file);
  312. if( isset( $_POST[ 'wp_cache_front_page_checks' ] ) ) {
  313. $wp_cache_front_page_checks = 1;
  314. } else {
  315. $wp_cache_front_page_checks = 0;
  316. }
  317. wp_cache_replace_line('^ *\$wp_cache_front_page_checks', "\$wp_cache_front_page_checks = " . $wp_cache_front_page_checks . ";", $wp_cache_config_file);
  318. $wp_supercache_cache_list = $_POST[ 'wp_supercache_cache_list' ] == 1 ? 1 : 0;
  319. wp_cache_replace_line('^ *\$wp_supercache_cache_list', "\$wp_supercache_cache_list = " . $wp_supercache_cache_list . ";", $wp_cache_config_file);
  320. if ( isset( $_POST[ 'wp_cache_status' ] ) ) {
  321. if ( $_POST[ 'wp_cache_status' ] == 'all' )
  322. wp_cache_enable();
  323. if ( isset( $_POST[ 'super_cache_enabled' ] ) ) {
  324. if ( $_POST[ 'super_cache_enabled' ] == 0 ) {
  325. wp_cache_enable();
  326. wp_super_cache_disable();
  327. }
  328. if( $_POST[ 'super_cache_enabled' ] == 1 ) {
  329. $wp_cache_mod_rewrite = 1; // we need this because supercached files can be served by PHP too.
  330. } else {
  331. $wp_cache_mod_rewrite = 0;
  332. }
  333. wp_cache_replace_line('^ *\$wp_cache_mod_rewrite', '$wp_cache_mod_rewrite = ' . $wp_cache_mod_rewrite . ";", $wp_cache_config_file);
  334. }
  335. } else {
  336. wp_cache_disable();
  337. }
  338. if( isset( $_POST[ 'wp_cache_hello_world' ] ) ) {
  339. $wp_cache_hello_world = 1;
  340. } else {
  341. $wp_cache_hello_world = 0;
  342. }
  343. wp_cache_replace_line('^ *\$wp_cache_hello_world', '$wp_cache_hello_world = ' . $wp_cache_hello_world . ";", $wp_cache_config_file);
  344. if( isset( $_POST[ 'wp_cache_clear_on_post_edit' ] ) ) {
  345. $wp_cache_clear_on_post_edit = 1;
  346. } else {
  347. $wp_cache_clear_on_post_edit = 0;
  348. }
  349. 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);
  350. if( isset( $_POST[ 'cache_rebuild_files' ] ) ) {
  351. $cache_rebuild_files = 1;
  352. } else {
  353. $cache_rebuild_files = 0;
  354. }
  355. wp_cache_replace_line('^ *\$cache_rebuild_files', "\$cache_rebuild_files = " . $cache_rebuild_files . ";", $wp_cache_config_file);
  356. if( isset( $_POST[ 'wp_cache_mutex_disabled' ] ) ) {
  357. $wp_cache_mutex_disabled = 0;
  358. } else {
  359. $wp_cache_mutex_disabled = 1;
  360. }
  361. if( defined( 'WPSC_DISABLE_LOCKING' ) ) {
  362. $wp_cache_mutex_disabled = 1;
  363. }
  364. wp_cache_replace_line('^ *\$wp_cache_mutex_disabled', "\$wp_cache_mutex_disabled = " . $wp_cache_mutex_disabled . ";", $wp_cache_config_file);
  365. if( isset( $_POST[ 'wp_cache_not_logged_in' ] ) ) {
  366. if( $wp_cache_not_logged_in == 0 && function_exists( 'prune_super_cache' ) )
  367. prune_super_cache ($cache_path, true);
  368. $wp_cache_not_logged_in = 1;
  369. } else {
  370. $wp_cache_not_logged_in = 0;
  371. }
  372. wp_cache_replace_line('^ *\$wp_cache_not_logged_in', "\$wp_cache_not_logged_in = " . $wp_cache_not_logged_in . ";", $wp_cache_config_file);
  373. if( $_wp_using_ext_object_cache && isset( $_POST[ 'wp_cache_object_cache' ] ) ) {
  374. if( $wp_cache_object_cache == 0 && function_exists( 'prune_super_cache' ) )
  375. prune_super_cache( $cache_path, true );
  376. $wp_cache_object_cache = 1;
  377. } else {
  378. $wp_cache_object_cache = 0;
  379. }
  380. wp_cache_replace_line('^ *\$wp_cache_object_cache', "\$wp_cache_object_cache = " . $wp_cache_object_cache . ";", $wp_cache_config_file);
  381. if( isset( $_POST[ 'wp_cache_refresh_single_only' ] ) ) {
  382. $wp_cache_refresh_single_only = 1;
  383. } else {
  384. $wp_cache_refresh_single_only = 0;
  385. }
  386. wp_cache_replace_line('^ *\$wp_cache_refresh_single_only', "\$wp_cache_refresh_single_only = '" . $wp_cache_refresh_single_only . "';", $wp_cache_config_file);
  387. if ( defined( 'WPSC_DISABLE_COMPRESSION' ) ) {
  388. $cache_compression = 0;
  389. wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file);
  390. } else {
  391. if ( isset( $_POST[ 'cache_compression' ] ) ) {
  392. $new_cache_compression = 1;
  393. } else {
  394. $new_cache_compression = 0;
  395. }
  396. if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) {
  397. 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>';
  398. } else {
  399. if ( $new_cache_compression != $cache_compression ) {
  400. $cache_compression = $new_cache_compression;
  401. wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file);
  402. if ( function_exists( 'prune_super_cache' ) )
  403. prune_super_cache( $cache_path, true );
  404. delete_option( 'super_cache_meta' );
  405. }
  406. }
  407. }
  408. }
  409. }
  410. if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wpsupercache' )
  411. add_action( 'admin_init', 'wp_cache_manager_updates' );
  412. function wp_cache_manager() {
  413. global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled, $wp_cache_hello_world;
  414. global $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers;
  415. global $wp_cache_cron_check, $wp_cache_debug, $wp_cache_not_logged_in, $wp_supercache_cache_list;
  416. 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;
  417. global $wpmu_version, $cache_max_time, $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks;
  418. if ( !wpsupercache_site_admin() )
  419. return false;
  420. // used by mod_rewrite rules and config file
  421. if ( function_exists( "cfmobi_default_browsers" ) ) {
  422. $wp_cache_mobile_browsers = cfmobi_default_browsers( "mobile" );
  423. $wp_cache_mobile_browsers = array_merge( $wp_cache_mobile_browsers, cfmobi_default_browsers( "touch" ) );
  424. } elseif ( function_exists( 'lite_detection_ua_contains' ) ) {
  425. $wp_cache_mobile_browsers = explode( '|', lite_detection_ua_contains() );
  426. } else {
  427. $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' );
  428. }
  429. if ( function_exists( "lite_detection_ua_prefixes" ) ) {
  430. $wp_cache_mobile_prefixes = lite_detection_ua_prefixes();
  431. } else {
  432. $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
  433. }
  434. $wp_cache_mobile_browsers = apply_filters( 'cached_mobile_browsers', $wp_cache_mobile_browsers ); // Allow mobile plugins access to modify the mobile UA list
  435. $wp_cache_mobile_prefixes = apply_filters( 'cached_mobile_prefixes', $wp_cache_mobile_prefixes ); // Allow mobile plugins access to modify the mobile UA prefix list
  436. $mobile_groups = apply_filters( 'cached_mobile_groups', array() ); // Group mobile user agents by capabilities. Lump them all together by default
  437. // mobile_groups = array( 'apple' => array( 'ipod', 'iphone' ), 'nokia' => array( 'nokia5800', 'symbianos' ) );
  438. if ( false == apply_filters( 'wp_super_cache_error_checking', true ) )
  439. return false;
  440. $supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
  441. if( get_option( 'gzipcompression' ) == 1 )
  442. update_option( 'gzipcompression', 0 );
  443. if( !isset( $cache_rebuild_files ) )
  444. $cache_rebuild_files = 0;
  445. $valid_nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache') : false;
  446. /* http://www.netlobo.com/div_hiding.html */
  447. ?>
  448. <script type='text/javascript'>
  449. <!--
  450. function toggleLayer( whichLayer ) {
  451. var elem, vis;
  452. if( document.getElementById ) // this is the way the standards work
  453. elem = document.getElementById( whichLayer );
  454. else if( document.all ) // this is the way old msie versions work
  455. elem = document.all[whichLayer];
  456. else if( document.layers ) // this is the way nn4 works
  457. elem = document.layers[whichLayer];
  458. vis = elem.style;
  459. // if the style.display value is blank we try to figure it out here
  460. if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
  461. vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  462. vis.display = (vis.display==''||vis.display=='block')?'none':'block';
  463. }
  464. // -->
  465. //Clicking header opens fieldset options
  466. jQuery(document).ready(function(){
  467. jQuery("fieldset h3").css("cursor","pointer").click(function(){
  468. jQuery(this).parent("fieldset").find("p,form,ul,blockquote").toggle("slow");
  469. });
  470. });
  471. </script>
  472. <style type='text/css'>
  473. #nav h2 {
  474. border-bottom: 1px solid #ccc;
  475. padding-bottom: 0;
  476. }
  477. </style>
  478. <?php
  479. echo '<a name="top"></a>';
  480. echo '<div class="wrap">';
  481. echo '<h2>' . __( 'WP Super Cache Settings', 'wp-super-cache' ) . '</h2>';
  482. // set a default
  483. if ( $cache_enabled == false && isset( $wp_cache_mod_rewrite ) == false ) {
  484. $wp_cache_mod_rewrite = 0;
  485. } elseif ( !isset( $wp_cache_mod_rewrite ) && $cache_enabled && $super_cache_enabled ) {
  486. $wp_cache_mod_rewrite = 1;
  487. }
  488. if ( !isset( $_GET[ 'tab' ] ) && $cache_enabled && ( $wp_cache_mod_rewrite || $super_cache_enabled == false ) ) {
  489. $_GET[ 'tab' ] = 'settings';
  490. echo '<div id="message" class="updated fade"><p>' . __( 'Notice: <em>Mod_rewrite or Legacy caching enabled</em>. Showing Advanced Settings Page by default.', 'wp-super-cache' ) . '</p></div>';
  491. }
  492. wpsc_admin_tabs();
  493. if ( isset( $wp_super_cache_front_page_check ) && $wp_super_cache_front_page_check == 1 && !wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
  494. wp_schedule_single_event( time() + 360 , 'wp_cache_check_site_hook' );
  495. 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 );
  496. }
  497. if(isset($_REQUEST['wp_restore_config']) && $valid_nonce) {
  498. unlink($wp_cache_config_file);
  499. 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>';
  500. }
  501. if ( substr( get_option( 'permalink_structure' ), -1 ) == '/' ) {
  502. wp_cache_replace_line('^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 1;", $wp_cache_config_file);
  503. } else {
  504. wp_cache_replace_line('^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 0;", $wp_cache_config_file);
  505. }
  506. if( $wp_cache_mobile_enabled == 1 ) {
  507. update_cached_mobile_ua_list( $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $mobile_groups );
  508. }
  509. ?> <table><td valign='top'><?php
  510. switch( $_GET[ 'tab' ] ) {
  511. case "cdn":
  512. scossdl_off_options();
  513. break;
  514. case "tester":
  515. case "contents":
  516. echo '<a name="test"></a>';
  517. wp_cache_files();
  518. break;
  519. case "preload":
  520. if ( !$cache_enabled )
  521. wp_die( __( 'Caching must be enabled to use this feature', 'wp-super-cache' ) );
  522. echo '<a name="preload"></a>';
  523. if ( $super_cache_enabled == true && false == defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
  524. global $wp_cache_preload_interval, $wp_cache_preload_on, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $wp_cache_preload_posts, $wpdb;
  525. $count = $wpdb->get_var( "SELECT count(*) FROM {$wpdb->posts} WHERE post_status = 'publish'" );
  526. if ( $count > 1000 ) {
  527. $min_refresh_interval = 720;
  528. } else {
  529. $min_refresh_interval = 30;
  530. }
  531. if ( array_key_exists('action', $_POST) && $_POST[ 'action' ] == 'preload' && $valid_nonce ) {
  532. if ( $_POST[ 'posts_to_cache' ] == 'all' ) {
  533. $wp_cache_preload_posts = 'all';
  534. } else {
  535. $wp_cache_preload_posts = (int)$_POST[ 'posts_to_cache' ];
  536. }
  537. wp_cache_replace_line('^ *\$wp_cache_preload_posts', "\$wp_cache_preload_posts = '$wp_cache_preload_posts';", $wp_cache_config_file);
  538. if ( isset( $_POST[ 'preload' ] ) && $_POST[ 'preload' ] == __( 'Cancel Cache Preload', 'wp-super-cache' ) ) {
  539. $next_preload = wp_next_scheduled( 'wp_cache_preload_hook' );
  540. if ( $next_preload ) {
  541. update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) );
  542. wp_unschedule_event( $next_preload, 'wp_cache_preload_hook' );
  543. }
  544. $fp = @fopen( $cache_path . "stop_preload.txt", 'w' );
  545. @fclose( $fp );
  546. echo "<p><strong>" . __( 'Scheduled preloading of cache cancelled.', 'wp-super-cache' ) . "</strong></p>";
  547. } elseif ( isset( $_POST[ 'custom_preload_interval' ] ) && ( $_POST[ 'custom_preload_interval' ] == 0 || $_POST[ 'custom_preload_interval' ] >= $min_refresh_interval ) ) {
  548. // if preload interval changes than unschedule any preload jobs and schedule any new one.
  549. $_POST[ 'custom_preload_interval' ] = (int)$_POST[ 'custom_preload_interval' ];
  550. if ( $wp_cache_preload_interval != $_POST[ 'custom_preload_interval' ] ) {
  551. $next_preload = wp_next_scheduled( 'wp_cache_full_preload_hook' );
  552. if ( $next_preload ) {
  553. update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) );
  554. add_option( 'preload_cache_stop', 1 );
  555. wp_unschedule_event( $next_preload, 'wp_cache_full_preload_hook' );
  556. if ( $wp_cache_preload_interval == 0 ) {
  557. echo "<p><strong>" . __( 'Scheduled preloading of cache cancelled.', 'wp-super-cache' ) . "</strong></p>";
  558. }
  559. }
  560. if ( $_POST[ 'custom_preload_interval' ] != 0 )
  561. wp_schedule_single_event( time() + ( $_POST[ 'custom_preload_interval' ] * 60 ), 'wp_cache_full_preload_hook' );
  562. }
  563. $wp_cache_preload_interval = (int)$_POST[ 'custom_preload_interval' ];
  564. wp_cache_replace_line('^ *\$wp_cache_preload_interval', "\$wp_cache_preload_interval = $wp_cache_preload_interval;", $wp_cache_config_file);
  565. if ( isset( $_POST[ 'preload_email_me' ] ) ) {
  566. $wp_cache_preload_email_me = 1;
  567. } else {
  568. $wp_cache_preload_email_me = 0;
  569. }
  570. wp_cache_replace_line('^ *\$wp_cache_preload_email_me', "\$wp_cache_preload_email_me = $wp_cache_preload_email_me;", $wp_cache_config_file);
  571. if ( isset( $_POST[ 'wp_cache_preload_email_volume' ] ) && in_array( $_POST[ 'wp_cache_preload_email_volume' ], array( 'less', 'medium', 'many' ) ) ) {
  572. $wp_cache_preload_email_volume = $_POST[ 'wp_cache_preload_email_volume' ];
  573. } else {
  574. $wp_cache_preload_email_volume = 'medium';
  575. }
  576. wp_cache_replace_line('^ *\$wp_cache_preload_email_volume', "\$wp_cache_preload_email_volume = '$wp_cache_preload_email_volume';", $wp_cache_config_file);
  577. if ( isset( $_POST[ 'preload_on' ] ) ) {
  578. $wp_cache_preload_on = 1;
  579. } else {
  580. $wp_cache_preload_on = 0;
  581. }
  582. wp_cache_replace_line('^ *\$wp_cache_preload_on', "\$wp_cache_preload_on = $wp_cache_preload_on;", $wp_cache_config_file);
  583. if ( isset( $_POST[ 'preload' ] ) && $_POST[ 'preload' ] == __( 'Preload Cache Now', 'wp-super-cache' ) ) {
  584. @unlink( $cache_path . "preload_mutex.tmp" );
  585. update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) );
  586. wp_schedule_single_event( time() + 10, 'wp_cache_preload_hook' );
  587. echo "<p><strong>" . __( 'Scheduled preloading of cache in 10 seconds.' ) . "</strong></p>";
  588. } elseif ( (int)$_POST[ 'custom_preload_interval' ] ) {
  589. @unlink( $cache_path . "preload_mutex.tmp" );
  590. update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) );
  591. wp_schedule_single_event( time() + ( (int)$_POST[ 'custom_preload_interval' ] * 60 ), 'wp_cache_full_preload_hook' );
  592. echo "<p><strong>" . sprintf( __( 'Scheduled preloading of cache in %d minutes', 'wp-super-cache' ), (int)$_POST[ 'custom_preload_interval' ] ) . "</strong></p>";
  593. }
  594. }
  595. }
  596. 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>';
  597. 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>';
  598. echo '<p>' . __( 'In &#8217;Preload Mode&#8217; 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>';
  599. echo '<form name="cache_filler" action="" method="POST">';
  600. echo '<input type="hidden" name="action" value="preload" />';
  601. echo '<input type="hidden" name="page" value="wpsupercache" />';
  602. 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>';
  603. if ( $count > 100 ) {
  604. $step = (int)( $count / 10 );
  605. $select = "<select name='posts_to_cache' size=1>";
  606. $select .= "<option value='all' ";
  607. if ( !isset( $wp_cache_preload_posts ) || $wp_cache_preload_posts == 'all' ) {
  608. $checked = 'selectect=1 ';
  609. $best = 'all';
  610. } else {
  611. $checked = ' ';
  612. $best = $wp_cache_preload_posts;
  613. }
  614. $select .= "{$checked}>" . __( 'all', 'wp-super-cache' ) . "</option>";
  615. for( $c = $step; $c < $count; $c += $step ) {
  616. $checked = ' ';
  617. if ( $best == $c )
  618. $checked = 'selected=1 ';
  619. $select .= "<option value='$c'{$checked}>$c</option>";
  620. }
  621. $checked = ' ';
  622. if ( $best == $count )
  623. $checked = 'selected=1 ';
  624. $select .= "<option value='$count'{$checked}>$count</option>";
  625. $select .= "</select>";
  626. echo '<p>' . sprintf( __( 'Preload %s posts.', 'wp-super-cache' ), $select ) . '</p>';
  627. } else {
  628. echo '<input type="hidden" name="posts_to_cache" value="' . $count . '" />';
  629. }
  630. echo '<input type="checkbox" name="preload_on" value="1" ';
  631. echo $wp_cache_preload_on == 1 ? 'checked=1' : '';
  632. echo ' /> ' . __( 'Preload mode (garbage collection only on legacy cache files. Recommended.)', 'wp-super-cache' ) . '<br />';
  633. echo '<input type="checkbox" name="preload_email_me" value="1" ';
  634. echo $wp_cache_preload_email_me == 1 ? 'checked=1' : '';
  635. echo ' /> ' . __( 'Send me status emails when files are refreshed.', 'wp-super-cache' ) . '<br />';
  636. if ( !isset( $wp_cache_preload_email_volume ) )
  637. $wp_cache_preload_email_volume = 'many';
  638. echo '&nbsp;&nbsp;&nbsp;&nbsp;<input name="wp_cache_preload_email_volume" type="radio" value="many" class="tog" ';
  639. checked( 'many', $wp_cache_preload_email_volume );
  640. echo '/> ' . __( 'Many emails, 2 emails per 100 posts.', 'wp-super-cache' ) . '<br >';
  641. echo '&nbsp;&nbsp;&nbsp;&nbsp;<input name="wp_cache_preload_email_volume" type="radio" value="medium" class="tog" ';
  642. checked( 'medium', $wp_cache_preload_email_volume );
  643. echo '/> ' . __( 'Medium, 1 email per 100 posts.', 'wp-super-cache' ) . '<br >';
  644. echo '&nbsp;&nbsp;&nbsp;&nbsp;<input name="wp_cache_preload_email_volume" type="radio" value="less" class="tog" ';
  645. checked( 'less', $wp_cache_preload_email_volume );
  646. echo '/> ' . __( 'Less emails, 1 at the start and 1 at the end of preloading all posts.', 'wp-super-cache' ) . '<br >';
  647. $currently_preloading = false;
  648. next_preload_message( 'wp_cache_preload_hook', __( 'Refresh of cache in %d hours %d minutes and %d seconds.', 'wp-super-cache' ), 60 );
  649. next_preload_message( 'wp_cache_full_preload_hook', __( 'Full refresh of cache in %d hours %d minutes and %d seconds.', 'wp-super-cache' ) );
  650. $preload_counter = get_option( 'preload_cache_counter' );
  651. if ( isset( $preload_counter[ 'first' ] ) ) // converted from int to array
  652. update_option( 'preload_cache_counter', array( 'c' => $preload_counter[ 'c' ], 't' => time() ) );
  653. if ( is_array( $preload_counter ) && $preload_counter[ 'c' ] > 0 ) {
  654. echo '<p><strong>' . sprintf( __( 'Currently caching from post %d to %d.', 'wp-super-cache' ), ( $preload_counter[ 'c' ] - 100 ), $preload_counter[ 'c' ] ) . '</strong></p>';
  655. $currently_preloading = true;
  656. if ( @file_exists( $cache_path . "preload_permalink.txt" ) ) {
  657. $url = file_get_contents( $cache_path . "preload_permalink.txt" );
  658. echo "<p>" . sprintf( __( "<strong>Page last cached:</strong> %s", 'wp-super-cache' ), $url ) . "</p>";
  659. }
  660. }
  661. echo '<div class="submit"><input type="submit" name="preload" value="' . __( 'Update Settings', 'wp-super-cache' ) . '" />&nbsp;<input type="submit" name="preload" value="' . __( 'Preload Cache Now', 'wp-super-cache' ) . '" />';
  662. if ( $currently_preloading ) {
  663. echo '&nbsp;<input type="submit" name="preload" value="' . __( 'Cancel Cache Preload', 'wp-super-cache' ) . '" />';
  664. }
  665. echo '</div>';
  666. wp_nonce_field('wp-cache');
  667. echo '</form>';
  668. } else {
  669. echo '<p>' . __( 'Preloading of cache disabled. Please disable legacy page caching or talk to your host administrator.', 'wp-super-cache' ) . '</p>';
  670. }
  671. break;
  672. case 'plugins':
  673. wpsc_plugins_tab();
  674. break;
  675. case 'debug':
  676. wp_cache_debug_settings();
  677. break;
  678. case 'settings':
  679. if ( isset( $wp_cache_front_page_checks ) == false )
  680. $wp_cache_front_page_checks = true;
  681. echo '<form name="wp_manager" action="' . add_query_arg( array( 'page' => 'wpsupercache', 'tab' => 'settings' ) ) . '" method="post">';
  682. wp_nonce_field('wp-cache');
  683. echo '<input type="hidden" name="action" value="scupdates" />';
  684. ?><table class="form-table">
  685. <tr valign="top">
  686. <th scope="row"><label for="wp_cache_status"><?php _e( 'Caching', 'wp-super-cache' ); ?></label></th>
  687. <td>
  688. <fieldset>
  689. <legend class="hidden">Caching</legend>
  690. <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 />
  691. <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 />
  692. <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 />
  693. <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 />
  694. <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 />
  695. </legend>
  696. </fieldset>
  697. </td>
  698. </tr>
  699. <tr valign="top">
  700. <th scope="row"><label for="wp_cache_status"><?php _e( 'Miscellaneous', 'wp-super-cache' ); ?></label></th>
  701. <td>
  702. <fieldset>
  703. <legend class="hidden">Miscellaneous</legend>
  704. <?php if ( false == defined( 'WPSC_DISABLE_COMPRESSION' ) ) { ?>
  705. <?php if ( false == function_exists( 'gzencode' ) ) { ?>
  706. <em><?php _e( 'Warning! Compression is disabled as gzencode() function not found.', 'wp-super-cache' ); ?></em><br />
  707. <?php } else { ?>
  708. <label><input type='checkbox' name='cache_compression' <?php if( $cache_compression ) echo "checked"; ?> value='1'> <?php _e( 'Compress pages so they&#8217;re served more quickly to visitors.', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br />
  709. <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 />
  710. <?php } ?>
  711. <?php } ?>
  712. <?php if ( 0 == $wp_cache_mod_rewrite ) { ?>
  713. <label><input 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 />
  714. <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 />
  715. <?php } ?>
  716. <label><input type='checkbox' name='wp_cache_not_logged_in' <?php if( $wp_cache_not_logged_in ) echo "checked"; ?> value='1'> <?php _e( 'Don&#8217;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 />
  717. <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 />
  718. <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&#8217;s footer)', 'wp-super-cache' ); ?></label><br />
  719. </legend>
  720. </fieldset>
  721. </td>
  722. </tr>
  723. <tr valign="top">
  724. <th scope="row"><label for="wp_cache_status"><?php _e( 'Advanced', 'wp-super-cache' ); ?></label></th>
  725. <td>
  726. <fieldset>
  727. <legend class="hidden">Advanced</legend>
  728. <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><br />
  729. <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.', 'wp-super-cache' ); ?></label><br />
  730. <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 />
  731. <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 />
  732. <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 />
  733. <?php if( false == defined( 'WPSC_DISABLE_LOCKING' ) ) { ?>
  734. <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&#8217;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 />
  735. <?php } ?>
  736. <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 />
  737. <?php if ( $_wp_using_ext_object_cache ) {
  738. ?><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
  739. }?>
  740. </legend>
  741. </fieldset>
  742. </td>
  743. </tr>
  744. </table>
  745. <h3><?php _e( 'Note:', 'wp-super-cache' ); ?></h3>
  746. <ol>
  747. <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>
  748. <li><?php

Large files files are truncated, but you can click here to view the full file