| Server IP : 167.235.67.158 / Your IP : 216.73.216.95 Web Server : Apache System : Linux ubuntu-8gb-nbg1-1 6.8.0-111-generic #111-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 11 23:16:02 UTC 2026 x86_64 User : upstairsbar.co.uk ( 982) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/pawsandpatience.co.uk/wp-content/plugins/wp-smushit/core/ |
Upload File : |
<?php
namespace Smush\Core;
/**
* URL Exclusions helper.
*/
class Urls_Exclusions {
/**
* Regex delimiter used for preg_match/preg_quote.
*
* @var string
*/
private $delimiter;
/**
* Constructor.
*
* @param string $delimiter Regex delimiter.
*/
public function __construct( $delimiter = '~' ) {
$this->delimiter = $delimiter;
}
/**
* Checks if the current request URI matches any of the excluded pages.
*
* @return bool True if the current request URI is excluded, false otherwise.
*/
public function is_excluded_uri( $request_uri, $excluded_page_urls ) {
$pattern = $this->get_excluded_uri_pattern( $excluded_page_urls );
if ( empty( $pattern ) ) {
return false;
}
$request_uri = wp_parse_url( $request_uri, PHP_URL_PATH );
$regex = $this->delimiter . $pattern . $this->delimiter . 'i';
return (bool) preg_match( $regex, $request_uri );
}
/**
* Generate a regex pattern from excluded page URLs.
*
* @return string Regex pattern without delimiters or flags.
*/
private function get_excluded_uri_pattern( $excluded_page_urls ) {
if ( empty( $excluded_page_urls ) ) {
return '';
}
$patterns = array_map( array( $this, 'build_url_pattern' ), $excluded_page_urls );
return implode( '|', array_filter( $patterns ) );
}
/**
* Build regex pattern for a single URL.
*
* @param string $url The URL to convert to regex pattern.
*
* @return string Regex pattern for the URL.
*/
private function build_url_pattern( $url ) {
$url = trim( $url );
if ( empty( $url ) ) {
return '';
}
if ( '/' === $url ) {
return $this->is_subsite()
? '^' . preg_quote( get_blog_details( get_current_blog_id() )->path, '~' ) . '$'
: '^/$';
}
return preg_quote( $url, '~' );
}
/**
* Checks if the current site is a subsite in a multisite network.
*
* @return bool True if the site is a subsite, false otherwise.
*/
private function is_subsite() {
return is_multisite() && ! is_main_site();
}
}