Ssl::match_domain()public staticWP 1.0

Match a hostname against a dNSName reference

Метод класса: Ssl{}

Хуков нет.


true|false. Does the domain match?


$result = Ssl::match_domain( $host, $reference );
$host(строка|Stringable) (обязательный)
Requested host
$reference(строка|Stringable) (обязательный)
dNSName to match against

Код Ssl::match_domain() WP 6.3.1

public static function match_domain($host, $reference) {
	if (InputValidator::is_string_or_stringable($host) === false) {
		throw InvalidArgument::create(1, '$host', 'string|Stringable', gettype($host));

	// Check if the reference is blocklisted first
	if (self::verify_reference_name($reference) !== true) {
		return false;

	// Check for a direct match
	if ((string) $host === (string) $reference) {
		return true;

	// Calculate the valid wildcard match if the host is not an IP address
	// Also validates that the host has 3 parts or more, as per Firefox's ruleset,
	// as a wildcard reference is only allowed with 3 parts or more, so the
	// comparison will never match if host doesn't contain 3 parts or more as well.
	if (ip2long($host) === false) {
		$parts    = explode('.', $host);
		$parts[0] = '*';
		$wildcard = implode('.', $parts);
		if ($wildcard === (string) $reference) {
			return true;

	return false;