@@ -94,7 +94,7 @@ public function getCharts() {
94
94
$ filter = filter_input ( INPUT_GET , 'filter ' , FILTER_SANITIZE_STRING );
95
95
}
96
96
97
- if ( $ filter && in_array ( $ filter , Visualizer_Plugin::getChartTypes () ) ) {
97
+ if ( $ filter && in_array ( $ filter , Visualizer_Plugin::getChartTypes (), true ) ) {
98
98
$ query_args ['meta_query ' ] = array (
99
99
array (
100
100
'key ' => Visualizer_Plugin::CF_CHART_TYPE ,
@@ -201,7 +201,7 @@ public static function _sendResponse( $results ) {
201
201
* @access public
202
202
*/
203
203
public function deleteChart () {
204
- $ is_post = $ _SERVER ['REQUEST_METHOD ' ] == 'POST ' ;
204
+ $ is_post = $ _SERVER ['REQUEST_METHOD ' ] === 'POST ' ;
205
205
$ input_method = $ is_post ? INPUT_POST : INPUT_GET ;
206
206
$ chart_id = $ success = false ;
207
207
$ nonce = wp_verify_nonce ( filter_input ( $ input_method , 'nonce ' ) );
@@ -219,7 +219,7 @@ public function deleteChart() {
219
219
);
220
220
if ( $ chart_id ) {
221
221
$ chart = get_post ( $ chart_id );
222
- $ success = $ chart && $ chart ->post_type == Visualizer_Plugin::CPT_VISUALIZER ;
222
+ $ success = $ chart && $ chart ->post_type === Visualizer_Plugin::CPT_VISUALIZER ;
223
223
}
224
224
}
225
225
if ( $ success ) {
@@ -248,7 +248,7 @@ public function renderChartPages() {
248
248
defined ( 'IFRAME_REQUEST ' ) || define ( 'IFRAME_REQUEST ' , 1 );
249
249
// check chart, if chart not exists, will create new one and redirects to the same page with proper chart id
250
250
$ chart_id = isset ( $ _GET ['chart ' ] ) ? filter_var ( $ _GET ['chart ' ], FILTER_VALIDATE_INT ) : '' ;
251
- if ( ! $ chart_id || ! ( $ chart = get_post ( $ chart_id ) ) || $ chart ->post_type != Visualizer_Plugin::CPT_VISUALIZER ) {
251
+ if ( ! $ chart_id || ! ( $ chart = get_post ( $ chart_id ) ) || $ chart ->post_type !== Visualizer_Plugin::CPT_VISUALIZER ) {
252
252
$ default_type = isset ( $ _GET ['type ' ] ) && ! empty ( $ _GET ['type ' ] ) ? $ _GET ['type ' ] : 'line ' ;
253
253
$ source = new Visualizer_Source_Csv ( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples ' . DIRECTORY_SEPARATOR . $ default_type . '.csv ' );
254
254
$ source ->fetch ();
@@ -406,8 +406,8 @@ private function _handleDataAndSettingsPage() {
406
406
if ( isset ( $ _POST ['map_api_key ' ] ) ) {
407
407
update_option ( 'visualizer-map-api-key ' , $ _POST ['map_api_key ' ] );
408
408
}
409
- if ( $ _SERVER ['REQUEST_METHOD ' ] == 'POST ' && isset ( $ _GET ['nonce ' ] ) && wp_verify_nonce ( $ _GET ['nonce ' ] ) ) {
410
- if ( $ this ->_chart ->post_status == 'auto-draft ' ) {
409
+ if ( $ _SERVER ['REQUEST_METHOD ' ] === 'POST ' && isset ( $ _GET ['nonce ' ] ) && wp_verify_nonce ( $ _GET ['nonce ' ] ) ) {
410
+ if ( $ this ->_chart ->post_status === 'auto-draft ' ) {
411
411
$ this ->_chart ->post_status = 'publish ' ;
412
412
413
413
// ensure that a revision is not created. If a revision is created it will have the proper data and the parent of the revision will have default data.
@@ -434,7 +434,7 @@ private function _handleDataAndSettingsPage() {
434
434
$ sidebar ->__data = $ data ['data ' ];
435
435
} else {
436
436
$ sidebar = apply_filters ( 'visualizer_pro_chart_type_sidebar ' , '' , $ data );
437
- if ( $ sidebar != '' ) {
437
+ if ( $ sidebar !== '' ) {
438
438
$ sidebar ->__series = $ data ['series ' ];
439
439
$ sidebar ->__data = $ data ['data ' ];
440
440
}
@@ -487,10 +487,10 @@ private function _handleDataAndSettingsPage() {
487
487
$ render ->custom_css = $ data ['css ' ];
488
488
$ render ->sidebar = $ sidebar ;
489
489
if ( filter_input ( INPUT_GET , 'library ' , FILTER_VALIDATE_BOOLEAN ) ) {
490
- $ render ->button = filter_input ( INPUT_GET , 'action ' ) == Visualizer_Plugin::ACTION_EDIT_CHART
490
+ $ render ->button = filter_input ( INPUT_GET , 'action ' ) === Visualizer_Plugin::ACTION_EDIT_CHART
491
491
? esc_html__ ( 'Save Chart ' , 'visualizer ' )
492
492
: esc_html__ ( 'Create Chart ' , 'visualizer ' );
493
- if ( filter_input ( INPUT_GET , 'action ' ) == Visualizer_Plugin::ACTION_EDIT_CHART ) {
493
+ if ( filter_input ( INPUT_GET , 'action ' ) === Visualizer_Plugin::ACTION_EDIT_CHART ) {
494
494
$ render ->cancel_button = esc_html__ ( 'Cancel ' , 'visualizer ' );
495
495
}
496
496
} else {
@@ -513,9 +513,9 @@ private function _handleDataAndSettingsPage() {
513
513
*/
514
514
private function _handleTypesPage () {
515
515
// process post request
516
- if ( $ _SERVER ['REQUEST_METHOD ' ] == 'POST ' && wp_verify_nonce ( filter_input ( INPUT_POST , 'nonce ' ) ) ) {
516
+ if ( $ _SERVER ['REQUEST_METHOD ' ] === 'POST ' && wp_verify_nonce ( filter_input ( INPUT_POST , 'nonce ' ) ) ) {
517
517
$ type = filter_input ( INPUT_POST , 'type ' );
518
- if ( in_array ( $ type , Visualizer_Plugin::getChartTypes () ) ) {
518
+ if ( in_array ( $ type , Visualizer_Plugin::getChartTypes (), true ) ) {
519
519
// save new chart type
520
520
update_post_meta ( $ this ->_chart ->ID , Visualizer_Plugin::CF_CHART_TYPE , $ type );
521
521
// if the chart has default data, update it with appropriate default data for new type
@@ -578,7 +578,7 @@ public function uploadData() {
578
578
// check chart, if chart exists
579
579
// do not use filter_input as it does not work for phpunit test cases, use filter_var instead
580
580
$ chart_id = isset ( $ _GET ['chart ' ] ) ? filter_var ( $ _GET ['chart ' ], FILTER_VALIDATE_INT ) : '' ;
581
- if ( ! $ chart_id || ! ( $ chart = get_post ( $ chart_id ) ) || $ chart ->post_type != Visualizer_Plugin::CPT_VISUALIZER ) {
581
+ if ( ! $ chart_id || ! ( $ chart = get_post ( $ chart_id ) ) || $ chart ->post_type !== Visualizer_Plugin::CPT_VISUALIZER ) {
582
582
if ( ! $ can_die ) {
583
583
return ;
584
584
}
@@ -606,6 +606,7 @@ public function uploadData() {
606
606
if ( isset ( $ _POST ['vz-import-time ' ] ) ) {
607
607
apply_filters ( 'visualizer_pro_chart_schedule ' , $ chart_id , $ _POST ['remote_data ' ], $ _POST ['vz-import-time ' ] );
608
608
}
609
+ // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
609
610
} elseif ( isset ( $ _FILES ['local_data ' ] ) && $ _FILES ['local_data ' ]['error ' ] == 0 ) {
610
611
$ source = new Visualizer_Source_Csv ( $ _FILES ['local_data ' ]['tmp_name ' ] );
611
612
} elseif ( isset ( $ _POST ['chart_data ' ] ) && strlen ( $ _POST ['chart_data ' ] ) > 0 ) {
@@ -671,7 +672,7 @@ public function cloneChart() {
671
672
);
672
673
if ( $ chart_id ) {
673
674
$ chart = get_post ( $ chart_id );
674
- $ success = $ chart && $ chart ->post_type == Visualizer_Plugin::CPT_VISUALIZER ;
675
+ $ success = $ chart && $ chart ->post_type === Visualizer_Plugin::CPT_VISUALIZER ;
675
676
}
676
677
}
677
678
$ redirect = wp_get_referer ();
0 commit comments