function prepare_items() { global $wpdb, $_wp_column_headers; $screen = get_current_screen(); /** * First, lets decide how many records per page to show */ $per_page = mailusers_get_user_settings_table_rows(); if ($per_page === false) { $per_page = 10; } /* -- Pagination parameters -- */ //Number of elements in your table? $totalitems = count_users(); //Search? $search = !empty($_GET['s']) ? esc_sql($_GET['s']) : ''; //Which page is this? $paged = !empty($_GET['paged']) ? esc_sql($_GET['paged']) : ''; //Page Number if (empty($paged) || !is_numeric($paged) || $paged <= 0) { $paged = 1; } //How many pages do we have in total? $totalpages = ceil($totalitems['total_users'] / $per_page); //adjust the query to take pagination into account if (!empty($paged) && !empty($per_page)) { $offset = ($paged - 1) * $per_page; //$query.=' LIMIT '.(int)$offset.','.(int)$per_page; } /* -- Ordering parameters -- */ //Parameters that are going to be used to order the result $orderby = !empty($_GET['orderby']) ? esc_sql($_GET['orderby']) : 'display_name'; $order = !empty($_GET['order']) ? esc_sql($_GET['order']) : 'ASC'; /* -- Register the pagination -- */ $this->set_pagination_args(array('total_items' => $totalitems['total_users'], 'total_pages' => $totalpages, 'per_page' => $per_page)); //The pagination links are automatically built according to those parameters /** * REQUIRED. Now we need to define our column headers. This includes a complete * array of columns to be displayed (slugs & titles), a list of columns * to keep hidden, and a list of columns that are sortable. Each of these * can be defined in another method (as we've done here) before being * used to build the value for our _column_headers property. */ $columns = $this->get_columns(); $hidden = array(); $sortable = $this->get_sortable_columns(); /** * REQUIRED. Finally, we build an array to be used by the class for column * headers. The $this->_column_headers property takes an array which contains * 3 other arrays. One for all columns, one for hidden columns, and one * for sortable columns. */ $this->_column_headers = array($columns, $hidden, $sortable); /** * Optional. You can handle your bulk actions however you see fit. In this * case, we'll handle them within our package just to keep things clean. */ $this->process_bulk_action(); /* -- Fetch the items -- */ $args = array('fields' => 'all_with_meta', 'order' => $order, 'orderby' => $orderby, 'number' => (int) $per_page, 'offset' => (int) $offset, 'search' => $search, 'search_columns' => array('user_login', 'user_email', 'display_name', 'user_nicename'), 'count_total' => true); // Retrieve data $this->items = get_users($args); // Need to adjust pagination? // Only when doing a search as results will not match original total item count. if (!empty($search)) { // Don't limit the query unset($args['number']); /* -- Pagination parameters -- */ //Number of elements in your results? $totalitems = count(get_users($args)); //How many pages do we have in total? $totalpages = ceil($totalitems / $per_page); /* -- Register the pagination -- */ $this->set_pagination_args(array('total_items' => $totalitems, 'total_pages' => $totalpages, 'per_page' => $per_page)); //The pagination links are automatically built according to those parameters } }
?> ><?php _e('100', MAILUSERS_I18N_DOMAIN); ?> </option> <option value="200" <?php if (mailusers_get_user_settings_table_rows() == '200') { echo 'selected="true"'; } ?> ><?php _e('200', MAILUSERS_I18N_DOMAIN); ?> </option> <option value="500" <?php if (mailusers_get_user_settings_table_rows() == '500') { echo 'selected="true"'; } ?> ><?php _e('500', MAILUSERS_I18N_DOMAIN); ?> </option> </select><br/><i><small><?php _e('By default the table will display 20 rows.', MAILUSERS_I18N_DOMAIN); ?> </small></i> </td> </tr> <tr> <th><?php