-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathclass.wpqp-table.php
43 lines (34 loc) · 1.04 KB
/
class.wpqp-table.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* @package wp_quick_provision
*/
if ( ! class_exists( "WP_List_Table" ) ) {
require_once( ABSPATH . "wp-admin/includes/class-wp-list-table.php" );
}
class WPQP_Table extends WP_List_Table {
private $_items;
private $checkbox_field_name = 'items';
function __construct( $data, $type='items' ) {
parent::__construct();
$this->_items = $data;
$this->checkbox_field_name = $type;
}
function get_columns() {
return [
'cb' => '<input type="checkbox">',
'slug' => __( 'Slug', 'wp-quick-provision' ),
// 'origin' => __( 'Origin', 'wp-quick-provision' ),
'installable' => __( 'Install From', 'wp-quick-provision' ),
];
}
function column_cb( $item ) {
return "<input type='checkbox' name='wpqp_{$this->checkbox_field_name}[]' value='{$item['slug']}' checked/>";
}
function prepare_items() {
$this->_column_headers = array( $this->get_columns(), array(), array() );
$this->items = $this->_items;
}
function column_default( $item, $column_name ) {
return $item[ $column_name ];
}
}