Make WordPress Core

Ticket #9128: 9128.2.diff

File 9128.2.diff, 2.2 KB (added by dd32, 15 years ago)
  • wp-includes/capabilities.php

     
    9797         * @global array $wp_user_roles Used to set the 'roles' property value.
    9898         */
    9999        function _init () {
    100                 global $wpdb;
    101                 global $wp_user_roles;
     100                global $wpdb, $wp_user_roles;
    102101                $this->role_key = $wpdb->prefix . 'user_roles';
    103102                if ( ! empty( $wp_user_roles ) ) {
    104103                        $this->roles = $wp_user_roles;
     
    545544                //Build $allcaps from role caps, overlay user's $caps
    546545                $this->allcaps = array();
    547546                foreach ( (array) $this->roles as $role ) {
    548                         $role =& $wp_roles->get_role( $role );
    549                         $this->allcaps = array_merge( (array) $this->allcaps, (array) $role->capabilities );
     547                        $the_role =& $wp_roles->get_role( $role );
     548                        $this->allcaps = array_merge( (array) $this->allcaps, (array) $the_role->capabilities );
    550549                }
    551550                $this->allcaps = array_merge( (array) $this->allcaps, (array) $this->caps );
    552551        }
     
    652651        function update_user_level_from_caps() {
    653652                global $wpdb;
    654653                $this->user_level = array_reduce( array_keys( $this->allcaps ), array( &$this, 'level_reduction' ), 0 );
    655                 update_usermeta( $this->ID, $wpdb->prefix.'user_level', $this->user_level );
     654                update_usermeta( $this->ID, $wpdb->prefix . 'user_level', $this->user_level );
    656655        }
    657656
    658657        /**
     
    678677         * @param string $cap Capability name.
    679678         */
    680679        function remove_cap( $cap ) {
    681                 if ( empty( $this->caps[$cap] ) ) return;
     680                if ( empty( $this->caps[$cap] ) )
     681                        return;
    682682                unset( $this->caps[$cap] );
    683683                update_usermeta( $this->ID, $this->cap_key, $this->caps );
    684684        }
     
    693693                global $wpdb;
    694694                $this->caps = array();
    695695                update_usermeta( $this->ID, $this->cap_key, '' );
    696                 update_usermeta( $this->ID, $wpdb->prefix.'user_level', '' );
     696                update_usermeta( $this->ID, $wpdb->prefix . 'user_level', '' );
    697697                $this->get_role_caps();
    698698        }
    699699
     
    782782                        return call_user_func_array( 'map_meta_cap', $args );
    783783                }
    784784
    785                 if ('' != $post->post_author) {
     785                if ( '' != $post->post_author ) {
    786786                        $post_author_data = get_userdata( $post->post_author );
    787787                } else {
    788788                        //No author set yet so default to current user for cap checks