- Timestamp:
- 05/02/2018 01:24:30 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r43001 r43087 847 847 848 848 $data = array(); 849 $ schema = $this->get_item_schema();850 851 if ( ! empty( $schema['properties']['id']) ) {849 $fields = $this->get_fields_for_response( $request ); 850 851 if ( in_array( 'id', $fields, true ) ) { 852 852 $data['id'] = $user->ID; 853 853 } 854 854 855 if ( ! empty( $schema['properties']['username']) ) {855 if ( in_array( 'username', $fields, true ) ) { 856 856 $data['username'] = $user->user_login; 857 857 } 858 858 859 if ( ! empty( $schema['properties']['name']) ) {859 if ( in_array( 'name', $fields, true ) ) { 860 860 $data['name'] = $user->display_name; 861 861 } 862 862 863 if ( ! empty( $schema['properties']['first_name']) ) {863 if ( in_array( 'first_name', $fields, true ) ) { 864 864 $data['first_name'] = $user->first_name; 865 865 } 866 866 867 if ( ! empty( $schema['properties']['last_name']) ) {867 if ( in_array( 'last_name', $fields, true ) ) { 868 868 $data['last_name'] = $user->last_name; 869 869 } 870 870 871 if ( ! empty( $schema['properties']['email']) ) {871 if ( in_array( 'email', $fields, true ) ) { 872 872 $data['email'] = $user->user_email; 873 873 } 874 874 875 if ( ! empty( $schema['properties']['url']) ) {875 if ( in_array( 'url', $fields, true ) ) { 876 876 $data['url'] = $user->user_url; 877 877 } 878 878 879 if ( ! empty( $schema['properties']['description']) ) {879 if ( in_array( 'description', $fields, true ) ) { 880 880 $data['description'] = $user->description; 881 881 } 882 882 883 if ( ! empty( $schema['properties']['link']) ) {883 if ( in_array( 'link', $fields, true ) ) { 884 884 $data['link'] = get_author_posts_url( $user->ID, $user->user_nicename ); 885 885 } 886 886 887 if ( ! empty( $schema['properties']['locale']) ) {887 if ( in_array( 'locale', $fields, true ) ) { 888 888 $data['locale'] = get_user_locale( $user ); 889 889 } 890 890 891 if ( ! empty( $schema['properties']['nickname']) ) {891 if ( in_array( 'nickname', $fields, true ) ) { 892 892 $data['nickname'] = $user->nickname; 893 893 } 894 894 895 if ( ! empty( $schema['properties']['slug']) ) {895 if ( in_array( 'slug', $fields, true ) ) { 896 896 $data['slug'] = $user->user_nicename; 897 897 } 898 898 899 if ( ! empty( $schema['properties']['roles']) ) {899 if ( in_array( 'roles', $fields, true ) ) { 900 900 // Defensively call array_values() to ensure an array is returned. 901 901 $data['roles'] = array_values( $user->roles ); 902 902 } 903 903 904 if ( ! empty( $schema['properties']['registered_date']) ) {904 if ( in_array( 'registered_date', $fields, true ) ) { 905 905 $data['registered_date'] = date( 'c', strtotime( $user->user_registered ) ); 906 906 } 907 907 908 if ( ! empty( $schema['properties']['capabilities']) ) {908 if ( in_array( 'capabilities', $fields, true ) ) { 909 909 $data['capabilities'] = (object) $user->allcaps; 910 910 } 911 911 912 if ( ! empty( $schema['properties']['extra_capabilities']) ) {912 if ( in_array( 'extra_capabilities', $fields, true ) ) { 913 913 $data['extra_capabilities'] = (object) $user->caps; 914 914 } 915 915 916 if ( ! empty( $schema['properties']['avatar_urls']) ) {916 if ( in_array( 'avatar_urls', $fields, true ) ) { 917 917 $data['avatar_urls'] = rest_get_avatar_urls( $user->user_email ); 918 918 } 919 919 920 if ( ! empty( $schema['properties']['meta']) ) {920 if ( in_array( 'meta', $fields, true ) ) { 921 921 $data['meta'] = $this->meta->get_value( $user->ID, $request ); 922 922 }
Note: See TracChangeset
for help on using the changeset viewer.