PHP Class WPCOM_VIP_Support_Role, vip-mu-plugins-public

Afficher le fichier Open project: Automattic/vip-mu-plugins-public Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( ) Class constructor. Handles hooking actions and filters, and sets some properties.
action_admin_init ( ) Hooks the admin_init action to run an update method.
action_init ( ) Hooks the init action to add the role, covering the cases where we should be using wpcom_vip_add_role.
filter_editable_roles ( array $roles ) : array Hooks the editable_roles filter to place the VIP Support at the bottom of any roles listing.
filter_user_has_cap ( array $user_caps, array $caps, array $args, WP_User $user ) : array Hooks the user_has_cap filter to allow VIP Support role users to do EVERYTHING
init ( ) : WPCOM_VIP_Support_Role Initiate an instance of this class if one doesn't exist already. Return the VipSupportRole instance.

Méthodes protégées

Méthode Description
add_role ( )
error_log ( string $message ) Log errors if WP_DEBUG is defined and true.
update ( ) Checks the version option value against the version property value, and runs update routines as appropriate.

Method Details

__construct() public méthode

Class constructor. Handles hooking actions and filters, and sets some properties.
public __construct ( )

action_admin_init() public méthode

Hooks the admin_init action to run an update method.
public action_admin_init ( )

action_init() public méthode

Hooks the init action to add the role, covering the cases where we should be using wpcom_vip_add_role.
public action_init ( )

add_role() protected static méthode

protected static add_role ( )

error_log() protected static méthode

Log errors if WP_DEBUG is defined and true.
protected static error_log ( string $message )
$message string The message to log

filter_editable_roles() public méthode

Hooks the editable_roles filter to place the VIP Support at the bottom of any roles listing.
public filter_editable_roles ( array $roles ) : array
$roles array An array of WP role data
Résultat array An array of WP role data

filter_user_has_cap() public méthode

Rather than explicitly adding all the capabilities to the admin role, and possibly missing some custom ones, or copying a role, and possibly being tripped up when that role doesn't exist, we filter all user capability checks and wave past our VIP Support users as automattically having the capability being checked.
public filter_user_has_cap ( array $user_caps, array $caps, array $args, WP_User $user ) : array
$user_caps array An array of all the user's capabilities.
$caps array Actual capabilities for meta capability.
$args array Optional parameters passed to has_cap(), typically object ID.
$user WP_User The user object.
Résultat array An array of all the user's caps, with the required cap added

init() public static méthode

Initiate an instance of this class if one doesn't exist already. Return the VipSupportRole instance.
public static init ( ) : WPCOM_VIP_Support_Role
Résultat WPCOM_VIP_Support_Role object The instance of WPCOM_VIP_Support_Role

update() protected méthode

Checks the version option value against the version property value, and runs update routines as appropriate.
protected update ( )