Trouble with WP_List_Table
-
I downloaded a plugin template designed as a ‘live learning’ example for the WP_List_Table function.
I have learned a lot from it and I want to use parts of it to improve a plugin i am currently using.
The problem is that it has a ‘sample data array’ instead of a query.
Example:
<?php /* Plugin Name: Custom List Table Example */ if(!class_exists('WP_List_Table')){ require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); } class TT_Example_List_Table extends WP_List_Table { var $example_data = array( array( 'ID' => 1, 'title' => '300', 'rating' => 'R', 'director' => 'Zach Snyder' ), array( 'ID' => 2, 'title' => 'Eyes Wide Shut', 'rating' => 'R', 'director' => 'Stanley Kubrick' ), array( 'ID' => 3, 'title' => 'Moulin Rouge!', 'rating' => 'PG-13', 'director' => 'Baz Luhrman' ), array( 'ID' => 4, 'title' => 'Snow White', 'rating' => 'G', 'director' => 'Walt Disney' ), array( 'ID' => 5, 'title' => 'Super 8', 'rating' => 'PG-13', 'director' => 'JJ Abrams' ), array( 'ID' => 6, 'title' => 'The Fountain', 'rating' => 'PG-13', 'director' => 'Darren Aronofsky' ), array( 'ID' => 7, 'title' => 'Watchmen', 'rating' => 'R', 'director' => 'Zach Snyder' ), array( 'ID' => 8, 'title' => '2001', 'rating' => 'G', 'director' => 'Stanley Kubrick' ), ); function __construct(){ global $status, $page; //Set parent defaults parent::__construct( array( 'singular' => 'movie', //singular name of the listed records 'plural' => 'movies', //plural name of the listed records 'ajax' => false //does this table support ajax? ) ); } }
The example data is like a movie database. The data I am after will come from the options table in wpdb.
The code I have so far is:
$example_data = get_option('limit_login_lockouts'); foreach($example_data as $value1 => $value2) { echo $value1 . " => " . $value2 . "<br />"; }
It echos an array just fine but I can’t figure out how to make the table show the values.
70.193.96.113 => 1447706565
Here is a link to the plugin I’m getting the code from
so you can see the entire code.I have pulled up every reference to WP_List_Table and get_options and array I could find online but still haven’t figured it out.
- The topic ‘Trouble with WP_List_Table’ is closed to new replies.