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
Resolves #223
  • Loading branch information
raamdev committed Sep 23, 2014
1 parent e42eaf0 commit 15dd263
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions quick-cache/quick-cache.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ public function setup()
add_action('wp_loaded', array($this, 'actions'));

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

add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles'));
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
Expand Down Expand Up @@ -1990,6 +1991,28 @@ public function auto_purge_comment_transition($new_status, $old_status, $comment
return apply_filters(__METHOD__, $counter, get_defined_vars());
}

/**
* 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 15dd263

Please sign in to comment.