Skip to content

Commit

Permalink
Merge branch 'feature/23' into release/140925
Browse files Browse the repository at this point in the history
  • Loading branch information
raamdev committed Sep 26, 2014
2 parents 48a9f2a + 99c51de commit 27979f8
Showing 1 changed file with 71 additions and 1 deletion.
72 changes: 71 additions & 1 deletion quick-cache-pro/quick-cache-pro.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public function check_version()
$this->add_advanced_cache();
$this->update_blog_paths();
}
$this->wipe_cache(); // Always wipe the cache; no exceptions.
$this->wipe_cache(); // Always wipe the cache; unless disabled by site owner; @see disable_wipe_cache_routines()

$this->enqueue_notice(__('<strong>Quick Cache:</strong> detected a new version of itself. Recompiling w/ latest version... wiping the cache... all done :-)', $this->text_domain), '', TRUE);
}
Expand Down Expand Up @@ -1079,6 +1079,9 @@ public function wipe_cache($manually = FALSE, $also_wipe_dir = '')
{
$counter = 0; // Initialize.

if($this->disable_wipe_cache_routines() && !$manually)
return $counter; // Nothing to do.

// @TODO When set_time_limit() is disabled by PHP configuration, display a warning message to users upon plugin activation.
@set_time_limit(1800); // In case of HUGE sites w/ a very large directory. Errors are ignored in case `set_time_limit()` is disabled.

Expand Down Expand Up @@ -1133,6 +1136,9 @@ public function wipe_htmlc_cache($manually = FALSE)
{
$counter = 0; // Initialize.

if($this->disable_wipe_cache_routines() && !$manually)
return $counter; // Nothing to do.

$cache_dir_public = $this->wp_content_dir_to($this->htmlc_cache_sub_dir_public);
$cache_dir_private = $this->wp_content_dir_to($this->htmlc_cache_sub_dir_private);

Expand Down Expand Up @@ -1175,6 +1181,9 @@ public function clear_cache($manually = FALSE)
{
$counter = 0; // Initialize.

if($this->disable_clear_cache_routines() && !$manually)
return $counter; // Nothing to do.

if(!is_dir($cache_dir = $this->cache_dir()))
return apply_filters(__METHOD__, $this->clear_htmlc_cache($manually), get_defined_vars());

Expand Down Expand Up @@ -1224,6 +1233,9 @@ public function clear_htmlc_cache($manually = FALSE)
{
$counter = 0; // Initialize.

if($this->disable_clear_cache_routines() && !$manually)
return $counter; // Nothing to do.

$host_token = $this->host_token(TRUE);
if(($host_dir_token = $this->host_dir_token(TRUE)) === '/')
$host_dir_token = ''; // Not necessary in this case.
Expand Down Expand Up @@ -1311,6 +1323,9 @@ public function auto_wipe_cache()
if(!$this->options['enable'])
return $counter; // Nothing to do.

if($this->disable_wipe_cache_routines())
return $counter; // Nothing to do.

$counter = $this->wipe_cache();

if($counter && $this->options['change_notifications_enable'] && is_admin())
Expand Down Expand Up @@ -1354,6 +1369,9 @@ public function auto_clear_cache()
if(!$this->options['enable'])
return $counter; // Nothing to do.

if($this->disable_clear_cache_routines())
return $counter; // Nothing to do.

$counter = $this->clear_cache();

if($counter && $this->options['change_notifications_enable'] && is_admin())
Expand All @@ -1363,6 +1381,58 @@ public function auto_clear_cache()
return apply_filters(__METHOD__, $counter, get_defined_vars());
}

/**
* Allows a site owner to disable the clear and wipe cache routines by filtering quick_cache_disable_auto_clear_cache_routines to return TRUE, in which case this method returns TRUE, otherwise it returns FALSE.
*
* @since 14xxxx First documented version.
*
* @see auto_clear_cache()
* @see clear_htmlc_cache()
* @see clear_cache()
*/
public function disable_clear_cache_routines()
{
if(apply_filters('quick_cache_disable_auto_clear_cache_routines', FALSE))
{
if($this->options['change_notifications_enable'] && is_admin())
{
$this->enqueue_notice('<img src="'.esc_attr($this->url('/client-s/images/clear.png')).'" style="float:left; margin:0 10px 0 0; border:0;" />'.
__('<strong>Quick Cache:</strong> detected important site changes that would normally trigger a clear cache routine, however clear cache routines have been disabled by a site administrator. [<a href="http://www.websharks-inc.com/r/quick-cache-clear-cache-and-wipe-cache-routines-wiki/" target="_blank">?</a>]', $this->text_domain));
}
return TRUE;
}
else
{
return FALSE;
}
}

/**
* Allows a site owner to disable the wipe cache routines by filtering quick_cache_disable_auto_wipe_cache_routines to return TRUE, in which case this method returns TRUE, otherwise it returns FALSE.
*
* @since 14xxxx First documented version.
*
* @see auto_wipe_cache()
* @see wipe_htmlc_cache()
* @see wipe_cache()
*/
public function disable_wipe_cache_routines()
{
if(apply_filters('quick_cache_disable_auto_wipe_cache_routines', FALSE))
{
if($this->options['change_notifications_enable'] && is_admin())
{
$this->enqueue_notice('<img src="'.esc_attr($this->url('/client-s/images/clear.png')).'" style="float:left; margin:0 10px 0 0; border:0;" />'.
__('<strong>Quick Cache:</strong> detected significant changes that would normally trigger a wipe cache routine, however wipe cache routines have been disabled by a site administrator. [<a href="http://www.websharks-inc.com/r/quick-cache-clear-cache-and-wipe-cache-routines-wiki/" target="_blank">?</a>]', $this->text_domain));
}
return TRUE;
}
else
{
return FALSE;
}
}

/**
* Automatically purge cache files for a particular post.
*
Expand Down

0 comments on commit 27979f8

Please sign in to comment.