Ticket #21120: 21120.4.diff
File 21120.4.diff, 38.4 KB (added by , 13 years ago) |
---|
-
wp-includes/pluggable-deprecated.php
168 168 else : 169 169 _deprecated_function( 'wp_login', '2.5', 'wp_signon()' ); 170 170 endif; 171 172 if ( !function_exists('get_userdata') ) : 173 /** 174 * Retrieve user info by user ID. 175 * 176 * @since 0.71 177 * 178 * @param int $user_id User ID. 179 * @return bool|object False on failure, WP_User object on success 180 */ 181 function get_userdata( $user_id ) { 182 $user = wp_get_user( $user_id ); 183 if ( $user->exists() ) 184 return $user; 185 186 return false; 187 } 188 else: 189 _deprecated_function( 'get_userdata', '3.5', 'wp_get_user()' ); 190 endif; 191 No newline at end of file -
wp-includes/comment.php
406 406 */ 407 407 function get_lastcommentmodified($timezone = 'server') { 408 408 global $wpdb; 409 static $cache_lastcommentmodified = array(); 409 static $cache = array(); 410 $blog_id = get_current_blog_id(); 410 411 411 if ( isset( $cache_lastcommentmodified[$timezone]) )412 return $cache _lastcommentmodified[$timezone];412 if ( isset( $cache[ $blog_id ][ $timezone ] ) ) 413 return $cache[ $blog_id ][ $timezone ]; 413 414 414 415 $add_seconds_server = date('Z'); 415 416 … … 425 426 break; 426 427 } 427 428 428 $cache _lastcommentmodified[$timezone] = $lastcommentmodified;429 $cache[ $blog_id ][ $timezone ] = $lastcommentmodified; 429 430 430 431 return $lastcommentmodified; 431 432 } … … 650 651 651 652 do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt ); 652 653 653 if ( isset($user_id) && $user_id) { 654 $userdata = get_userdata($user_id); 655 $user = new WP_User($user_id); 654 if ( ! empty( $user_id ) ) { 655 $user = wp_get_user($user_id); 656 656 $post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", $comment_post_ID)); 657 657 } 658 658 659 if ( isset( $userdata) && ( $user_id == $post_author || $user->has_cap('moderate_comments') ) ) {659 if ( isset( $user ) && $user->exists() && ( $user_id == $post_author || $user->has_cap('moderate_comments') ) ) { 660 660 // The author and the admins get respect. 661 661 $approved = 1; 662 662 } else { -
wp-includes/comment-template.php
22 22 */ 23 23 function get_comment_author( $comment_ID = 0 ) { 24 24 $comment = get_comment( $comment_ID ); 25 if ( empty( $comment->comment_author) ) {26 if ( !empty($comment->user_id)){27 $user =get_userdata($comment->user_id);28 $author =$user->user_login;25 if ( empty( $comment->comment_author ) ) { 26 if ( ! empty( $comment->user_id ) ) { 27 $user = wp_get_user( $comment->user_id ); 28 $author = $user->user_login; 29 29 } else { 30 30 $author = __('Anonymous'); 31 31 } … … 307 307 $classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type; 308 308 309 309 // If the comment author has an id (registered), then print the log in name 310 if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) {310 if ( $comment->user_id && ( $user = wp_get_user( $comment->user_id ) ) && $user->exists() ) { 311 311 // For all registered users, 'byuser' 312 312 $classes[] = 'byuser'; 313 313 $classes[] = 'comment-author-' . sanitize_html_class($user->user_nicename, $comment->user_id); -
wp-includes/user.php
110 110 return new WP_Error( 'incorrect_password', sprintf( __( '<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s" title="Password Lost and Found">Lost your password</a>?' ), 111 111 $username, wp_lostpassword_url() ) ); 112 112 113 $user = new WP_User($userdata->ID); 114 return $user; 113 return $userdata; 115 114 } 116 115 117 116 /** … … 123 122 if ( empty($username) && empty($password) ) { 124 123 $user_id = wp_validate_auth_cookie(); 125 124 if ( $user_id ) 126 return new WP_User($user_id);125 return wp_get_user( $user_id ); 127 126 128 127 global $auth_secure_cookie; 129 128 … … 254 253 if ( !empty( $deprecated ) ) 255 254 _deprecated_argument( __FUNCTION__, '3.0' ); 256 255 257 if ( empty( $user ) ) 258 $user = wp_get_current_user(); 259 else 260 $user = new WP_User( $user ); 256 $user = wp_get_user( $user ); 261 257 262 258 if ( ! $user->exists() ) 263 259 return false; … … 922 918 * @global string $user_url The url in the user's profile 923 919 * @global string $user_identity The display name of the user 924 920 * 925 * @param int $for_user_id Optional. User ID to set up global data.921 * @param mixed $user Optional. WP_User object or user ID to set up global data. 926 922 */ 927 function setup_userdata( $for_user_id = '') {923 function setup_userdata( $user = '' ) { 928 924 global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_identity; 929 925 930 if ( '' == $for_user_id ) 931 $user = wp_get_current_user(); 932 else 933 $user = new WP_User($for_user_id); 926 if ( ! is_a( $user, 'WP_User' ) ) 927 $user = wp_get_user( $user ); 934 928 935 929 $userdata = null; 936 930 $user_ID = (int) $user->ID; … … 1031 1025 } 1032 1026 1033 1027 if ( $include_selected && ! $found_selected && ( $selected > 0 ) ) { 1034 $user = get_userdata( $selected );1028 $user = wp_get_user( $selected ); 1035 1029 $_selected = selected( $user->ID, $selected, false ); 1036 1030 $display = !empty($user->$show) ? $user->$show : '('. $user->user_login . ')'; 1037 1031 $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n"; … … 1142 1136 */ 1143 1137 function clean_user_cache( $user ) { 1144 1138 if ( is_numeric( $user ) ) 1145 $user = new WP_User( $user );1139 $user = wp_get_user( $user ); 1146 1140 1147 1141 if ( ! $user->exists() ) 1148 1142 return; … … 1351 1345 $user_id = (int) $wpdb->insert_id; 1352 1346 } 1353 1347 1354 $user = new WP_User( $user_id );1348 $user = wp_get_user( $user_id ); 1355 1349 1356 1350 foreach ( _get_additional_user_keys( $user ) as $key ) { 1357 1351 if ( isset( $$key ) ) … … 1397 1391 $ID = (int) $userdata['ID']; 1398 1392 1399 1393 // First, get all of the original fields 1400 $user_obj = get_userdata( $ID );1394 $user_obj = wp_get_user( $ID ); 1401 1395 1402 1396 $user = get_object_vars( $user_obj->data ); 1403 1397 -
wp-includes/class-wp-xmlrpc-server.php
785 785 } 786 786 787 787 // Get the author info. 788 $author = get_userdata( $page->post_author );788 $author = wp_get_user( $page->post_author ); 789 789 790 790 $page_template = get_page_template_slug( $page->ID ); 791 791 if ( empty( $page_template ) ) … … 985 985 if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) 986 986 return new IXR_Error( 401, __( 'You are not allowed to create posts as this user.' ) ); 987 987 988 $author = get_userdata( $post_data['post_author'] );988 $author = wp_get_user( $post_data['post_author'] ); 989 989 990 if ( ! $author )990 if ( ! $author->exists() ) 991 991 return new IXR_Error( 404, __( 'Invalid author ID.' ) ); 992 992 } else { 993 993 $post_data['post_author'] = $user->ID; … … 3737 3737 return(new IXR_Error(401, __('Invalid post type'))); 3738 3738 break; 3739 3739 } 3740 $author = get_userdata( $content_struct['wp_author_id'] );3741 if ( ! $author )3740 $author = wp_get_user( $content_struct['wp_author_id'] ); 3741 if ( ! $author->exists() ) 3742 3742 return new IXR_Error( 404, __( 'Invalid author ID.' ) ); 3743 3743 $post_author = $content_struct['wp_author_id']; 3744 3744 } … … 4272 4272 $link = post_permalink($postdata['ID']); 4273 4273 4274 4274 // Get the author info. 4275 $author = get_userdata($postdata['post_author']);4275 $author = wp_get_user($postdata['post_author']); 4276 4276 4277 4277 $allow_comments = ('open' == $postdata['comment_status']) ? 1 : 0; 4278 4278 $allow_pings = ('open' == $postdata['ping_status']) ? 1 : 0; … … 4403 4403 $link = post_permalink($entry['ID']); 4404 4404 4405 4405 // Get the post author info. 4406 $author = get_userdata($entry['post_author']);4406 $author = wp_get_user($entry['post_author']); 4407 4407 4408 4408 $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0; 4409 4409 $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0; -
wp-includes/query.php
2990 2990 $this->queried_object_id = (int) $this->post->ID; 2991 2991 } elseif ( $this->is_author ) { 2992 2992 $this->queried_object_id = (int) $this->get('author'); 2993 $this->queried_object = get_userdata( $this->queried_object_id );2993 $this->queried_object = wp_get_user( $this->queried_object_id ); 2994 2994 } 2995 2995 2996 2996 return $this->queried_object; … … 3593 3593 3594 3594 $id = (int) $post->ID; 3595 3595 3596 $authordata = get_userdata($post->post_author);3596 $authordata = wp_get_user($post->post_author); 3597 3597 3598 3598 $currentday = mysql2date('d.m.y', $post->post_date, false); 3599 3599 $currentmonth = mysql2date('m', $post->post_date, false); -
wp-includes/link-template.php
138 138 139 139 $author = ''; 140 140 if ( strpos($permalink, '%author%') !== false ) { 141 $authordata = get_userdata($post->post_author);141 $authordata = wp_get_user($post->post_author); 142 142 $author = $authordata->user_nicename; 143 143 } 144 144 -
wp-includes/author-template.php
64 64 * @since 2.8 65 65 * @uses $post The current post's DB object. 66 66 * @uses get_post_meta() Retrieves the ID of the author who last edited the current post. 67 * @uses get_userdata() Retrieves the author's DB object.67 * @uses wp_get_user() Retrieves the author's DB object. 68 68 * @uses apply_filters() Calls 'the_modified_author' hook on the author display name. 69 69 * @return string The author's display name. 70 70 */ 71 71 function get_the_modified_author() { 72 72 global $post; 73 73 if ( $last_id = get_post_meta($post->ID, '_edit_last', true) ) { 74 $last_user = get_userdata($last_id);74 $last_user = wp_get_user($last_id); 75 75 return apply_filters('the_modified_author', $last_user->display_name); 76 76 } 77 77 } … … 101 101 global $authordata; 102 102 $user_id = isset( $authordata->ID ) ? $authordata->ID : 0; 103 103 } else { 104 $authordata = get_userdata( $user_id );104 $authordata = wp_get_user( $user_id ); 105 105 } 106 106 107 107 if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) ) … … 226 226 $link = $file . '?author=' . $auth_ID; 227 227 } else { 228 228 if ( '' == $author_nicename ) { 229 $user = get_userdata($author_id);229 $user = wp_get_user($author_id); 230 230 if ( !empty($user->user_nicename) ) 231 231 $author_nicename = $user->user_nicename; 232 232 } … … 290 290 $author_count[$row->post_author] = $row->count; 291 291 292 292 foreach ( $authors as $author_id ) { 293 $author = get_userdata( $author_id );293 $author = wp_get_user( $author_id ); 294 294 295 295 if ( $exclude_admin && 'admin' == $author->display_name ) 296 296 continue; -
wp-includes/canonical.php
152 152 if ( $redirect_url = get_year_link(get_query_var('year')) ) 153 153 $redirect['query'] = remove_query_arg('year', $redirect['query']); 154 154 } elseif ( is_author() && !empty($_GET['author']) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) { 155 $author = get_userdata(get_query_var('author'));156 if ( ( false !== $author) && $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID ) ) ) {155 $author = wp_get_user(get_query_var('author')); 156 if ( $author->exists() && $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID ) ) ) { 157 157 if ( $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) ) 158 158 $redirect['query'] = remove_query_arg('author', $redirect['query']); 159 159 } -
wp-includes/capabilities.php
922 922 } 923 923 924 924 /** 925 * Returns a WP_User object of the requested user ID. 926 * 927 * @since 3.5.0 928 * 929 * @param int $user_id Optional. Defaults to the current user ID. 930 * @return WP_User 931 */ 932 function wp_get_user( $user_id = null ) { 933 if ( is_a( $user_id, 'WP_User' ) ) 934 return $user_id; 935 936 if ( ! $user_id ) 937 $user_id = get_current_user_id(); 938 939 if ( $user = get_user_by( 'id', $user_id ) ) 940 return $user; 941 942 return new WP_User; 943 } 944 945 /** 925 946 * Map meta capabilities to primitive capabilities. 926 947 * 927 948 * This does not actually compare whether the user ID has the actual capability, … … 960 981 break; 961 982 case 'delete_post': 962 983 case 'delete_page': 963 $author_data = get_userdata( $user_id );964 984 $post = get_post( $args[0] ); 965 985 966 986 if ( 'revision' == $post->post_type ) { … … 978 998 } 979 999 980 1000 if ( '' != $post->post_author ) { 981 $post_author_data = get_userdata( $post->post_author );1001 $post_author_data = wp_get_user( $post->post_author ); 982 1002 } else { 983 1003 // No author set yet, so default to current user for cap checks. 984 $post_author_data = $author_data;1004 $post_author_data = wp_get_user( $user_id ); 985 1005 } 986 1006 987 1007 // If the user is the author... 988 if ( is_object( $post_author_data) && $user_id == $post_author_data->ID ) {1008 if ( $post_author_data->exists() && $user_id == $post_author_data->ID ) { 989 1009 // If the post is published... 990 1010 if ( 'publish' == $post->post_status ) { 991 1011 $caps[] = $post_type->cap->delete_published_posts; … … 1010 1030 // edit_others_posts 1011 1031 case 'edit_post': 1012 1032 case 'edit_page': 1013 $author_data = get_userdata( $user_id );1014 1033 $post = get_post( $args[0] ); 1015 1034 1016 1035 if ( 'revision' == $post->post_type ) { … … 1028 1047 } 1029 1048 1030 1049 if ( '' != $post->post_author ) { 1031 $post_author_data = get_userdata( $post->post_author );1050 $post_author_data = wp_get_user( $post->post_author ); 1032 1051 } else { 1033 1052 // No author set yet, so default to current user for cap checks. 1034 $post_author_data = $author_data;1053 $post_author_data = wp_get_user( $user_id ); 1035 1054 } 1036 1055 1037 1056 //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br />"; 1038 1057 // If the user is the author... 1039 if ( is_object( $post_author_data) && $user_id == $post_author_data->ID ) {1058 if ( $post_author_data->exists() && $user_id == $post_author_data->ID ) { 1040 1059 // If the post is published... 1041 1060 if ( 'publish' == $post->post_status ) { 1042 1061 $caps[] = $post_type->cap->edit_published_posts; … … 1059 1078 break; 1060 1079 case 'read_post': 1061 1080 case 'read_page': 1062 $author_data = get_userdata( $user_id );1063 1081 $post = get_post( $args[0] ); 1064 1082 1065 1083 if ( 'revision' == $post->post_type ) { … … 1083 1101 } 1084 1102 1085 1103 if ( '' != $post->post_author ) { 1086 $post_author_data = get_userdata( $post->post_author );1104 $post_author_data = wp_get_user( $post->post_author ); 1087 1105 } else { 1088 1106 // No author set yet, so default to current user for cap checks. 1089 $post_author_data = $author_data;1107 $post_author_data = wp_get_user( $user_id ); 1090 1108 } 1091 1109 1092 if ( is_object( $post_author_data) && $user_id == $post_author_data->ID )1110 if ( $post_author_data->exists() && $user_id == $post_author_data->ID ) 1093 1111 $caps[] = $post_type->cap->read; 1094 1112 elseif ( $status_obj->private ) 1095 1113 $caps[] = $post_type->cap->read_private_posts; … … 1240 1258 return false; 1241 1259 1242 1260 // Create new object to avoid stomping the global current_user. 1243 $user = new WP_User( $current_user->ID );1261 $user = new WP_User( $current_user->ID ); 1244 1262 1245 1263 // Set the blog id. @todo add blog id arg to WP_User constructor? 1246 1264 $user->for_blog( $blog_id ); … … 1264 1282 if ( !$post = get_post($post) ) 1265 1283 return false; 1266 1284 1267 $author = new WP_User( $post->post_author );1285 $author = wp_get_user( $post->post_author ); 1268 1286 1269 if ( empty( $author->ID) )1287 if ( ! $author->exists() ) 1270 1288 return false; 1271 1289 1272 1290 $args = array_slice( func_get_args(), 2 ); … … 1286 1304 */ 1287 1305 function user_can( $user, $capability ) { 1288 1306 if ( ! is_object( $user ) ) 1289 $user = new WP_User( $user );1307 $user = wp_get_user( $user ); 1290 1308 1291 if ( ! $user || ! $user->exists() )1309 if ( ! $user->exists() ) 1292 1310 return false; 1293 1311 1294 1312 $args = array_slice( func_get_args(), 2 ); … … 1380 1398 * @return bool True if the user is a site admin. 1381 1399 */ 1382 1400 function is_super_admin( $user_id = false ) { 1383 if ( $user_id ) 1384 $user = new WP_User( $user_id ); 1385 else 1386 $user = wp_get_current_user(); 1401 $user = wp_get_user( $user_id ); 1387 1402 1388 1403 if ( ! $user->exists() ) 1389 1404 return false; -
wp-includes/deprecated.php
207 207 function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') { 208 208 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); 209 209 210 $author_data = get_userdata($user_id);210 $author_data = wp_get_user($user_id); 211 211 return ($author_data->user_level > 1); 212 212 } 213 213 … … 227 227 function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') { 228 228 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); 229 229 230 $author_data = get_userdata($user_id);230 $author_data = wp_get_user($user_id); 231 231 return ($author_data->user_level >= 1); 232 232 } 233 233 … … 247 247 function user_can_edit_post($user_id, $post_id, $blog_id = 1) { 248 248 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); 249 249 250 $author_data = get_userdata($user_id);250 $author_data = wp_get_user($user_id); 251 251 $post = get_post($post_id); 252 $post_author_data = get_userdata($post->post_author);252 $post_author_data = wp_get_user($post->post_author); 253 253 254 254 if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2)) 255 255 || ($author_data->user_level > $post_author_data->user_level) … … 296 296 function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') { 297 297 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); 298 298 299 $author_data = get_userdata($user_id);299 $author_data = wp_get_user($user_id); 300 300 return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id)); 301 301 } 302 302 … … 316 316 function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) { 317 317 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); 318 318 319 $author_data = get_userdata($user_id);319 $author_data = wp_get_user($user_id); 320 320 return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id)); 321 321 } 322 322 … … 375 375 function user_can_edit_user($user_id, $other_user) { 376 376 _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); 377 377 378 $user = get_userdata($user_id);379 $other = get_userdata($other_user);378 $user = wp_get_user($user_id); 379 $other = wp_get_user($other_user); 380 380 if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID ) 381 381 return true; 382 382 else -
wp-includes/pluggable.php
32 32 33 33 $current_user = new WP_User( $id, $name ); 34 34 35 setup_userdata( $current_user ->ID);35 setup_userdata( $current_user ); 36 36 37 37 do_action('set_current_user'); 38 38 … … 108 108 } 109 109 endif; 110 110 111 if ( !function_exists('get_userdata') ) :112 /**113 * Retrieve user info by user ID.114 *115 * @since 0.71116 *117 * @param int $user_id User ID118 * @return bool|object False on failure, WP_User object on success119 */120 function get_userdata( $user_id ) {121 return get_user_by( 'id', $user_id );122 }123 endif;124 125 111 if ( !function_exists('get_user_by') ) : 126 112 /** 127 113 * Retrieve user info by a given field … … 133 119 * @return bool|object False on failure, WP_User object on success 134 120 */ 135 121 function get_user_by( $field, $value ) { 122 if ( 'id' === $field && $value && get_current_user_id() === intval( $value ) ) 123 return wp_get_current_user(); 124 136 125 $userdata = WP_User::get_data_by( $field, $value ); 137 126 138 127 if ( !$userdata ) … … 147 136 148 137 if ( !function_exists('cache_users') ) : 149 138 /** 150 * Retrieve info for user lists to prevent multiple queries by get_userdata()139 * Retrieve info for user lists to prevent multiple queries by wp_get_user() 151 140 * 152 141 * @since 3.0.0 153 142 * … … 576 565 * @return string Authentication cookie contents 577 566 */ 578 567 function wp_generate_auth_cookie($user_id, $expiration, $scheme = 'auth') { 579 $user = get_userdata($user_id);568 $user = wp_get_user($user_id); 580 569 581 570 $pass_frag = substr($user->user_pass, 8, 4); 582 571 … … 993 982 function wp_notify_postauthor( $comment_id, $comment_type = '' ) { 994 983 $comment = get_comment( $comment_id ); 995 984 $post = get_post( $comment->comment_post_ID ); 996 $author = get_userdata( $post->post_author );997 985 998 986 // The comment was left by the author 999 987 if ( $comment->user_id == $post->post_author ) … … 1003 991 if ( $post->post_author == get_current_user_id() ) 1004 992 return false; 1005 993 994 $author = wp_get_user( $post->post_author ); 995 1006 996 // If there's no email to send the comment to 1007 997 if ( '' == $author->user_email ) 1008 998 return false; … … 1099 1089 1100 1090 $comment = get_comment($comment_id); 1101 1091 $post = get_post($comment->comment_post_ID); 1102 $user = get_userdata( $post->post_author );1092 $user = wp_get_user( $post->post_author ); 1103 1093 // Send to the administration and to the post author if the author can modify the comment. 1104 1094 $email_to = array( get_option('admin_email') ); 1105 1095 if ( user_can($user->ID, 'edit_comment', $comment_id) && !empty($user->user_email) && ( get_option('admin_email') != $user->user_email) ) … … 1195 1185 * @param string $plaintext_pass Optional. The user's plaintext password 1196 1186 */ 1197 1187 function wp_new_user_notification($user_id, $plaintext_pass = '') { 1198 $user = new WP_User($user_id);1188 $user = wp_get_user($user_id); 1199 1189 1200 1190 $user_login = stripslashes($user->user_login); 1201 1191 $user_email = stripslashes($user->user_email); … … 1595 1585 $email = ''; 1596 1586 if ( is_numeric($id_or_email) ) { 1597 1587 $id = (int) $id_or_email; 1598 $user = get_userdata($id);1599 if ( $user )1588 $user = wp_get_user($id); 1589 if ( $user->exists() ) 1600 1590 $email = $user->user_email; 1601 1591 } elseif ( is_object($id_or_email) ) { 1602 1592 // No avatar for pingbacks or trackbacks … … 1606 1596 1607 1597 if ( !empty($id_or_email->user_id) ) { 1608 1598 $id = (int) $id_or_email->user_id; 1609 $user = get_userdata($id);1610 if ( $user )1599 $user = wp_get_user($id); 1600 if ( $user->exists() ) 1611 1601 $email = $user->user_email; 1612 1602 } elseif ( !empty($id_or_email->comment_author_email) ) { 1613 1603 $email = $id_or_email->comment_author_email; -
wp-includes/ms-functions.php
183 183 function add_user_to_blog( $blog_id, $user_id, $role ) { 184 184 switch_to_blog($blog_id); 185 185 186 $user = new WP_User($user_id);186 $user = wp_get_user($user_id); 187 187 188 188 if ( ! $user->exists() ) { 189 189 restore_current_blog(); … … 246 246 } 247 247 248 248 // wp_revoke_user($user_id); 249 $user = new WP_User($user_id);249 $user = wp_get_user($user_id); 250 250 if ( ! $user->exists() ) { 251 251 restore_current_blog(); 252 252 return new WP_Error('user_does_not_exist', __('That user does not exist.')); … … 1056 1056 if ( is_email($email) == false ) 1057 1057 return false; 1058 1058 1059 $user = new WP_User($user_id);1059 $user = wp_get_user($user_id); 1060 1060 1061 1061 $options_site_url = esc_url(network_admin_url('settings.php')); 1062 1062 $msg = sprintf(__('New User: %1s … … 1233 1233 --The Team @ SITE_NAME' ) ); 1234 1234 1235 1235 $url = get_blogaddress_by_id($blog_id); 1236 $user = new WP_User($user_id);1236 $user = wp_get_user($user_id); 1237 1237 1238 1238 $welcome_email = str_replace( 'SITE_NAME', $current_site->site_name, $welcome_email ); 1239 1239 $welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email ); … … 1282 1282 1283 1283 $welcome_email = get_site_option( 'welcome_user_email' ); 1284 1284 1285 $user = new WP_User($user_id);1285 $user = wp_get_user($user_id); 1286 1286 1287 1287 $welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta); 1288 1288 $welcome_email = str_replace( 'SITE_NAME', $current_site->site_name, $welcome_email ); … … 1536 1536 */ 1537 1537 function wpmu_log_new_registrations( $blog_id, $user_id ) { 1538 1538 global $wpdb; 1539 $user = new WP_User( (int) $user_id );1539 $user = wp_get_user( (int) $user_id ); 1540 1540 $wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '',$_SERVER['REMOTE_ADDR'] ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) ); 1541 1541 } 1542 1542 … … 1802 1802 } else { 1803 1803 $user_id = get_user_id_from_string( $username ); 1804 1804 } 1805 $u = new WP_User( $user_id );1805 $u = wp_get_user( $user_id ); 1806 1806 1807 1807 return ( isset( $u->spam ) && $u->spam == 1 ); 1808 1808 } -
wp-mail.php
154 154 155 155 // Set $post_status based on $author_found and on author's publish_posts capability 156 156 if ( $author_found ) { 157 $user = new WP_User($post_author);157 $user = wp_get_user($post_author); 158 158 $post_status = ( $user->has_cap('publish_posts') ) ? 'publish' : 'pending'; 159 159 } else { 160 160 // Author not found in DB, set status to pending. Author already set to admin. -
wp-activate.php
77 77 } else { 78 78 extract($result); 79 79 $url = get_blogaddress_by_id( (int) $blog_id); 80 $user = new WP_User( (int) $user_id);80 $user = wp_get_user( (int) $user_id ); 81 81 ?> 82 82 <h2><?php _e('Your account is now active!'); ?></h2> 83 83 -
wp-admin/users.php
111 111 if ( is_multisite() && !is_user_member_of_blog( $id ) ) 112 112 wp_die(__('Cheatin’ uh?')); 113 113 114 $user = new WP_User($id);114 $user = wp_get_user($id); 115 115 $user->set_role($_REQUEST['new_role']); 116 116 } 117 117 … … 201 201 $go_delete = 0; 202 202 foreach ( $userids as $id ) { 203 203 $id = (int) $id; 204 $user = new WP_User($id);204 $user = wp_get_user($id); 205 205 if ( $id == $current_user->ID ) { 206 206 echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n"; 207 207 } else { … … 302 302 $go_remove = false; 303 303 foreach ( $userids as $id ) { 304 304 $id = (int) $id; 305 $user = new WP_User($id);305 $user = wp_get_user($id); 306 306 if ( $id == $current_user->ID && !is_super_admin() ) { 307 307 echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be removed.</strong>'), $id, $user->user_login) . "</li>\n"; 308 308 } elseif ( !current_user_can('remove_user', $id) ) { -
wp-admin/includes/ajax-actions.php
1018 1018 ) ); 1019 1019 $x->send(); 1020 1020 } 1021 $user_object = new WP_User( $user_id );1021 $user_object = wp_get_user( $user_id ); 1022 1022 1023 1023 $wp_list_table = _get_list_table('WP_Users_List_Table'); 1024 1024 … … 1069 1069 if ( $last = wp_check_post_lock( $post->ID ) ) { 1070 1070 $do_autosave = $do_lock = false; 1071 1071 1072 $last_user = get_userdata( $last );1073 $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );1072 $last_user = wp_get_user( $last ); 1073 $last_user_name = $last_user->exists() ? $last_user->display_name : __( 'Someone' ); 1074 1074 $data = __( 'Autosave disabled.' ); 1075 1075 1076 1076 $supplemental['disable_autosave'] = 'disable'; … … 1331 1331 set_current_screen( $_POST['screen'] ); 1332 1332 1333 1333 if ( $last = wp_check_post_lock( $post_ID ) ) { 1334 $last_user = get_userdata( $last );1335 $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );1334 $last_user = wp_get_user( $last ); 1335 $last_user_name = $last_user->exists() ? $last_user->display_name : __( 'Someone' ); 1336 1336 printf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ), esc_html( $last_user_name ) ); 1337 1337 wp_die(); 1338 1338 } … … 1752 1752 } 1753 1753 1754 1754 if ( $last_id = get_post_meta($post_id, '_edit_last', true) ) { 1755 $last_user = get_userdata($last_id);1755 $last_user = wp_get_user($last_id); 1756 1756 $last_edited = sprintf( __('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), $last_date, $last_time ); 1757 1757 } else { 1758 1758 $last_edited = sprintf( __('Last edited on %1$s at %2$s'), $last_date, $last_time ); -
wp-admin/includes/post.php
1228 1228 1229 1229 $lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) ); 1230 1230 $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); 1231 $last_user = get_userdata( $user );1232 $last_user_name = $last_user ? $last_user->display_name : __('Somebody');1231 $last_user = wp_get_user( $user ); 1232 $last_user_name = $last_user->exists() ? $last_user->display_name : __('Somebody'); 1233 1233 1234 1234 switch ($post->post_type) { 1235 1235 case 'post': -
wp-admin/includes/class-wp-users-list-table.php
218 218 global $wp_roles; 219 219 220 220 if ( !( is_object( $user_object ) && is_a( $user_object, 'WP_User' ) ) ) 221 $user_object = new WP_User( (int) $user_object );221 $user_object = wp_get_user( (int) $user_object ); 222 222 $user_object->filter = 'display'; 223 223 $email = $user_object->user_email; 224 224 -
wp-admin/includes/upgrade.php
75 75 $message = __('User already exists. Password inherited.'); 76 76 } 77 77 78 $user = new WP_User($user_id);78 $user = wp_get_user($user_id); 79 79 $user->set_role('administrator'); 80 80 81 81 wp_install_defaults($user_id); … … 292 292 $wp_rewrite->init(); 293 293 $wp_rewrite->flush_rules(); 294 294 295 $user = new WP_User($user_id);295 $user = wp_get_user($user_id); 296 296 $wpdb->update( $wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email') ); 297 297 298 298 // Remove all perms except for the login user. … … 320 320 * @param string $password User's Password. 321 321 */ 322 322 function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) { 323 $user = new WP_User($user_id);323 $user = wp_get_user($user_id); 324 324 $email = $user->user_email; 325 325 $name = $user->user_login; 326 326 $message = sprintf(__("Your new WordPress site has been successfully set up at: -
wp-admin/includes/deprecated.php
249 249 250 250 global $wpdb; 251 251 252 $user = new WP_User( $user_id );252 $user = wp_get_user( $user_id ); 253 253 $post_type_obj = get_post_type_object($post_type); 254 254 255 255 if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) { -
wp-admin/includes/user.php
33 33 if ( $user_id ) { 34 34 $update = true; 35 35 $user->ID = (int) $user_id; 36 $userdata = get_userdata( $user_id );36 $userdata = wp_get_user( $user_id ); 37 37 $user->user_login = $wpdb->escape( $userdata->user_login ); 38 38 } else { 39 39 $update = false; … … 198 198 * @return object WP_User object with user data. 199 199 */ 200 200 function get_user_to_edit( $user_id ) { 201 $user = new WP_User( $user_id );201 $user = wp_get_user( $user_id ); 202 202 203 203 $user->filter = 'edit'; 204 204 … … 238 238 global $wpdb; 239 239 240 240 $id = (int) $id; 241 $user = new WP_User( $id );241 $user = wp_get_user( $id ); 242 242 243 243 // allow for transaction statement 244 244 do_action('delete_user', $id); … … 303 303 function wp_revoke_user($id) { 304 304 $id = (int) $id; 305 305 306 $user = new WP_User($id);306 $user = wp_get_user($id); 307 307 $user->remove_all_caps(); 308 308 } 309 309 … … 331 331 if ( ! get_user_option('default_password_nag', $user_ID) ) //Short circuit it. 332 332 return; 333 333 334 $new_data = get_userdata($user_ID);334 $new_data = wp_get_user($user_ID); 335 335 336 336 if ( $new_data->user_pass != $old_data->user_pass ) { //Remove the nag if the password has been changed. 337 337 delete_user_setting('default_password_nag', $user_ID); -
wp-admin/includes/ms.php
132 132 global $wpdb; 133 133 134 134 $id = (int) $id; 135 $user = new WP_User( $id );135 $user = wp_get_user( $id ); 136 136 137 137 do_action( 'wpmu_delete_user', $id ); 138 138 … … 393 393 394 394 $wpdb->update( $wpdb->users, array( $pref => $value ), array( 'ID' => $id ) ); 395 395 396 $user = new WP_User( $id );396 $user = wp_get_user( $id ); 397 397 clean_user_cache( $user ); 398 398 399 399 if ( $pref == 'spam' ) { … … 409 409 function refresh_user_details( $id ) { 410 410 $id = (int) $id; 411 411 412 if ( !$user = get_userdata( $id ) ) 412 $user = wp_get_user( $id ); 413 if ( ! $user->exists() ) 413 414 return false; 414 415 415 416 clean_user_cache( $user ); … … 650 651 // Directly fetch site_admins instead of using get_super_admins() 651 652 $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); 652 653 653 $user = new WP_User( $user_id );654 $user = wp_get_user( $user_id ); 654 655 if ( ! in_array( $user->user_login, $super_admins ) ) { 655 656 $super_admins[] = $user->user_login; 656 657 update_site_option( 'site_admins' , $super_admins ); … … 678 679 // Directly fetch site_admins instead of using get_super_admins() 679 680 $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); 680 681 681 $user = new WP_User( $user_id );682 $user = wp_get_user( $user_id ); 682 683 if ( $user->user_email != get_site_option( 'admin_email' ) ) { 683 684 if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) { 684 685 unset( $super_admins[$key] ); -
wp-admin/includes/export.php
239 239 240 240 $authors = array(); 241 241 $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts" ); 242 foreach ( (array) $results as $result ) 243 $authors[] = get_userdata( $result->post_author ); 242 foreach ( (array) $results as $result ) { 243 $author = wp_get_user( $result->post_author ); 244 if ( $author->exists() ) 245 $authors[] = $author; 246 } 244 247 245 $authors = array_filter( $authors );246 247 248 foreach ( $authors as $author ) { 248 249 echo "\t<wp:author>"; 249 250 echo '<wp:author_id>' . $author->ID . '</wp:author_id>'; -
wp-admin/edit-form-advanced.php
322 322 if ( 'auto-draft' != $post->post_status ) { 323 323 echo '<span id="last-edit">'; 324 324 if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) { 325 $last_user = get_userdata($last_id);325 $last_user = wp_get_user($last_id); 326 326 printf(__('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); 327 327 } else { 328 328 printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); -
wp-admin/network/users.php
34 34 35 35 foreach ( ( $allusers = (array) $_POST['allusers'] ) as $key => $val ) { 36 36 if ( $val != '' && $val != '0' ) { 37 $delete_user = new WP_User( $val );37 $delete_user = wp_get_user( $val ); 38 38 39 39 if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) 40 40 wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) ); … … 139 139 break; 140 140 141 141 case 'spam': 142 $user = new WP_User( $val );142 $user = wp_get_user( $val ); 143 143 if ( in_array( $user->user_login, get_super_admins() ) ) 144 144 wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) ); 145 145 -
wp-admin/network/site-users.php
143 143 if ( !is_user_member_of_blog( $user_id ) ) 144 144 wp_die(__('Cheatin’ uh?')); 145 145 146 $user = new WP_User( $user_id );146 $user = wp_get_user( $user_id ); 147 147 $user->set_role( $_REQUEST['new_role'] ); 148 148 } 149 149 } else { -
wp-admin/user-edit.php
20 20 $user_id = $current_user->ID; 21 21 elseif ( ! $user_id && ! IS_PROFILE_PAGE ) 22 22 wp_die(__( 'Invalid user ID.' ) ); 23 elseif ( ! get_userdata( $user_id) )23 elseif ( ! wp_get_user( $user_id )->exists() ) 24 24 wp_die( __('Invalid user ID.') ); 25 25 26 26 wp_enqueue_script('user-profile'); … … 113 113 if ( !is_multisite() ) { 114 114 $errors = edit_user($user_id); 115 115 } else { 116 $user = get_userdata( $user_id );116 $user = wp_get_user( $user_id ); 117 117 118 118 // Update the email address in signups, if present. 119 119 if ( $user->user_login && isset( $_POST[ 'email' ] ) && is_email( $_POST[ 'email' ] ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) )