WP_Interactivity_API_Directives_Processor::next_balanced_tag_closer_tag()publicWP 6.5.0

Finds the matching closing tag for an opening tag.

When called while the processor is on an open tag, it traverses the HTML until it finds the matching closer tag, respecting any in-between content, including nested tags of the same name. Returns false when called on a closer tag, a tag that doesn't have a closer tag (void), a tag that doesn't visit the closer tag, or if no matching closing tag was found.

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

Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.

Хуков нет.

Возвращает

true|false. Whether a matching closing tag was found.

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

$WP_Interactivity_API_Directives_Processor = new WP_Interactivity_API_Directives_Processor();
$WP_Interactivity_API_Directives_Processor->next_balanced_tag_closer_tag(): bool;

Список изменений

С версии 6.5.0 Введена.

Код WP_Interactivity_API_Directives_Processor::next_balanced_tag_closer_tag() WP 6.7.1

public function next_balanced_tag_closer_tag(): bool {
	$depth    = 0;
	$tag_name = $this->get_tag();

	if ( ! $this->has_and_visits_its_closer_tag() ) {
		return false;
	}

	while ( $this->next_tag(
		array(
			'tag_name'    => $tag_name,
			'tag_closers' => 'visit',
		)
	) ) {
		if ( ! $this->is_tag_closer() ) {
			++$depth;
			continue;
		}

		if ( 0 === $depth ) {
			return true;
		}

		--$depth;
	}

	return false;
}