Changeset 2264461
- Timestamp:
- 03/20/2020 11:34:31 AM (6 years ago)
- Location:
- kodeks-dashboard/trunk
- Files:
-
- 2 edited
-
functions.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kodeks-dashboard/trunk/functions.php
r2250600 r2264461 172 172 add_action( 'init', 'isa_editor_manage_users' ); 173 173 174 //prevent editor from deleting, editing, or creating an administrator175 // only needed if the editor was given right to edit users176 177 class ISA_User_Caps {178 179 // Add our filters180 function __construct() {181 add_filter( 'editable_roles', array(&$this, 'editable_roles'));182 add_filter( 'map_meta_cap', array(&$this, 'map_meta_cap'),10,4);183 }184 // Remove 'Administrator' from the list of roles if the current user is not an admin185 function editable_roles( $roles ){186 if( isset( $roles['administrator'] ) && !current_user_can('administrator') ){187 unset( $roles['administrator']);188 }189 return $roles;190 }191 // If someone is trying to edit or delete an192 // admin and that user isn't an admin, don't allow it193 function map_meta_cap( $caps, $cap, $user_id, $args ){194 switch( $cap ){195 case 'edit_user':196 case 'remove_user':197 case 'promote_user':198 if( isset($args[0]) && $args[0] == $user_id )199 break;200 elseif( !isset($args[0]) )201 $caps[] = 'do_not_allow';202 $other = new WP_User( absint($args[0]) );203 if( $other->has_cap( 'administrator' ) ){204 if(!current_user_can('administrator')){205 $caps[] = 'do_not_allow';206 }207 }208 break;209 case 'delete_user':210 case 'delete_users':211 if( !isset($args[0]) )212 break;213 $other = new WP_User( absint($args[0]) );214 if( $other->has_cap( 'administrator' ) ){215 if(!current_user_can('administrator')){216 $caps[] = 'do_not_allow';217 }218 }219 break;220 default:221 break;222 }223 return $caps;224 }225 226 }227 228 $isa_user_caps = new ISA_User_Caps();174 //prevent editor from deleting, editing, or creating an administrator 175 // only needed if the editor was given right to edit users 176 177 class ISA_User_Caps { 178 179 // Add our filters 180 function __construct() { 181 add_filter( 'editable_roles', array(&$this, 'editable_roles')); 182 add_filter( 'map_meta_cap', array(&$this, 'map_meta_cap'),10,4); 183 } 184 // Remove 'Administrator' from the list of roles if the current user is not an admin 185 function editable_roles( $roles ){ 186 if( isset( $roles['administrator'] ) && !current_user_can('administrator') ){ 187 unset( $roles['administrator']); 188 } 189 return $roles; 190 } 191 // If someone is trying to edit or delete an 192 // admin and that user isn't an admin, don't allow it 193 function map_meta_cap( $caps, $cap, $user_id, $args ){ 194 switch( $cap ){ 195 case 'edit_user': 196 case 'remove_user': 197 case 'promote_user': 198 if( isset($args[0]) && $args[0] == $user_id ) 199 break; 200 elseif( !isset($args[0]) ) 201 $caps[] = 'do_not_allow'; 202 $other = new WP_User( absint($args[0]) ); 203 if( $other->has_cap( 'administrator' ) ){ 204 if(!current_user_can('administrator')){ 205 $caps[] = 'do_not_allow'; 206 } 207 } 208 break; 209 case 'delete_user': 210 case 'delete_users': 211 if( !isset($args[0]) ) 212 break; 213 $other = new WP_User( absint($args[0]) ); 214 if( $other->has_cap( 'administrator' ) ){ 215 if(!current_user_can('administrator')){ 216 $caps[] = 'do_not_allow'; 217 } 218 } 219 break; 220 default: 221 break; 222 } 223 return $caps; 224 } 225 226 } 227 228 $isa_user_caps = new ISA_User_Caps(); 229 229 // Hide all administrators from user list. 230 230 add_action('pre_user_query','isa_pre_user_query'); … … 692 692 } 693 693 694 if ( is_plugin_active( 'acf-content-analysis-for-yoast-seo/yoast-acf-analysis.php' ) ) { 695 add_filter( 'yoast-acf-analysis/refresh_rate', function () { 696 // Refresh rates in milliseconds 697 return 20000; 698 }); 699 } 700 701 694 702 ?> -
kodeks-dashboard/trunk/readme.txt
r2250603 r2264461 1 1 === Kodeks Dashboard === 2 Version: 2. 12 Version: 2.2 3 3 Contributors: Kodeks AS 4 4 Tested up to: 5.3.2
Note: See TracChangeset
for help on using the changeset viewer.