Changeset 59072 for trunk/src/wp-includes/blocks/navigation.php
- Timestamp:
- 09/20/2024 01:53:52 AM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/navigation.php
r58565 r59072 242 242 $blocks = block_core_navigation_filter_out_empty_blocks( $parsed_blocks ); 243 243 244 if ( function_exists( 'set_ignored_hooked_blocks_metadata' ) ) { 245 // Run Block Hooks algorithm to inject hooked blocks. 246 $markup = block_core_navigation_insert_hooked_blocks( $blocks, $navigation_post ); 247 $root_nav_block = parse_blocks( $markup )[0]; 248 249 $blocks = isset( $root_nav_block['innerBlocks'] ) ? $root_nav_block['innerBlocks'] : $blocks; 250 } 244 // Run Block Hooks algorithm to inject hooked blocks. 245 $markup = block_core_navigation_insert_hooked_blocks( $blocks, $navigation_post ); 246 $root_nav_block = parse_blocks( $markup )[0]; 247 248 $blocks = isset( $root_nav_block['innerBlocks'] ) ? $root_nav_block['innerBlocks'] : $blocks; 251 249 252 250 // TODO - this uses the full navigation block attributes for the … … 484 482 } 485 483 $toggle_button_content = $should_display_icon_label ? $toggle_button_icon : __( 'Menu' ); 486 $toggle_close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d=" M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg>';484 $toggle_close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z"></path></svg>'; 487 485 $toggle_close_button_content = $should_display_icon_label ? $toggle_close_button_icon : __( 'Close' ); 488 486 $toggle_aria_label_open = $should_display_icon_label ? 'aria-label="' . __( 'Open menu' ) . '"' : ''; // Open button label. … … 627 625 $suffix = wp_scripts_get_suffix(); 628 626 if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) { 629 $module_url = gutenberg_url( '/build /interactivity/navigation.min.js' );627 $module_url = gutenberg_url( '/build-module/block-library/navigation/view.min.js' ); 630 628 } 631 629 … … 1084 1082 $fallback_blocks = ! empty( $maybe_fallback ) ? $maybe_fallback : $fallback_blocks; 1085 1083 1086 if ( function_exists( 'set_ignored_hooked_blocks_metadata' ) ) { 1087 // Run Block Hooks algorithm to inject hooked blocks. 1088 // We have to run it here because we need the post ID of the Navigation block to track ignored hooked blocks. 1089 $markup = block_core_navigation_insert_hooked_blocks( $fallback_blocks, $navigation_post ); 1090 $blocks = parse_blocks( $markup ); 1091 1092 if ( isset( $blocks[0]['innerBlocks'] ) ) { 1093 $fallback_blocks = $blocks[0]['innerBlocks']; 1094 } 1084 // Run Block Hooks algorithm to inject hooked blocks. 1085 // We have to run it here because we need the post ID of the Navigation block to track ignored hooked blocks. 1086 $markup = block_core_navigation_insert_hooked_blocks( $fallback_blocks, $navigation_post ); 1087 $blocks = parse_blocks( $markup ); 1088 1089 if ( isset( $blocks[0]['innerBlocks'] ) ) { 1090 $fallback_blocks = $blocks[0]['innerBlocks']; 1095 1091 } 1096 1092 } … … 1622 1618 * Do not add the `block_core_navigation_update_ignore_hooked_blocks_meta` filter in the following cases: 1623 1619 * - If Core has added the `update_ignored_hooked_blocks_postmeta` filter already (WP >= 6.6); 1624 * - or if the `set_ignored_hooked_blocks_metadata` function is unavailable (which is required for the filter to work. It was introduced by WP 6.5 but is not present in Gutenberg's WP 6.5 compatibility layer);1625 1620 * - or if the `$rest_insert_wp_navigation_core_callback` filter has already been added. 1626 1621 */ 1627 1622 if ( 1628 1623 ! has_filter( 'rest_pre_insert_wp_navigation', 'update_ignored_hooked_blocks_postmeta' ) && 1629 function_exists( 'set_ignored_hooked_blocks_metadata' ) &&1630 1624 ! has_filter( 'rest_pre_insert_wp_navigation', $rest_insert_wp_navigation_core_callback ) 1631 1625 ) { 1632 1626 add_filter( 'rest_pre_insert_wp_navigation', 'block_core_navigation_update_ignore_hooked_blocks_meta' ); 1633 }1634 1635 /*1636 * Previous versions of Gutenberg were attaching the block_core_navigation_update_ignore_hooked_blocks_meta1637 * function to the `rest_insert_wp_navigation` _action_ (rather than the `rest_pre_insert_wp_navigation` _filter_).1638 * To avoid collisions, we need to remove the filter from that action if it's present.1639 */1640 if ( has_filter( 'rest_insert_wp_navigation', $rest_insert_wp_navigation_core_callback ) ) {1641 remove_filter( 'rest_insert_wp_navigation', $rest_insert_wp_navigation_core_callback );1642 1627 } 1643 1628 … … 1679 1664 * Do not add the `block_core_navigation_insert_hooked_blocks_into_rest_response` filter in the following cases: 1680 1665 * - If Core has added the `insert_hooked_blocks_into_rest_response` filter already (WP >= 6.6); 1681 * - or if the `set_ignored_hooked_blocks_metadata` function is unavailable (which is required for the filter to work. It was introduced by WP 6.5 but is not present in Gutenberg's WP 6.5 compatibility layer);1682 1666 * - or if the `$rest_prepare_wp_navigation_core_callback` filter has already been added. 1683 1667 */ 1684 1668 if ( 1685 1669 ! has_filter( 'rest_prepare_wp_navigation', 'insert_hooked_blocks_into_rest_response' ) && 1686 function_exists( 'set_ignored_hooked_blocks_metadata' ) &&1687 1670 ! has_filter( 'rest_prepare_wp_navigation', $rest_prepare_wp_navigation_core_callback ) 1688 1671 ) {
Note: See TracChangeset
for help on using the changeset viewer.