Changeset 55673
- Timestamp:
- 04/21/2023 10:41:58 AM (17 months ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/post.php
r55365 r55673 2179 2179 * 2180 2180 * @since 5.0.0 2181 * @since 6.3.0 Added `selectors` field. 2181 2182 * 2182 2183 * @return array An associative array of registered block data. … … 2193 2194 'provides_context' => 'providesContext', 2194 2195 'uses_context' => 'usesContext', 2196 'selectors' => 'selectors', 2195 2197 'supports' => 'supports', 2196 2198 'category' => 'category', -
trunk/src/wp-includes/blocks.php
r55641 r55673 301 301 * @since 5.9.0 Added support for `variations` and `viewScript` fields. 302 302 * @since 6.1.0 Added support for `render` field. 303 * @since 6.3.0 Added `selectors` field. 303 304 * 304 305 * @param string $file_or_folder Path to the JSON file with metadata definition for … … 383 384 'providesContext' => 'provides_context', 384 385 'usesContext' => 'uses_context', 386 'selectors' => 'selectors', 385 387 'supports' => 'supports', 386 388 'styles' => 'styles', -
trunk/src/wp-includes/class-wp-block-type.php
r54895 r55673 117 117 */ 118 118 public $variations = array(); 119 120 /** 121 * Custom CSS selectors for theme.json style generation. 122 * 123 * @since 6.3.0 124 * @var array 125 */ 126 public $selectors = array(); 119 127 120 128 /** … … 246 254 * `editor_style_handles`, and `style_handles` properties. 247 255 * Deprecated the `editor_script`, `script`, `view_script`, `editor_style`, and `style` properties. 256 * @since 6.3.0 Added the `selectors` property. 248 257 * 249 258 * @see register_block_type() … … 269 278 * @type array[] $styles Alternative block styles. 270 279 * @type array[] $variations Block variations. 280 * @type array $selectors Custom CSS selectors for theme.json style generation. 271 281 * @type array|null $supports Supported features. 272 282 * @type array|null $example Structured data for the block preview. -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php
r54670 r55673 238 238 * @since 5.5.0 239 239 * @since 5.9.0 Renamed `$block_type` to `$item` to match parent class for PHP 8 named parameter support. 240 * @since 6.3.0 Added `selectors` field. 240 241 * 241 242 * @param WP_Block_Type $item Block type data. … … 279 280 'provides_context', 280 281 'uses_context', 282 'selectors', 281 283 'supports', 282 284 'styles', … … 380 382 * 381 383 * @since 5.5.0 384 * @since 6.3.0 Added `selectors` field. 382 385 * 383 386 * @return array Item schema data. … … 516 519 'type' => 'string', 517 520 ), 521 'context' => array( 'embed', 'view', 'edit' ), 522 'readonly' => true, 523 ), 524 'selectors' => array( 525 'description' => __( 'Custom CSS selectors.' ), 526 'type' => 'object', 527 'default' => array(), 528 'properties' => array(), 518 529 'context' => array( 'embed', 'view', 'edit' ), 519 530 'readonly' => true, -
trunk/tests/phpunit/data/blocks/notice/block.json
r54155 r55673 27 27 "type": "string" 28 28 } 29 }, 30 "selectors": { 31 "root": ".wp-block-notice" 29 32 }, 30 33 "supports": { -
trunk/tests/phpunit/tests/admin/includesPost.php
r54244 r55673 827 827 'render_callback' => 'foo', 828 828 'ancestor' => array( 'core/test-ancestor' ), 829 'selectors' => array( 'root' => '.wp-block-test' ), 829 830 ); 830 831 … … 846 847 ), 847 848 'usesContext' => array(), 849 'selectors' => array( 'root' => '.wp-block-test' ), 848 850 'category' => 'common', 849 851 'styles' => array(), -
trunk/tests/phpunit/tests/blocks/register.php
r55486 r55673 484 484 * @ticket 50263 485 485 * @ticket 50328 486 * @ticket 57585 486 487 */ 487 488 public function test_block_registers_with_metadata_fixture() { … … 516 517 ); 517 518 $this->assertSameSets( array( 'groupId' ), $result->uses_context ); 519 // @ticket 57585 520 $this->assertSame( 521 array( 'root' => '.wp-block-notice' ), 522 $result->selectors, 523 'Block type should contain selectors from metadata.' 524 ); 518 525 $this->assertSame( 519 526 array( -
trunk/tests/phpunit/tests/rest-api/rest-block-type-controller.php
r55457 r55673 197 197 /** 198 198 * @ticket 47620 199 * @ticket 57585 199 200 */ 200 201 public function test_get_item_invalid() { … … 217 218 'parent' => 'invalid_parent', 218 219 'ancestor' => 'invalid_ancestor', 220 'selectors' => 'invalid_selectors', 219 221 'supports' => 'invalid_supports', 220 222 'styles' => array(), … … 248 250 $this->assertSameSets( array( 'invalid_parent' ), $data['parent'] ); 249 251 $this->assertSameSets( array( 'invalid_ancestor' ), $data['ancestor'] ); 252 $this->assertSameSets( array(), $data['selectors'], 'invalid selectors defaults to empty array' ); 250 253 $this->assertSameSets( array(), $data['supports'] ); 251 254 $this->assertSameSets( array(), $data['styles'] ); … … 266 269 /** 267 270 * @ticket 47620 271 * @ticket 57585 268 272 */ 269 273 public function test_get_item_defaults() { … … 285 289 'parent' => false, 286 290 'ancestor' => false, 291 'selectors' => false, 287 292 'supports' => false, 288 293 'styles' => false, … … 317 322 $this->assertSameSets( array(), $data['parent'] ); 318 323 $this->assertSameSets( array(), $data['ancestor'] ); 324 $this->assertSameSets( array(), $data['selectors'], 'selectors defaults to empty array' ); 319 325 $this->assertSameSets( array(), $data['supports'] ); 320 326 $this->assertSameSets( array(), $data['styles'] ); … … 535 541 /** 536 542 * @ticket 47620 543 * @ticket 57585 537 544 */ 538 545 public function test_get_item_schema() { … … 542 549 $data = $response->get_data(); 543 550 $properties = $data['schema']['properties']; 544 $this->assertCount( 2 8, $properties );551 $this->assertCount( 29, $properties ); 545 552 $this->assertArrayHasKey( 'api_version', $properties ); 546 553 $this->assertArrayHasKey( 'title', $properties ); … … 552 559 $this->assertArrayHasKey( 'name', $properties ); 553 560 $this->assertArrayHasKey( 'attributes', $properties ); 561 $this->assertArrayHasKey( 'selectors', $properties, 'schema must contain selectors' ); 554 562 $this->assertArrayHasKey( 'supports', $properties ); 555 563 $this->assertArrayHasKey( 'category', $properties );
Note: See TracChangeset
for help on using the changeset viewer.