<?php
/*
Plugin Name: My List Table Plugin
Author: scribu
Version: 1.0
*/

class My_Admin_Screen {
	function __construct() {
		add_filter( 'get_list_table_My_List_Table', array( $this, 'register_list_table' ) );
		add_action( '_admin_menu', array( $this, '_init' ) );
	}

	function register_list_table( $class ) {
		require_once dirname( __FILE__ ) . '/my-list-table-class.php';

		return $class;
	}

	function _init() {
		$screen_id = add_menu_page( 'Test', 'Test', 'manage_options', 'test', array( $this, 'display' ) );

		add_action( "load-$screen_id", array( $this, '_init_list_table' ) );
	}

	// The list table class has to be instantiated before screen_meta() is called
	function _init_list_table() {
		$this->list_table = get_list_table('My_List_Table');
	}

	function display() {
		echo "<div class='wrap'>\n";
		screen_icon();
		echo "<h2>Test</h2>\n";

		$this->list_table->prepare_items();
		$this->list_table->display();

		echo "</div>\n";
	}
}

new My_Admin_Screen();

