/** * Retrieve attachment objects for list table display * * Compatibility shim for MLAQuery::mla_query_list_table_items * * @since 0.1 * * @param array query parameters from web page, usually found in $_REQUEST * @param int number of rows to skip over to reach desired page * @param int number of rows on each page * * @return array attachment objects (posts) including parent data, meta data and references */ public static function mla_query_list_table_items($request, $offset, $count) { return MLAQuery::mla_query_list_table_items($request, $offset, $count); }
/** * 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 0.1 */ function prepare_items() { // Initialize $this->_column_headers $this->get_column_info(); /* * Calculate and filter pagination arguments. */ $user = get_current_user_id(); $option = $this->screen->get_option('per_page', 'option'); $per_page = (int) get_user_meta($user, $option, true); if (empty($per_page) || $per_page < 1) { $per_page = (int) $this->screen->get_option('per_page', 'default'); } $current_page = isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1; $pagination = apply_filters_ref_array('mla_list_table_prepare_items_pagination', array(compact(array('per_page', 'current_page')), &$this)); $per_page = isset($pagination['per_page']) ? $pagination['per_page'] : $per_page; $current_page = isset($pagination['current_page']) ? $pagination['current_page'] : $current_page; /* * Assign sorted and paginated data to the items property, where * it can be used by the rest of the class. */ $total_items = apply_filters_ref_array('mla_list_table_prepare_items_total_items', array(NULL, &$this)); if (is_null($total_items)) { $total_items = MLAQuery::mla_count_list_table_items($_REQUEST, ($current_page - 1) * $per_page, $per_page); } /* * Register the pagination options & calculations. */ $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page))); $this->items = apply_filters_ref_array('mla_list_table_prepare_items_the_items', array(NULL, &$this)); if (is_null($this->items)) { $this->items = MLAQuery::mla_query_list_table_items($_REQUEST, ($current_page - 1) * $per_page, $per_page); } do_action_ref_array('mla_list_table_prepare_items', array(&$this)); }