[wp-hackers] Expire the cache

David House dmhouse at gmail.com
Thu Jan 26 21:45:31 GMT 2006


On 26/01/06, David House <dmhouse at gmail.com> wrote:
> Okay, here's my patch. It isn't tested much since I can't get my cache
> to aquire a lock, which is odd. It should work, though. Give it a
> patch -p0 < file and click Options -> Clear Cache.

Some people didn't get the patch, so here it is as a .txt.

--
-David House, dmhouse at gmail.com, http://xmouse.ithium.net
-------------- next part --------------
Index: wp-admin/clear-cache.php
===================================================================
--- wp-admin/clear-cache.php	(revision 0)
+++ wp-admin/clear-cache.php	(revision 0)
@@ -0,0 +1,57 @@
+<?php
+
+require 'admin.php';
+
+$title = __('Clear Cache');
+$parent_file = 'options-general.php';
+
+require_once 'admin-header.php';
+
+$wpvarstoreset = array('action', 'cleared');
+for ($i=0; $i<count($wpvarstoreset); $i += 1) {
+	$wpvar = $wpvarstoreset[$i];
+	if (!isset($$wpvar)) {
+		if (empty($_POST["$wpvar"])) {
+			if (empty($_GET["$wpvar"])) {
+				$$wpvar = '';
+			} else {
+				$$wpvar = $_GET["$wpvar"];
+			}
+		} else {
+			$$wpvar = $_POST["$wpvar"];
+		}
+	}
+}
+
+switch ($action) {
+
+case 'clear':
+
+wp_cache_flush();
+$to = add_query_arg('action', '');
+$to = add_query_arg('cleared', 'true', $to);
+wp_redirect($to);
+die();
+break;
+
+default:
+?>
+
+<?php if ($cleared == true) { ?>
+<div id="message" class="updated fade"><p><strong><?php _e('Cache cleared.') ?></strong></p></div>
+<?php } ?>
+
+<div class="wrap">
+	<h2><?php _e('Clear Cache'); ?></h2>
+	<p><?php _e('Use this page to flush the cache. WARNING: Do not press this button if you do not know what you are doing.');?></p>
+	
+	<form action="clear-cache.php">
+		<input type="hidden" name="action" value="clear" />
+		<input type="submit" value="<?php _e('Clear Cache'); ?>" />
+	</form>
+</div>
+
+<?php
+}
+include 'admin-footer.php';
+?>
\ No newline at end of file
Index: wp-admin/menu.php
===================================================================
--- wp-admin/menu.php	(revision 3469)
+++ wp-admin/menu.php	(working copy)
@@ -42,6 +42,7 @@
 $submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php');
 $submenu['options-general.php'][30] = array(__('Permalinks'), 'manage_options', 'options-permalink.php');
 $submenu['options-general.php'][35] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php');
+$submenu['options-general.php'][40] = array(__('Clear Cache'), 'edit_files', 'clear-cache.php');
 
 $submenu['plugins.php'][5] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
 $submenu['plugins.php'][10] = array(__('Plugin Editor'), 'edit_plugins', 'plugin-editor.php');


More information about the wp-hackers mailing list