Skip to content

Commit

Permalink
Register list table column headers with screen settings #19
Browse files Browse the repository at this point in the history
  • Loading branch information
shadyvb committed Dec 5, 2013
1 parent 663a3ea commit ec419ec
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions includes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ class WP_Stream_Admin {
*/
public static $screen_id = array();

/**
* List table object
* @var WP_Stream_List_Table
*/
public static $list_table = null;

const ADMIN_PAGE_SLUG = 'wp_stream';
const ADMIN_PARENT_PAGE = 'options-general.php';

Expand Down Expand Up @@ -58,6 +64,9 @@ public static function register_menu() {
'wp_stream_settings',
array( __CLASS__, 'render_page' )
);

// Register the list table early, so it associates the column headers with 'Screen settings'
add_action( 'load-' . self::$screen_id['main'], array( __CLASS__, 'register_list_table' ) );
}

/**
Expand Down Expand Up @@ -136,14 +145,17 @@ public static function render_page() {
<?php
}

public static function stream_page() {
public static function register_list_table() {
require_once WP_STREAM_INC_DIR . 'list-table.php';
$list_table = new WP_Stream_List_Table();
$list_table->prepare_items();
self::$list_table = new WP_Stream_List_Table( array( 'screen' => self::$screen_id['main'] ) );
}

public static function stream_page() {
self::$list_table->prepare_items();

echo '<div class="wrap">';
echo sprintf( '<h2>%s</h2>', __( 'Stream Records', 'stream' ) ); // xss okay
$list_table->display();
self::$list_table->display();
echo '</div>';
}

Expand Down

0 comments on commit ec419ec

Please sign in to comment.