Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Post_Template::extract_list_items
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.
Method of the class: Post_Template{}
No Hooks.
Returns
array<int, string>. Inner HTML of each list item, in document order.
Usage
// private - for code of main (parent) class only $result = $this->extract_list_items( $dom, $list_element ): array;
- $dom(Dom_Document_Helper) (required)
- Parsed block content.
- $list_element(DOMElement) (required)
- The post-template list element.
Post_Template::extract_list_items() Post Template::extract list items code WC 11.1.2
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;
}