Ticket #38681: 38681.diff
File 38681.diff, 3.9 KB (added by , 8 years ago) |
---|
-
src/wp-includes/class-wp-user.php
113 113 * 114 114 * @global wpdb $wpdb WordPress database abstraction object. 115 115 * 116 * @param int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB.117 * @param string $name Optional. User's username118 * @param int $ blog_id Optional Site ID, defaults to current site.116 * @param int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB. 117 * @param string $name Optional. User's username 118 * @param int $site_id Optional Site ID, defaults to current site. 119 119 */ 120 public function __construct( $id = 0, $name = '', $ blog_id = '' ) {120 public function __construct( $id = 0, $name = '', $site_id = '' ) { 121 121 if ( ! isset( self::$back_compat_keys ) ) { 122 122 $prefix = $GLOBALS['wpdb']->prefix; 123 123 self::$back_compat_keys = array( … … 131 131 } 132 132 133 133 if ( $id instanceof WP_User ) { 134 $this->init( $id->data, $ blog_id );134 $this->init( $id->data, $site_id ); 135 135 return; 136 136 } elseif ( is_object( $id ) ) { 137 $this->init( $id, $ blog_id );137 $this->init( $id, $site_id ); 138 138 return; 139 139 } 140 140 … … 150 150 } 151 151 152 152 if ( $data ) { 153 $this->init( $data, $ blog_id );153 $this->init( $data, $site_id ); 154 154 } else { 155 155 $this->data = new stdClass; 156 156 } … … 160 160 * Sets up object properties, including capabilities. 161 161 * 162 162 * @param object $data User DB row object. 163 * @param int $ blog_id Optional. The site ID to initialize for.163 * @param int $site_id Optional. The site ID to initialize for. 164 164 */ 165 public function init( $data, $ blog_id = '' ) {165 public function init( $data, $site_id = '' ) { 166 166 $this->data = $data; 167 167 $this->ID = (int) $data->ID; 168 168 169 $this->for_ blog( $blog_id );169 $this->for_site( $site_id ); 170 170 } 171 171 172 172 /** … … 254 254 * @return mixed|false Return value of the callback, false otherwise. 255 255 */ 256 256 public function __call( $name, $arguments ) { 257 if ( '_init_caps' === $name ) { 258 return call_user_func_array( array( $this, $name ), $arguments ); 257 switch ( $name ) { 258 case 'for_blog': 259 return call_user_func_array( array( $this, 'for_site' ), $arguments ); 260 case '_init_caps': 261 return call_user_func_array( array( $this, $name ), $arguments ); 259 262 } 263 260 264 return false; 261 265 } 262 266 … … 772 776 /** 773 777 * Set the site to operate on. Defaults to the current site. 774 778 * 775 * @since 3.0.0 779 * @since 4.8.0 780 * @access public 776 781 * 777 782 * @global wpdb $wpdb WordPress database abstraction object. 778 783 * 779 * @param int $ blog_id Optional. Site ID, defaults to current site.784 * @param int $site_id Optional. Site ID, defaults to current site. 780 785 */ 781 public function for_ blog( $blog_id = '' ) {786 public function for_site( $site_id = '' ) { 782 787 global $wpdb; 783 if ( ! empty( $blog_id ) ) 784 $cap_key = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities'; 785 else 788 789 if ( ! empty( $site_id ) ) { 790 $cap_key = $wpdb->get_blog_prefix( $site_id ) . 'capabilities'; 791 } else { 786 792 $cap_key = ''; 793 } 794 787 795 $this->_init_caps( $cap_key ); 788 796 } 789 797 } -
src/wp-includes/ms-blogs.php
824 824 if ( did_action( 'init' ) ) { 825 825 $wp_roles = new WP_Roles(); 826 826 $current_user = wp_get_current_user(); 827 $current_user->for_ blog( $new_blog );827 $current_user->for_site( $new_blog ); 828 828 } 829 829 830 830 /** This filter is documented in wp-includes/ms-blogs.php */ … … 898 898 if ( did_action( 'init' ) ) { 899 899 $wp_roles = new WP_Roles(); 900 900 $current_user = wp_get_current_user(); 901 $current_user->for_ blog( $blog );901 $current_user->for_site( $blog ); 902 902 } 903 903 904 904 /** This filter is documented in wp-includes/ms-blogs.php */