Edit File by line
/home/barbar84/www/wp-inclu...
File: class-wp-role.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* User API: WP_Role class
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Users
[5] Fix | Delete
* @since 4.4.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Core class used to extend the user roles API.
[10] Fix | Delete
*
[11] Fix | Delete
* @since 2.0.0
[12] Fix | Delete
*/
[13] Fix | Delete
class WP_Role {
[14] Fix | Delete
/**
[15] Fix | Delete
* Role name.
[16] Fix | Delete
*
[17] Fix | Delete
* @since 2.0.0
[18] Fix | Delete
* @var string
[19] Fix | Delete
*/
[20] Fix | Delete
public $name;
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* List of capabilities the role contains.
[24] Fix | Delete
*
[25] Fix | Delete
* @since 2.0.0
[26] Fix | Delete
* @var bool[] Array of key/value pairs where keys represent a capability name and boolean values
[27] Fix | Delete
* represent whether the role has that capability.
[28] Fix | Delete
*/
[29] Fix | Delete
public $capabilities;
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* Constructor - Set up object properties.
[33] Fix | Delete
*
[34] Fix | Delete
* The list of capabilities must have the key as the name of the capability
[35] Fix | Delete
* and the value a boolean of whether it is granted to the role.
[36] Fix | Delete
*
[37] Fix | Delete
* @since 2.0.0
[38] Fix | Delete
*
[39] Fix | Delete
* @param string $role Role name.
[40] Fix | Delete
* @param bool[] $capabilities Array of key/value pairs where keys represent a capability name and boolean values
[41] Fix | Delete
* represent whether the role has that capability.
[42] Fix | Delete
*/
[43] Fix | Delete
public function __construct( $role, $capabilities ) {
[44] Fix | Delete
$this->name = $role;
[45] Fix | Delete
$this->capabilities = $capabilities;
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Assign role a capability.
[50] Fix | Delete
*
[51] Fix | Delete
* @since 2.0.0
[52] Fix | Delete
*
[53] Fix | Delete
* @param string $cap Capability name.
[54] Fix | Delete
* @param bool $grant Whether role has capability privilege.
[55] Fix | Delete
*/
[56] Fix | Delete
public function add_cap( $cap, $grant = true ) {
[57] Fix | Delete
$this->capabilities[ $cap ] = $grant;
[58] Fix | Delete
wp_roles()->add_cap( $this->name, $cap, $grant );
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Removes a capability from a role.
[63] Fix | Delete
*
[64] Fix | Delete
* @since 2.0.0
[65] Fix | Delete
*
[66] Fix | Delete
* @param string $cap Capability name.
[67] Fix | Delete
*/
[68] Fix | Delete
public function remove_cap( $cap ) {
[69] Fix | Delete
unset( $this->capabilities[ $cap ] );
[70] Fix | Delete
wp_roles()->remove_cap( $this->name, $cap );
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Determines whether the role has the given capability.
[75] Fix | Delete
*
[76] Fix | Delete
* @since 2.0.0
[77] Fix | Delete
*
[78] Fix | Delete
* @param string $cap Capability name.
[79] Fix | Delete
* @return bool Whether the role has the given capability.
[80] Fix | Delete
*/
[81] Fix | Delete
public function has_cap( $cap ) {
[82] Fix | Delete
/**
[83] Fix | Delete
* Filters which capabilities a role has.
[84] Fix | Delete
*
[85] Fix | Delete
* @since 2.0.0
[86] Fix | Delete
*
[87] Fix | Delete
* @param bool[] $capabilities Array of key/value pairs where keys represent a capability name and boolean values
[88] Fix | Delete
* represent whether the role has that capability.
[89] Fix | Delete
* @param string $cap Capability name.
[90] Fix | Delete
* @param string $name Role name.
[91] Fix | Delete
*/
[92] Fix | Delete
$capabilities = apply_filters( 'role_has_cap', $this->capabilities, $cap, $this->name );
[93] Fix | Delete
[94] Fix | Delete
if ( ! empty( $capabilities[ $cap ] ) ) {
[95] Fix | Delete
return $capabilities[ $cap ];
[96] Fix | Delete
} else {
[97] Fix | Delete
return false;
[98] Fix | Delete
}
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function