Issues (206)

Plugin/Lib/OverviewTable.php (8 issues)

1
<?php
2
namespace NirjharLo\Cgss\Lib;
3
4
if ( ! defined( 'ABSPATH' ) ) exit;
5
6
use \WP_List_Table;
0 ignored issues
show
The type \WP_List_Table was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use \NirjharLo\Cgss\Models\Insight as InsightModel;
0 ignored issues
show
The type \NirjharLo\Cgss\Models\Insight was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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' ),
0 ignored issues
show
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
				'singular' => /** @scrutinizer ignore-call */ __( 'Insight', 'cgss' ),
Loading history...
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' );
0 ignored issues
show
The function _e was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
			/** @scrutinizer ignore-call */ 
47
   _e( 'Database is empty. Please reactivate the plugin.', 'cgss' );
Loading history...
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' ),
0 ignored issues
show
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

97
							'item'	=> /** @scrutinizer ignore-call */ __( 'Item', 'cgss' ),
Loading history...
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();
0 ignored issues
show
Bug Best Practice introduced by
The property _column_headers does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
109
			$this->items = self::get_insight();
0 ignored issues
show
Bug Best Practice introduced by
The property items does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
110
		}
111
	} ?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
112