Changeset 59023
- Timestamp:
- 09/16/2024 11:31:17 AM (4 weeks ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/meta.php
r58962 r59023 1370 1370 * @since 5.5.0 The `$default` argument was added to the arguments array. 1371 1371 * @since 6.4.0 The `$revisions_enabled` argument was added to the arguments array. 1372 * @since 6.7.0 The `label` argument was added to the arguments array. 1372 1373 * 1373 1374 * @param string $object_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', … … 1381 1382 * @type string $type The type of data associated with this meta key. 1382 1383 * Valid values are 'string', 'boolean', 'integer', 'number', 'array', and 'object'. 1384 * @type string $label A human-readable label of the data attached to this meta key. 1383 1385 * @type string $description A description of the data attached to this meta key. 1384 1386 * @type bool $single Whether the meta key has one value per object, or an array of values per object. … … 1413 1415 'object_subtype' => '', 1414 1416 'type' => 'string', 1417 'label' => '', 1415 1418 'description' => '', 1416 1419 'default' => '', -
trunk/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php
r58831 r59023 479 479 $default_schema = array( 480 480 'type' => $default_args['type'], 481 'title' => empty( $args['label'] ) ? '' : $args['label'], 481 482 'description' => empty( $args['description'] ) ? '' : $args['description'], 482 483 'default' => isset( $args['default'] ) ? $args['default'] : null, -
trunk/tests/phpunit/tests/meta/registerMeta.php
r56714 r59023 93 93 'flight_number' => array( 94 94 'type' => 'string', 95 'label' => '', 95 96 'description' => '', 96 97 'single' => false, … … 118 119 'category_icon' => array( 119 120 'type' => 'string', 121 'label' => '', 120 122 'description' => '', 121 123 'single' => false, … … 173 175 'flight_number' => array( 174 176 'type' => 'string', 177 'label' => '', 175 178 'description' => '', 176 179 'single' => false, … … 257 260 } 258 261 262 /** 263 * @ticket 61998 264 */ 265 public function test_get_registered_meta_keys_label_arg() { 266 register_meta( 'post', 'registered_key1', array( 'label' => 'Field label' ) ); 267 268 $meta_keys = get_registered_meta_keys( 'post' ); 269 270 unregister_meta_key( 'post', 'registered_key1' ); 271 272 $this->assertSame( 'Field label', $meta_keys['registered_key1']['label'] ); 273 } 274 259 275 public function test_get_registered_meta_keys_description_arg() { 260 276 register_meta( 'post', 'registered_key1', array( 'description' => 'I\'m just a field, take a good look at me' ) ); … … 341 357 'flight_number' => array( 342 358 'type' => 'string', 359 'label' => '', 343 360 'description' => '', 344 361 'single' => false, … … 395 412 'flight_number' => array( 396 413 'type' => 'string', 414 'label' => '', 397 415 'description' => '', 398 416 'single' => false, -
trunk/tests/phpunit/tests/rest-api/rest-post-meta-fields.php
r58948 r59023 241 241 'show_in_rest' => true, 242 242 'default' => 'Goodnight Moon', 243 ) 244 ); 245 246 register_post_meta( 247 'post', 248 'with_label', 249 array( 250 'type' => 'string', 251 'single' => true, 252 'show_in_rest' => true, 253 'label' => 'Meta Label', 254 'default' => '', 243 255 ) 244 256 ); … … 3092 3104 3093 3105 $schema = $response->get_data()['schema']['properties']['meta']['properties']['with_default']; 3094 $this->assertArrayHasKey( 'default', $schema ); 3095 $this->assertSame( 'Goodnight Moon', $schema['default'] ); 3106 $this->assertArrayHasKey( 'default', $schema, 'Schema is expected to have the default property' ); 3107 $this->assertSame( 'Goodnight Moon', $schema['default'], 'Schema default is expected to be defined and contain the value of the meta default argument.' ); 3108 } 3109 3110 /** 3111 * @ticket 61998 3112 */ 3113 public function test_title_is_added_to_schema() { 3114 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts' ); 3115 $response = rest_do_request( $request ); 3116 3117 $schema = $response->get_data()['schema']['properties']['meta']['properties']['with_label']; 3118 3119 $this->assertArrayHasKey( 'title', $schema, 'Schema is expected to have the title property' ); 3120 $this->assertSame( 'Meta Label', $schema['title'], 'Schema title is expected to be defined and contain the value of the meta label argument.' ); 3096 3121 } 3097 3122 -
trunk/tests/phpunit/tests/user/wpRegisterPersistedPreferencesMeta.php
r56714 r59023 32 32 array( 33 33 'type' => 'object', 34 'label' => '', 34 35 'description' => '', 35 36 'single' => true,
Note: See TracChangeset
for help on using the changeset viewer.