本文整理汇总了PHP中WP_Roles::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Roles::__construct方法的具体用法?PHP WP_Roles::__construct怎么用?PHP WP_Roles::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Roles
的用法示例。
在下文中一共展示了WP_Roles::__construct方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: count
/**
* The class constructor, that extends in some part the default constructor of parent WP_Roles
*
* @brief The constructor
*
* @since 0.0.1
*
* @note Here is a different, cleaner approach to the singleton concept.
*
*/
function __construct()
{
// If this is first New about this object
// if( ! isset( self::$_firstInstance )) {
// Parent
parent::__construct();
// Get the # of users for every role
$this->_countUsersByRole();
// # of roles
$this->countRoles = count($this->roles);
// At last, save this instance in private static environment: AT LAST!!!!!
// self::$_firstInstance = $this;
// }
// else {
//
// // Get previous instance data and create a mirror
// foreach( get_object_vars( self::$_firstInstance ) as $sProp => $sValue ) {
// $this->$sProp = $sValue;
// }
//
// }
}
示例2:
function __construct()
{
parent::__construct();
}
示例3: __construct
/**
* Create an instance of WPDKUserRoles class
*
* @brief Construct
*
* @note This is a singleton class but for backward compatibility subclass this method can not private
*
* @return WPDKUserRoles
*
*/
public function __construct()
{
parent::__construct();
// WPXtreme::caller();
// Get the extended data
$this->extend_data = get_option(self::OPTION_KEY);
if (!empty($this->role_names)) {
$this->count = count($this->role_names);
}
// Init the `wordPressRoles` property with the list of WordPress default roles
$this->wordPressRoles();
// Init the `arrayCountUsersByRole` property with the count user by role
$this->countUsersByRole();
// Init the `activeRoles` and `inactiveRoles` properties with the list of used and unused role
$this->statusRoles();
// Init the `arrayCapabilitiesByRole` property with key = role and value = list of capabilities
$this->arrayCapabilitiesByRole();
// Init `all_roles` property with the list of all roles
$this->all_roles = array_merge($this->activeRoles, $this->inactiveRoles, $this->wordPressRoles);
/*
* $this->all_roles
*
* array(13) {
* ["administrator"]=> array(3) {
* [0]=> string(13) "Administrator"
* [1]=> string(58) "Somebody who has access to all the administration features"
* [2]=> string(9) "WordPress"
* }
* ["subscriber"]=> array(3) {
* [0]=> string(10) "Subscriber"
* [1]=> string(42) "Somebody who can only manage their profile"
* [2]=> string(9) "WordPress"
* }
* ...
* ["adv-manager"]=>
* array(3) {
* [0]=> string(11) "Adv Manager"
* [1]=> string(29) "This role is for adv manager."
* [2]=> string(13) "Roles Manager"
* }
* }
*/
if (empty($this->extend_data)) {
$this->extend_data = $this->all_roles;
update_option(self::OPTION_KEY, $this->extend_data);
/**
* Fires when the role is updated.
*
* @param array $extend The array extra (extends) data.
*/
do_action('wpdk_user_roles_extend_update', $this->extend_data);
}
}