Changeset 38768 for trunk/src/wp-includes/class-wp-user.php
- Timestamp:
- 10/10/2016 06:37:02 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-user.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-user.php
r38705 r38768 105 105 106 106 /** 107 * @since 4.7.0108 * @access protected109 * @var wpdb110 */111 protected $db;112 113 /**114 107 * Constructor. 115 108 * … … 118 111 * @since 2.0.0 119 112 * @access public 113 * 114 * @global wpdb $wpdb WordPress database abstraction object. 120 115 * 121 116 * @param int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB. … … 124 119 */ 125 120 public function __construct( $id = 0, $name = '', $blog_id = '' ) { 126 $this->db = $GLOBALS['wpdb'];127 128 121 if ( ! isset( self::$back_compat_keys ) ) { 129 $prefix = $ this->db->prefix;122 $prefix = $GLOBALS['wpdb']->prefix; 130 123 self::$back_compat_keys = array( 131 124 'user_firstname' => 'first_name', … … 242 235 243 236 if ( !$user = $wpdb->get_row( $wpdb->prepare( 244 "SELECT * FROM {$wpdb->users}WHERE $db_field = %s", $value245 ) ) ) {237 "SELECT * FROM $wpdb->users WHERE $db_field = %s", $value 238 ) ) ) 246 239 return false; 247 } 240 248 241 update_user_caches( $user ); 249 242 … … 452 445 * @since 2.1.0 453 446 * 447 * @global wpdb $wpdb WordPress database abstraction object. 448 * 454 449 * @param string $cap_key Optional capability key 455 450 */ 456 451 protected function _init_caps( $cap_key = '' ) { 457 if ( empty( $cap_key ) ) { 458 $this->cap_key = $this->db->get_blog_prefix() . 'capabilities'; 459 } else { 452 global $wpdb; 453 454 if ( empty($cap_key) ) 455 $this->cap_key = $wpdb->get_blog_prefix() . 'capabilities'; 456 else 460 457 $this->cap_key = $cap_key; 461 } 458 462 459 $this->caps = get_user_meta( $this->ID, $this->cap_key, true ); 463 460 … … 637 634 * @since 2.0.0 638 635 * @access public 636 * 637 * @global wpdb $wpdb WordPress database abstraction object. 639 638 */ 640 639 public function update_user_level_from_caps() { 640 global $wpdb; 641 641 $this->user_level = array_reduce( array_keys( $this->allcaps ), array( $this, 'level_reduction' ), 0 ); 642 update_user_meta( $this->ID, $ this->db->get_blog_prefix() . 'user_level', $this->user_level );642 update_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level', $this->user_level ); 643 643 } 644 644 … … 682 682 * @since 2.1.0 683 683 * @access public 684 * 685 * @global wpdb $wpdb WordPress database abstraction object. 684 686 */ 685 687 public function remove_all_caps() { 688 global $wpdb; 686 689 $this->caps = array(); 687 690 delete_user_meta( $this->ID, $this->cap_key ); 688 delete_user_meta( $this->ID, $ this->db->get_blog_prefix() . 'user_level' );691 delete_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level' ); 689 692 $this->get_role_caps(); 690 693 } … … 772 775 * @since 3.0.0 773 776 * 777 * @global wpdb $wpdb WordPress database abstraction object. 778 * 774 779 * @param int $blog_id Optional. Site ID, defaults to current site. 775 780 */ 776 781 public function for_blog( $blog_id = '' ) { 777 if ( ! empty( $blog_id ) ) { 778 $cap_key = $this->db->get_blog_prefix( $blog_id ) . 'capabilities'; 779 } else { 782 global $wpdb; 783 if ( ! empty( $blog_id ) ) 784 $cap_key = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities'; 785 else 780 786 $cap_key = ''; 781 }782 787 $this->_init_caps( $cap_key ); 783 788 }
Note: See TracChangeset
for help on using the changeset viewer.