Automattic\WooCommerce\Vendor\Pelago\Emogrifier\HtmlProcessor
AbstractHtmlProcessor::hasEndOfHeadElement
Tests whether the <head> element ends within the given HTML. Due to tag omission rules, HTML parsers are expected to end the <head> element and start the <body> element upon encountering a start tag for any element which is permitted only within the <body>.
Method of the class: AbstractHtmlProcessor{}
No Hooks.
Returns
true|false.
Usage
// private - for code of main (parent) class only $result = $this->hasEndOfHeadElement( $html ): bool;
- $html(string) (required)
- .
AbstractHtmlProcessor::hasEndOfHeadElement() AbstractHtmlProcessor::hasEndOfHeadElement code WC 10.4.3
private function hasEndOfHeadElement(string $html): bool
{
if (
(new Preg())->match('%<(?!' . self::TAGNAME_ALLOWED_BEFORE_BODY_MATCHER . '[\\s/>])\\w|</head>%i', $html)
!== 0
) {
// An exception to the implicit end of the `<head>` is any content within a `<template>` element, as well in
// comments. As an optimization, this is only checked for if a potential `<head>` end tag is found.
$htmlWithoutCommentsOrTemplates = $this->removeHtmlTemplateElements($this->removeHtmlComments($html));
$hasEndOfHeadElement = $htmlWithoutCommentsOrTemplates === $html
|| $this->hasEndOfHeadElement($htmlWithoutCommentsOrTemplates);
} else {
$hasEndOfHeadElement = false;
}
return $hasEndOfHeadElement;
}