Changeset 57493
- Timestamp:
- 01/31/2024 09:09:22 AM (8 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r57372 r57493 65 65 'editorStyle' => 'editor-style', 66 66 'style' => 'style', 67 'viewStyle' => 'view-style', 67 68 ); 68 69 $asset_handle = str_replace( '/', '-', $block_name ) . … … 327 328 * @since 6.3.0 Added `selectors` field. 328 329 * @since 6.4.0 Added support for `blockHooks` field. 330 * @since 6.5.0 Added support for `viewStyle` field. 329 331 * 330 332 * @param string $file_or_folder Path to the JSON file with metadata definition for … … 504 506 'editorStyle' => 'editor_style_handles', 505 507 'style' => 'style_handles', 508 'viewStyle' => 'view_style_handles', 506 509 ); 507 510 foreach ( $style_fields as $metadata_field_name => $settings_field_name ) { -
trunk/src/wp-includes/class-wp-block-type.php
r57315 r57493 234 234 */ 235 235 public $style_handles = array(); 236 237 /** 238 * Block type front end only style handles. 239 * 240 * @since 6.5.0 241 * @var string[] 242 */ 243 public $view_style_handles = array(); 236 244 237 245 /** … … 279 287 * @since 6.3.0 Added the `selectors` property. 280 288 * @since 6.4.0 Added the `block_hooks` property. 289 * @since 6.5.0 Added the `view_style_handles` property. 281 290 * 282 291 * @see register_block_type() … … 316 325 * @type string[] $editor_style_handles Block type editor only style handles. 317 326 * @type string[] $style_handles Block type front end and editor style handles. 327 * @type string[] $view_style_handles Block type front end only style handles. 318 328 * } 319 329 */ -
trunk/src/wp-includes/class-wp-block.php
r56549 r57493 281 281 } 282 282 283 if ( ( ! empty( $this->block_type->view_style_handles ) ) ) { 284 foreach ( $this->block_type->view_style_handles as $view_style_handle ) { 285 wp_enqueue_style( $view_style_handle ); 286 } 287 } 288 283 289 /** 284 290 * Filters the content of a single block. -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php
r56676 r57493 293 293 'editor_style_handles', 294 294 'style_handles', 295 'view_style_handles', 295 296 'variations', 296 297 'block_hooks', … … 603 604 'readonly' => true, 604 605 ), 606 'view_style_handles' => array( 607 'description' => __( 'Public facing style handles.' ), 608 'type' => array( 'array' ), 609 'default' => array(), 610 'items' => array( 611 'type' => 'string', 612 ), 613 'context' => array( 'embed', 'view', 'edit' ), 614 'readonly' => true, 615 ), 605 616 'styles' => array( 606 617 'description' => __( 'Block style variations.' ), -
trunk/tests/phpunit/data/blocks/notice/block.json
r57336 r57493 71 71 "editorStyle": "tests-notice-editor-style", 72 72 "style": [ "tests-notice-style", "tests-notice-style-2" ], 73 "viewStyle": [ "tests-notice-view-style" ], 73 74 "render": "file:./render.php" 74 75 } -
trunk/tests/phpunit/tests/blocks/register.php
r57068 r57493 157 157 generate_block_asset_handle( $block_name, 'style' ) 158 158 ); 159 // @ticket 59673 160 $this->assertSame( 161 'unit-tests-my-block-view-style', 162 generate_block_asset_handle( $block_name, 'viewStyle' ), 163 'asset handle for viewStyle is not generated correctly' 164 ); 159 165 } 160 166 … … 440 446 public function test_success_register_block_style_handle() { 441 447 $metadata = array( 442 'file' => DIR_TESTDATA . '/blocks/notice/block.json', 443 'name' => 'unit-tests/test-block', 444 'style' => 'file:./block.css', 448 'file' => DIR_TESTDATA . '/blocks/notice/block.json', 449 'name' => 'unit-tests/test-block', 450 'style' => 'file:./block.css', 451 'viewStyle' => 'file:./block-view.css', 445 452 ); 446 453 $result = register_block_style_handle( $metadata, 'style' ); … … 453 460 wp_normalize_path( realpath( DIR_TESTDATA . '/blocks/notice/block.css' ) ), 454 461 wp_normalize_path( wp_styles()->get_data( 'unit-tests-test-block-style', 'path' ) ) 462 ); 463 464 // Test viewStyle property 465 $result = register_block_style_handle( $metadata, 'viewStyle' ); 466 $this->assertSame( 'unit-tests-test-block-view-style', $result ); 467 468 // @ticket 59673 469 $this->assertSame( 470 wp_normalize_path( realpath( DIR_TESTDATA . '/blocks/notice/block-view.css' ) ), 471 wp_normalize_path( wp_styles()->get_data( 'unit-tests-test-block-view-style', 'path' ) ), 472 'viewStyle asset path is not correct' 455 473 ); 456 474 … … 838 856 $result->style_handles 839 857 ); 858 // @ticket 59673 859 $this->assertSameSets( 860 array( 'tests-notice-view-style' ), 861 $result->view_style_handles, 862 'parsed view_style_handles is not correct' 863 ); 840 864 841 865 // @ticket 50328 … … 843 867 wp_normalize_path( realpath( DIR_TESTDATA . '/blocks/notice/block.css' ) ), 844 868 wp_normalize_path( wp_styles()->get_data( 'unit-tests-test-block-style', 'path' ) ) 869 ); 870 871 // @ticket 59673 872 $this->assertSame( 873 wp_normalize_path( realpath( DIR_TESTDATA . '/blocks/notice/block-view.css' ) ), 874 wp_normalize_path( wp_styles()->get_data( 'unit-tests-test-block-view-style', 'path' ) ), 875 'viewStyle asset path is not correct' 845 876 ); 846 877 -
trunk/tests/phpunit/tests/rest-api/rest-block-type-controller.php
r57315 r57493 558 558 $data = $response->get_data(); 559 559 $properties = $data['schema']['properties']; 560 $this->assertCount( 3 0, $properties );560 $this->assertCount( 31, $properties ); 561 561 $this->assertArrayHasKey( 'api_version', $properties ); 562 562 $this->assertArrayHasKey( 'name', $properties ); … … 583 583 $this->assertArrayHasKey( 'editor_style_handles', $properties ); 584 584 $this->assertArrayHasKey( 'style_handles', $properties ); 585 $this->assertArrayHasKey( 'view_style_handles', $properties, 'schema must contain view_style_handles' ); 585 586 $this->assertArrayHasKey( 'is_dynamic', $properties ); 586 587 // Deprecated properties.
Note: See TracChangeset
for help on using the changeset viewer.