/** ************************************************************************ * REQUIRED! 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(), although the following properties and methods * are frequently interacted with here... * * @uses $this->_column_headers * @uses $this->items * @uses $this->get_columns() * @uses $this->get_sortable_columns() * @uses $this->get_pagenum() * @uses $this->set_pagination_args() **************************************************************************/ function prepare_items($items = false) { // process bulk actions $this->process_bulk_action(); // get pagination state $current_page = $this->get_pagenum(); $per_page = $this->get_items_per_page('listings_per_page', 20); // define columns $this->_column_headers = $this->get_column_info(); // fetch listings from model - if no parameter passed if (!$items) { $listingsModel = new WPLA_ListingsModel(); $this->items = $listingsModel->getPageItems($current_page, $per_page, 'repricing'); $this->total_items = $listingsModel->total_items; } else { $this->items = $items; $this->total_items = count($items); } // register our pagination options & calculations. $this->set_pagination_args(array('total_items' => $this->total_items, 'per_page' => $per_page, 'total_pages' => ceil($this->total_items / $per_page))); }