Changeset 43445 for branches/4.9/src/wp-includes/rest-api/endpoints/class-wp-rest-users-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-users-controller.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
-
branches/4.9/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r43138 r43445 838 838 839 839 $data = array(); 840 $ schema = $this->get_item_schema();841 842 if ( ! empty( $schema['properties']['id']) ) {840 $fields = $this->get_fields_for_response( $request ); 841 842 if ( in_array( 'id', $fields, true ) ) { 843 843 $data['id'] = $user->ID; 844 844 } 845 845 846 if ( ! empty( $schema['properties']['username']) ) {846 if ( in_array( 'username', $fields, true ) ) { 847 847 $data['username'] = $user->user_login; 848 848 } 849 849 850 if ( ! empty( $schema['properties']['name']) ) {850 if ( in_array( 'name', $fields, true ) ) { 851 851 $data['name'] = $user->display_name; 852 852 } 853 853 854 if ( ! empty( $schema['properties']['first_name']) ) {854 if ( in_array( 'first_name', $fields, true ) ) { 855 855 $data['first_name'] = $user->first_name; 856 856 } 857 857 858 if ( ! empty( $schema['properties']['last_name']) ) {858 if ( in_array( 'last_name', $fields, true ) ) { 859 859 $data['last_name'] = $user->last_name; 860 860 } 861 861 862 if ( ! empty( $schema['properties']['email']) ) {862 if ( in_array( 'email', $fields, true ) ) { 863 863 $data['email'] = $user->user_email; 864 864 } 865 865 866 if ( ! empty( $schema['properties']['url']) ) {866 if ( in_array( 'url', $fields, true ) ) { 867 867 $data['url'] = $user->user_url; 868 868 } 869 869 870 if ( ! empty( $schema['properties']['description']) ) {870 if ( in_array( 'description', $fields, true ) ) { 871 871 $data['description'] = $user->description; 872 872 } 873 873 874 if ( ! empty( $schema['properties']['link']) ) {874 if ( in_array( 'link', $fields, true ) ) { 875 875 $data['link'] = get_author_posts_url( $user->ID, $user->user_nicename ); 876 876 } 877 877 878 if ( ! empty( $schema['properties']['locale']) ) {878 if ( in_array( 'locale', $fields, true ) ) { 879 879 $data['locale'] = get_user_locale( $user ); 880 880 } 881 881 882 if ( ! empty( $schema['properties']['nickname']) ) {882 if ( in_array( 'nickname', $fields, true ) ) { 883 883 $data['nickname'] = $user->nickname; 884 884 } 885 885 886 if ( ! empty( $schema['properties']['slug']) ) {886 if ( in_array( 'slug', $fields, true ) ) { 887 887 $data['slug'] = $user->user_nicename; 888 888 } 889 889 890 if ( ! empty( $schema['properties']['roles']) ) {890 if ( in_array( 'roles', $fields, true ) ) { 891 891 // Defensively call array_values() to ensure an array is returned. 892 892 $data['roles'] = array_values( $user->roles ); 893 893 } 894 894 895 if ( ! empty( $schema['properties']['registered_date']) ) {895 if ( in_array( 'registered_date', $fields, true ) ) { 896 896 $data['registered_date'] = date( 'c', strtotime( $user->user_registered ) ); 897 897 } 898 898 899 if ( ! empty( $schema['properties']['capabilities']) ) {899 if ( in_array( 'capabilities', $fields, true ) ) { 900 900 $data['capabilities'] = (object) $user->allcaps; 901 901 } 902 902 903 if ( ! empty( $schema['properties']['extra_capabilities']) ) {903 if ( in_array( 'extra_capabilities', $fields, true ) ) { 904 904 $data['extra_capabilities'] = (object) $user->caps; 905 905 } 906 906 907 if ( ! empty( $schema['properties']['avatar_urls']) ) {907 if ( in_array( 'avatar_urls', $fields, true ) ) { 908 908 $data['avatar_urls'] = rest_get_avatar_urls( $user->user_email ); 909 909 } 910 910 911 if ( ! empty( $schema['properties']['meta']) ) {911 if ( in_array( 'meta', $fields, true ) ) { 912 912 $data['meta'] = $this->meta->get_value( $user->ID, $request ); 913 913 }
Note: See TracChangeset
for help on using the changeset viewer.