forked from shield-9/opcache-dashboard
/
class.status-list-table.php
92 lines (79 loc) · 2.19 KB
/
class.status-list-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
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
84
85
86
87
88
89
90
91
92
<?php
class OPcache_List_Table extends WP_List_Table {
private $data = array();
function __construct($data) {
global $status, $page;
$this->data = $data;
parent::__construct(array(
'singular' => 'status',
'plural' => 'status',
'ajax' => false
));
}
function extra_tablenav($which) {
switch($which) {
case 'top':
//esc_html_e('Extra Table Navigation(Top)', 'opcache');
break;
case 'bottom':
//esc_html_e('Extra Table Navigation(Bottom)', 'opcache');
break;
}
}
function get_columns() {
$columns = array(
'name' => __('Status Name', 'opcache'),
'value' => _x('Value', 'Value of Status', 'opcache')
);
return $columns;
}
function column_name($item) {
$actions = NULL;
switch($item['name']) {
case 'opcache_enabled':
if($item['value']!=='true') $actions['notice'] = __('You should enabled opcache');
break;
case 'cache_full':
if($item['value']==='true') $actions['notice'] = __('You should increase opcache.memory_consumption');
break;
}
return sprintf('<strong><span class="row-status">%1$s</span></strong>%2$s', $item['name'], $this->row_actions($actions));
}
function column_value($item){
switch($item['name']) {
case 'start_time':
case 'last_restart_time':
return $item['value'] ? date(__('j M, Y @ G:i:s', 'opcache'), $item['value']) : __('never');
case 'used_memory':
case 'free_memory':
case 'wasted_memory':
return OPcache_dashboard::size($item['value']);
case 'current_wasted_percentage':
case 'blacklist_miss_ratio':
case 'opcache_hit_rate':
return OPcache_dashboard::number_format($item['value']) . '%';
default:
return $item['value'];
}
}
function column_default($item, $column_name){
switch($column_name) {
default:
return $item[$column_name];
}
}
function prepare_items() {
$columns = $this->get_columns();
$hidden = array();
$sortable = array();
$this->_column_headers = array($columns, $hidden, $sortable);
$current_page = $this->get_pagenum();
$total_items = count($this->data);
$this->items = $this->data;
$this->set_pagination_args(array(
'total_items' => $total_items,
'per_page' => $total_items,
'total_pages' => 1
));
}
}