예제 #1
0
 /**
  * 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
0
 function __construct()
 {
     parent::__construct();
 }
예제 #3
0
 /**
  * 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);
     }
 }