'category', 'plural' => 'categories', 'ajax' => false ) ); } function column_default($item, $column_name){ switch($column_name) { case 'actions' : $act = '
Edit'; $act .= '   Delete
'; return $act; break; case 'published' : $published = ( $item->published == 1 ) ? 'Yes' : 'No'; return '
'.$published.'
'; break; default : return '
'.$item->$column_name.'
'; break; } } function column_cb($item){ return sprintf( '', $this->_args['singular'], $item->id ); } function get_columns(){ $columns = array( 'cb' => '', 'name' => 'Category Name', 'id' => 'Category ID', 'published' => 'Published', 'actions' => 'Actions' ); return $columns; } function get_bulk_actions() { $actions = array( 'delete' => 'Delete' ); return $actions; } function process_bulk_action() { if( 'delete'===$this->current_action() ) { foreach($_GET['category'] as $category) { $this->wpdb->query("DELETE FROM $this->table_name WHERE id=".$category); } echo ''; } } function prepare_items( $data, $table_name, $wpdb ) { $this->table_name = $table_name; $this->wpdb = $wpdb; $columns = $this->get_columns(); $hidden = array(); $sortable = array(); $this->_column_headers = array($columns, $hidden, $sortable); $this->process_bulk_action(); $per_page = 5; $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) ) ); } } $table = new AllVideoGallery_Table(); $data = $wpdb->get_results("SELECT * FROM $table_name"); $table->prepare_items( $data, $table_name, $wpdb ); ?>


display(); ?>