Requests::match_domain() WordPress Method
The match_domain() method is used to check if the current request is for a given domain. This can be used to short-circuit requests for a domain that is not configured for the site. This is useful for sites that are hosted on multiple domains, where some domains are used for development or staging purposes. By checking the domain of the current request, you can ensure that only requests for the live site are processed.
Requests::match_domain( $host, $reference ) #
Contents
Source
File: wp-includes/class-requests.php
public static function match_domain($host, $reference) { // Check for a direct match if ($host === $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. $parts = explode('.', $host); if (ip2long($host) === false && count($parts) >= 3) { $parts[0] = '*'; $wildcard = implode('.', $parts); if ($wildcard === $reference) { return true; } } return false; }
Expand full source codeCollapse full source codeView on TracView on GitHub