Changeset 2387363
- Timestamp:
- 09/23/2020 11:36:22 PM (6 years ago)
- Location:
- dd-roles
- Files:
-
- 4 edited
- 1 copied
-
tags/4.0 (copied) (copied from dd-roles/trunk)
-
tags/4.0/dd_roles.php (modified) (3 diffs)
-
tags/4.0/readme.txt (modified) (2 diffs)
-
trunk/dd_roles.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dd-roles/tags/4.0/dd_roles.php
r2386617 r2387363 2 2 /* 3 3 Plugin Name: DD_Roles 4 Version: 3.24 Version: 4.0 5 5 Plugin URI: http://dijkstradesign.com 6 6 Description: A plug-in to add and edit the roles and capabilities … … 364 364 365 365 $default_caps = self::get_default_caps(); 366 $prefixes = array('assign_','edit_others_','edit_private_','edit_published_','edit_','publish_','read_private_','read_','delete_published_','delete_private_','delete_others_','delete_','manage_','_terms'); 367 $capa_types = []; 366 368 367 369 foreach ($ordered_caps as $cap=>$params) { … … 384 386 $ordered_caps['others']['capabilities'] = array_unique( array_diff($ordered_caps['others']['capabilities'], self::getAllGroupedCaps($ordered_caps))); 385 387 $this->customCapabilities = $ordered_caps['others']['capabilities']; 386 $this->groupedCapabilities = $ordered_caps; 387 } 388 } 389 390 // loop through others capabilities en remove the prefixes 391 foreach ($ordered_caps['others']['capabilities'] as $key=>$capability) { 392 $raw_capa_type = str_replace($prefixes, "", $capability); 393 $capa_types [] = $raw_capa_type; 394 } 395 // create unique values 396 $capa_types = array_unique($capa_types); 397 398 // remove the plurals 399 foreach ($capa_types as $capa_type) { 400 $plural = $capa_type.'s'; 401 if (($key = array_search($plural, $capa_types)) !== false) { 402 unset($capa_types[$key]); 403 } 404 } 405 406 foreach ($capa_types as $capa_type) { 407 $ordered_caps[$capa_type]['title'] = ucfirst(str_replace('_', ' ', $capa_type)); 408 $ordered_caps[$capa_type]['desc'] = 'Allows access to capability type "'.$capa_type.'"'; 409 foreach ($ordered_caps['others']['capabilities'] as $capability) { 410 411 if ($capability === $capa_type) { 412 $ordered_caps[$capa_type]['capabilities'][] = $capability; 413 } 414 foreach ($prefixes as $prefix) { 415 if( strpos($capability, $prefix.$capa_type) !== false || strpos($capability, $prefix.$capa_type.'s') !== false) { 416 $ordered_caps[$capa_type]['capabilities'][] = $capability; 417 } 418 } 419 } 420 } 421 // remove 'others' 422 unset($ordered_caps['others']); 423 $this->groupedCapabilities = $ordered_caps; 388 424 } 389 425 -
dd-roles/tags/4.0/readme.txt
r2386617 r2387363 5 5 Requires at least: 3.3 6 6 Tested up to: 5.5.1 7 Stable tag: 3.27 Stable tag: 4.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 31 31 32 32 == Changelog == 33 34 = 4.0 = 35 * Filter on custom capability types 33 36 34 37 = 3.2 = -
dd-roles/trunk/dd_roles.php
r2386617 r2387363 2 2 /* 3 3 Plugin Name: DD_Roles 4 Version: 3.24 Version: 4.0 5 5 Plugin URI: http://dijkstradesign.com 6 6 Description: A plug-in to add and edit the roles and capabilities … … 364 364 365 365 $default_caps = self::get_default_caps(); 366 $prefixes = array('assign_','edit_others_','edit_private_','edit_published_','edit_','publish_','read_private_','read_','delete_published_','delete_private_','delete_others_','delete_','manage_','_terms'); 367 $capa_types = []; 366 368 367 369 foreach ($ordered_caps as $cap=>$params) { … … 384 386 $ordered_caps['others']['capabilities'] = array_unique( array_diff($ordered_caps['others']['capabilities'], self::getAllGroupedCaps($ordered_caps))); 385 387 $this->customCapabilities = $ordered_caps['others']['capabilities']; 386 $this->groupedCapabilities = $ordered_caps; 387 } 388 } 389 390 // loop through others capabilities en remove the prefixes 391 foreach ($ordered_caps['others']['capabilities'] as $key=>$capability) { 392 $raw_capa_type = str_replace($prefixes, "", $capability); 393 $capa_types [] = $raw_capa_type; 394 } 395 // create unique values 396 $capa_types = array_unique($capa_types); 397 398 // remove the plurals 399 foreach ($capa_types as $capa_type) { 400 $plural = $capa_type.'s'; 401 if (($key = array_search($plural, $capa_types)) !== false) { 402 unset($capa_types[$key]); 403 } 404 } 405 406 foreach ($capa_types as $capa_type) { 407 $ordered_caps[$capa_type]['title'] = ucfirst(str_replace('_', ' ', $capa_type)); 408 $ordered_caps[$capa_type]['desc'] = 'Allows access to capability type "'.$capa_type.'"'; 409 foreach ($ordered_caps['others']['capabilities'] as $capability) { 410 411 if ($capability === $capa_type) { 412 $ordered_caps[$capa_type]['capabilities'][] = $capability; 413 } 414 foreach ($prefixes as $prefix) { 415 if( strpos($capability, $prefix.$capa_type) !== false || strpos($capability, $prefix.$capa_type.'s') !== false) { 416 $ordered_caps[$capa_type]['capabilities'][] = $capability; 417 } 418 } 419 } 420 } 421 // remove 'others' 422 unset($ordered_caps['others']); 423 $this->groupedCapabilities = $ordered_caps; 388 424 } 389 425 -
dd-roles/trunk/readme.txt
r2386617 r2387363 5 5 Requires at least: 3.3 6 6 Tested up to: 5.5.1 7 Stable tag: 3.27 Stable tag: 4.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 31 31 32 32 == Changelog == 33 34 = 4.0 = 35 * Filter on custom capability types 33 36 34 37 = 3.2 =
Note: See TracChangeset
for help on using the changeset viewer.