Automattic\WooCommerce\Vendor\Pelago\Emogrifier\HtmlProcessor

AbstractHtmlProcessor::hasEndOfHeadElement │ private │ WC 1.0

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>.

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

Хуков нет.

Возвращает

bool.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->hasEndOfHeadElement( $html ): bool;
$html(строка) (обязательный)
.

Код AbstractHtmlProcessor::hasEndOfHeadElement() WC 11.2.1

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;
}