Ticket #12997: 12997.diff

File 12997.diff, 2.1 KB (added by ryan, 3 years ago)
  • wp-includes/capabilities.php

     
    299299        function add_cap( $cap, $grant = true ) { 
    300300                global $wp_roles; 
    301301 
    302                 if ( ! isset( $wp_roles ) ) 
    303                         $wp_roles = new WP_Roles(); 
    304  
    305302                $this->capabilities[$cap] = $grant; 
    306303                $wp_roles->add_cap( $this->name, $cap, $grant ); 
    307304        } 
     
    322319        function remove_cap( $cap ) { 
    323320                global $wp_roles; 
    324321 
    325                 if ( ! isset( $wp_roles ) ) 
    326                         $wp_roles = new WP_Roles(); 
    327  
    328322                unset( $this->capabilities[$cap] ); 
    329323                $wp_roles->remove_cap( $this->name, $cap ); 
    330324        } 
     
    539533        function get_role_caps() { 
    540534                global $wp_roles; 
    541535 
    542                 if ( ! isset( $wp_roles ) ) 
    543                         $wp_roles = new WP_Roles(); 
    544  
    545                 //Filter out caps that are not role names and assign to $this->roles 
     536                // Filter out caps that are not role names and assign to $this->roles 
    546537                if ( is_array( $this->caps ) ) 
    547538                        $this->roles = array_filter( array_keys( $this->caps ), array( &$wp_roles, 'is_role' ) ); 
    548539 
     
    11091100function get_role( $role ) { 
    11101101        global $wp_roles; 
    11111102 
    1112         if ( ! isset( $wp_roles ) ) 
    1113                 $wp_roles = new WP_Roles(); 
    1114  
    11151103        return $wp_roles->get_role( $role ); 
    11161104} 
    11171105 
     
    11291117function add_role( $role, $display_name, $capabilities = array() ) { 
    11301118        global $wp_roles; 
    11311119 
    1132         if ( ! isset( $wp_roles ) ) 
    1133                 $wp_roles = new WP_Roles(); 
    1134  
    11351120        return $wp_roles->add_role( $role, $display_name, $capabilities ); 
    11361121} 
    11371122 
     
    11471132function remove_role( $role ) { 
    11481133        global $wp_roles; 
    11491134 
    1150         if ( ! isset( $wp_roles ) ) 
    1151                 $wp_roles = new WP_Roles(); 
    1152  
    11531135        return $wp_roles->remove_role( $role ); 
    11541136} 
    11551137 
  • wp-settings.php

     
    234234$wp =& new WP(); 
    235235 
    236236/** 
     237 * WordPress Roles Object 
     238 * @global object $wp_roles 
     239 * @since 2.0.0 
     240 */ 
     241$wp_roles =& new WP_Roles(); 
     242 
     243/** 
    237244 * WordPress Widget Factory Object 
    238245 * @global object $wp_widget_factory 
    239246 * @since 2.8.0