Example #1
0
 /**
  * 
  * @global type $wpdb
  */
 public function prepare_items()
 {
     if (!class_exists("Bbpp_ThankMeLater_Message")) {
         require_once BBPP_THANKMELATER_PLUGIN_PATH . "Message.php";
     }
     // we'll store the messages in this object:
     $message = new Bbpp_ThankMeLater_Message();
     // set the table headers
     $this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns());
     // do the bulk actions, if any
     $this->process_bulk_action();
     // get the number of results
     $current_page = $this->get_pagenum();
     $total_items = $message->countMessages();
     $this->set_pagination_args(array("total_items" => $total_items, "per_page" => $this->per_page, "total_pages" => ceil($total_items / $this->per_page)));
     $orderby = NULL;
     $order = NULL;
     $sortable_vals = array_keys($this->get_sortable_columns());
     if (!empty($_REQUEST["orderby"]) && in_array(stripslashes($_REQUEST["orderby"]), $sortable_vals)) {
         $orderby = stripslashes($_REQUEST["orderby"]);
         if (!empty($_REQUEST["order"]) && in_array(stripslashes($_REQUEST["order"]), array("asc", "desc"))) {
             $order = stripslashes($_REQUEST["order"]);
         }
     }
     // get the results
     $this->items = $message->readMessages($this->per_page, ($current_page - 1) * $this->per_page, $orderby, $order);
 }