From dc648e56de18dd81326a0dd8f11e728169f59751 Mon Sep 17 00:00:00 2001 From: Carlos Bravo <37012961+c4rl0sbr4v0@users.noreply.github.com> Date: Wed, 13 Mar 2024 16:48:30 +0100 Subject: [PATCH] Interactivity API: Fix interactivity api e2e tests. (#59836) * Use same prioprity than in Core * Backport priority filter * Add argument Co-authored-by: c4rl0sbr4v0 Co-authored-by: sirreal --- .../interactivity-api/interactivity-api.php | 14 +++++++++----- packages/e2e-tests/plugins/interactive-blocks.php | 3 ++- 2 files changed, 11 insertions(+), 6 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..c4c0ac37519f4 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, 1 ); } if ( ! function_exists( 'wp_interactivity' ) ) { 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 ); } }