/**
  * Setup the rule.
  *
  * @since  1.0.0
  */
 public function prepare_obj()
 {
     if (MS_Rule_MemberCaps_Model::is_active()) {
         MS_Model_Rule::register_rule(self::RULE_ID, __CLASS__, __('Capabilities', 'membership2'), 1);
     }
     $this->add_filter('ms_view_protectedcontent_define-' . self::RULE_ID, 'handle_render_callback', 10, 2);
     $this->add_filter('ms_rule_listtable-' . self::RULE_ID, 'return_listtable');
 }
 /**
  * Prepares the list of effective capabilities to use
  *
  * Relevant Action Hooks:
  * - user_has_cap
  *
  * @since  1.0.0
  *
  * @param array   $allcaps An array of all the role's capabilities.
  * @param array   $caps    Actual capabilities for meta capability.
  * @param array   $args    Optional parameters passed to has_cap(), typically object ID.
  */
 public function prepare_caps($allcaps, $caps, $args, $user)
 {
     global $wp_roles;
     if (isset(self::$real_caps[$user->ID])) {
         // Only run the init code once for each user-ID.
         return $allcaps;
     } else {
         // First get a list of the users default capabilities.
         self::$real_caps[$user->ID] = $allcaps;
     }
     $caps = $this->rule_value;
     if (null === self::$real_caps) {
         // First get a list of the users default capabilities.
         self::$real_caps = $allcaps;
         // Use the permissions of the first rule without checking.
         foreach ($caps as $key => $value) {
             self::$real_caps[$key] = $value;
         }
     } else {
         // Only add additional capabilities from now on...
         foreach ($caps as $key => $value) {
             if ($value) {
                 self::$real_caps[$key] = 1;
             }
         }
     }
     return $allcaps;
 }