* * @return string */ private function get_uris_to_exclude( $use_trailing_slash ) { $site_url = site_url(); $uris = get_rocket_cache_reject_uri(); $uris = str_replace( [ '/(.*)|', '/(.*)/|' ], '/|', $uris ); foreach ( [ '/wp-admin', '/logout' ] as $uri ) { $uris .= "|{$uri}"; if ( $use_trailing_slash ) { $uris .= '/'; } } foreach ( [ wp_logout_url(), wp_login_url() ] as $uri ) { if ( strpos( $uri, '?' ) !== false ) { continue; } $uris .= '|' . str_replace( $site_url, '', $uri ); } $default = [ '/refer/', '/go/', '/recommend/', '/recommends/', ]; $excluded = $default; /** * Filters the patterns excluded from links preload * * @since 3.10.8 * * @param string[] $excluded Array of excluded patterns. * @param string[] $default Array of default excluded patterns. */ $excluded = apply_filters( 'rocket_preload_links_exclusions', $excluded, $default ); if ( ! is_array( $excluded ) ) { $excluded = (array) $excluded; } $excluded = array_filter( $excluded ); $excluded_patterns = ''; if ( ! empty( $excluded ) ) { $excluded_patterns = '|' . implode( '|', $excluded ); } return $uris . $excluded_patterns; } /** * Checks if the given URL has a trailing slash. * * @since 3.7 * * @param string $url URL to check. * * @return bool */ private function has_trailing_slash( $url ) { return substr( $url, -1 ) === '/'; } /** * Indicates if the site uses a trailing slash in the permalink structure. * * @since 3.7 * * @return bool when true, uses `/`; else, no. */ private function use_trailing_slash() { return $this->has_trailing_slash( get_permalink() ); } }