/** * Makes a http request to the url this points at and checks if the requests * returns the correct validation result. * * @return bool */ public function is_valid() { $url_glue = false === strpos($this->url, '?') ? '?' : '&'; $url = trailingslashit($this->url) . ($this->language_code ? '/' . $this->language_code . '/' : '') . $url_glue . '____icl_validate_domain=1'; $response = $this->http->request($url, 'timeout=15'); return !is_wp_error($response) && $response['response']['code'] == '200' && ($response['body'] === '<!--' . untrailingslashit($this->wp_api->get_home_url()) . '-->' || $response['body'] === '<!--' . untrailingslashit($this->wp_api->get_site_url()) . '-->'); }