wpseek.com
A WordPress-centric search engine for devs and theme authors



block_core_page_list_render_nested_page_list › WordPress Function

Sincen/a
Deprecatedn/a
block_core_page_list_render_nested_page_list ( $nested_pages )
Parameters:
  • (array) $nested_pages The array of nested pages.
    Required: Yes
Returns:
  • (string) List markup.
Defined at:
Codex:

Outputs Page list markup from an array of pages with nested children.



Source

function block_core_page_list_render_nested_page_list( $nested_pages ) {
	if ( empty( $nested_pages ) ) {
		return;
	}
	$markup = '';
	foreach ( (array) $nested_pages as $page ) {
		$css_class = 'wp-block-pages-list__item';
		if ( isset( $page['children'] ) ) {
			$css_class .= ' has-child';
		}
		$markup .= '<li class="' . $css_class . '">';
		$markup .= '<a class="wp-block-pages-list__item__link" href="' . esc_url( $page['link'] ) . '">' . wp_kses(
			$page['title'],
			wp_kses_allowed_html( 'post' )
		) . '</a>';
		if ( isset( $page['children'] ) ) {
			$markup .= '<span class="wp-block-page-list__submenu-icon"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" role="img" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg></span>';
			$markup .= '<ul class="submenu-container">' . block_core_page_list_render_nested_page_list( $page['children'] ) . '</ul>';
		}
		$markup .= '</li>';
	}
	return $markup;
}