equal
deleted
inserted
replaced
111 * |
111 * |
112 * @param WP_REST_Request $request Full details about the request. |
112 * @param WP_REST_Request $request Full details about the request. |
113 * @return WP_REST_Response Response object on success, or WP_Error object on failure. |
113 * @return WP_REST_Response Response object on success, or WP_Error object on failure. |
114 */ |
114 */ |
115 public function get_items( $request ) { |
115 public function get_items( $request ) { |
|
116 if ( $request->is_method( 'HEAD' ) ) { |
|
117 // Return early as this handler doesn't add any response headers. |
|
118 return new WP_REST_Response( array() ); |
|
119 } |
116 |
120 |
117 // Retrieve the list of registered collection query parameters. |
121 // Retrieve the list of registered collection query parameters. |
118 $registered = $this->get_collection_params(); |
122 $registered = $this->get_collection_params(); |
119 |
123 |
120 if ( isset( $registered['type'] ) && ! empty( $request['type'] ) ) { |
124 if ( isset( $registered['type'] ) && ! empty( $request['type'] ) ) { |
147 * Checks if a given request has access to a taxonomy. |
151 * Checks if a given request has access to a taxonomy. |
148 * |
152 * |
149 * @since 4.7.0 |
153 * @since 4.7.0 |
150 * |
154 * |
151 * @param WP_REST_Request $request Full details about the request. |
155 * @param WP_REST_Request $request Full details about the request. |
152 * @return true|WP_Error True if the request has read access for the item, otherwise false or WP_Error object. |
156 * @return bool|WP_Error True if the request has read access for the item, otherwise false or WP_Error object. |
153 */ |
157 */ |
154 public function get_item_permissions_check( $request ) { |
158 public function get_item_permissions_check( $request ) { |
155 |
159 |
156 $tax_obj = get_taxonomy( $request['taxonomy'] ); |
160 $tax_obj = get_taxonomy( $request['taxonomy'] ); |
157 |
161 |
207 * @return WP_REST_Response Response object. |
211 * @return WP_REST_Response Response object. |
208 */ |
212 */ |
209 public function prepare_item_for_response( $item, $request ) { |
213 public function prepare_item_for_response( $item, $request ) { |
210 // Restores the more descriptive, specific name for use within this method. |
214 // Restores the more descriptive, specific name for use within this method. |
211 $taxonomy = $item; |
215 $taxonomy = $item; |
|
216 |
|
217 // Don't prepare the response body for HEAD requests. |
|
218 if ( $request->is_method( 'HEAD' ) ) { |
|
219 /** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php */ |
|
220 return apply_filters( 'rest_prepare_taxonomy', new WP_REST_Response( array() ), $taxonomy, $request ); |
|
221 } |
212 |
222 |
213 $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name; |
223 $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name; |
214 |
224 |
215 $fields = $this->get_fields_for_response( $request ); |
225 $fields = $this->get_fields_for_response( $request ); |
216 $data = array(); |
226 $data = array(); |