/**
  * Setup the rule.
  *
  * @since  1.0.0
  */
 public function prepare_obj()
 {
     if (MS_Rule_CptGroup_Model::is_active()) {
         MS_Model_Rule::register_rule(self::RULE_ID, __CLASS__, __('Custom Post Types', MS_TEXT_DOMAIN), 30, true);
     }
     $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');
 }
 /**
  * Get WP_Query object arguments.
  *
  * Return default search arguments.
  *
  * @since  1.0.0
  *
  * @param $args The query post args
  *     @see @link http://codex.wordpress.org/Function_Reference/get_pages
  * @return array $args The parsed args.
  */
 public function get_query_args($args = null)
 {
     $cpts = MS_Rule_CptGroup_Model::get_custom_post_types();
     if (!isset($args['post_type'])) {
         $args['post_type'] = $cpts;
     }
     return parent::prepare_query_args($args, 'get_posts');
 }
 /**
  * Get rule accordingly to post type.
  *
  * @since  1.0.0
  *
  * @param MS_Model_Membership The membership to get rule from.
  * @param string $post_type The post_type name of the queried post object.
  * @return MS_Rule The rule model.
  */
 private function get_rule($membership, $post_type)
 {
     $rule = null;
     switch ($post_type) {
         case 'post':
             $rule = $membership->get_rule(MS_Rule_Post::RULE_ID);
             break;
         case 'page':
             $rule = $membership->get_rule(MS_Rule_Page::RULE_ID);
             break;
         case 'attachment':
             $rule = $membership->get_rule(MS_Rule_Media::RULE_ID);
             break;
         default:
             if (in_array($post_type, MS_Rule_CptGroup_Model::get_custom_post_types())) {
                 if (MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_CPT_POST_BY_POST)) {
                     $rule = $membership->get_rule(MS_Rule_CptItem::RULE_ID);
                 } else {
                     $rule = $membership->get_rule(MS_Rule_CptGroup::RULE_ID);
                 }
             } else {
                 $rule = $membership->get_rule($post_type);
             }
             break;
     }
     return apply_filters('ms_controller_metabox_get_rule', $rule, $membership, $post_type, $this);
 }
 /**
  * Determine whether Membership access can be changed or is read-only.
  *
  * @since  1.0.0
  * @param string $post_type The post type of the post.
  * @return bool
  */
 public function is_read_only($post_type)
 {
     if ('post' == $post_type && !MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_POST_BY_POST)) {
         $read_only = true;
     } elseif ('attachment' == $post_type) {
         $read_only = true;
     } elseif (in_array($post_type, MS_Rule_CptGroup_Model::get_custom_post_types())) {
         if (MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_CPT_POST_BY_POST)) {
             $read_only = false;
         } else {
             $read_only = true;
         }
     } else {
         $read_only = false;
     }
     return apply_filters('ms_controller_membership_metabox_is_read_only', $read_only, $post_type, $this);
 }