wppaste
WordPress

WP_Navigation_Block_Renderer

Since
6.5.0
Source
wp-includes/blocks/navigation.php:87
Helper functions used to render the navigation block.

Compatibility

WordPress
since 6.5.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 2

Every hook that fires from inside WP_Navigation_Block_Renderer, in the order it appears in the class, grouped by the method that fires it.

Properties · 3

$has_submenusprivate static
Used to determine whether or not a navigation has submenus.
$needs_list_item_wrapperarrayprivate static
Used to determine which blocks need an
  • wrapper.
  • $seen_menu_namesarrayprivate static
    Keeps track of all the navigation names that have been seen.

    Methods · 25

    Source code

    class WP_Navigation_Block_Renderer { 	/**	 * Used to determine whether or not a navigation has submenus.	 *	 * @since 6.5.0	 */	private static $has_submenus = false; 	/**	 * Used to determine which blocks need an <li> wrapper.	 *	 * @since 6.5.0	 *	 * @var array	 */	private static $needs_list_item_wrapper = array(		'core/site-title',		'core/site-logo',		'core/social-links',	); 	/**	 * Keeps track of all the navigation names that have been seen.	 *	 * @since 6.5.0	 *	 * @var array	 */	private static $seen_menu_names = array();  	/**	 * Returns whether or not this is responsive navigation.	 *	 * @since 6.5.0	 *	 * @param array $attributes The block attributes.	 * @return bool Returns whether or not this is responsive navigation.	 */	private static function is_responsive( $attributes ) {		/**		 * This is for backwards compatibility after the `isResponsive` attribute was been removed.		 */ 		$has_old_responsive_attribute = ! empty( $attributes['isResponsive'] ) && $attributes['isResponsive'];		return isset( $attributes['overlayMenu'] ) && 'never' !== $attributes['overlayMenu'] || $has_old_responsive_attribute;	} 	/**	 * Returns whether or not a navigation has a submenu.	 *	 * @since 6.5.0	 *	 * @param WP_Block_List $inner_blocks The list of inner blocks.	 * @return bool Returns whether or not a navigation has a submenu and also sets the member variable.	 */	private static function has_submenus( $inner_blocks ) {		if ( true === static::$has_submenus ) {			return static::$has_submenus;		} 		foreach ( $inner_blocks as $inner_block ) {			// If this is a page list then work out if any of the pages have children.			if ( 'core/page-list' === $inner_block->name ) {				$all_pages = get_pages(					array(						'sort_column' => 'menu_order,post_title',						'order'       => 'asc',					)				);				foreach ( (array) $all_pages as $page ) {					if ( $page->post_parent ) {						static::$has_submenus = true;						break;					}				}			}			// If this is a navigation submenu then we know we have submenus.			if ( 'core/navigation-submenu' === $inner_block->name ) {

    Changelog

    Introduced in 6.5.0. 9 changes between 6.7.7 and 7.1.0.

    1. 6.7.7
    2. 6.8.8
    3. 6.9.7
    4. 7.0.4
    5. 7.1.0

    Signature, return type and hooks compared across 5 parsed releases.

    7.0.4
    Method get_template_part_blocks_html() added.verified against source
    7.0.4
    Method disable_overlay_menu_for_nested_navigation_blocks() added.verified against source
    7.0.4
    Method get_overlay_blocks_from_template_part() added.verified against source
    7.0.4
    Method get_responsive_container_classes() added.verified against source
    7.0.4
    Method get_overlay_inline_styles() added.verified against source
    7.0.4
    Method get_nav_attributes() added.verified against source
    7.0.4
    Method get_inner_block_markup() added.verified against source
    7.0.4
    Method get_nav_wrapper_attributes() removed.verified against source
    7.0.4
    Method get_wrapper_markup() removed.verified against source
    6.5.0
    Introduced.from the docblock

    About this page

    Parsed data
    Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/blocks/navigation.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
    Corrections
    Something wrong on this page? Report it and it gets fixed in the next regeneration.