From f4eb8108e457d0d839691c71d2aaa047855acf97 Mon Sep 17 00:00:00 2001 From: Carlos Bravo Date: Wed, 13 Mar 2024 15:43:28 +0100 Subject: [PATCH 1/3] Use same prioprity than in Core --- packages/e2e-tests/plugins/interactive-blocks.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/e2e-tests/plugins/interactive-blocks.php b/packages/e2e-tests/plugins/interactive-blocks.php index 0d35cc827d6da..ab2f85156e3b3 100644 --- a/packages/e2e-tests/plugins/interactive-blocks.php +++ b/packages/e2e-tests/plugins/interactive-blocks.php @@ -31,7 +31,8 @@ function () { // But remove the server directive processing. remove_filter( 'render_block_data', - 'wp_interactivity_process_directives_of_interactive_blocks' + 'wp_interactivity_process_directives_of_interactive_blocks', + 100 ); } } From ca08e8c3095d6d979fec9185a97b47a03b23ffd8 Mon Sep 17 00:00:00 2001 From: Carlos Bravo Date: Wed, 13 Mar 2024 15:45:25 +0100 Subject: [PATCH 2/3] Backport priority filter --- .../interactivity-api/interactivity-api.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php b/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php index e532fe2444713..67fad2cc9ef4d 100644 --- a/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php +++ b/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php @@ -58,16 +58,20 @@ function wp_interactivity_process_directives_of_interactive_blocks( array $parse }; /* - * Uses a priority of 20 to ensure that other filters can add additional - * directives before the processing starts. - */ - add_filter( 'render_block_' . $block_name, $process_interactive_blocks, 20, 2 ); + * Uses a priority of 100 to ensure that other filters can add additional + * directives before the processing starts. + */ + add_filter( 'render_block_' . $block_name, $process_interactive_blocks, 100, 2 ); } } return $parsed_block; } - add_filter( 'render_block_data', 'wp_interactivity_process_directives_of_interactive_blocks' ); + /* + * Uses a priority of 100 to ensure that other filters can edit $parsed_block + * without crashing the SSR. + */ + add_filter( 'render_block_data', 'wp_interactivity_process_directives_of_interactive_blocks', 100 ); } if ( ! function_exists( 'wp_interactivity' ) ) { From b5824eb806746752329332bb459caa115c0064b2 Mon Sep 17 00:00:00 2001 From: Carlos Bravo Date: Wed, 13 Mar 2024 16:14:59 +0100 Subject: [PATCH 3/3] Add argument --- .../wordpress-6.5/interactivity-api/interactivity-api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php b/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php index 67fad2cc9ef4d..c4c0ac37519f4 100644 --- a/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php +++ b/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php @@ -71,7 +71,7 @@ function wp_interactivity_process_directives_of_interactive_blocks( array $parse * Uses a priority of 100 to ensure that other filters can edit $parsed_block * without crashing the SSR. */ - add_filter( 'render_block_data', 'wp_interactivity_process_directives_of_interactive_blocks', 100 ); + add_filter( 'render_block_data', 'wp_interactivity_process_directives_of_interactive_blocks', 100, 1 ); } if ( ! function_exists( 'wp_interactivity' ) ) {