Ticket #9128: 9128.2.diff
File 9128.2.diff, 2.2 KB (added by , 15 years ago) |
---|
-
wp-includes/capabilities.php
97 97 * @global array $wp_user_roles Used to set the 'roles' property value. 98 98 */ 99 99 function _init () { 100 global $wpdb; 101 global $wp_user_roles; 100 global $wpdb, $wp_user_roles; 102 101 $this->role_key = $wpdb->prefix . 'user_roles'; 103 102 if ( ! empty( $wp_user_roles ) ) { 104 103 $this->roles = $wp_user_roles; … … 545 544 //Build $allcaps from role caps, overlay user's $caps 546 545 $this->allcaps = array(); 547 546 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 ); 550 549 } 551 550 $this->allcaps = array_merge( (array) $this->allcaps, (array) $this->caps ); 552 551 } … … 652 651 function update_user_level_from_caps() { 653 652 global $wpdb; 654 653 $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 ); 656 655 } 657 656 658 657 /** … … 678 677 * @param string $cap Capability name. 679 678 */ 680 679 function remove_cap( $cap ) { 681 if ( empty( $this->caps[$cap] ) ) return; 680 if ( empty( $this->caps[$cap] ) ) 681 return; 682 682 unset( $this->caps[$cap] ); 683 683 update_usermeta( $this->ID, $this->cap_key, $this->caps ); 684 684 } … … 693 693 global $wpdb; 694 694 $this->caps = array(); 695 695 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', '' ); 697 697 $this->get_role_caps(); 698 698 } 699 699 … … 782 782 return call_user_func_array( 'map_meta_cap', $args ); 783 783 } 784 784 785 if ( '' != $post->post_author) {785 if ( '' != $post->post_author ) { 786 786 $post_author_data = get_userdata( $post->post_author ); 787 787 } else { 788 788 //No author set yet so default to current user for cap checks