Skip to content

Commit

Permalink
Interactivity API: Fix interactivity api e2e tests. (#59836)
Browse files Browse the repository at this point in the history
* Use same prioprity than in Core

* Backport priority filter

* Add argument

Co-authored-by: c4rl0sbr4v0 <cbravobernal@git.wordpress.org>
Co-authored-by: sirreal <jonsurrell@git.wordpress.org>
  • Loading branch information
3 people authored and getdave committed Mar 19, 2024
1 parent d50bbf7 commit b9e73ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) ) {
Expand Down
3 changes: 2 additions & 1 deletion packages/e2e-tests/plugins/interactive-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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
);
}
}
Expand Down

0 comments on commit b9e73ef

Please sign in to comment.