/**
  * Prepare the list and choose which items to display.
  *
  * This is the core logic of the listtable parent class!
  *
  * @since  1.0.0
  */
 public function prepare_items()
 {
     $args = null;
     $this->_column_headers = array($this->get_columns(), $this->get_hidden_columns(), $this->get_sortable_columns());
     // Some columns have a pre-defined title that cannot be changed.
     if (isset($this->_column_headers[0]['cb'])) {
         $this->_column_headers[0]['cb'] = '<input type="checkbox" />';
     }
     $is_dripped = in_array($this->model->rule_type, MS_Model_Rule::get_dripped_rule_types());
     if ($is_dripped) {
         $this->_column_headers[0]['dripped'] = __('Reveal Content', 'membership2');
     } else {
         unset($this->_column_headers[0]['dripped']);
     }
     if (isset($this->_column_headers[0]['access'])) {
         $this->_column_headers[0]['access'] = __('Who Has Access', 'membership2');
     }
     // Initialize current pagination Page
     $per_page = $this->get_items_per_page("{$this->id}_per_page", self::DEFAULT_PAGE_SIZE);
     /**
      * Custom filter to modify the items on all Protection Rule list tables.
      *
      * @since 1.0.1.0
      * @var   int
      */
     $per_page = apply_filters('rule_items_per_page', $per_page, $this->id);
     $current_page = $this->get_pagenum();
     $args = array('posts_per_page' => $per_page, 'number' => $per_page, 'offset' => ($current_page - 1) * $per_page);
     // Add a status filter
     if (!empty($_GET['status'])) {
         $args['rule_status'] = $_GET['status'];
     }
     // Search string.
     if (!empty($_REQUEST['s'])) {
         $this->search_string = $_REQUEST['s'];
         $args['s'] = $_REQUEST['s'];
         $args['posts_per_page'] = -1;
         $args['number'] = false;
         $args['offset'] = 0;
     }
     // Month filter.
     if (!empty($_REQUEST['m']) && 6 == strlen($_REQUEST['m'])) {
         $args['year'] = substr($_REQUEST['m'], 0, 4);
         $args['monthnum'] = substr($_REQUEST['m'], 5, 2);
     }
     // If a membership is filtered then only show protected items
     if (!empty($_REQUEST['membership_id'])) {
         $args['membership_id'] = $_REQUEST['membership_id'];
     }
     // Allow other helper list tables to customize the args array.
     $args = $this->prepare_items_args($args);
     // Count items
     $total_items = $this->model->get_content_count($args);
     // List available items
     $this->items = apply_filters("ms_rule_{$this->id}_items", $this->model->get_contents($args));
     // Save the args for use in later functions
     $this->prepared_args = $args;
     // Prepare the table pagination
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page));
 }