diff --git a/src/includes/classes/CdnFilters.php b/src/includes/classes/CdnFilters.php index cabcf248..874e2e8d 100644 --- a/src/includes/classes/CdnFilters.php +++ b/src/includes/classes/CdnFilters.php @@ -243,14 +243,13 @@ protected function maybeSetupFilters() if (!$this->cdn_when_logged_in && $this->plugin->isLikeUserLoggedIn()) { return; // Disable in this case. } - $_this = $this; // Needed for closures below. - add_action('wp_head', function () use ($_this) { - $_this->completed_wp_head_action_hook = true; + add_action('wp_head', function () { + $this->completed_wp_head_action_hook = true; }, PHP_INT_MAX); // The very last hook, ideally. - add_action('wp_footer', function () use ($_this) { - $_this->started_wp_footer_action_hook = true; + add_action('wp_footer', function () { + $this->started_wp_footer_action_hook = true; }, -PHP_INT_MAX); // The very first hook, ideally. add_filter('home_url', array($this, 'urlFilter'), PHP_INT_MAX - 10, 4); @@ -340,7 +339,6 @@ public function contentFilter($string) if (strpos($string, '<') === false) { return $string; // Nothing to do. } - $_this = $this; // Reference needed by closures below. $regex_url_attrs = '/'.// HTML attributes containing a URL. @@ -361,9 +359,9 @@ public function contentFilter($string) '/i'; // End regex pattern; case insensitive. $orig_string = $string; // In case of regex errors. - $string = preg_replace_callback($regex_url_attrs, function ($m) use ($_this) { + $string = preg_replace_callback($regex_url_attrs, function ($m) { unset($m[0]); // Discard full match. - $m[6] = $_this->filterUrl($m[6], null, true, null); + $m[6] = $this->filterUrl($m[6], null, true, null); return implode('', $m); // Concatenate all parts. }, $string); // End content filter. diff --git a/src/includes/traits/Ac/PostloadUtils.php b/src/includes/traits/Ac/PostloadUtils.php index 7bbe8710..5cb43d6c 100644 --- a/src/includes/traits/Ac/PostloadUtils.php +++ b/src/includes/traits/Ac/PostloadUtils.php @@ -216,13 +216,12 @@ public function maybeFilterStatusHeaderPostload() if (empty($this->postload['filter_status_header'])) { return; // Nothing to do in this case. } - $_this = $this; // Reference needed below. add_filter( 'status_header', - function ($status_header, $status_code) use ($_this) { + function ($status_header, $status_code) { if ($status_code > 0) { - $_this->http_status = (integer) $status_code; + $this->http_status = (integer) $status_code; } return $status_header; }, @@ -282,12 +281,11 @@ public function wpMainQueryPostload() $this->is_user_logged_in = is_user_logged_in(); $this->content_url = rtrim(content_url(), '/'); $this->is_maintenance = $this->functionIsPossible('is_maintenance') && is_maintenance(); - $_this = $this; // Reference for the closure below. add_action( 'template_redirect', - function () use ($_this) { - $_this->is_a_wp_content_type = $_this->is_404 || $_this->is_maintenance + function () { + $this->is_a_wp_content_type = $this->is_404 || $this->is_maintenance || is_front_page() // See || is_home() || is_singular() || is_archive() || is_post_type_archive() || is_tax() || is_search() || is_feed(); }, diff --git a/src/includes/traits/Shared/CachePathUtils.php b/src/includes/traits/Shared/CachePathUtils.php index 9d97c441..a986cf22 100644 --- a/src/includes/traits/Shared/CachePathUtils.php +++ b/src/includes/traits/Shared/CachePathUtils.php @@ -313,7 +313,6 @@ public function buildHostCachePathRegexFragsFromWcUris($uris, $regex_suffix_frag $uris = trim((string) $uris); $regex_suffix_frag = $this->cachePathRegexSuffixFrag($regex_suffix_frag); - $_this = $this; // Reference for the closure below. $flags = $this::CACHE_PATH_ALLOW_WILDCARDS | $this::CACHE_PATH_NO_SCHEME | $this::CACHE_PATH_NO_HOST | $this::CACHE_PATH_NO_PATH_INDEX | $this::CACHE_PATH_NO_QUV | $this::CACHE_PATH_NO_EXT; @@ -324,7 +323,7 @@ public function buildHostCachePathRegexFragsFromWcUris($uris, $regex_suffix_frag foreach ($uri_patterns as $_key => &$_uri_pattern) { if (($_uri_pattern = trim($_uri_pattern, '^$'))) { - $_cache_path = $_this->buildCachePath($host_url.'/'.trim($_uri_pattern, '/'), '', '', $flags); + $_cache_path = $this->buildCachePath($host_url.'/'.trim($_uri_pattern, '/'), '', '', $flags); $_relative_cache_path = preg_replace('/^'.preg_quote($host_cache_path, '/').'(?:\/|$)/i', '', $_cache_path); $_uri_pattern = $this->wdRegexToActualRegexFrag($_relative_cache_path); }