From a1395f77e6ed81f14b8eaf3315c9d6f646a1da29 Mon Sep 17 00:00:00 2001 From: Tom Cafferkey Date: Mon, 29 Jan 2024 15:20:05 +0000 Subject: [PATCH 1/2] Update the feature gate to check for the presence of function get_hooked_block_markup --- packages/block-library/src/navigation/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 70cf02e714cf8..5461c668ec935 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -192,7 +192,7 @@ private static function get_inner_blocks_from_navigation_post( $attributes ) { // it encounters whitespace. This code strips it. $blocks = block_core_navigation_filter_out_empty_blocks( $parsed_blocks ); - if ( function_exists( 'get_hooked_blocks' ) ) { + if ( function_exists( 'get_hooked_block_markup' ) ) { // Run Block Hooks algorithm to inject hooked blocks. $markup = block_core_navigation_insert_hooked_blocks( $blocks, $navigation_post ); $root_nav_block = parse_blocks( $markup )[0]; @@ -987,7 +987,7 @@ function block_core_navigation_get_fallback_blocks() { // In this case default to the (Page List) fallback. $fallback_blocks = ! empty( $maybe_fallback ) ? $maybe_fallback : $fallback_blocks; - if ( function_exists( 'get_hooked_blocks' ) ) { + if ( function_exists( 'get_hooked_block_markup' ) ) { // Run Block Hooks algorithm to inject hooked blocks. // We have to run it here because we need the post ID of the Navigation block to track ignored hooked blocks. $markup = block_core_navigation_insert_hooked_blocks( $fallback_blocks, $navigation_post ); @@ -1415,7 +1415,7 @@ function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) { // Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.4 // that are not present in Gutenberg's WP 6.4 compatibility layer. -if ( function_exists( 'get_hooked_blocks' ) ) { +if ( function_exists( 'get_hooked_block_markup' ) ) { add_action( 'rest_insert_wp_navigation', 'block_core_navigation_update_ignore_hooked_blocks_meta', 10, 3 ); } @@ -1447,6 +1447,6 @@ function block_core_navigation_insert_hooked_blocks_into_rest_response( $respons // Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.4 // that are not present in Gutenberg's WP 6.4 compatibility layer. -if ( function_exists( 'get_hooked_blocks' ) ) { +if ( function_exists( 'get_hooked_block_markup' ) ) { add_filter( 'rest_prepare_wp_navigation', 'block_core_navigation_insert_hooked_blocks_into_rest_response', 10, 3 ); } From d62993a6d7ff2198f2fe78d6ddbd302b65d77ea8 Mon Sep 17 00:00:00 2001 From: Tom Cafferkey Date: Mon, 29 Jan 2024 15:48:35 +0000 Subject: [PATCH 2/2] Update comments --- packages/block-library/src/navigation/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 5461c668ec935..2c7a818cc4f4c 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -1413,8 +1413,8 @@ function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) { } } -// Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.4 -// that are not present in Gutenberg's WP 6.4 compatibility layer. +// Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.5 +// that are not present in Gutenberg's WP 6.5 compatibility layer. if ( function_exists( 'get_hooked_block_markup' ) ) { add_action( 'rest_insert_wp_navigation', 'block_core_navigation_update_ignore_hooked_blocks_meta', 10, 3 ); } @@ -1445,8 +1445,8 @@ function block_core_navigation_insert_hooked_blocks_into_rest_response( $respons return $response; } -// Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.4 -// that are not present in Gutenberg's WP 6.4 compatibility layer. +// Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.5 +// that are not present in Gutenberg's WP 6.5 compatibility layer. if ( function_exists( 'get_hooked_block_markup' ) ) { add_filter( 'rest_prepare_wp_navigation', 'block_core_navigation_insert_hooked_blocks_into_rest_response', 10, 3 ); }