예제 #1
0
 function prepare_items()
 {
     $perks = GWPerks::get_perks_listing();
     $this->is_valid_key = GWPerks::has_valid_key();
     if (!is_array($perks)) {
         $this->items = array();
         return;
     }
     $items = array();
     $total = count($perks);
     $page = gwget('paged') ? gwget('paged') : 1;
     $per_page = 10;
     $offset = $page * $per_page - $per_page;
     $cap = $total > $offset + $per_page ? $offset + $per_page : $total;
     for ($i = $offset; $i < $cap; $i++) {
         $items[$perks[$i]['slug']] = array('title' => $this->get_column_title($perks[$i]), 'description' => $perks[$i]['description'], 'slug' => $perks[$i]['slug'], 'version' => $perks[$i]['version']);
     }
     $this->items = $items;
     $this->set_pagination_args(array('total_items' => $total, 'per_page' => $per_page));
 }