'snapshots', 'screen' => 'snapshots' ) ); } protected function get_table_classes() { return array( 'widefat striped' ); } public function get_columns() { $columns = array(); $columns['cb'] = __( 'cb', 'wpvivid-snapshot-database' ); $columns['wpvivid_time'] = __( 'Time', 'wpvivid-snapshot-database' ); $columns['wpvivid_type'] = __( 'Type', 'wpvivid-snapshot-database' ); $columns['wpvivid_prefix'] = __( 'Prefix', 'wpvivid-snapshot-database' ); $columns['wpvivid_comment'] = __( 'Comment', 'wpvivid-snapshot-database' ); $columns['wpvivid_actions'] = __( 'Actions', 'wpvivid-snapshot-database' ); return $columns; } public function column_cb( $data ) { echo ''; } public function _column_wpvivid_time( $data ) { $time = gmdate('M-d-Y H:i', $data['time']); echo '' . esc_html( $time ) . ''; } public function _column_wpvivid_type( $data ) { echo '' . esc_html( $data['type'] ) . ''; } public function _column_wpvivid_prefix( $data ) { echo '' . esc_html( $data['id'] ) . ''; } public function _column_wpvivid_comment( $data ) { echo '' . esc_html($data['comment'] ) . ''; } public function _column_wpvivid_actions( $data ) { echo '
Restore | Delete
'; } public function set_list($Snapshots_list,$page_num=1) { $this->Snapshots_list=$Snapshots_list; $this->page_num=$page_num; } public function get_pagenum() { if($this->page_num=='first') { $this->page_num=1; } else if($this->page_num=='last') { $this->page_num=$this->_pagination_args['total_pages']; } $pagenum = $this->page_num ? $this->page_num : 0; if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) { $pagenum = $this->_pagination_args['total_pages']; } return max( 1, $pagenum ); } public function prepare_items() { $columns = $this->get_columns(); $hidden = array(); $sortable = array(); $this->_column_headers = array($columns, $hidden, $sortable); $total_items =sizeof($this->Snapshots_list); $this->set_pagination_args( array( 'total_items' => $total_items, 'per_page' => 10, ) ); } public function has_items() { return !empty($this->Snapshots_list); } public function display_rows() { $this->_display_rows($this->Snapshots_list); } private function _display_rows($Snapshots_list) { $page=$this->get_pagenum(); $page_file_list=array(); $count=0; while ( $count<$page ) { $page_file_list = array_splice( $Snapshots_list, 0, 10); $count++; } foreach ( $page_file_list as $data) { $this->single_row($data); } } public function single_row($data) { ?> single_row_columns( $data ); ?> _pagination_args ) ) { return; } $total_items = $this->_pagination_args['total_items']; $total_pages = $this->_pagination_args['total_pages']; $infinite_scroll = false; if ( isset( $this->_pagination_args['infinite_scroll'] ) ) { $infinite_scroll = $this->_pagination_args['infinite_scroll']; } if ( 'top' === $which && $total_pages > 1 ) { $this->screen->render_screen_reader_content( 'heading_pagination' ); } $output = '' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . ''; $current = $this->get_pagenum(); $page_links = array(); $total_pages_before = ''; $total_pages_after = ''; $disable_first = $disable_last = $disable_prev = $disable_next = false; if ( $current == 1 ) { $disable_first = true; $disable_prev = true; } if ( $current == 2 ) { $disable_first = true; } if ( $current == $total_pages ) { $disable_last = true; $disable_next = true; } if ( $current == $total_pages - 1 ) { $disable_last = true; } if ( $disable_first ) { $page_links[] = ''; } else { $page_links[] = sprintf( "
%s
", __( 'First page' ), '«' ); } if ( $disable_prev ) { $page_links[] = ''; } else { $page_links[] = sprintf( "
%s
", $current, __( 'Previous page' ), '‹' ); } if ( 'bottom' === $which ) { $html_current_page = $current; $total_pages_before = '' . __( 'Current Page' ) . ''; } else { $html_current_page = sprintf( "%s", '', $current, strlen( $total_pages ) ); } $html_total_pages = sprintf( "%s", number_format_i18n( $total_pages ) ); $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after; if ( $disable_next ) { $page_links[] = ''; } else { $page_links[] = sprintf( "
%s
", $current, __( 'Next page' ), '›' ); } if ( $disable_last ) { $page_links[] = ''; } else { $page_links[] = sprintf( "
%s
", __( 'Last page' ), '»' ); } $pagination_links_class = 'pagination-links'; if ( ! empty( $infinite_scroll ) ) { $pagination_links_class .= ' hide-if-js'; } $output .= "\n" . join( "\n", $page_links ) . ''; if ( $total_pages ) { $page_class = $total_pages < 2 ? ' one-page' : ''; } else { $page_class = ' no-pages'; } $this->_pagination = "
$output
"; echo $this->_pagination; } protected function display_tablenav( $which ) { $css_type = ''; if ( 'top' === $which ) { wp_nonce_field( 'bulk-' . $this->_args['plural'] ); $css_type = 'margin: 0 0 10px 0'; } else if( 'bottom' === $which ) { $css_type = 'margin: 10px 0 0 0'; } $total_pages = $this->_pagination_args['total_pages']; if ( $total_pages >1 && 'top' === $which) { ?>
extra_tablenav( $which ); $this->pagination( $which ); ?>
1) { ?>
extra_tablenav( $which ); $this->pagination( $which ); ?>

_args['singular']; $this->display_tablenav( 'top' ); $this->screen->render_screen_reader_content( 'heading_list' ); ?> print_column_headers(); ?> > display_rows_or_placeholder(); ?>
display_tablenav( 'bottom' ); } } }