HEX
Server: Apache/2.4.65 (Debian)
System: Linux 88f31f35b0b8 6.1.0-38-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.147-1 (2025-08-02) x86_64
User: www-data (33)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/breeze/inc/class-breeze-dns-prefetch.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
	header( 'Status: 403 Forbidden' );
	header( 'HTTP/1.1 403 Forbidden' );
	exit;
}

class Breeze_DNS_Prefetch {

	function __construct() {
		add_filter( 'wp_resource_hints', array( &$this, 'breeze_dns_prefetch' ), 10, 2 );
	}

	/**
	 * Optimize by adding URLs to the prefetch DNS list.
	 *
	 * @param array $urls Array of resources and their attributes, or URLs to print for resource hints.
	 * @param string $relation_type The relation type the URLs are printed for,  e.g. 'preconnect' or 'prerender'.
	 *
	 * @return array
	 * @since 2.0.2
	 * @access public
	 */
	public function breeze_dns_prefetch( $urls, $relation_type ) {

		$prefetch_url_list = Breeze_Options_Reader::get_option_value( 'breeze-prefetch-urls' );
		if ( ! is_array( $prefetch_url_list ) ) {
			$prefetch_url_list = array();
		}

		if ( ! empty( $prefetch_url_list ) ) {
			$prefetch_url_list = array_map( 'breeze_rtrim_urls', $prefetch_url_list );
			$prefetch_url_list = array_map( array( $this, 'clean_schema' ), $prefetch_url_list );

			foreach ( $prefetch_url_list as $url_domain ) {

				if ( 'dns-prefetch' === $relation_type ) {
					$urls[] = $url_domain;
				}
			}
		}

		return $urls;
	}

	/**
	 * Remove link schema.
	 *
	 * @param string $current_url Given url string.
	 *
	 * @return string
	 * @since 2.0.2
	 * @access public
	 */
	private function clean_schema( $current_url ) {
		// Strip the URL scheme (http://, https://, or protocol-relative //) as a substring.
		// Note: ltrim() must NOT be used here because its second argument is a character
		// mask, which would incorrectly strip leading h/t/p/s/: characters from domains
		// such as "tracking.example.net" (it would become "racking.example.net").
		return preg_replace( '#^(?:https?:)?//#i', '', (string) $current_url );
	}
}

new Breeze_DNS_Prefetch();