Plugin Directory

Changeset 2387363


Ignore:
Timestamp:
09/23/2020 11:36:22 PM (6 years ago)
Author:
Mosterd3d
Message:

tagging version 4.0

Location:
dd-roles
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • dd-roles/tags/4.0/dd_roles.php

    r2386617 r2387363  
    22/*
    33Plugin Name: DD_Roles
    4 Version: 3.2
     4Version: 4.0
    55Plugin URI: http://dijkstradesign.com
    66Description: A plug-in to add and edit the roles and capabilities
     
    364364
    365365        $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 = [];
    366368
    367369        foreach ($ordered_caps as $cap=>$params) {
     
    384386            $ordered_caps['others']['capabilities'] = array_unique( array_diff($ordered_caps['others']['capabilities'], self::getAllGroupedCaps($ordered_caps)));
    385387            $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;
    388424    }
    389425
  • dd-roles/tags/4.0/readme.txt

    r2386617 r2387363  
    55Requires at least: 3.3
    66Tested up to: 5.5.1
    7 Stable tag: 3.2
     7Stable tag: 4.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3131
    3232== Changelog ==
     33
     34= 4.0 =
     35* Filter on custom capability types
    3336
    3437= 3.2 =
  • dd-roles/trunk/dd_roles.php

    r2386617 r2387363  
    22/*
    33Plugin Name: DD_Roles
    4 Version: 3.2
     4Version: 4.0
    55Plugin URI: http://dijkstradesign.com
    66Description: A plug-in to add and edit the roles and capabilities
     
    364364
    365365        $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 = [];
    366368
    367369        foreach ($ordered_caps as $cap=>$params) {
     
    384386            $ordered_caps['others']['capabilities'] = array_unique( array_diff($ordered_caps['others']['capabilities'], self::getAllGroupedCaps($ordered_caps)));
    385387            $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;
    388424    }
    389425
  • dd-roles/trunk/readme.txt

    r2386617 r2387363  
    55Requires at least: 3.3
    66Tested up to: 5.5.1
    7 Stable tag: 3.2
     7Stable tag: 4.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3131
    3232== Changelog ==
     33
     34= 4.0 =
     35* Filter on custom capability types
    3336
    3437= 3.2 =
Note: See TracChangeset for help on using the changeset viewer.