<?php
/**
 * Plugin Name: Dummy List Table
 * Description: Minimal list table example with extra_tablenav button.
 */

add_action( 'admin_menu', function() {
	add_management_page(
		'Dummy List Table',
		'Dummy List Table',
		'manage_options',
		'dummy-list-table',
		function() {
			$table = new Dummy_List_Table();
			$table->prepare_items();
			echo '<div class="wrap">';
			echo '<h1>Dummy List Table</h1>';
			echo '<form method="post">';
			$table->display();
			echo '</form>';
			echo '</div>';
		}
	);
} );

add_action( 'admin_init', function() {
	class Dummy_List_Table extends WP_List_Table {
		public function get_columns() {
			return array(
				'title' => 'Title',
				'value' => 'Value',
			);
		}

		public function prepare_items() {
			$this->_column_headers = array( $this->get_columns(), array(), array() );
			$this->items = array(
				array( 'title' => 'Item One', 'value' => 'Alpha' ),
				array( 'title' => 'Item Two', 'value' => 'Beta' ),
				array( 'title' => 'Item Three', 'value' => 'Gamma' ),
			);
		}

		protected function column_default( $item, $column_name ) {
			return esc_html( $item[ $column_name ] );
		}

		protected function extra_tablenav( $which ) {
			printf(
				'<button class="button" type="submit" name="dummy_action" value="export">%s</button>',
				esc_html( 'Export' )
			);
		}
	}
} );
