-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathlist_table_class.sublime-snippet
83 lines (71 loc) · 1.75 KB
/
list_table_class.sublime-snippet
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<snippet>
<content><![CDATA[
<?php
/**
* @author ${1:jeffry ghazally}
*/
class ${2:My_List_Table} extends WP_List_Table {
/**
* Setup the columns and set the prizes
* @return null
* @author ${1:jeffry ghazally}
*/
function __construct() {
global \$status, \$page;
parent::__construct( array(
'singular' => '${2:my_list_table}',
'plural' => '${2:my_list_table}',
'ajax' => false
) );
}
/**
* Return all default column data
* @param array \$item
* @param string \$column_name name of the column
* @return string
* @author ${1:jeffry ghazally}
*/
function column_default(\$item, \$column_name) {
if ( isset(\$item[\$column_name]) )
return \$item[\$column_name];
}
/**
* Provide the columns for the table
* @return array
* @author ${1:jeffry ghazally}
*/
function get_columns() {
\$columns = array(
${3:Column Names}
);
return \$columns;
}
/**
* Prepare the table for output
* @return null
* @author ${1:jeffry ghazally}
*/
function prepare_items() {
\$columns = \$this->get_columns();
\$hidden = array();
\$this->_column_headers = array( \$columns , \$hidden , \$sortable );
\$this->items = \$this->get_data();
}
/**
* Here we collate and return the data required for listing in the table,
* The data needs to be returned as an associative array with keys being
* the column name and values being the data to be output
* @return array data to be displayed in the table
*/
function get_data() {
global $wpdb;
${4}
}
}
?>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>list_table</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>