Changeset 57826
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/interactivity-api/interactivity-api.php
r57774 r57826 58 58 59 59 /* 60 * Uses a priority of 20 to ensure that other filters can add additional60 * Uses a priority of 100 to ensure that other filters can add additional 61 61 * directives before the processing starts. 62 62 */ 63 add_filter( 'render_block_' . $block_name, $process_interactive_blocks, 20, 2 );63 add_filter( 'render_block_' . $block_name, $process_interactive_blocks, 100, 2 ); 64 64 } 65 65 } … … 67 67 return $parsed_block; 68 68 } 69 add_filter( 'render_block_data', 'wp_interactivity_process_directives_of_interactive_blocks' ); 69 /* 70 * Uses a priority of 100 to ensure that other filters can add additional attributes to 71 * $parsed_block before the processing starts. 72 */ 73 add_filter( 'render_block_data', 'wp_interactivity_process_directives_of_interactive_blocks', 100, 1 ); 70 74 71 75 /** -
trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPIFunctions.php
r57822 r57826 309 309 $this->data_wp_test_processor_count = 0; 310 310 do_blocks( $post_content ); 311 unregister_block_type( 'test/custom-directive-block' ); 311 312 $this->assertEquals( 2, $this->data_wp_test_processor_count ); 313 $directive_processors->setValue( null, $old_directive_processors ); 314 } 315 316 /** 317 * Tests that directives are server side processing even if the $parsed_block variable is edited by a filter. 318 * 319 * @ticket 60743 320 * 321 * @covers ::wp_interactivity_process_directives_of_interactive_blocks 322 */ 323 public function test_process_directives_when_block_is_filtered() { 324 register_block_type( 325 'test/custom-directive-block', 326 array( 327 'render_callback' => function () { 328 return '<input data-wp-interactive="nameSpace" ' . wp_interactivity_data_wp_context( array( 'text' => 'test' ) ) . ' data-wp-bind--value="context.text" />'; 329 }, 330 'supports' => array( 331 'interactivity' => true, 332 ), 333 ) 334 ); 335 function test_render_block_data( $parsed_block ) { 336 $parsed_block['testKey'] = true; 337 return $parsed_block; 338 } 339 add_filter( 'render_block_data', 'test_render_block_data' ); 340 $post_content = '<!-- wp:test/custom-directive-block /-->'; 341 $processed_content = do_blocks( $post_content ); 342 $processor = new WP_HTML_Tag_Processor( $processed_content ); 343 $processor->next_tag( array( 'data-wp-interactive' => 'nameSpace' ) ); 344 remove_filter( 'render_block_data', 'test_render_block_data' ); 312 345 unregister_block_type( 'test/custom-directive-block' ); 313 $ directive_processors->setValue( null, $old_directive_processors);346 $this->assertEquals( 'test', $processor->get_attribute( 'value' ) ); 314 347 } 315 348
Note: See TracChangeset
for help on using the changeset viewer.