[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/blocks/ -> navigation.php (summary)

Server-side rendering of the `core/navigation` block.

File Size: 1575 lines (59 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_Navigation_Block_Renderer:: (46 methods):
  is_responsive()
  has_submenus()
  is_interactive()
  does_block_need_a_list_item_wrapper()
  get_markup_for_inner_block()
  get_inner_blocks_html()
  get_inner_blocks_from_navigation_post()
  get_inner_blocks_from_fallback()
  get_inner_blocks()
  get_navigation_name()
  get_layout_class()
  get_classes()
  get_styles()
  get_responsive_container_markup()
  get_nav_wrapper_attributes()
  get_nav_element_directives()
  handle_view_script_module_loading()
  get_wrapper_markup()
  get_unique_navigation_name()
  render()
  block_core_navigation_get_menu_items_at_location()
  block_core_navigation_sort_menu_items_by_parent_id()
  block_core_navigation_get_inner_blocks_from_unstable_location()
  block_core_navigation_add_directives_to_submenu()
  block_core_navigation_build_css_colors()
  block_core_navigation_build_css_font_sizes()
  block_core_navigation_render_submenu_icon()
  block_core_navigation_filter_out_empty_blocks()
  block_core_navigation_block_contains_core_navigation()
  block_core_navigation_get_fallback_blocks()
  block_core_navigation_get_post_ids()
  block_core_navigation_from_block_get_post_ids()
  render_block_core_navigation()
  register_block_core_navigation()
  block_core_navigation_typographic_presets_backcompatibility()
  block_core_navigation_parse_blocks_from_menu_items()
  block_core_navigation_get_classic_menu_fallback()
  block_core_navigation_get_classic_menu_fallback_blocks()
  block_core_navigation_maybe_use_classic_menu_fallback()
  block_core_navigation_get_most_recently_published_navigation()
  block_core_navigation_remove_serialized_parent_block()
  block_core_navigation_mock_parsed_block()
  block_core_navigation_insert_hooked_blocks()
  block_core_navigation_set_ignored_hooked_blocks_metadata()
  block_core_navigation_update_ignore_hooked_blocks_meta()
  block_core_navigation_insert_hooked_blocks_into_rest_response()


Class: WP_Navigation_Block_Renderer  - X-Ref

Helper functions used to render the navigation block.

is_responsive( $attributes )   X-Ref
Returns whether or not this is responsive navigation.

param: array $attributes The block attributes.
return: bool Returns whether or not this is responsive navigation.

has_submenus( $inner_blocks )   X-Ref
Returns whether or not a navigation has a submenu.

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.

is_interactive( $attributes, $inner_blocks )   X-Ref
Determine whether the navigation blocks is interactive.

param: array         $attributes   The block attributes.
param: WP_Block_List $inner_blocks The list of inner blocks.
return: bool Returns whether or not to load the view script.

does_block_need_a_list_item_wrapper( $block )   X-Ref
Returns whether or not a block needs a list item wrapper.

param: WP_Block $block The block.
return: bool Returns whether or not a block needs a list item wrapper.

get_markup_for_inner_block( $inner_block )   X-Ref
Returns the markup for a single inner block.

param: WP_Block $inner_block The inner block.
return: string Returns the markup for a single inner block.

get_inner_blocks_html( $attributes, $inner_blocks )   X-Ref
Returns the html for the inner blocks of the navigation block.

param: array         $attributes   The block attributes.
param: WP_Block_List $inner_blocks The list of inner blocks.
return: string Returns the html for the inner blocks of the navigation block.

get_inner_blocks_from_navigation_post( $attributes )   X-Ref
Gets the inner blocks for the navigation block from the navigation post.

param: array $attributes The block attributes.
return: WP_Block_List Returns the inner blocks for the navigation block.

get_inner_blocks_from_fallback( $attributes )   X-Ref
Gets the inner blocks for the navigation block from the fallback.

param: array $attributes The block attributes.
return: WP_Block_List Returns the inner blocks for the navigation block.

get_inner_blocks( $attributes, $block )   X-Ref
Gets the inner blocks for the navigation block.

param: array    $attributes The block attributes.
param: WP_Block $block The parsed block.
return: WP_Block_List Returns the inner blocks for the navigation block.

get_navigation_name( $attributes )   X-Ref
Gets the name of the current navigation, if it has one.

param: array $attributes The block attributes.
return: string Returns the name of the navigation.

get_layout_class( $attributes )   X-Ref
Returns the layout class for the navigation block.

param: array $attributes The block attributes.
return: string Returns the layout class for the navigation block.

get_classes( $attributes )   X-Ref
Return classes for the navigation block.

param: array $attributes The block attributes.
return: string Returns the classes for the navigation block.

get_styles( $attributes )   X-Ref
Get styles for the navigation block.

param: array $attributes The block attributes.
return: string Returns the styles for the navigation block.

get_responsive_container_markup( $attributes, $inner_blocks, $inner_blocks_html )   X-Ref
Get the responsive container markup

param: array         $attributes The block attributes.
param: WP_Block_List $inner_blocks The list of inner blocks.
param: string        $inner_blocks_html The markup for the inner blocks.
return: string Returns the container markup.

get_nav_wrapper_attributes( $attributes, $inner_blocks )   X-Ref
Get the wrapper attributes

param: array         $attributes    The block attributes.
param: WP_Block_List $inner_blocks  A list of inner blocks.
return: string Returns the navigation block markup.

get_nav_element_directives( $is_interactive )   X-Ref
Gets the nav element directives.

param: bool $is_interactive Whether the block is interactive.
return: string the directives for the navigation element.

handle_view_script_module_loading( $attributes, $block, $inner_blocks )   X-Ref
Handle view script module loading.

param: array         $attributes   The block attributes.
param: WP_Block      $block        The parsed block.
param: WP_Block_List $inner_blocks The list of inner blocks.

get_wrapper_markup( $attributes, $inner_blocks )   X-Ref
Returns the markup for the navigation block.

param: array         $attributes The block attributes.
param: WP_Block_List $inner_blocks The list of inner blocks.
return: string Returns the navigation wrapper markup.

get_unique_navigation_name( $attributes )   X-Ref
Returns a unique name for the navigation.

param: array $attributes The block attributes.
return: string Returns a unique name for the navigation.

render( $attributes, $content, $block )   X-Ref
Renders the navigation block.

param: array    $attributes The block attributes.
param: string   $content    The saved content.
param: WP_Block $block      The parsed block.
return: string Returns the navigation block markup.

block_core_navigation_get_menu_items_at_location( $location )   X-Ref
Returns the menu items for a WordPress menu location.

param: string $location The menu location.
return: array Menu items for the location.

block_core_navigation_sort_menu_items_by_parent_id( $menu_items )   X-Ref
Sorts a standard array of menu items into a nested structure keyed by the
id of the parent menu.

param: array $menu_items Menu items to sort.
return: array An array keyed by the id of the parent menu where each element

block_core_navigation_get_inner_blocks_from_unstable_location( $attributes )   X-Ref
Gets the inner blocks for the navigation block from the unstable location attribute.

param: array $attributes The block attributes.
return: WP_Block_List Returns the inner blocks for the navigation block.

block_core_navigation_add_directives_to_submenu( $tags, $block_attributes )   X-Ref
Add Interactivity API directives to the navigation-submenu and page-list
blocks markup using the Tag Processor.

param: WP_HTML_Tag_Processor $tags             Markup of the navigation block.
param: array                 $block_attributes Block attributes.
return: string Submenu markup with the directives injected.

block_core_navigation_build_css_colors( $attributes )   X-Ref
Build an array with CSS classes and inline styles defining the colors
which will be applied to the navigation markup in the front-end.

param: array $attributes Navigation block attributes.
return: array Colors CSS classes and inline styles.

block_core_navigation_build_css_font_sizes( $attributes )   X-Ref
Build an array with CSS classes and inline styles defining the font sizes
which will be applied to the navigation markup in the front-end.

param: array $attributes Navigation block attributes.
return: array Font size CSS classes and inline styles.

block_core_navigation_render_submenu_icon()   X-Ref
Returns the top-level submenu SVG chevron icon.

return: string

block_core_navigation_filter_out_empty_blocks( $parsed_blocks )   X-Ref
Filter out empty "null" blocks from the block list.
'parse_blocks' includes a null block with '\n\n' as the content when
it encounters whitespace. This is not a bug but rather how the parser
is designed.

param: array $parsed_blocks the parsed blocks to be normalized.
return: array the normalized parsed blocks.

block_core_navigation_block_contains_core_navigation( $inner_blocks )   X-Ref
No description

block_core_navigation_get_fallback_blocks()   X-Ref
Retrieves the appropriate fallback to be used on the front of the
site when there is no menu assigned to the Nav block.

This aims to mirror how the fallback mechanic for wp_nav_menu works.
See https://developer.wordpress.org/reference/functions/wp_nav_menu/#more-information.

return: array the array of blocks to be used as a fallback.

block_core_navigation_get_post_ids( $inner_blocks )   X-Ref
Iterate through all inner blocks recursively and get navigation link block's post IDs.

param: WP_Block_List $inner_blocks Block list class instance.
return: array Array of post IDs.

block_core_navigation_from_block_get_post_ids( $block )   X-Ref
Get post IDs from a navigation link block instance.

param: WP_Block $block Instance of a block.
return: array Array of post IDs.

render_block_core_navigation( $attributes, $content, $block )   X-Ref
Renders the `core/navigation` block on server.

param: array    $attributes The block attributes.
param: string   $content    The saved content.
param: WP_Block $block      The parsed block.
return: string Returns the navigation block markup.

register_block_core_navigation()   X-Ref
Register the navigation block.


block_core_navigation_typographic_presets_backcompatibility( $parsed_block )   X-Ref
Filter that changes the parsed attribute values of navigation blocks contain typographic presets to contain the values directly.

param: array $parsed_block The block being rendered.
return: array The block being rendered without typographic presets.

block_core_navigation_parse_blocks_from_menu_items( $menu_items, $menu_items_by_parent_id )   X-Ref
Turns menu item data into a nested array of parsed blocks

param: array $menu_items               An array of menu items that represent
param: array $menu_items_by_parent_id  An array keyed by the id of the
return: array An array of parsed block data.

block_core_navigation_get_classic_menu_fallback()   X-Ref
Get the classic navigation menu to use as a fallback.

return: object WP_Term The classic navigation.

block_core_navigation_get_classic_menu_fallback_blocks( $classic_nav_menu )   X-Ref
No description

block_core_navigation_maybe_use_classic_menu_fallback()   X-Ref
If there's a classic menu then use it as a fallback.

return: array the normalized parsed blocks.

block_core_navigation_get_most_recently_published_navigation()   X-Ref
Finds the most recently published `wp_navigation` Post.

return: WP_Post|null the first non-empty Navigation or null.

block_core_navigation_remove_serialized_parent_block( $serialized_block )   X-Ref
Accepts the serialized markup of a block and its inner blocks, and returns serialized markup of the inner blocks.

param: string $serialized_block The serialized markup of a block and its inner blocks.
return: string

block_core_navigation_mock_parsed_block( $inner_blocks, $post )   X-Ref
Mock a parsed block for the Navigation block given its inner blocks and the `wp_navigation` post object.
The `wp_navigation` post's `_wp_ignored_hooked_blocks` meta is queried to add the `metadata.ignoredHookedBlocks` attribute.

param: array   $inner_blocks Parsed inner blocks of a Navigation block.
param: WP_Post $post         `wp_navigation` post object corresponding to the block.
return: array the normalized parsed blocks.

block_core_navigation_insert_hooked_blocks( $inner_blocks, $post )   X-Ref
Insert hooked blocks into a Navigation block.

Given a Navigation block's inner blocks and its corresponding `wp_navigation` post object,
this function inserts hooked blocks into it, and returns the serialized inner blocks in a
mock Navigation block wrapper.

If there are any hooked blocks that need to be inserted as the Navigation block's first or last
children, the `wp_navigation` post's `_wp_ignored_hooked_blocks` meta is checked to see if any
of those hooked blocks should be exempted from insertion.

param: array   $inner_blocks Parsed inner blocks of a Navigation block.
param: WP_Post $post         `wp_navigation` post object corresponding to the block.
return: string Serialized inner blocks in mock Navigation block wrapper, with hooked blocks inserted, if any.

block_core_navigation_set_ignored_hooked_blocks_metadata( $inner_blocks, $post )   X-Ref
Insert ignoredHookedBlocks meta into the Navigation block and its inner blocks.

Given a Navigation block's inner blocks and its corresponding `wp_navigation` post object,
this function inserts ignoredHookedBlocks meta into it, and returns the serialized inner blocks in a
mock Navigation block wrapper.

param: array   $inner_blocks Parsed inner blocks of a Navigation block.
param: WP_Post $post         `wp_navigation` post object corresponding to the block.
return: string Serialized inner blocks in mock Navigation block wrapper, with hooked blocks inserted, if any.

block_core_navigation_update_ignore_hooked_blocks_meta( $post )   X-Ref
Updates the post meta with the list of ignored hooked blocks when the navigation is created or updated via the REST API.

param: stdClass $post Post object.
return: stdClass The updated post object.

block_core_navigation_insert_hooked_blocks_into_rest_response( $response, $post )   X-Ref
Hooks into the REST API response for the core/navigation block and adds the first and last inner blocks.

param: WP_REST_Response $response The response object.
param: WP_Post          $post     Post object.
return: WP_REST_Response The response object.



Generated : Sun May 19 08:20:01 2024 Cross-referenced by PHPXref