1
|
|
|
<?php |
2
|
|
|
namespace NirjharLo\Cgss\Lib; |
3
|
|
|
|
4
|
|
|
if ( ! defined( 'ABSPATH' ) ) exit; |
5
|
|
|
|
6
|
|
|
use \WP_List_Table; |
|
|
|
|
7
|
|
|
use \NirjharLo\Cgss\Models\Insight as InsightModel; |
|
|
|
|
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Implimentation of WordPress inbuilt functions for creating an extension of a default table class. |
11
|
|
|
* |
12
|
|
|
* $myPluginNameTable = new CGSS_OVERVIEW_TABLE(); |
13
|
|
|
* $myPluginNameTable->prepare_items(); |
14
|
|
|
* $myPluginNameTable->display(); |
15
|
|
|
* |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
final class OverviewTable extends WP_List_Table { |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
|
22
|
|
|
public function __construct() { |
23
|
|
|
|
24
|
|
|
parent::__construct( [ |
25
|
|
|
'singular' => __( 'Insight', 'cgss' ), |
|
|
|
|
26
|
|
|
'plural' => __( 'Inssight', 'cgss' ), |
27
|
|
|
'ajax' => false, |
28
|
|
|
] ); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
|
33
|
|
|
//fetch the data using custom named method function |
34
|
|
|
public static function get_insight() { |
35
|
|
|
|
36
|
|
|
$model = new InsightModel(); |
37
|
|
|
|
38
|
|
|
return $model->all(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
|
43
|
|
|
//If there is no data to show |
44
|
|
|
public function no_items() { |
45
|
|
|
|
46
|
|
|
_e( 'Database is empty. Please reactivate the plugin.', 'cgss' ); |
|
|
|
|
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
|
51
|
|
|
//How many rows are present there |
52
|
|
|
public static function record_count() { |
53
|
|
|
|
54
|
|
|
$model = new InsightModel(); |
55
|
|
|
|
56
|
|
|
return $model->count(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
|
61
|
|
|
//Display columns content |
62
|
|
|
public function column_name( $item ) { |
63
|
|
|
|
64
|
|
|
$title = sprintf( '<strong>%s</strong>', $item['item'] ); |
65
|
|
|
|
66
|
|
|
//Change the page instruction where you want to show it |
67
|
|
|
$actions = array(); |
68
|
|
|
return $title . $this->row_actions( $actions ); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
|
73
|
|
|
//set coulmns name |
74
|
|
|
public function column_default( $item, $column_name ) { |
75
|
|
|
|
76
|
|
|
switch ( $column_name ) { |
77
|
|
|
|
78
|
|
|
case 'item': |
79
|
|
|
//This is the first column |
80
|
|
|
return $this->column_name( $item ); |
81
|
|
|
case 'remark': |
82
|
|
|
return $item[ $column_name ]; |
83
|
|
|
|
84
|
|
|
default: |
85
|
|
|
|
86
|
|
|
//Show the whole array for troubleshooting purposes |
87
|
|
|
return print_r( $item, true ); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
|
93
|
|
|
//Columns callback |
94
|
|
|
public function get_columns() { |
95
|
|
|
|
96
|
|
|
$columns = array( |
97
|
|
|
'item' => __( 'Item', 'cgss' ), |
|
|
|
|
98
|
|
|
'remark' => __( 'Remark', 'cgss' ), |
99
|
|
|
); |
100
|
|
|
return $columns; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
|
104
|
|
|
|
105
|
|
|
//Prapare the display variables for screen options |
106
|
|
|
public function prepare_items() { |
107
|
|
|
|
108
|
|
|
$this->_column_headers = $this->get_column_info(); |
|
|
|
|
109
|
|
|
$this->items = self::get_insight(); |
|
|
|
|
110
|
|
|
} |
111
|
|
|
} ?> |
|
|
|
|
112
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths