/** * Disable the WP Super Cache. */ function disable($args = array(), $assoc_args = array()) { global $super_cache_enabled; wp_super_cache_disable(); if (!$super_cache_enabled) { WP_CLI::success('The WP Super Cache is disabled.'); } else { WP_CLI::error('The WP Super Cache is still enabled, check its settings page for more info.'); } }
function wp_supercache_ktaistyle_admin() { global $valid_nonce, $wp_cache_config_file, $cache_ktaistyle, $wp_cache_mobile_browsers, $orig_wp_cache_mobile_browsers; if (!isset($cache_ktaistyle)) { $cache_ktaistyle = 0; } $ktaistyle_browsers = 'DoCoMo/, J-PHONE/, J-EMULATOR/, Vodafone/, MOT-, MOTEMULATOR-, SoftBank/, emulator/, DDIPOCKET;, WILLCOM;, KDDI-, UP.Browser/, emobile/, Huawei/, IAC/, Nokia, Opera Mini, Opera Mobi, Palm OS, Windows CE;, PDA; SL-, PlayStation Portable, SONY/COM, Nitro, Nintendo, mixi-mobile-converter/'; if (function_exists('ks_option') && ks_option('ks_theme_touch')) { $ktaistyle_browsers .= ', iPhone;, iPod;, Android'; } if (isset($_POST['cache_ktaistyle']) && $valid_nonce) { if (!class_exists('KtaiStyle') && !class_exists('Ktai_Style')) { $_POST['cache_ktaistyle'] = __('Disable', 'wp-super-cache'); $err = __('Ktai Style not found. Please check your install.', 'wp-super-cache'); } $cache_ktaistyle = $_POST['cache_ktaistyle'] == __('Disable', 'wp-super-cache') ? 0 : 1; wp_cache_replace_line('^ *\\$cache_ktaistyle', "\$cache_ktaistyle = '{$cache_ktaistyle}';", $wp_cache_config_file); if ($cache_ktaistyle) { if (!isset($orig_wp_cache_mobile_browsers)) { wp_cache_replace_line('^ *\\$orig_wp_cache_mobile_browsers', "\$orig_wp_cache_mobile_browsers = '{$wp_cache_mobile_browsers}';", $wp_cache_config_file); } wp_cache_replace_line('^ *\\$wp_cache_mobile_browsers ', "\$wp_cache_mobile_browsers = '{$ktaistyle_browsers}';", $wp_cache_config_file); } elseif (isset($orig_wp_cache_mobile_browsers) && $orig_wp_cache_mobile_browsers != $ktaistyle_browsers) { wp_cache_replace_line('^ *\\$wp_cache_mobile_browsers ', "\$wp_cache_mobile_browsers = '{$orig_wp_cache_mobile_browsers}';", $wp_cache_config_file); wp_cache_replace_line('^ *\\$orig_wp_cache_mobile_browsers', '', $wp_cache_config_file); } } echo '<form name="wp_supercache_ktaistyle_admin" action="' . $_SERVER["REQUEST_URI"] . '" method="post">'; wp_nonce_field('wp-cache'); if ($cache_ktaistyle == 0) { $ks_status = __('disabled', 'wp-super-cache'); } else { $ks_status = __('enabled', 'wp-super-cache'); wp_super_cache_disable(); } echo '<strong>' . sprintf(__('Ktai Style support is %s', 'wp-super-cache'), $ks_status); echo '.</strong>'; printf(__('(Changing supporting mobile devices. Requires <a href="http://wppluginsj.sourceforge.jp/ktai_style/">Ktai Style</a>.) ', 'wp-super-cache')); if ($cache_ktaistyle == 0) { echo '<input type="submit" name="cache_ktaistyle" value="' . __('Enable', 'wp-super-cache') . '" />'; } else { echo '<input type="submit" name="cache_ktaistyle" value="' . __('Disable', 'wp-super-cache') . '" />'; } echo "</form>\n"; if ($err) { echo "<p><strong>" . __('Warning!', 'wp-super-cache') . "</strong> {$err}</p>"; } }
function wp_supercache_badbehaviour_admin() { global $cache_badbehaviour, $wp_cache_config_file, $valid_nonce; $cache_badbehaviour = $cache_badbehaviour == '' ? 'no' : $cache_badbehaviour; $err = false; if (isset($_POST['cache_badbehaviour']) && $valid_nonce) { $bbfile = get_bb_file_loc(); if (!$bbfile) { $_POST['cache_badbehaviour'] = 'Disable'; $err = __('Bad Behaviour not found. Please check your install.', 'wp-super-cache'); } $cache_badbehaviour = $_POST['cache_badbehaviour'] == __('Disable', 'wp-super-cache') ? 0 : 1; wp_cache_replace_line('^ *\\$cache_compression', "\$cache_compression = 0;", $wp_cache_config_file); wp_cache_replace_line('^ *\\$cache_badbehaviour', "\$cache_badbehaviour = {$cache_badbehaviour};", $wp_cache_config_file); wp_cache_replace_line('^ *\\$cache_badbehaviour_file', "\$cache_badbehaviour_file = '{$bbfile}';", $wp_cache_config_file); } echo '<form name="wp_supercache_badbehaviour_admin" action="' . $_SERVER["REQUEST_URI"] . '" method="post">'; wp_nonce_field('wp-cache'); if ($cache_badbehaviour == 0) { $bb_status = __('disabled', 'wp-super-cache'); } else { $bb_status = __('enabled', 'wp-super-cache'); wp_super_cache_disable(); } echo '<strong>' . sprintf(__('Bad Behaviour support is %s', 'wp-super-cache'), $bb_status); echo '.</strong>'; printf(__('(Only half-on caching supported, disabled compression and requires <a href="http://www.bad-behavior.ioerror.us/">Bad Behavior</a> in "%s/plugins/bad-behavior/") ', 'wp-super-cache'), WP_CONTENT_DIR); if ($cache_badbehaviour == 0) { echo '<input type="submit" name="cache_badbehaviour" value="' . __('Enable', 'wp-super-cache') . '" />'; } else { echo '<input type="submit" name="cache_badbehaviour" value="' . __('Disable', 'wp-super-cache') . '" />'; } echo "</form>\n"; if ($err) { echo "<p><strong>" . __('Warning!', 'wp-super-cache') . "</strong> {$err}</p>"; } }
function wp_cache_disable() { global $cache_path, $wp_cache_config_file, $cache_enabled, $supercachedir, $cache_path; if (wp_cache_replace_line('^ *\\$cache_enabled', '$cache_enabled = false;', $wp_cache_config_file)) { $cache_enabled = false; } wp_super_cache_disable(); sleep(1); // allow existing processes to write to the supercachedir and then delete it if (function_exists('prune_super_cache') && is_dir($supercachedir)) { prune_super_cache($cache_path, true); } }
function wp_cache_disable() { global $wp_cache_config_file, $cache_enabled; if (wp_cache_replace_line('^ *\\$cache_enabled', '$cache_enabled = false;', $wp_cache_config_file)) { $cache_enabled = false; } wp_super_cache_disable(); }
function wp_cache_manager_updates() { 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; if (!wpsupercache_site_admin()) { return false; } if (false == isset($cache_page_secret)) { $cache_page_secret = md5(date('H:i:s') . mt_rand()); wp_cache_replace_line('^ *\\$cache_page_secret', "\$cache_page_secret = '" . $cache_page_secret . "';", $wp_cache_config_file); } // Delete cache for a specific page if (isset($_GET['action']) && $_GET['action'] == 'delete' && (isset($_GET['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'delete-cache') : false)) { $path = get_supercache_dir() . preg_replace('/:.*$/', '', $_GET['path']); $files = get_all_supercache_filenames($path); foreach ($files as $cache_file) { prune_super_cache($path . $cache_file, true); } wp_redirect(preg_replace('/[ <>\'\\"\\r\\n\\t\\(\\)]/', '', $_GET['path'])); die; } $valid_nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache') : false; if ($valid_nonce == false) { return false; } if (isset($_POST['action']) && $_POST['action'] == 'easysetup') { $_POST['action'] = 'scupdates'; if (isset($_POST['wp_cache_easy_on']) && $_POST['wp_cache_easy_on'] == 1) { $_POST['wp_cache_mobile_enabled'] = 1; $_POST['wp_cache_status'] = 'all'; $_POST['super_cache_enabled'] = 2; // PHP $_POST['cache_rebuild_files'] = 1; unset($_POST['cache_compression']); } else { unset($_POST['wp_cache_status']); $_POST['super_cache_enabled'] = 0; } } if (isset($_POST['action']) && $_POST['action'] == 'scupdates') { if (isset($_POST['wp_super_cache_late_init'])) { $wp_super_cache_late_init = 1; } else { $wp_super_cache_late_init = 0; } wp_cache_replace_line('^ *\\$wp_super_cache_late_init', "\$wp_super_cache_late_init = " . $wp_super_cache_late_init . ";", $wp_cache_config_file); if (isset($_POST['wp_supercache_304'])) { $wp_supercache_304 = 1; } else { $wp_supercache_304 = 0; } wp_cache_replace_line('^ *\\$wp_supercache_304', "\$wp_supercache_304 = " . $wp_supercache_304 . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_mobile_enabled'])) { $wp_cache_mobile_enabled = 1; } else { $wp_cache_mobile_enabled = 0; } wp_cache_replace_line('^ *\\$wp_cache_mobile_enabled', "\$wp_cache_mobile_enabled = " . $wp_cache_mobile_enabled . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_front_page_checks'])) { $wp_cache_front_page_checks = 1; } else { $wp_cache_front_page_checks = 0; } wp_cache_replace_line('^ *\\$wp_cache_front_page_checks', "\$wp_cache_front_page_checks = " . $wp_cache_front_page_checks . ";", $wp_cache_config_file); $wp_supercache_cache_list = $_POST['wp_supercache_cache_list'] == 1 ? 1 : 0; wp_cache_replace_line('^ *\\$wp_supercache_cache_list', "\$wp_supercache_cache_list = " . $wp_supercache_cache_list . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_status'])) { if ($_POST['wp_cache_status'] == 'all') { wp_cache_enable(); } if (isset($_POST['super_cache_enabled'])) { if ($_POST['super_cache_enabled'] == 0) { wp_cache_enable(); wp_super_cache_disable(); } if ($_POST['super_cache_enabled'] == 1) { $wp_cache_mod_rewrite = 1; // we need this because supercached files can be served by PHP too. } else { $wp_cache_mod_rewrite = 0; } wp_cache_replace_line('^ *\\$wp_cache_mod_rewrite', '$wp_cache_mod_rewrite = ' . $wp_cache_mod_rewrite . ";", $wp_cache_config_file); } } else { wp_cache_disable(); } if (isset($_POST['wp_cache_hello_world'])) { $wp_cache_hello_world = 1; } else { $wp_cache_hello_world = 0; } wp_cache_replace_line('^ *\\$wp_cache_hello_world', '$wp_cache_hello_world = ' . $wp_cache_hello_world . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_clear_on_post_edit'])) { $wp_cache_clear_on_post_edit = 1; } else { $wp_cache_clear_on_post_edit = 0; } 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); if (isset($_POST['cache_rebuild_files'])) { $cache_rebuild_files = 1; } else { $cache_rebuild_files = 0; } wp_cache_replace_line('^ *\\$cache_rebuild_files', "\$cache_rebuild_files = " . $cache_rebuild_files . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_mutex_disabled'])) { $wp_cache_mutex_disabled = 0; } else { $wp_cache_mutex_disabled = 1; } if (defined('WPSC_DISABLE_LOCKING')) { $wp_cache_mutex_disabled = 1; } wp_cache_replace_line('^ *\\$wp_cache_mutex_disabled', "\$wp_cache_mutex_disabled = " . $wp_cache_mutex_disabled . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_not_logged_in'])) { if ($wp_cache_not_logged_in == 0 && function_exists('prune_super_cache')) { prune_super_cache($cache_path, true); } $wp_cache_not_logged_in = 1; } else { $wp_cache_not_logged_in = 0; } wp_cache_replace_line('^ *\\$wp_cache_not_logged_in', "\$wp_cache_not_logged_in = " . $wp_cache_not_logged_in . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_make_known_anon'])) { if ($wp_cache_make_known_anon == 0 && function_exists('prune_super_cache')) { prune_super_cache($cache_path, true); } $wp_cache_make_known_anon = 1; } else { $wp_cache_make_known_anon = 0; } wp_cache_replace_line('^ *\\$wp_cache_make_known_anon', "\$wp_cache_make_known_anon = " . $wp_cache_make_known_anon . ";", $wp_cache_config_file); if ($_wp_using_ext_object_cache && isset($_POST['wp_cache_object_cache'])) { if ($wp_cache_object_cache == 0 && function_exists('prune_super_cache')) { prune_super_cache($cache_path, true); } $wp_cache_object_cache = 1; } else { $wp_cache_object_cache = 0; } wp_cache_replace_line('^ *\\$wp_cache_object_cache', "\$wp_cache_object_cache = " . $wp_cache_object_cache . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_refresh_single_only'])) { $wp_cache_refresh_single_only = 1; } else { $wp_cache_refresh_single_only = 0; } wp_cache_replace_line('^ *\\$wp_cache_refresh_single_only', "\$wp_cache_refresh_single_only = '" . $wp_cache_refresh_single_only . "';", $wp_cache_config_file); if (defined('WPSC_DISABLE_COMPRESSION')) { $cache_compression = 0; wp_cache_replace_line('^ *\\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file); } else { if (isset($_POST['cache_compression'])) { $new_cache_compression = 1; } else { $new_cache_compression = 0; } if (1 == ini_get('zlib.output_compression') || "on" == strtolower(ini_get('zlib.output_compression'))) { 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>'; } else { if ($new_cache_compression != $cache_compression) { $cache_compression = $new_cache_compression; wp_cache_replace_line('^ *\\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file); if (function_exists('prune_super_cache')) { prune_super_cache($cache_path, true); } delete_option('super_cache_meta'); } } } } }
function wp_cache_manager_updates() { global $wp_cache_mobile_enabled, $wp_cache_mfunc_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; global $cache_schedule_type, $cache_scheduled_time, $cache_max_time, $cache_time_interval, $wp_cache_shutdown_gc; if (!wpsupercache_site_admin()) { return false; } if (false == isset($cache_page_secret)) { $cache_page_secret = md5(date('H:i:s') . mt_rand()); wp_cache_replace_line('^ *\\$cache_page_secret', "\$cache_page_secret = '" . $cache_page_secret . "';", $wp_cache_config_file); } $valid_nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache') : false; if ($valid_nonce == false) { return false; } if (isset($_POST['action']) && $_POST['action'] == 'easysetup') { $_POST['action'] = 'scupdates'; if (isset($_POST['wp_cache_easy_on']) && $_POST['wp_cache_easy_on'] == 1) { $_POST['wp_cache_mobile_enabled'] = 1; $_POST['wp_cache_status'] = 'all'; $_POST['super_cache_enabled'] = 2; // PHP $_POST['cache_rebuild_files'] = 1; unset($_POST['cache_compression']); if ($cache_path != WP_CONTENT_DIR . '/cache/') { $_POST['wp_cache_location'] = $cache_path; } // // set up garbage collection with some default settings if ((!isset($wp_cache_shutdown_gc) || $wp_cache_shutdown_gc == 0) && false == wp_next_scheduled('wp_cache_gc')) { if (false == isset($cache_schedule_type)) { $cache_schedule_type = 'interval'; $cache_time_interval = 600; $cache_max_time = 1800; wp_cache_replace_line('^ *\\$cache_schedule_type', "\$cache_schedule_type = '{$cache_schedule_type}';", $wp_cache_config_file); wp_cache_replace_line('^ *\\$cache_time_interval', "\$cache_time_interval = '{$cache_time_interval}';", $wp_cache_config_file); wp_cache_replace_line('^ *\\$cache_max_time', "\$cache_max_time = '{$cache_max_time}';", $wp_cache_config_file); } wp_schedule_single_event(time() + 600, 'wp_cache_gc'); } } else { unset($_POST['wp_cache_status']); $_POST['super_cache_enabled'] = 0; wp_clear_scheduled_hook('wp_cache_check_site_hook'); wp_clear_scheduled_hook('wp_cache_gc'); wp_clear_scheduled_hook('wp_cache_gc_watcher'); } $advanced_settings = array('wp_super_cache_late_init', 'wp_cache_disable_utf8', 'wp_cache_no_cache_for_get', 'wp_supercache_304', 'wp_cache_mfunc_enabled', 'wp_cache_mobile_enabled', 'wp_cache_front_page_checks', 'wp_supercache_cache_list', 'wp_cache_hello_world', 'wp_cache_clear_on_post_edit', 'wp_cache_not_logged_in', 'wp_cache_make_known_anon', 'wp_cache_object_cache', 'wp_cache_refresh_single_only', 'cache_compression', 'wp_cache_mutex_disabled'); foreach ($advanced_settings as $setting) { if (isset(${$setting}) && ${$setting} == 1) { $_POST[$setting] = 1; } } } if (isset($_POST['action']) && $_POST['action'] == 'scupdates') { if (isset($_POST['wp_cache_location']) && $_POST['wp_cache_location'] != '') { $dir = realpath(trailingslashit(dirname($_POST['wp_cache_location']))); if ($dir == false) { $dir = WP_CONTENT_DIR . '/cache/'; } else { $dir = trailingslashit($dir) . wpsc_deep_replace(array('..', '\\'), basename($_POST['wp_cache_location'])); } $new_cache_path = $dir; } else { $new_cache_path = WP_CONTENT_DIR . '/cache/'; } if ($new_cache_path != $cache_path) { if (file_exists($new_cache_path) == false) { rename($cache_path, $new_cache_path); } $cache_path = $new_cache_path; wp_cache_replace_line('^ *\\$cache_path', "\$cache_path = '" . $cache_path . "';", $wp_cache_config_file); } if (isset($_POST['wp_super_cache_late_init'])) { $wp_super_cache_late_init = 1; } else { $wp_super_cache_late_init = 0; } wp_cache_replace_line('^ *\\$wp_super_cache_late_init', "\$wp_super_cache_late_init = " . $wp_super_cache_late_init . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_disable_utf8'])) { $wp_cache_disable_utf8 = 1; } else { $wp_cache_disable_utf8 = 0; } wp_cache_replace_line('^ *\\$wp_cache_disable_utf8', "\$wp_cache_disable_utf8 = " . $wp_cache_disable_utf8 . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_no_cache_for_get'])) { $wp_cache_no_cache_for_get = 1; } else { $wp_cache_no_cache_for_get = 0; } 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); if (isset($_POST['wp_supercache_304'])) { $wp_supercache_304 = 1; } else { $wp_supercache_304 = 0; } wp_cache_replace_line('^ *\\$wp_supercache_304', "\$wp_supercache_304 = " . $wp_supercache_304 . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_mfunc_enabled'])) { $wp_cache_mfunc_enabled = 1; } else { $wp_cache_mfunc_enabled = 0; } wp_cache_replace_line('^ *\\$wp_cache_mfunc_enabled', "\$wp_cache_mfunc_enabled = " . $wp_cache_mfunc_enabled . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_mobile_enabled'])) { $wp_cache_mobile_enabled = 1; } else { $wp_cache_mobile_enabled = 0; } wp_cache_replace_line('^ *\\$wp_cache_mobile_enabled', "\$wp_cache_mobile_enabled = " . $wp_cache_mobile_enabled . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_front_page_checks'])) { $wp_cache_front_page_checks = 1; } else { $wp_cache_front_page_checks = 0; } wp_cache_replace_line('^ *\\$wp_cache_front_page_checks', "\$wp_cache_front_page_checks = " . $wp_cache_front_page_checks . ";", $wp_cache_config_file); if (isset($_POST['wp_supercache_cache_list'])) { $wp_supercache_cache_list = 1; } else { $wp_supercache_cache_list = 0; } wp_cache_replace_line('^ *\\$wp_supercache_cache_list', "\$wp_supercache_cache_list = " . $wp_supercache_cache_list . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_status'])) { if ($_POST['wp_cache_status'] == 'all') { wp_cache_enable(); } if (isset($_POST['super_cache_enabled'])) { if ($_POST['super_cache_enabled'] == 0) { wp_cache_enable(); wp_super_cache_disable(); } if ($_POST['super_cache_enabled'] == 1) { $wp_cache_mod_rewrite = 1; // we need this because supercached files can be served by PHP too. } else { $wp_cache_mod_rewrite = 0; } wp_cache_replace_line('^ *\\$wp_cache_mod_rewrite', '$wp_cache_mod_rewrite = ' . $wp_cache_mod_rewrite . ";", $wp_cache_config_file); } } else { wp_cache_disable(); } if (isset($_POST['wp_cache_hello_world'])) { $wp_cache_hello_world = 1; } else { $wp_cache_hello_world = 0; } wp_cache_replace_line('^ *\\$wp_cache_hello_world', '$wp_cache_hello_world = ' . $wp_cache_hello_world . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_clear_on_post_edit'])) { $wp_cache_clear_on_post_edit = 1; } else { $wp_cache_clear_on_post_edit = 0; } 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); if (isset($_POST['cache_rebuild_files'])) { $cache_rebuild_files = 1; } else { $cache_rebuild_files = 0; } wp_cache_replace_line('^ *\\$cache_rebuild_files', "\$cache_rebuild_files = " . $cache_rebuild_files . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_mutex_disabled'])) { $wp_cache_mutex_disabled = 0; } else { $wp_cache_mutex_disabled = 1; } if (defined('WPSC_DISABLE_LOCKING')) { $wp_cache_mutex_disabled = 1; } wp_cache_replace_line('^ *\\$wp_cache_mutex_disabled', "\$wp_cache_mutex_disabled = " . $wp_cache_mutex_disabled . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_not_logged_in'])) { if ($wp_cache_not_logged_in == 0 && function_exists('prune_super_cache')) { prune_super_cache($cache_path, true); } $wp_cache_not_logged_in = 1; } else { $wp_cache_not_logged_in = 0; } wp_cache_replace_line('^ *\\$wp_cache_not_logged_in', "\$wp_cache_not_logged_in = " . $wp_cache_not_logged_in . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_make_known_anon'])) { if ($wp_cache_make_known_anon == 0 && function_exists('prune_super_cache')) { prune_super_cache($cache_path, true); } $wp_cache_make_known_anon = 1; } else { $wp_cache_make_known_anon = 0; } wp_cache_replace_line('^ *\\$wp_cache_make_known_anon', "\$wp_cache_make_known_anon = " . $wp_cache_make_known_anon . ";", $wp_cache_config_file); if ($_wp_using_ext_object_cache && isset($_POST['wp_cache_object_cache'])) { if ($wp_cache_object_cache == 0 && function_exists('prune_super_cache')) { prune_super_cache($cache_path, true); } $wp_cache_object_cache = 1; } else { $wp_cache_object_cache = 0; } wp_cache_replace_line('^ *\\$wp_cache_object_cache', "\$wp_cache_object_cache = " . $wp_cache_object_cache . ";", $wp_cache_config_file); if (isset($_POST['wp_cache_refresh_single_only'])) { $wp_cache_refresh_single_only = 1; } else { $wp_cache_refresh_single_only = 0; } wp_cache_replace_line('^ *\\$wp_cache_refresh_single_only', "\$wp_cache_refresh_single_only = '" . $wp_cache_refresh_single_only . "';", $wp_cache_config_file); if (defined('WPSC_DISABLE_COMPRESSION')) { $cache_compression = 0; wp_cache_replace_line('^ *\\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file); } else { if (isset($_POST['cache_compression'])) { $new_cache_compression = 1; } else { $new_cache_compression = 0; } if (1 == ini_get('zlib.output_compression') || "on" == strtolower(ini_get('zlib.output_compression'))) { 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>'; } else { if ($new_cache_compression != $cache_compression) { $cache_compression = $new_cache_compression; wp_cache_replace_line('^ *\\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file); if (function_exists('prune_super_cache')) { prune_super_cache($cache_path, true); } delete_option('super_cache_meta'); } } } } }
/** * Disable the WP Super Cache * * @param array $args * @param array $vars */ function disable($args = array(), $vars = array()) { if (function_exists('wp_super_cache_disable')) { global $super_cache_enabled; wp_super_cache_disable(); if (!$super_cache_enabled) { WP_CLI::success('The WP Super Cache is disabled.'); } else { WP_CLI::error('The WP Super Cache is still enabled, check its settings page for more info.'); } } else { WP_CLI::error('The WP Super Cache could not be found, is it installed?'); } }