equal
deleted
inserted
replaced
65 $parent_controller = new WP_REST_Posts_Controller( $parent_post_type ); |
65 $parent_controller = new WP_REST_Posts_Controller( $parent_post_type ); |
66 } |
66 } |
67 |
67 |
68 $this->parent_controller = $parent_controller; |
68 $this->parent_controller = $parent_controller; |
69 $this->revisions_controller = new WP_REST_Revisions_Controller( $parent_post_type ); |
69 $this->revisions_controller = new WP_REST_Revisions_Controller( $parent_post_type ); |
70 $this->rest_namespace = 'wp/v2'; |
70 $this->namespace = 'wp/v2'; |
71 $this->rest_base = 'autosaves'; |
71 $this->rest_base = 'autosaves'; |
72 $this->parent_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name; |
72 $this->parent_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name; |
73 } |
73 } |
74 |
74 |
75 /** |
75 /** |
79 * |
79 * |
80 * @see register_rest_route() |
80 * @see register_rest_route() |
81 */ |
81 */ |
82 public function register_routes() { |
82 public function register_routes() { |
83 register_rest_route( |
83 register_rest_route( |
84 $this->rest_namespace, |
84 $this->namespace, |
85 '/' . $this->parent_base . '/(?P<id>[\d]+)/' . $this->rest_base, |
85 '/' . $this->parent_base . '/(?P<id>[\d]+)/' . $this->rest_base, |
86 array( |
86 array( |
87 'args' => array( |
87 'args' => array( |
88 'parent' => array( |
88 'parent' => array( |
89 'description' => __( 'The ID for the parent of the object.' ), |
89 'description' => __( 'The ID for the parent of the autosave.' ), |
90 'type' => 'integer', |
90 'type' => 'integer', |
91 ), |
91 ), |
92 ), |
92 ), |
93 array( |
93 array( |
94 'methods' => WP_REST_Server::READABLE, |
94 'methods' => WP_REST_Server::READABLE, |
105 'schema' => array( $this, 'get_public_item_schema' ), |
105 'schema' => array( $this, 'get_public_item_schema' ), |
106 ) |
106 ) |
107 ); |
107 ); |
108 |
108 |
109 register_rest_route( |
109 register_rest_route( |
110 $this->rest_namespace, |
110 $this->namespace, |
111 '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base . '/(?P<id>[\d]+)', |
111 '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base . '/(?P<id>[\d]+)', |
112 array( |
112 array( |
113 'args' => array( |
113 'args' => array( |
114 'parent' => array( |
114 'parent' => array( |
115 'description' => __( 'The ID for the parent of the object.' ), |
115 'description' => __( 'The ID for the parent of the autosave.' ), |
116 'type' => 'integer', |
116 'type' => 'integer', |
117 ), |
117 ), |
118 'id' => array( |
118 'id' => array( |
119 'description' => __( 'The ID for the object.' ), |
119 'description' => __( 'The ID for the autosave.' ), |
120 'type' => 'integer', |
120 'type' => 'integer', |
121 ), |
121 ), |
122 ), |
122 ), |
123 array( |
123 array( |
124 'methods' => WP_REST_Server::READABLE, |
124 'methods' => WP_REST_Server::READABLE, |
423 $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
423 $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
424 $response->data = $this->add_additional_fields_to_object( $response->data, $request ); |
424 $response->data = $this->add_additional_fields_to_object( $response->data, $request ); |
425 $response->data = $this->filter_response_by_context( $response->data, $context ); |
425 $response->data = $this->filter_response_by_context( $response->data, $context ); |
426 |
426 |
427 /** |
427 /** |
428 * Filters a revision returned from the API. |
428 * Filters a revision returned from the REST API. |
429 * |
429 * |
430 * Allows modification of the revision right before it is returned. |
430 * Allows modification of the revision right before it is returned. |
431 * |
431 * |
432 * @since 5.0.0 |
432 * @since 5.0.0 |
433 * |
433 * |