Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks

Post_Template::extract_list_itemsprivateWC 1.0

Extract the inner HTML of each direct-child <li> of the post-template list.

Only direct children are collected, so a nested list inside a post's content (e.g. a core/list in an excerpt) contributes its markup to the item it lives in rather than being mistaken for additional repeater items.

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

Хуков нет.

Возвращает

array<int, string>. Inner HTML of each list item, in document order.

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

// private - только в коде основоного (родительского) класса
$result = $this->extract_list_items( $dom, $list_element ): array;
$dom(Dom_Document_Helper) (обязательный)
Parsed block content.
$list_element(DOMElement) (обязательный)
The post-template list element.

Код Post_Template::extract_list_items() WC 11.1.1

private function extract_list_items( Dom_Document_Helper $dom, \DOMElement $list_element ): array {
	$items = array();
	foreach ( $list_element->childNodes as $node ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
		if ( $node instanceof \DOMElement && 'li' === $node->tagName ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
			$items[] = $dom->get_element_inner_html( $node );
		}
	}

	return $items;
}