Changeset 59093
- Timestamp:
- 09/26/2024 12:45:41 PM (2 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-block-supports.php
r58112 r59093 105 105 106 106 $block_attributes = array_key_exists( 'attrs', self::$block_to_render ) && is_array( self::$block_to_render['attrs'] ) 107 ? self::$block_to_render['attrs']107 ? $block_type->prepare_attributes_for_render( self::$block_to_render['attrs'] ) 108 108 : array(); 109 109 -
trunk/tests/phpunit/tests/blocks/render.php
r56994 r59093 288 288 289 289 /** 290 * @ticket 62114 291 */ 292 public function test_dynamic_block_with_default_attributes() { 293 $settings = array( 294 'attributes' => array( 295 'content' => array( 296 'type' => 'string', 297 'default' => 'Default content.', 298 ), 299 'align' => array( 300 'type' => 'string', 301 'default' => 'full', 302 ), 303 'backgroundColor' => array( 304 'type' => 'string', 305 'default' => 'blueberry-1', 306 ), 307 'textColor' => array( 308 'type' => 'string', 309 'default' => 'white', 310 ), 311 ), 312 'supports' => array( 313 'align' => array( 'wide', 'full' ), 314 'color' => array( 315 'background' => true, 316 'text' => true, 317 ), 318 ), 319 'render_callback' => function ( $attributes ) { 320 return '<p ' . get_block_wrapper_attributes() . '>' . $attributes['content'] . '</p>'; 321 }, 322 ); 323 register_block_type( 'core/dynamic', $settings ); 324 325 $post_content = 326 'before' . 327 '<!-- wp:core/dynamic --><!-- /wp:core/dynamic -->' . 328 'after'; 329 330 $updated_post_content = do_blocks( $post_content ); 331 $this->assertSame( 332 $updated_post_content, 333 'before' . 334 '<p class="alignfull wp-block-dynamic has-text-color has-white-color has-background has-blueberry-1-background-color">Default content.</p>' . 335 'after' 336 ); 337 } 338 339 /** 290 340 * @ticket 45109 291 341 */
Note: See TracChangeset
for help on using the changeset viewer.