PHP Class WPCOM_VIP_Support_Role, vip-mu-plugins-public

Datei anzeigen Open project: Automattic/vip-mu-plugins-public Class Usage Examples

Public Methods

Method 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.

Protected Methods

Method 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 method

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

action_admin_init() public method

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

action_init() public method

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 method

protected static add_role ( )

error_log() protected static method

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 method

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
return array An array of WP role data

filter_user_has_cap() public method

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.
return array An array of all the user's caps, with the required cap added

init() public static method

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

update() protected method

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