Changeset 43445 for branches/4.9/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php
- Timestamp:
- 07/13/2018 06:50:51 AM (7 years ago)
- Location:
- branches/4.9
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
-
branches/4.9/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php
r43443 r43445 178 178 public function prepare_item_for_response( $taxonomy, $request ) { 179 179 $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name; 180 $data = array( 181 'name' => $taxonomy->label, 182 'slug' => $taxonomy->name, 183 'capabilities' => $taxonomy->cap, 184 'description' => $taxonomy->description, 185 'labels' => $taxonomy->labels, 186 'types' => $taxonomy->object_type, 187 'show_cloud' => $taxonomy->show_tagcloud, 188 'hierarchical' => $taxonomy->hierarchical, 189 'rest_base' => $base, 190 ); 180 181 $fields = $this->get_fields_for_response( $request ); 182 $data = array(); 183 184 if ( in_array( 'name', $fields, true ) ) { 185 $data['name'] = $taxonomy->label; 186 } 187 188 if ( in_array( 'slug', $fields, true ) ) { 189 $data['slug'] = $taxonomy->name; 190 } 191 192 if ( in_array( 'capabilities', $fields, true ) ) { 193 $data['capabilities'] = $taxonomy->cap; 194 } 195 196 if ( in_array( 'description', $fields, true ) ) { 197 $data['description'] = $taxonomy->description; 198 } 199 200 if ( in_array( 'labels', $fields, true ) ) { 201 $data['labels'] = $taxonomy->labels; 202 } 203 204 if ( in_array( 'types', $fields, true ) ) { 205 $data['types'] = $taxonomy->object_type; 206 } 207 208 if ( in_array( 'show_cloud', $fields, true ) ) { 209 $data['show_cloud'] = $taxonomy->show_tagcloud; 210 } 211 212 if ( in_array( 'hierarchical', $fields, true ) ) { 213 $data['hierarchical'] = $taxonomy->hierarchical; 214 } 215 216 if ( in_array( 'rest_base', $fields, true ) ) { 217 $data['rest_base'] = $base; 218 } 219 220 if ( in_array( 'visibility', $fields, true ) ) { 221 $data['visibility'] = array( 222 'public' => (bool) $taxonomy->public, 223 'publicly_queryable' => (bool) $taxonomy->publicly_queryable, 224 'show_admin_column' => (bool) $taxonomy->show_admin_column, 225 'show_in_nav_menus' => (bool) $taxonomy->show_in_nav_menus, 226 'show_in_quick_edit' => (bool) $taxonomy->show_in_quick_edit, 227 'show_ui' => (bool) $taxonomy->show_ui, 228 ); 229 } 191 230 192 231 $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
Note: See TracChangeset
for help on using the changeset viewer.