diff --git a/wp-admin/includes/deprecated.php b/wp-admin/includes/deprecated.php index 259d145411..9f68646b67 100644 --- a/wp-admin/includes/deprecated.php +++ b/wp-admin/includes/deprecated.php @@ -255,7 +255,7 @@ function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'p if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) { if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros ) - return array($user->id); + return array($user->ID); else return array(); } diff --git a/wp-admin/includes/ms.php b/wp-admin/includes/ms.php index 98991ef618..8f4bf131bc 100644 --- a/wp-admin/includes/ms.php +++ b/wp-admin/includes/ms.php @@ -250,7 +250,7 @@ function send_confirmation_on_profile_email() { if ( ! is_object($errors) ) $errors = new WP_Error(); - if ( $current_user->id != $_POST['user_id'] ) + if ( $current_user->ID != $_POST['user_id'] ) return false; if ( $current_user->user_email != $_POST['email'] ) { diff --git a/wp-admin/my-sites.php b/wp-admin/my-sites.php index 9f5928287d..2cbbb13231 100644 --- a/wp-admin/my-sites.php +++ b/wp-admin/my-sites.php @@ -17,7 +17,7 @@ if ( ! current_user_can('read') ) $action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash'; -$blogs = get_blogs_of_user( $current_user->id ); +$blogs = get_blogs_of_user( $current_user->ID ); if ( empty( $blogs ) ) wp_die( __( 'You must be a member of at least one site to use this page.' ) ); @@ -28,7 +28,7 @@ if ( 'updateblogsettings' == $action && isset( $_POST['primary_blog'] ) ) { $blog = get_blog_details( (int) $_POST['primary_blog'] ); if ( $blog && isset( $blog->domain ) ) { - update_user_option( $current_user->id, 'primary_blog', (int) $_POST['primary_blog'], true ); + update_user_option( $current_user->ID, 'primary_blog', (int) $_POST['primary_blog'], true ); $updated = true; } else { wp_die( __( 'The primary site you chose does not exist.' ) ); diff --git a/wp-admin/users.php b/wp-admin/users.php index 1bdeadefe8..72d25e3d2a 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -216,7 +216,7 @@ case 'doremove': $update = 'remove'; foreach ( $userids as $id ) { $id = (int) $id; - if ( $id == $current_user->id && !is_super_admin() ) { + if ( $id == $current_user->ID && !is_super_admin() ) { $update = 'err_admin_remove'; continue; } @@ -269,7 +269,7 @@ case 'remove': foreach ( $userids as $id ) { $id = (int) $id; $user = new WP_User($id); - if ( $id == $current_user->id && !is_super_admin() ) { + if ( $id == $current_user->ID && !is_super_admin() ) { echo "
  • " . sprintf(__('ID #%1s: %2s The current user will not be removed.'), $id, $user->user_login) . "
  • \n"; } elseif ( !current_user_can('remove_user', $id) ) { echo "
  • " . sprintf(__('ID #%1s: %2s You don\'t have permission to remove this user.'), $id, $user->user_login) . "
  • \n"; diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 86b3d85574..b449134ec2 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -360,8 +360,6 @@ class WP_User { /** * User data container. * - * This will be set as properties of the object. - * * @since 2.0.0 * @access private * @var array @@ -377,17 +375,6 @@ class WP_User { */ var $ID = 0; - /** - * The deprecated user's ID. - * - * @since 2.0.0 - * @access public - * @deprecated Use WP_User::$ID - * @see WP_User::$ID - * @var int - */ - var $id = 0; - /** * The individual capabilities the user has been given. * @@ -471,7 +458,6 @@ class WP_User { * @return WP_User */ function __construct( $id, $name = '', $blog_id = '' ) { - if ( empty( $id ) && empty( $name ) ) return; @@ -488,12 +474,40 @@ class WP_User { if ( empty( $this->data->ID ) ) return; - foreach ( get_object_vars( $this->data ) as $key => $value ) { - $this->{$key} = $value; + $this->ID = $this->data->ID; + $this->for_blog( $blog_id ); + } + + /** + * Magic method for checking the existance of a certain custom field + * + * @since 3.3.0 + */ + function __isset( $key ) { + return isset( $this->data->$key ); + } + + /** + * Magic method for accessing custom fields + * + * @since 3.3.0 + */ + function __get( $key ) { + if ( 'id' == $key ) { + _deprecated_argument( 'WP_User->id', '2.1', __( 'Use WP_User->ID instead.' ) ); + return $this->ID; } - $this->id = $this->ID; - $this->for_blog( $blog_id ); + return $this->data->$key; + } + + /** + * Magic method for setting custom fields + * + * @since 3.3.0 + */ + function __set( $key, $value ) { + $this->data->$key = $value; } /** @@ -511,13 +525,16 @@ class WP_User { */ function _init_caps( $cap_key = '' ) { global $wpdb; + if ( empty($cap_key) ) $this->cap_key = $wpdb->prefix . 'capabilities'; else $this->cap_key = $cap_key; - $this->caps = &$this->{$this->cap_key}; + + $this->caps = &$this->data->{$this->cap_key}; if ( ! is_array( $this->caps ) ) $this->caps = array(); + $this->get_role_caps(); } @@ -956,10 +973,10 @@ function map_meta_cap( $cap, $user_id ) { case 'add_post_meta': $post = get_post( $args[0] ); $post_type_object = get_post_type_object( $post->post_type ); - $caps = map_meta_cap( $post_type_object->cap->edit_post, $user_id, $post->ID ); + $caps = map_meta_cap( $post_type_object->cap->edit_post, $user_id, $post->ID ); + + $meta_key = isset( $args[ 1 ] ) ? $args[ 1 ] : false; - $meta_key = isset( $args[ 1 ] ) ? $args[ 1 ] : false; - if ( $meta_key && has_filter( "auth_post_meta_{$meta_key}" ) ) { $allowed = apply_filters( "auth_post_meta_{$meta_key}", false, $meta_key, $post->ID, $user_id, $cap, $caps ); if ( ! $allowed ) @@ -1080,7 +1097,7 @@ function current_user_can_for_blog( $blog_id, $capability ) { return false; // Create new object to avoid stomping the global current_user. - $user = new WP_User( $current_user->id) ; + $user = new WP_User( $current_user->ID) ; // Set the blog id. @todo add blog id arg to WP_User constructor? $user->for_blog( $blog_id ); @@ -1225,7 +1242,7 @@ function is_super_admin( $user_id = false ) { else $user = wp_get_current_user(); - if ( empty( $user->id ) ) + if ( empty( $user->ID ) ) return false; if ( is_multisite() ) { diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 3001433b82..4137ebaf1b 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -783,7 +783,7 @@ if ( !function_exists('is_user_logged_in') ) : function is_user_logged_in() { $user = wp_get_current_user(); - if ( $user->id == 0 ) + if ( $user->ID == 0 ) return false; return true; @@ -1308,7 +1308,7 @@ if ( !function_exists('wp_verify_nonce') ) : */ function wp_verify_nonce($nonce, $action = -1) { $user = wp_get_current_user(); - $uid = (int) $user->id; + $uid = (int) $user->ID; $i = wp_nonce_tick(); @@ -1334,7 +1334,7 @@ if ( !function_exists('wp_create_nonce') ) : */ function wp_create_nonce($action = -1) { $user = wp_get_current_user(); - $uid = (int) $user->id; + $uid = (int) $user->ID; $i = wp_nonce_tick(); diff --git a/wp-includes/user.php b/wp-includes/user.php index 44262cd3c9..b7f49f564f 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -1566,7 +1566,7 @@ function wp_update_user($userdata) { // Update the cookies if the password changed. $current_user = wp_get_current_user(); - if ( $current_user->id == $ID ) { + if ( $current_user->ID == $ID ) { if ( isset($plaintext_pass) ) { wp_clear_auth_cookie(); wp_set_auth_cookie($ID); diff --git a/wp-login.php b/wp-login.php index 849c4ab9e8..76788f17b2 100644 --- a/wp-login.php +++ b/wp-login.php @@ -586,10 +586,10 @@ default: if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) { // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile. - if ( is_multisite() && !get_active_blog_for_user($user->id) && !is_super_admin( $user->id ) ) + if ( is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin( $user->ID ) ) $redirect_to = user_admin_url(); elseif ( is_multisite() && !$user->has_cap('read') ) - $redirect_to = get_dashboard_url( $user->id ); + $redirect_to = get_dashboard_url( $user->ID ); elseif ( !$user->has_cap('edit_posts') ) $redirect_to = admin_url('profile.php'); } diff --git a/wp-signup.php b/wp-signup.php index cce20833e8..475d8cb5a4 100644 --- a/wp-signup.php +++ b/wp-signup.php @@ -213,7 +213,7 @@ function validate_another_blog_signup() { $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // deprecated $meta = apply_filters( 'add_signup_meta', $meta ); - wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid ); + wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid ); confirm_another_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta); return true; }