Changeset 51962 for trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php
- Timestamp:
- 10/31/2021 11:15:10 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php
r51961 r51962 181 181 $taxonomies = wp_list_pluck( $taxonomies, 'name' ); 182 182 $base = ! empty( $post_type->rest_base ) ? $post_type->rest_base : $post_type->name; 183 $namespace = ! empty( $post_type->rest_namespace ) ? $post_type->rest_namespace : 'wp/v2'; 183 184 $supports = get_all_post_type_supports( $post_type->name ); 184 185 … … 233 234 } 234 235 236 if ( in_array( 'rest_namespace', $fields, true ) ) { 237 $data['rest_namespace'] = $namespace; 238 } 239 235 240 $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; 236 241 $data = $this->add_additional_fields_to_object( $data, $request ); … … 246 251 ), 247 252 'https://api.w.org/items' => array( 248 'href' => rest_url( sprintf( 'wp/v2/%s', $base ) ),253 'href' => rest_url( rest_get_route_for_post_type_items( $post_type->name ) ), 249 254 ), 250 255 ) … … 270 275 * @since 4.7.0 271 276 * @since 4.8.0 The `supports` property was added. 272 * @since 5.9.0 The `visibility` property wasadded.277 * @since 5.9.0 The `visibility` and `rest_namespace` properties were added. 273 278 * 274 279 * @return array Item schema data. … … 284 289 'type' => 'object', 285 290 'properties' => array( 286 'capabilities' => array(291 'capabilities' => array( 287 292 'description' => __( 'All capabilities used by the post type.' ), 288 293 'type' => 'object', … … 290 295 'readonly' => true, 291 296 ), 292 'description' => array(297 'description' => array( 293 298 'description' => __( 'A human-readable description of the post type.' ), 294 299 'type' => 'string', … … 296 301 'readonly' => true, 297 302 ), 298 'hierarchical' => array(303 'hierarchical' => array( 299 304 'description' => __( 'Whether or not the post type should have children.' ), 300 305 'type' => 'boolean', … … 302 307 'readonly' => true, 303 308 ), 304 'viewable' => array(309 'viewable' => array( 305 310 'description' => __( 'Whether or not the post type can be viewed.' ), 306 311 'type' => 'boolean', … … 308 313 'readonly' => true, 309 314 ), 310 'labels' => array(315 'labels' => array( 311 316 'description' => __( 'Human-readable labels for the post type for various contexts.' ), 312 317 'type' => 'object', … … 314 319 'readonly' => true, 315 320 ), 316 'name' => array(321 'name' => array( 317 322 'description' => __( 'The title for the post type.' ), 318 323 'type' => 'string', … … 320 325 'readonly' => true, 321 326 ), 322 'slug' => array(327 'slug' => array( 323 328 'description' => __( 'An alphanumeric identifier for the post type.' ), 324 329 'type' => 'string', … … 326 331 'readonly' => true, 327 332 ), 328 'supports' => array(333 'supports' => array( 329 334 'description' => __( 'All features, supported by the post type.' ), 330 335 'type' => 'object', … … 332 337 'readonly' => true, 333 338 ), 334 'taxonomies' => array(339 'taxonomies' => array( 335 340 'description' => __( 'Taxonomies associated with post type.' ), 336 341 'type' => 'array', … … 341 346 'readonly' => true, 342 347 ), 343 'rest_base' => array(348 'rest_base' => array( 344 349 'description' => __( 'REST base route for the post type.' ), 345 350 'type' => 'string', … … 347 352 'readonly' => true, 348 353 ), 349 'visibility' => array( 354 'rest_namespace' => array( 355 'description' => __( 'REST route\'s namespace for the post type.' ), 356 'type' => 'string', 357 'context' => array( 'view', 'edit', 'embed' ), 358 'readonly' => true, 359 ), 360 'visibility' => array( 350 361 'description' => __( 'The visibility settings for the post type.' ), 351 362 'type' => 'object',
Note: See TracChangeset
for help on using the changeset viewer.