WPDK  1.5.0
WordPress Development Kit
 All Data Structures Files Functions Variables Pages
WPDKRoles Class Reference
Inheritance diagram for WPDKRoles:

Public Member Functions

 __construct ()
 Construct. More...
 
 activeRoles ()
 Active roles. More...
 
 inactiveRoles ()
 Inactive roles. More...
 
 countUsersByRole ($user_role= '')
 Counts the number of users for roles. More...
 
 arrayCapabilitiesByRole ()
 List of caps for role. More...
 
 roleExists ($role)
 Check if a role exists. More...
 
 wordPressRoles ()
 WordPress default roles. More...
 
 add_role ($role, $display_name, $capabilities=array(), $description= '', $owner= '')
 Add role name with capabilities to list. More...
 
 remove_role ($role)
 Role. More...
 
 selectCapabilitiesWithRole ($role)
 

Static Public Member Functions

static init ()
 Get singleton instance. More...
 
static getInstance ()
 Get singleton instance. More...
 
static invalidate ()
 Invalidate. More...
 

Data Fields

const OPTION_KEY = '_wpdk_roles_extends'
 The option key prefix. More...
 
const SUPER_ADMIN = 'super-admin'
 
const ADMINISTRATOR = 'administrator'
 
const EDITOR = 'editor'
 
const AUTHOR = 'author'
 
const CONTRIBUTOR = 'contributor'
 
const SUBSCRIBER = 'subscriber'
 
 $activeRoles
 Active roles. More...
 
 $inactiveRoles
 Inactive roles. More...
 
 $wordPressRoles
 WordPress. More...
 
 $count
 Counts of roles. More...
 
 $arrayCountUsersByRole
 Array with count for user. More...
 
 $arrayCapabilitiesByRole
 List of caps for role. More...
 

Detailed Description

An extended version of WordPress WP_Roles model.

Author
=undo= info@.nosp@m.wpxt.nosp@m.re.me
Date
2014-02-02
Version
1.0.0

Definition at line 1786 of file wpdk-user.php.

Constructor & Destructor Documentation

__construct ( )

Construct.

Create an instance of WPDKRoles class

Note
This is a singleton class but for backward compatibility subclass this method can not private
Returns
WPDKRoles

Definition at line 1928 of file wpdk-user.php.

Member Function Documentation

activeRoles ( )

Active roles.

Gets all the roles that have users for the site.

Returns
array

Definition at line 1966 of file wpdk-user.php.

add_role (   $role,
  $display_name,
  $capabilities = array(),
  $description = '',
  $owner = '' 
)

Add role name with capabilities to list.

Updates the list of roles, if the role doesn't already exist.

The capabilities are defined in the following format `array( 'read' => true );` To explicitly deny a role a capability you set the value for that capability to false.

In this overide method you can extends the capapilities array with format `array( 'read' => true, 'description' => 'Thsi capability allow access to...' );`

Parameters
string$roleRole name.
string$display_nameRole display name.
array$capabilitiesOptional. List of role capabilities in the above format.
string$descriptionOptional. An extend description for this role.
string$ownerOptional. Owner of this role
Note
This method override the WP_Roles method to extend
Returns
null|WP_Role

Definition at line 2148 of file wpdk-user.php.

arrayCapabilitiesByRole ( )

List of caps for role.

Create An key value pairs array with key = role and value = list of capabilities.

Returns
array

Definition at line 2071 of file wpdk-user.php.

countUsersByRole (   $user_role = '')

Counts the number of users for roles.

Return the global or singular count for role. Counts the number of users for all roles on the site and returns this as an array. If the $user_role is input, the return value will be the count just for that particular role.

Parameters
string$user_roleOptional. The role to get the user count for.
Returns
int

Definition at line 2021 of file wpdk-user.php.

static getInstance ( )
static

Get singleton instance.

Create a singleton instance of WPDKRoles class

Returns
WPDKRoles

Definition at line 1896 of file wpdk-user.php.

inactiveRoles ( )

Inactive roles.

Gets all the roles that do not have users for the site.

Returns
array

Definition at line 1991 of file wpdk-user.php.

static init ( )
static

Get singleton instance.

Create a singleton instance of WPDKRoles class

Note
This is an alias of getInstance() static method
Returns
WPDKRoles

Definition at line 1884 of file wpdk-user.php.

static invalidate ( )
static

Invalidate.

Used to invalidate static (internal singleton) and refresh all roles list

Returns
WPDKRoles

Definition at line 1911 of file wpdk-user.php.

remove_role (   $role)

Role.

Remove a role

Parameters
string$role

Definition at line 2177 of file wpdk-user.php.

roleExists (   $role)

Check if a role exists.

Return TRUE if the role exists

Parameters
string$roleRole key name
Returns
bool

Definition at line 2097 of file wpdk-user.php.

selectCapabilitiesWithRole (   $role)

Return the HTML markup for a combo select

Parameters
string | WPDKRole$roleRole
Returns
string

Definition at line 2196 of file wpdk-user.php.

wordPressRoles ( )

WordPress default roles.

Return a key value pairs array with name of role and extra info.

Returns
mixed|void

Definition at line 2109 of file wpdk-user.php.

Field Documentation

array $activeRoles

Active roles.

An array with all active roles

Definition at line 1811 of file wpdk-user.php.

List of caps for role.

An key value pairs array with key = role and value = list of capabilities.

Definition at line 1856 of file wpdk-user.php.

array $arrayCountUsersByRole

Array with count for user.

List with count role group by user

Definition at line 1847 of file wpdk-user.php.

int $count

Counts of roles.

Number of roles

Definition at line 1838 of file wpdk-user.php.

array $inactiveRoles

Inactive roles.

An array with all inactive roles

Definition at line 1820 of file wpdk-user.php.

WordPress.

Default WordPress roles

Definition at line 1829 of file wpdk-user.php.

const ADMINISTRATOR = 'administrator'

Definition at line 1798 of file wpdk-user.php.

const AUTHOR = 'author'

Definition at line 1800 of file wpdk-user.php.

const CONTRIBUTOR = 'contributor'

Definition at line 1801 of file wpdk-user.php.

const EDITOR = 'editor'

Definition at line 1799 of file wpdk-user.php.

const OPTION_KEY = '_wpdk_roles_extends'

The option key prefix.

The extra data are save in option table with this prefix

Definition at line 1794 of file wpdk-user.php.

const SUBSCRIBER = 'subscriber'

Definition at line 1802 of file wpdk-user.php.

const SUPER_ADMIN = 'super-admin'

Definition at line 1797 of file wpdk-user.php.


The documentation for this class was generated from the following file: