Changeset 52186
- Timestamp:
- 11/16/2021 06:04:49 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php
r52062 r52186 71 71 '/' . $this->rest_base . '/(?P<id>[\/\w-]+)', 72 72 array( 73 'args' => array( 74 'id' => array( 75 'description' => __( 'The id of a template' ), 76 'type' => 'string', 77 ), 78 ), 73 79 array( 74 80 'methods' => WP_REST_Server::READABLE, … … 76 82 'permission_callback' => array( $this, 'get_item_permissions_check' ), 77 83 'args' => array( 78 'id' => array( 79 'description' => __( 'The id of a template' ), 80 'type' => 'string', 81 ), 84 'context' => $this->get_context_param( array( 'default' => 'view' ) ), 82 85 ), 83 86 ), … … 232 235 if ( isset( $request['source'] ) && 'theme' === $request['source'] ) { 233 236 wp_delete_post( $template->wp_id, true ); 234 return $this->prepare_item_for_response( get_block_file_template( $request['id'], $this->post_type ), $request ); 237 $request->set_param( 'context', 'edit' ); 238 239 $template = get_block_template( $request['id'], $this->post_type ); 240 $response = $this->prepare_item_for_response( $template, $request ); 241 242 return rest_ensure_response( $response ); 235 243 } 236 244 … … 242 250 $result = wp_insert_post( wp_slash( (array) $changes ), true ); 243 251 } 252 244 253 if ( is_wp_error( $result ) ) { 254 if ( 'db_update_error' === $result->get_error_code() ) { 255 $result->add_data( array( 'status' => 500 ) ); 256 } else { 257 $result->add_data( array( 'status' => 400 ) ); 258 } 245 259 return $result; 246 260 } … … 252 266 } 253 267 254 return $this->prepare_item_for_response( 255 get_block_template( $request['id'], $this->post_type ), 256 $request 257 ); 268 $request->set_param( 'context', 'edit' ); 269 270 $response = $this->prepare_item_for_response( $template, $request ); 271 272 return rest_ensure_response( $response ); 258 273 } 259 274 … … 279 294 */ 280 295 public function create_item( $request ) { 281 $changes = $this->prepare_item_for_database( $request ); 282 $changes->post_name = $request['slug']; 283 $result = wp_insert_post( wp_slash( (array) $changes ), true ); 284 if ( is_wp_error( $result ) ) { 285 return $result; 286 } 287 $posts = get_block_templates( array( 'wp_id' => $result ), $this->post_type ); 296 $prepared_post = $this->prepare_item_for_database( $request ); 297 $prepared_post->post_name = $request['slug']; 298 $post_id = wp_insert_post( wp_slash( (array) $prepared_post ), true ); 299 if ( is_wp_error( $post_id ) ) { 300 if ( 'db_insert_error' === $post_id->get_error_code() ) { 301 $post_id->add_data( array( 'status' => 500 ) ); 302 } else { 303 $post_id->add_data( array( 'status' => 400 ) ); 304 } 305 306 return $post_id; 307 } 308 $posts = get_block_templates( array( 'wp_id' => $post_id ), $this->post_type ); 288 309 if ( ! count( $posts ) ) { 289 return new WP_Error( 'rest_template_insert_error', __( 'No templates exist with that id.' ) );310 return new WP_Error( 'rest_template_insert_error', __( 'No templates exist with that id.' ), array( 'status' => 400 ) ); 290 311 } 291 312 $id = $posts[0]->id; … … 296 317 } 297 318 298 return $this->prepare_item_for_response( 299 get_block_template( $id, $this->post_type ), 300 $request 301 ); 319 $response = $this->prepare_item_for_response( $template, $request ); 320 $response = rest_ensure_response( $response ); 321 322 $response->set_status( 201 ); 323 $response->header( 'Location', rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, $template->id ) ) ); 324 325 return $response; 302 326 } 303 327 … … 334 358 $force = (bool) $request['force']; 335 359 360 $request->set_param( 'context', 'edit' ); 361 336 362 // If we're forcing, then delete permanently. 337 363 if ( $force ) { 338 364 $previous = $this->prepare_item_for_response( $template, $request ); 339 wp_delete_post( $id, true );365 $result = wp_delete_post( $id, true ); 340 366 $response = new WP_REST_Response(); 341 367 $response->set_data( … … 345 371 ) 346 372 ); 347 348 return $response; 349 } 350 351 // Otherwise, only trash if we haven't already. 352 if ( 'trash' === $template->status ) { 373 } else { 374 // Otherwise, only trash if we haven't already. 375 if ( 'trash' === $template->status ) { 376 return new WP_Error( 377 'rest_template_already_trashed', 378 __( 'The template has already been deleted.' ), 379 array( 'status' => 410 ) 380 ); 381 } 382 383 // (Note that internally this falls through to `wp_delete_post()` 384 // if the Trash is disabled.) 385 $result = wp_trash_post( $id ); 386 $template->status = 'trash'; 387 $response = $this->prepare_item_for_response( $template, $request ); 388 } 389 390 if ( ! $result ) { 353 391 return new WP_Error( 354 'rest_ template_already_trashed',355 __( 'The template has already beendeleted.' ),356 array( 'status' => 410 )392 'rest_cannot_delete', 393 __( 'The template cannot be deleted.' ), 394 array( 'status' => 500 ) 357 395 ); 358 396 } 359 397 360 wp_trash_post( $id ); 361 $template->status = 'trash'; 362 return $this->prepare_item_for_response( $template, $request ); 398 return $response; 363 399 } 364 400 … … 393 429 } 394 430 if ( isset( $request['content'] ) ) { 395 $changes->post_content = $request['content']; 431 if ( is_string( $request['content'] ) ) { 432 $changes->post_content = $request['content']; 433 } elseif ( isset( $request['content']['raw'] ) ) { 434 $changes->post_content = $request['content']['raw']; 435 } 396 436 } elseif ( null !== $template && 'custom' !== $template->source ) { 397 437 $changes->post_content = $template->content; 398 438 } 399 439 if ( isset( $request['title'] ) ) { 400 $changes->post_title = $request['title']; 440 if ( is_string( $request['title'] ) ) { 441 $changes->post_title = $request['title']; 442 } elseif ( ! empty( $request['title']['raw'] ) ) { 443 $changes->post_title = $request['title']['raw']; 444 } 401 445 } elseif ( null !== $template && 'custom' !== $template->source ) { 402 446 $changes->post_title = $template->title; … … 434 478 // Restores the more descriptive, specific name for use within this method. 435 479 $template = $item; 436 $result = array( 437 'id' => $template->id, 438 'theme' => $template->theme, 439 'content' => array( 'raw' => $template->content ), 440 'slug' => $template->slug, 441 'source' => $template->source, 442 'type' => $template->type, 443 'description' => $template->description, 444 'title' => array( 445 'raw' => $template->title, 446 'rendered' => $template->title, 447 ), 448 'status' => $template->status, 449 'wp_id' => $template->wp_id, 450 'has_theme_file' => $template->has_theme_file, 451 ); 452 453 if ( 'wp_template_part' === $template->type ) { 454 $result['area'] = $template->area; 455 } 456 457 $result = $this->add_additional_fields_to_object( $result, $request ); 458 459 $response = rest_ensure_response( $result ); 460 $links = $this->prepare_links( $template->id ); 480 481 $fields = $this->get_fields_for_response( $request ); 482 483 // Base fields for every template. 484 $data = array(); 485 486 if ( rest_is_field_included( 'id', $fields ) ) { 487 $data['id'] = $template->id; 488 } 489 490 if ( rest_is_field_included( 'theme', $fields ) ) { 491 $data['theme'] = $template->theme; 492 } 493 494 if ( rest_is_field_included( 'content', $fields ) ) { 495 $data['content'] = array(); 496 } 497 if ( rest_is_field_included( 'content.raw', $fields ) ) { 498 $data['content']['raw'] = $template->content; 499 } 500 501 if ( rest_is_field_included( 'content.block_version', $fields ) ) { 502 $data['content']['block_version'] = block_version( $template->content ); 503 } 504 505 if ( rest_is_field_included( 'slug', $fields ) ) { 506 $data['slug'] = $template->slug; 507 } 508 509 if ( rest_is_field_included( 'source', $fields ) ) { 510 $data['source'] = $template->source; 511 } 512 513 if ( rest_is_field_included( 'type', $fields ) ) { 514 $data['type'] = $template->type; 515 } 516 517 if ( rest_is_field_included( 'description', $fields ) ) { 518 $data['description'] = $template->description; 519 } 520 521 if ( rest_is_field_included( 'title', $fields ) ) { 522 $data['title'] = array(); 523 } 524 525 if ( rest_is_field_included( 'title.raw', $fields ) ) { 526 $data['title']['raw'] = $template->title; 527 } 528 529 if ( rest_is_field_included( 'title.rendered', $fields ) ) { 530 if ( $template->wp_id ) { 531 /** This filter is documented in wp-includes/post-template.php */ 532 $data['title']['rendered'] = apply_filters( 'the_title', $template->title, $template->wp_id ); 533 } else { 534 $data['title']['rendered'] = $template->title; 535 } 536 } 537 538 if ( rest_is_field_included( 'status', $fields ) ) { 539 $data['status'] = $template->status; 540 } 541 542 if ( rest_is_field_included( 'wp_id', $fields ) ) { 543 $data['wp_id'] = (int) $template->wp_id; 544 } 545 546 if ( rest_is_field_included( 'has_theme_file', $fields ) ) { 547 $data['has_theme_file'] = (bool) $template->has_theme_file; 548 } 549 550 if ( rest_is_field_included( 'area', $fields ) && 'wp_template_part' === $template->type ) { 551 $data['area'] = $template->area; 552 } 553 554 $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; 555 $data = $this->add_additional_fields_to_object( $data, $request ); 556 $data = $this->filter_response_by_context( $data, $context ); 557 558 // Wrap the data in a response object. 559 $response = rest_ensure_response( $data ); 560 561 $links = $this->prepare_links( $template->id ); 461 562 $response->add_links( $links ); 462 563 if ( ! empty( $links['self']['href'] ) ) { … … 531 632 public function get_collection_params() { 532 633 return array( 533 'context' => $this->get_context_param( ),634 'context' => $this->get_context_param( array( 'default' => 'view' ) ), 534 635 'wp_id' => array( 535 636 'description' => __( 'Limit to the specified post id.' ), … … 584 685 'context' => array( 'embed', 'view', 'edit' ), 585 686 ), 687 'type' => array( 688 'description' => __( 'Type of template.' ), 689 'type' => 'string', 690 'context' => array( 'embed', 'view', 'edit' ), 691 ), 586 692 'source' => array( 587 693 'description' => __( 'Source of template' ), … … 595 701 'default' => '', 596 702 'context' => array( 'embed', 'view', 'edit' ), 703 'properties' => array( 704 'raw' => array( 705 'description' => __( 'Content for the template, as it exists in the database.' ), 706 'type' => 'string', 707 'context' => array( 'view', 'edit' ), 708 ), 709 'block_version' => array( 710 'description' => __( 'Version of the content block format used by the template.' ), 711 'type' => 'integer', 712 'context' => array( 'edit' ), 713 'readonly' => true, 714 ), 715 ), 597 716 ), 598 717 'title' => array( … … 601 720 'default' => '', 602 721 'context' => array( 'embed', 'view', 'edit' ), 722 'properties' => array( 723 'raw' => array( 724 'description' => __( 'Title for the template, as it exists in the database.' ), 725 'type' => 'string', 726 'context' => array( 'view', 'edit', 'embed' ), 727 ), 728 'rendered' => array( 729 'description' => __( 'HTML title for the template, transformed for display.' ), 730 'type' => 'string', 731 'context' => array( 'view', 'edit', 'embed' ), 732 'readonly' => true, 733 ), 734 ), 603 735 ), 604 736 'description' => array( … … 611 743 'description' => __( 'Status of template.' ), 612 744 'type' => 'string', 745 'enum' => array_keys( get_post_stati( array( 'internal' => false ) ) ), 613 746 'default' => 'publish', 614 747 'context' => array( 'embed', 'view', 'edit' ), -
trunk/tests/phpunit/tests/rest-api/wpRestTemplatesController.php
r52185 r52186 7 7 */ 8 8 9 class WP_REST_Template_Controller_Test extends WP_Test_REST_Controller_Testcase { 9 /** 10 * Tests for REST API for templates. 11 * 12 * @covers WP_REST_Templates_Controller 13 * 14 * @group restapi 15 */ 16 class Tests_REST_WpRestTemplatesController extends WP_Test_REST_Controller_Testcase { 10 17 /** 11 18 * @var int … … 54 61 } 55 62 63 /** 64 * @covers WP_REST_Templates_Controller::get_context_param 65 */ 56 66 public function test_context_param() { 57 // TODO: Implement test_context_param() method. 58 } 59 67 // Collection. 68 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/templates' ); 69 $response = rest_get_server()->dispatch( $request ); 70 $data = $response->get_data(); 71 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 72 $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 73 // Single. 74 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/templates/default//my_template' ); 75 $response = rest_get_server()->dispatch( $request ); 76 $data = $response->get_data(); 77 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 78 $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 79 } 80 81 /** 82 * @covers WP_REST_Templates_Controller::get_items 83 */ 60 84 public function test_get_items() { 61 function find_and_normalize_template_by_id( $templates, $id ) {62 foreach ( $templates as $template ) {63 if ( $template['id'] === $id ) {64 unset( $template['content'] );65 unset( $template['_links'] );66 return $template;67 }68 }69 70 return null;71 }72 73 wp_set_current_user( 0 );74 $request = new WP_REST_Request( 'GET', '/wp/v2/templates' );75 $response = rest_get_server()->dispatch( $request );76 $this->assertErrorResponse( 'rest_cannot_manage_templates', $response, 401 );77 78 85 wp_set_current_user( self::$admin_id ); 79 86 $request = new WP_REST_Request( 'GET', '/wp/v2/templates' ); … … 97 104 'has_theme_file' => false, 98 105 ), 99 find_and_normalize_template_by_id( $data, 'default//my_template' ) 100 ); 101 } 102 106 $this->find_and_normalize_template_by_id( $data, 'default//my_template' ) 107 ); 108 } 109 110 /** 111 * @covers WP_REST_Templates_Controller::get_items 112 */ 113 public function test_get_items_no_permission() { 114 wp_set_current_user( 0 ); 115 $request = new WP_REST_Request( 'GET', '/wp/v2/templates' ); 116 $response = rest_get_server()->dispatch( $request ); 117 $this->assertErrorResponse( 'rest_cannot_manage_templates', $response, 401 ); 118 } 119 120 /** 121 * @covers WP_REST_Templates_Controller::get_item 122 */ 103 123 public function test_get_item() { 104 124 wp_set_current_user( self::$admin_id ); … … 129 149 } 130 150 151 /** 152 * @ticket 54422 153 * @covers WP_REST_Templates_Controller::create_item 154 */ 131 155 public function test_create_item() { 132 156 wp_set_current_user( self::$admin_id ); … … 167 191 } 168 192 193 /** 194 * @ticket 54422 195 * @covers WP_REST_Templates_Controller::create_item 196 */ 197 public function test_create_item_raw() { 198 wp_set_current_user( self::$admin_id ); 199 $request = new WP_REST_Request( 'POST', '/wp/v2/templates' ); 200 $request->set_body_params( 201 array( 202 'slug' => 'my_custom_template_raw', 203 'description' => 'Just a description', 204 'title' => array( 205 'raw' => 'My Template', 206 ), 207 'content' => array( 208 'raw' => 'Content', 209 ), 210 ) 211 ); 212 $response = rest_get_server()->dispatch( $request ); 213 $data = $response->get_data(); 214 unset( $data['_links'] ); 215 unset( $data['wp_id'] ); 216 217 $this->assertSame( 218 array( 219 'id' => 'default//my_custom_template_raw', 220 'theme' => 'default', 221 'content' => array( 222 'raw' => 'Content', 223 ), 224 'slug' => 'my_custom_template_raw', 225 'source' => 'custom', 226 'type' => 'wp_template', 227 'description' => 'Just a description', 228 'title' => array( 229 'raw' => 'My Template', 230 'rendered' => 'My Template', 231 ), 232 'status' => 'publish', 233 'has_theme_file' => false, 234 ), 235 $data 236 ); 237 } 238 239 /** 240 * @covers WP_REST_Templates_Controller::update_item 241 */ 169 242 public function test_update_item() { 170 243 wp_set_current_user( self::$admin_id ); … … 181 254 } 182 255 256 /** 257 * @covers WP_REST_Templates_Controller::update_item 258 */ 259 public function test_update_item_raw() { 260 wp_set_current_user( self::$admin_id ); 261 $request = new WP_REST_Request( 'PUT', '/wp/v2/templates/default//my_template' ); 262 $request->set_body_params( 263 array( 264 'title' => array( 'raw' => 'My new raw Index Title' ), 265 ) 266 ); 267 $response = rest_get_server()->dispatch( $request ); 268 $data = $response->get_data(); 269 $this->assertSame( 'My new raw Index Title', $data['title']['raw'] ); 270 $this->assertSame( 'custom', $data['source'] ); 271 } 272 273 /** 274 * @covers WP_REST_Templates_Controller::delete_item 275 */ 183 276 public function test_delete_item() { 277 // Set up template post. 278 $args = array( 279 'post_type' => 'wp_template', 280 'post_name' => 'my_test_template', 281 'post_title' => 'My Template', 282 'post_content' => 'Content', 283 'post_excerpt' => 'Description of my template.', 284 'tax_input' => array( 285 'wp_theme' => array( 286 get_stylesheet(), 287 ), 288 ), 289 ); 290 $post_id = self::factory()->post->create( $args ); 291 wp_set_post_terms( $post_id, get_stylesheet(), 'wp_theme' ); 292 293 wp_set_current_user( self::$admin_id ); 294 $request = new WP_REST_Request( 'DELETE', '/wp/v2/templates/default//my_test_template' ); 295 $request->set_param( 'force', 'false' ); 296 $response = rest_get_server()->dispatch( $request ); 297 $data = $response->get_data(); 298 $this->assertSame( 'My Template', $data['title']['raw'] ); 299 $this->assertSame( 'trash', $data['status'] ); 300 } 301 302 /** 303 * @covers WP_REST_Templates_Controller::delete_item 304 */ 305 public function test_delete_item_skip_trash() { 306 // Set up template post. 307 $args = array( 308 'post_type' => 'wp_template', 309 'post_name' => 'my_test_template', 310 'post_title' => 'My Template', 311 'post_content' => 'Content', 312 'post_excerpt' => 'Description of my template.', 313 'tax_input' => array( 314 'wp_theme' => array( 315 get_stylesheet(), 316 ), 317 ), 318 ); 319 $post_id = self::factory()->post->create( $args ); 320 wp_set_post_terms( $post_id, get_stylesheet(), 'wp_theme' ); 321 322 wp_set_current_user( self::$admin_id ); 323 $request = new WP_REST_Request( 'DELETE', '/wp/v2/templates/default//my_test_template' ); 324 $request->set_param( 'force', 'true' ); 325 $response = rest_get_server()->dispatch( $request ); 326 $this->assertSame( 200, $response->get_status() ); 327 $data = $response->get_data(); 328 $this->assertTrue( $data['deleted'] ); 329 $this->assertNotEmpty( $data['previous'] ); 330 } 331 332 /** 333 * @covers WP_REST_Templates_Controller::delete_item 334 */ 335 public function test_delete_item_fail() { 184 336 wp_set_current_user( self::$admin_id ); 185 337 $request = new WP_REST_Request( 'DELETE', '/wp/v2/templates/justrandom//template' ); … … 192 344 } 193 345 346 public function test_prepare_item_limit_fields() { 347 wp_set_current_user( self::$admin_id ); 348 349 $endpoint = new WP_REST_Templates_Controller( 'wp_template' ); 350 $request = new WP_REST_Request( 'GET', '/wp/v2/templates/default//my_template' ); 351 $request->set_param( 'context', 'edit' ); 352 $request->set_param( '_fields', 'id,slug' ); 353 $obj = get_block_template( 'default//my_template', 'wp_template' ); 354 $response = $endpoint->prepare_item_for_response( $obj, $request ); 355 $this->assertSame( 356 array( 357 'id', 358 'slug', 359 ), 360 array_keys( $response->get_data() ) 361 ); 362 } 363 364 /** 365 * @ticket 54422 366 * @covers WP_REST_Templates_Controller::get_item_schema 367 */ 194 368 public function test_get_item_schema() { 195 // TODO: Implement test_get_item_schema() method. 196 } 369 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/templates' ); 370 $response = rest_get_server()->dispatch( $request ); 371 $data = $response->get_data(); 372 $properties = $data['schema']['properties']; 373 $this->assertCount( 11, $properties ); 374 $this->assertArrayHasKey( 'id', $properties ); 375 $this->assertArrayHasKey( 'description', $properties ); 376 $this->assertArrayHasKey( 'slug', $properties ); 377 $this->assertArrayHasKey( 'theme', $properties ); 378 $this->assertArrayHasKey( 'type', $properties ); 379 $this->assertArrayHasKey( 'source', $properties ); 380 $this->assertArrayHasKey( 'content', $properties ); 381 $this->assertArrayHasKey( 'title', $properties ); 382 $this->assertArrayHasKey( 'description', $properties ); 383 $this->assertArrayHasKey( 'status', $properties ); 384 $this->assertArrayHasKey( 'wp_id', $properties ); 385 $this->assertArrayHasKey( 'has_theme_file', $properties ); 386 } 387 388 protected function find_and_normalize_template_by_id( $templates, $id ) { 389 foreach ( $templates as $template ) { 390 if ( $template['id'] === $id ) { 391 unset( $template['content'] ); 392 unset( $template['_links'] ); 393 return $template; 394 } 395 } 396 397 return null; 398 } 399 197 400 } -
trunk/tests/qunit/fixtures/wp-api-generated.js
r52184 r52186 5001 5001 "edit" 5002 5002 ], 5003 "default": "view", 5003 5004 "required": false 5004 5005 }, … … 5034 5035 "theme": { 5035 5036 "description": "Theme identifier for the template.", 5037 "type": "string", 5038 "required": false 5039 }, 5040 "type": { 5041 "description": "Type of template.", 5036 5042 "type": "string", 5037 5043 "required": false … … 5044 5050 "string" 5045 5051 ], 5052 "properties": { 5053 "raw": { 5054 "description": "Content for the template, as it exists in the database.", 5055 "type": "string", 5056 "context": [ 5057 "view", 5058 "edit" 5059 ] 5060 }, 5061 "block_version": { 5062 "description": "Version of the content block format used by the template.", 5063 "type": "integer", 5064 "context": [ 5065 "edit" 5066 ], 5067 "readonly": true 5068 } 5069 }, 5046 5070 "required": false 5047 5071 }, … … 5053 5077 "string" 5054 5078 ], 5079 "properties": { 5080 "raw": { 5081 "description": "Title for the template, as it exists in the database.", 5082 "type": "string", 5083 "context": [ 5084 "view", 5085 "edit", 5086 "embed" 5087 ] 5088 }, 5089 "rendered": { 5090 "description": "HTML title for the template, transformed for display.", 5091 "type": "string", 5092 "context": [ 5093 "view", 5094 "edit", 5095 "embed" 5096 ], 5097 "readonly": true 5098 } 5099 }, 5055 5100 "required": false 5056 5101 }, … … 5065 5110 "description": "Status of template.", 5066 5111 "type": "string", 5112 "enum": [ 5113 "publish", 5114 "future", 5115 "draft", 5116 "pending", 5117 "private" 5118 ], 5067 5119 "required": false 5068 5120 } … … 5097 5149 "type": "string", 5098 5150 "required": false 5151 }, 5152 "context": { 5153 "description": "Scope under which the request is made; determines fields present in response.", 5154 "type": "string", 5155 "enum": [ 5156 "view", 5157 "embed", 5158 "edit" 5159 ], 5160 "default": "view", 5161 "required": false 5099 5162 } 5100 5163 } … … 5107 5170 ], 5108 5171 "args": { 5172 "id": { 5173 "description": "The id of a template", 5174 "type": "string", 5175 "required": false 5176 }, 5109 5177 "slug": { 5110 5178 "description": "Unique slug identifying the template.", … … 5116 5184 "theme": { 5117 5185 "description": "Theme identifier for the template.", 5186 "type": "string", 5187 "required": false 5188 }, 5189 "type": { 5190 "description": "Type of template.", 5118 5191 "type": "string", 5119 5192 "required": false … … 5125 5198 "string" 5126 5199 ], 5200 "properties": { 5201 "raw": { 5202 "description": "Content for the template, as it exists in the database.", 5203 "type": "string", 5204 "context": [ 5205 "view", 5206 "edit" 5207 ] 5208 }, 5209 "block_version": { 5210 "description": "Version of the content block format used by the template.", 5211 "type": "integer", 5212 "context": [ 5213 "edit" 5214 ], 5215 "readonly": true 5216 } 5217 }, 5127 5218 "required": false 5128 5219 }, … … 5133 5224 "string" 5134 5225 ], 5226 "properties": { 5227 "raw": { 5228 "description": "Title for the template, as it exists in the database.", 5229 "type": "string", 5230 "context": [ 5231 "view", 5232 "edit", 5233 "embed" 5234 ] 5235 }, 5236 "rendered": { 5237 "description": "HTML title for the template, transformed for display.", 5238 "type": "string", 5239 "context": [ 5240 "view", 5241 "edit", 5242 "embed" 5243 ], 5244 "readonly": true 5245 } 5246 }, 5135 5247 "required": false 5136 5248 }, … … 5143 5255 "description": "Status of template.", 5144 5256 "type": "string", 5257 "enum": [ 5258 "publish", 5259 "future", 5260 "draft", 5261 "pending", 5262 "private" 5263 ], 5145 5264 "required": false 5146 5265 } … … 5152 5271 ], 5153 5272 "args": { 5273 "id": { 5274 "description": "The id of a template", 5275 "type": "string", 5276 "required": false 5277 }, 5154 5278 "force": { 5155 5279 "type": "boolean", … … 5372 5496 "required": false 5373 5497 }, 5498 "type": { 5499 "description": "Type of template.", 5500 "type": "string", 5501 "required": false 5502 }, 5374 5503 "content": { 5375 5504 "description": "Content of template.", … … 5378 5507 "string" 5379 5508 ], 5509 "properties": { 5510 "raw": { 5511 "description": "Content for the template, as it exists in the database.", 5512 "type": "string", 5513 "context": [ 5514 "view", 5515 "edit" 5516 ] 5517 }, 5518 "block_version": { 5519 "description": "Version of the content block format used by the template.", 5520 "type": "integer", 5521 "context": [ 5522 "edit" 5523 ], 5524 "readonly": true 5525 } 5526 }, 5380 5527 "required": false 5381 5528 }, … … 5386 5533 "string" 5387 5534 ], 5535 "properties": { 5536 "raw": { 5537 "description": "Title for the template, as it exists in the database.", 5538 "type": "string", 5539 "context": [ 5540 "view", 5541 "edit", 5542 "embed" 5543 ] 5544 }, 5545 "rendered": { 5546 "description": "HTML title for the template, transformed for display.", 5547 "type": "string", 5548 "context": [ 5549 "view", 5550 "edit", 5551 "embed" 5552 ], 5553 "readonly": true 5554 } 5555 }, 5388 5556 "required": false 5389 5557 }, … … 5396 5564 "description": "Status of template.", 5397 5565 "type": "string", 5566 "enum": [ 5567 "publish", 5568 "future", 5569 "draft", 5570 "pending", 5571 "private" 5572 ], 5398 5573 "required": false 5399 5574 } … … 5458 5633 "edit" 5459 5634 ], 5635 "default": "view", 5460 5636 "required": false 5461 5637 }, … … 5491 5667 "theme": { 5492 5668 "description": "Theme identifier for the template.", 5669 "type": "string", 5670 "required": false 5671 }, 5672 "type": { 5673 "description": "Type of template.", 5493 5674 "type": "string", 5494 5675 "required": false … … 5501 5682 "string" 5502 5683 ], 5684 "properties": { 5685 "raw": { 5686 "description": "Content for the template, as it exists in the database.", 5687 "type": "string", 5688 "context": [ 5689 "view", 5690 "edit" 5691 ] 5692 }, 5693 "block_version": { 5694 "description": "Version of the content block format used by the template.", 5695 "type": "integer", 5696 "context": [ 5697 "edit" 5698 ], 5699 "readonly": true 5700 } 5701 }, 5503 5702 "required": false 5504 5703 }, … … 5510 5709 "string" 5511 5710 ], 5711 "properties": { 5712 "raw": { 5713 "description": "Title for the template, as it exists in the database.", 5714 "type": "string", 5715 "context": [ 5716 "view", 5717 "edit", 5718 "embed" 5719 ] 5720 }, 5721 "rendered": { 5722 "description": "HTML title for the template, transformed for display.", 5723 "type": "string", 5724 "context": [ 5725 "view", 5726 "edit", 5727 "embed" 5728 ], 5729 "readonly": true 5730 } 5731 }, 5512 5732 "required": false 5513 5733 }, … … 5522 5742 "description": "Status of template.", 5523 5743 "type": "string", 5744 "enum": [ 5745 "publish", 5746 "future", 5747 "draft", 5748 "pending", 5749 "private" 5750 ], 5524 5751 "required": false 5525 5752 }, … … 5559 5786 "type": "string", 5560 5787 "required": false 5788 }, 5789 "context": { 5790 "description": "Scope under which the request is made; determines fields present in response.", 5791 "type": "string", 5792 "enum": [ 5793 "view", 5794 "embed", 5795 "edit" 5796 ], 5797 "default": "view", 5798 "required": false 5561 5799 } 5562 5800 } … … 5569 5807 ], 5570 5808 "args": { 5809 "id": { 5810 "description": "The id of a template", 5811 "type": "string", 5812 "required": false 5813 }, 5571 5814 "slug": { 5572 5815 "description": "Unique slug identifying the template.", … … 5578 5821 "theme": { 5579 5822 "description": "Theme identifier for the template.", 5823 "type": "string", 5824 "required": false 5825 }, 5826 "type": { 5827 "description": "Type of template.", 5580 5828 "type": "string", 5581 5829 "required": false … … 5587 5835 "string" 5588 5836 ], 5837 "properties": { 5838 "raw": { 5839 "description": "Content for the template, as it exists in the database.", 5840 "type": "string", 5841 "context": [ 5842 "view", 5843 "edit" 5844 ] 5845 }, 5846 "block_version": { 5847 "description": "Version of the content block format used by the template.", 5848 "type": "integer", 5849 "context": [ 5850 "edit" 5851 ], 5852 "readonly": true 5853 } 5854 }, 5589 5855 "required": false 5590 5856 }, … … 5595 5861 "string" 5596 5862 ], 5863 "properties": { 5864 "raw": { 5865 "description": "Title for the template, as it exists in the database.", 5866 "type": "string", 5867 "context": [ 5868 "view", 5869 "edit", 5870 "embed" 5871 ] 5872 }, 5873 "rendered": { 5874 "description": "HTML title for the template, transformed for display.", 5875 "type": "string", 5876 "context": [ 5877 "view", 5878 "edit", 5879 "embed" 5880 ], 5881 "readonly": true 5882 } 5883 }, 5597 5884 "required": false 5598 5885 }, … … 5605 5892 "description": "Status of template.", 5606 5893 "type": "string", 5894 "enum": [ 5895 "publish", 5896 "future", 5897 "draft", 5898 "pending", 5899 "private" 5900 ], 5607 5901 "required": false 5608 5902 }, … … 5619 5913 ], 5620 5914 "args": { 5915 "id": { 5916 "description": "The id of a template", 5917 "type": "string", 5918 "required": false 5919 }, 5621 5920 "force": { 5622 5921 "type": "boolean", … … 5839 6138 "required": false 5840 6139 }, 6140 "type": { 6141 "description": "Type of template.", 6142 "type": "string", 6143 "required": false 6144 }, 5841 6145 "content": { 5842 6146 "description": "Content of template.", … … 5845 6149 "string" 5846 6150 ], 6151 "properties": { 6152 "raw": { 6153 "description": "Content for the template, as it exists in the database.", 6154 "type": "string", 6155 "context": [ 6156 "view", 6157 "edit" 6158 ] 6159 }, 6160 "block_version": { 6161 "description": "Version of the content block format used by the template.", 6162 "type": "integer", 6163 "context": [ 6164 "edit" 6165 ], 6166 "readonly": true 6167 } 6168 }, 5847 6169 "required": false 5848 6170 }, … … 5853 6175 "string" 5854 6176 ], 6177 "properties": { 6178 "raw": { 6179 "description": "Title for the template, as it exists in the database.", 6180 "type": "string", 6181 "context": [ 6182 "view", 6183 "edit", 6184 "embed" 6185 ] 6186 }, 6187 "rendered": { 6188 "description": "HTML title for the template, transformed for display.", 6189 "type": "string", 6190 "context": [ 6191 "view", 6192 "edit", 6193 "embed" 6194 ], 6195 "readonly": true 6196 } 6197 }, 5855 6198 "required": false 5856 6199 }, … … 5863 6206 "description": "Status of template.", 5864 6207 "type": "string", 6208 "enum": [ 6209 "publish", 6210 "future", 6211 "draft", 6212 "pending", 6213 "private" 6214 ], 5865 6215 "required": false 5866 6216 },
Note: See TracChangeset
for help on using the changeset viewer.