Skip to content
This repository has been archived by the owner on Jul 3, 2022. It is now read-only.

Commit

Permalink
Change location of apply_filter and add extra optional parameters for…
Browse files Browse the repository at this point in the history
… the filter (szepeviktor#74)
  • Loading branch information
charlesLF authored and nigrosimone committed Sep 20, 2016
1 parent 90a0ab7 commit 1d3d3c3
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions lib/W3/PgCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class W3_PgCache {

var $_old_exists = false;
/**
* Returns instance.
* Returns instance.
* For backward compatibility with 0.9.2.3 version of /wp-content files
*
* @return W3_PgCache
Expand All @@ -138,7 +138,6 @@ function __construct() {
if ($pos !== false)
$request_host = substr($request_host, 0, $pos);
$this->_request_host = $request_host;

$this->_request_uri = $_SERVER['REQUEST_URI'];
$this->_lifetime = $this->_config->get_integer('pgcache.lifetime');
$this->_late_init = $this->_config->get_boolean('pgcache.late_init');
Expand Down Expand Up @@ -580,7 +579,7 @@ function _can_cache2(&$buffer) {

return false;
}

return true;
}

Expand Down Expand Up @@ -769,10 +768,10 @@ function _check_logged_in_role_allowed() {
if (!$this->_config->get_boolean('pgcache.reject.logged_roles'))
return true;
$roles = $this->_config->get_array('pgcache.reject.roles');

if (empty($roles))
return true;

foreach (array_keys($_COOKIE) as $cookie_name) {
if (strpos($cookie_name, 'w3tc_logged_') === 0) {
foreach($roles as $role) {
Expand Down Expand Up @@ -983,7 +982,7 @@ function _get_cached_headers() {
* @param string $request_uri
* @return string
*/
function _get_page_key($mobile_group = '', $referrer_group = '',
function _get_page_key($mobile_group = '', $referrer_group = '',
$encryption = '', $compression = '', $content_type = '', $request_uri = '') {

if ($request_uri){
Expand Down Expand Up @@ -1540,6 +1539,18 @@ private function _can_cache_buffer(&$buffer, $has_dynamic) {
} elseif ($this->_sitemap_matched)
$group = 'sitemaps';

/**
* Filters the current theme page cache lifetime.
*
* @since 0.9.4.5
*
* @param integer $_lifetime The page cache lifetime.
* @param string $_request_uri The URI of the page.
* @param integer $mobile_group The request's mobile group.
* @param integer $referrer_group The request's referrer group.
*/
$_expire = apply_filters('w3tc_pgcache_lifetime', $this->_lifetime, $this->_request_uri, $mobile_group, $referrer_group);

foreach ($compressions as $_compression) {
$_page_key = $this->_get_page_key($mobile_group,
$referrer_group, $encryption, $_compression,
Expand All @@ -1562,7 +1573,7 @@ private function _can_cache_buffer(&$buffer, $has_dynamic) {
'content' => &$buffers[$_compression]
);

$cache->set($_page_key, $_data, $this->_lifetime, $group);
$cache->set($_page_key, $_data, $_expire, $group);
}

/**
Expand Down

0 comments on commit 1d3d3c3

Please sign in to comment.