Changeset 47122 for trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php
r46821 r47122 88 88 $taxonomies = get_taxonomies( '', 'objects' ); 89 89 } 90 90 91 foreach ( $taxonomies as $taxonomy ) { 91 92 if ( ! empty( $taxonomy->show_in_rest ) && current_user_can( $taxonomy->cap->assign_terms ) ) { … … 93 94 } 94 95 } 95 return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) ); 96 } 96 97 return new WP_Error( 98 'rest_cannot_view', 99 __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), 100 array( 'status' => rest_authorization_required_code() ) 101 ); 102 } 103 97 104 return true; 98 105 } … … 116 123 $taxonomies = get_taxonomies( '', 'objects' ); 117 124 } 125 118 126 $data = array(); 127 119 128 foreach ( $taxonomies as $tax_type => $value ) { 120 129 if ( empty( $value->show_in_rest ) || ( 'edit' === $request['context'] && ! current_user_can( $value->cap->assign_terms ) ) ) { 121 130 continue; 122 131 } 132 123 133 $tax = $this->prepare_item_for_response( $value, $request ); 124 134 $tax = $this->prepare_response_for_collection( $tax ); … … 150 160 return false; 151 161 } 162 152 163 if ( 'edit' === $request['context'] && ! current_user_can( $tax_obj->cap->assign_terms ) ) { 153 return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) ); 164 return new WP_Error( 165 'rest_forbidden_context', 166 __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), 167 array( 'status' => rest_authorization_required_code() ) 168 ); 154 169 } 155 170 } … … 168 183 public function get_item( $request ) { 169 184 $tax_obj = get_taxonomy( $request['taxonomy'] ); 185 170 186 if ( empty( $tax_obj ) ) { 171 return new WP_Error( 'rest_taxonomy_invalid', __( 'Invalid taxonomy.' ), array( 'status' => 404 ) ); 172 } 187 return new WP_Error( 188 'rest_taxonomy_invalid', 189 __( 'Invalid taxonomy.' ), 190 array( 'status' => 404 ) 191 ); 192 } 193 173 194 $data = $this->prepare_item_for_response( $tax_obj, $request ); 195 174 196 return rest_ensure_response( $data ); 175 197 } … … 380 402 381 403 $this->schema = $schema; 404 382 405 return $this->add_additional_fields_schema( $this->schema ); 383 406 }
Note: See TracChangeset
for help on using the changeset viewer.