Changeset 4113
- Timestamp:
- 08/24/2006 11:23:36 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/capabilities.php
r3859 r4113 7 7 var $role_names = array(); 8 8 var $role_key; 9 var $use_db = true; 9 10 10 11 function WP_Roles() { … … 14 15 function _init () { 15 16 global $wpdb; 17 global $wp_user_roles; 16 18 $this->role_key = $wpdb->prefix . 'user_roles'; 17 18 $this->roles = get_option($this->role_key); 19 if ( ! empty($wp_user_roles) ) { 20 $this->roles = $wp_user_roles; 21 $this->use_db = false; 22 } else { 23 $this->roles = get_option($this->role_key); 24 } 19 25 20 26 if ( empty($this->roles) ) … … 36 42 'name' => $display_name, 37 43 'capabilities' => $capabilities); 38 update_option($this->role_key, $this->roles); 44 if ( $this->use_db ) 45 update_option($this->role_key, $this->roles); 39 46 $this->role_objects[$role] = new WP_Role($role, $capabilities); 40 47 $this->role_names[$role] = $display_name; … … 49 56 unset($this->role_names[$role]); 50 57 unset($this->roles[$role]); 51 52 update_option($this->role_key, $this->roles); 58 59 if ( $this->use_db ) 60 update_option($this->role_key, $this->roles); 53 61 } 54 62 55 63 function add_cap($role, $cap, $grant = true) { 56 64 $this->roles[$role]['capabilities'][$cap] = $grant; 57 update_option($this->role_key, $this->roles); 65 if ( $this->use_db ) 66 update_option($this->role_key, $this->roles); 58 67 } 59 68 60 69 function remove_cap($role, $cap) { 61 70 unset($this->roles[$role]['capabilities'][$cap]); 62 update_option($this->role_key, $this->roles); 71 if ( $this->use_db ) 72 update_option($this->role_key, $this->roles); 63 73 } 64 74
Note: See TracChangeset
for help on using the changeset viewer.