/** * Prepares the list of items for displaying * * This is where you prepare your data for display. This method will usually * be used to query the database, sort and filter the data, and generally * get it ready to be displayed. At a minimum, we should set $this->items and * $this->set_pagination_args(). * * @since 1.40 * * @return void */ function prepare_items() { $this->_column_headers = array($this->get_columns(), $this->get_hidden_columns(), $this->get_sortable_columns()); /* * REQUIRED for pagination. */ $total_items = MLAMime::mla_count_view_items($_REQUEST); $user = get_current_user_id(); $screen = get_current_screen(); $option = $screen->get_option('per_page', 'option'); if (is_string($option)) { $per_page = get_user_meta($user, $option, true); } else { $per_page = 10; } if (empty($per_page) || $per_page < 1) { $per_page = $screen->get_option('per_page', 'default'); } /* * REQUIRED. We also have to register our pagination options & calculations. */ $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page))); $current_page = $this->get_pagenum(); /* * REQUIRED. Assign sorted and paginated data to the items property, where * it can be used by the rest of the class. */ $this->items = MLAMime::mla_query_view_items($_REQUEST, ($current_page - 1) * $per_page, $per_page); }