Skip to content

Commit

Permalink
Clear site cache when WordPress Reading Settings are updated
Browse files Browse the repository at this point in the history
  • Loading branch information
raamdev committed Sep 23, 2014
1 parent 5176cfd commit 89b1804
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions quick-cache-pro/quick-cache-pro.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ public function setup()

add_action('admin_init', array($this, 'check_version'));
add_action('admin_init', array($this, 'check_update_sync_version'));
add_action('admin_init', array($this, 'maybe_auto_clear_cache'));

add_action('admin_bar_menu', array($this, 'admin_bar_menu'));
add_action('wp_head', array($this, 'admin_bar_meta_tags'), 0);
Expand Down Expand Up @@ -2580,6 +2581,28 @@ public function auto_purge_user_cache_cur()
$this->auto_purge_user_cache(get_current_user_id());
}

/**
* Automatically clears all cache files for current blog under various conditions;
* used to check for conditions that don't have a hook that we can attach to.
*
* @since 140922 First documented version.
*
* @attaches-to `admin_init` hook.
*
* @see auto_clear_cache()
*/
public function maybe_auto_clear_cache()
{
$_pagenow = $GLOBALS['pagenow'];
if(isset($this->cache[__FUNCTION__][$_pagenow]))
return; // Already did this.
$this->cache[__FUNCTION__][$_pagenow] = -1;

// If Dashboard → Settings → Reading options are updated
if($GLOBALS['pagenow'] === 'options-reading.php' && !empty($_REQUEST['settings-updated']))
$this->auto_clear_cache();
}

/**
* Automatically clears all cache files for current blog when JetPack Custom CSS is saved.
*
Expand Down

0 comments on commit 89b1804

Please sign in to comment.