コード例 #1
0
 function prepare_items()
 {
     /**
      * First, lets decide how many records per page to show
      */
     $per_page = 25;
     $album_id = 0;
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     $this->process_bulk_action();
     global $wpdb;
     $album_table = WPPG_TBL_ALBUM;
     /* -- Ordering parameters -- */
     //Parameters that are going to be used to order the result
     isset($_GET["orderby"]) ? $orderby = strip_tags($_GET["orderby"]) : ($orderby = '');
     isset($_GET["order"]) ? $order = strip_tags($_GET["order"]) : ($order = '');
     $orderby = !empty($_GET["orderby"]) ? esc_sql($_GET["orderby"]) : 'id';
     $order = !empty($_GET["order"]) ? esc_sql($_GET["order"]) : 'ASC';
     $orderby = WP_Photo_Gallery_Utility::sanitize_value_by_array($orderby, $sortable);
     $order = WP_Photo_Gallery_Utility::sanitize_value_by_array($order, array('DESC' => '1', 'ASC' => '1'));
     $data = $wpdb->get_results("SELECT * FROM {$album_table} ORDER BY {$orderby} {$order}", ARRAY_A);
     $current_page = $this->get_pagenum();
     $total_items = count($data);
     $data = array_slice($data, ($current_page - 1) * $per_page, $per_page);
     $this->items = $data;
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }
 function prepare_items()
 {
     /**
      * First, lets decide how many records per page to show
      */
     $per_page = 25;
     $gallery_id = 0;
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     $this->process_bulk_action();
     global $wpdb;
     $gallery_items_table = WPPG_TBL_GALLERY;
     //Let's get the gallery id
     if (isset($_GET['wppg_gallery_id'])) {
         $gallery_id = strip_tags($_GET['wppg_gallery_id']);
     }
     /* -- Ordering parameters -- */
     //Parameters that are going to be used to order the result
     isset($_GET["orderby"]) ? $orderby = strip_tags($_GET["orderby"]) : ($orderby = '');
     isset($_GET["order"]) ? $order = strip_tags($_GET["order"]) : ($order = '');
     $orderby = !empty($_GET["orderby"]) ? esc_sql($_GET["orderby"]) : 'id';
     $order = !empty($_GET["order"]) ? esc_sql($_GET["order"]) : 'DESC';
     $orderby = WP_Photo_Gallery_Utility::sanitize_value_by_array($orderby, $sortable);
     $order = WP_Photo_Gallery_Utility::sanitize_value_by_array($order, array('DESC' => '1', 'ASC' => '1'));
     $data = $this->fetch_gallery_images($gallery_id, $orderby, $order);
     $current_page = $this->get_pagenum();
     $total_items = count($data);
     $data = array_slice($data, ($current_page - 1) * $per_page, $per_page);
     $this->items = $data;
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }