changeset 18 | be944660c56a |
parent 16 | a86126ab1dd4 |
child 19 | 3d72ae0968f4 |
17:34716fd837a4 | 18:be944660c56a |
---|---|
73 $this->namespace, |
73 $this->namespace, |
74 '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base, |
74 '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base, |
75 array( |
75 array( |
76 'args' => array( |
76 'args' => array( |
77 'parent' => array( |
77 'parent' => array( |
78 'description' => __( 'The ID for the parent of the object.' ), |
78 'description' => __( 'The ID for the parent of the revision.' ), |
79 'type' => 'integer', |
79 'type' => 'integer', |
80 ), |
80 ), |
81 ), |
81 ), |
82 array( |
82 array( |
83 'methods' => WP_REST_Server::READABLE, |
83 'methods' => WP_REST_Server::READABLE, |
93 $this->namespace, |
93 $this->namespace, |
94 '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base . '/(?P<id>[\d]+)', |
94 '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base . '/(?P<id>[\d]+)', |
95 array( |
95 array( |
96 'args' => array( |
96 'args' => array( |
97 'parent' => array( |
97 'parent' => array( |
98 'description' => __( 'The ID for the parent of the object.' ), |
98 'description' => __( 'The ID for the parent of the revision.' ), |
99 'type' => 'integer', |
99 'type' => 'integer', |
100 ), |
100 ), |
101 'id' => array( |
101 'id' => array( |
102 'description' => __( 'Unique identifier for the object.' ), |
102 'description' => __( 'Unique identifier for the revision.' ), |
103 'type' => 'integer', |
103 'type' => 'integer', |
104 ), |
104 ), |
105 ), |
105 ), |
106 array( |
106 array( |
107 'methods' => WP_REST_Server::READABLE, |
107 'methods' => WP_REST_Server::READABLE, |
360 * Checks if a given request has access to get a specific revision. |
360 * Checks if a given request has access to get a specific revision. |
361 * |
361 * |
362 * @since 4.7.0 |
362 * @since 4.7.0 |
363 * |
363 * |
364 * @param WP_REST_Request $request Full details about the request. |
364 * @param WP_REST_Request $request Full details about the request. |
365 * @return bool|WP_Error True if the request has read access for the item, WP_Error object otherwise. |
365 * @return true|WP_Error True if the request has read access for the item, WP_Error object otherwise. |
366 */ |
366 */ |
367 public function get_item_permissions_check( $request ) { |
367 public function get_item_permissions_check( $request ) { |
368 return $this->get_items_permissions_check( $request ); |
368 return $this->get_items_permissions_check( $request ); |
369 } |
369 } |
370 |
370 |
395 * Checks if a given request has access to delete a revision. |
395 * Checks if a given request has access to delete a revision. |
396 * |
396 * |
397 * @since 4.7.0 |
397 * @since 4.7.0 |
398 * |
398 * |
399 * @param WP_REST_Request $request Full details about the request. |
399 * @param WP_REST_Request $request Full details about the request. |
400 * @return bool|WP_Error True if the request has access to delete the item, WP_Error object otherwise. |
400 * @return true|WP_Error True if the request has access to delete the item, WP_Error object otherwise. |
401 */ |
401 */ |
402 public function delete_item_permissions_check( $request ) { |
402 public function delete_item_permissions_check( $request ) { |
403 $parent = $this->get_parent( $request['parent'] ); |
403 $parent = $this->get_parent( $request['parent'] ); |
404 if ( is_wp_error( $parent ) ) { |
404 if ( is_wp_error( $parent ) ) { |
405 return $parent; |
405 return $parent; |
619 if ( ! empty( $data['parent'] ) ) { |
619 if ( ! empty( $data['parent'] ) ) { |
620 $response->add_link( 'parent', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->parent_base, $data['parent'] ) ) ); |
620 $response->add_link( 'parent', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->parent_base, $data['parent'] ) ) ); |
621 } |
621 } |
622 |
622 |
623 /** |
623 /** |
624 * Filters a revision returned from the API. |
624 * Filters a revision returned from the REST API. |
625 * |
625 * |
626 * Allows modification of the revision right before it is returned. |
626 * Allows modification of the revision right before it is returned. |
627 * |
627 * |
628 * @since 4.7.0 |
628 * @since 4.7.0 |
629 * |
629 * |
673 'title' => "{$this->parent_post_type}-revision", |
673 'title' => "{$this->parent_post_type}-revision", |
674 'type' => 'object', |
674 'type' => 'object', |
675 // Base properties for every Revision. |
675 // Base properties for every Revision. |
676 'properties' => array( |
676 'properties' => array( |
677 'author' => array( |
677 'author' => array( |
678 'description' => __( 'The ID for the author of the object.' ), |
678 'description' => __( 'The ID for the author of the revision.' ), |
679 'type' => 'integer', |
679 'type' => 'integer', |
680 'context' => array( 'view', 'edit', 'embed' ), |
680 'context' => array( 'view', 'edit', 'embed' ), |
681 ), |
681 ), |
682 'date' => array( |
682 'date' => array( |
683 'description' => __( "The date the object was published, in the site's timezone." ), |
683 'description' => __( "The date the revision was published, in the site's timezone." ), |
684 'type' => 'string', |
684 'type' => 'string', |
685 'format' => 'date-time', |
685 'format' => 'date-time', |
686 'context' => array( 'view', 'edit', 'embed' ), |
686 'context' => array( 'view', 'edit', 'embed' ), |
687 ), |
687 ), |
688 'date_gmt' => array( |
688 'date_gmt' => array( |
689 'description' => __( 'The date the object was published, as GMT.' ), |
689 'description' => __( 'The date the revision was published, as GMT.' ), |
690 'type' => 'string', |
690 'type' => 'string', |
691 'format' => 'date-time', |
691 'format' => 'date-time', |
692 'context' => array( 'view', 'edit' ), |
692 'context' => array( 'view', 'edit' ), |
693 ), |
693 ), |
694 'guid' => array( |
694 'guid' => array( |
695 'description' => __( 'GUID for the object, as it exists in the database.' ), |
695 'description' => __( 'GUID for the revision, as it exists in the database.' ), |
696 'type' => 'string', |
696 'type' => 'string', |
697 'context' => array( 'view', 'edit' ), |
697 'context' => array( 'view', 'edit' ), |
698 ), |
698 ), |
699 'id' => array( |
699 'id' => array( |
700 'description' => __( 'Unique identifier for the object.' ), |
700 'description' => __( 'Unique identifier for the revision.' ), |
701 'type' => 'integer', |
701 'type' => 'integer', |
702 'context' => array( 'view', 'edit', 'embed' ), |
702 'context' => array( 'view', 'edit', 'embed' ), |
703 ), |
703 ), |
704 'modified' => array( |
704 'modified' => array( |
705 'description' => __( "The date the object was last modified, in the site's timezone." ), |
705 'description' => __( "The date the revision was last modified, in the site's timezone." ), |
706 'type' => 'string', |
706 'type' => 'string', |
707 'format' => 'date-time', |
707 'format' => 'date-time', |
708 'context' => array( 'view', 'edit' ), |
708 'context' => array( 'view', 'edit' ), |
709 ), |
709 ), |
710 'modified_gmt' => array( |
710 'modified_gmt' => array( |
711 'description' => __( 'The date the object was last modified, as GMT.' ), |
711 'description' => __( 'The date the revision was last modified, as GMT.' ), |
712 'type' => 'string', |
712 'type' => 'string', |
713 'format' => 'date-time', |
713 'format' => 'date-time', |
714 'context' => array( 'view', 'edit' ), |
714 'context' => array( 'view', 'edit' ), |
715 ), |
715 ), |
716 'parent' => array( |
716 'parent' => array( |
717 'description' => __( 'The ID for the parent of the object.' ), |
717 'description' => __( 'The ID for the parent of the revision.' ), |
718 'type' => 'integer', |
718 'type' => 'integer', |
719 'context' => array( 'view', 'edit', 'embed' ), |
719 'context' => array( 'view', 'edit', 'embed' ), |
720 ), |
720 ), |
721 'slug' => array( |
721 'slug' => array( |
722 'description' => __( 'An alphanumeric identifier for the object unique to its type.' ), |
722 'description' => __( 'An alphanumeric identifier for the revision unique to its type.' ), |
723 'type' => 'string', |
723 'type' => 'string', |
724 'context' => array( 'view', 'edit', 'embed' ), |
724 'context' => array( 'view', 'edit', 'embed' ), |
725 ), |
725 ), |
726 ), |
726 ), |
727 ); |
727 ); |