Make WordPress Core

Ticket #36961: 36961.diff

File 36961.diff, 1.0 KB (added by flixos90, 8 years ago)
  • src/wp-includes/class-wp-user.php

     
    480480         * @return array List of all capabilities for the user.
    481481         */
    482482        public function get_role_caps() {
     483                $switch_site = false;
     484                if ( is_multisite() && $this->db->get_blog_prefix() . 'capabilities' !== $this->cap_key ) {
     485                        $base_prefix = $this->db->get_blog_prefix( 1 );
     486                        if ( $base_prefix . 'capabilities' === $this->cap_key ) {
     487                                $switch_site = 1;
     488                        } else {
     489                                $switch_site = absint( substr( $this->cap_key, strlen( $base_prefix ), - strlen( '_capabilities' ) ) );
     490                        }
     491
     492                        switch_to_blog( $switch_site );
     493                }
     494
    483495                $wp_roles = wp_roles();
    484496
    485497                //Filter out caps that are not role names and assign to $this->roles
     
    494506                }
    495507                $this->allcaps = array_merge( (array) $this->allcaps, (array) $this->caps );
    496508
     509                if ( $switch_site ) {
     510                        restore_current_blog();
     511                }
     512
    497513                return $this->allcaps;
    498514        }
    499515