Skip to content

Commit 6141352

Browse files
grunt
1 parent c7377e2 commit 6141352

File tree

19 files changed

+54
-48
lines changed

19 files changed

+54
-48
lines changed

classes/Visualizer/Gutenberg/Block.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Visualizer_Gutenberg_Block {
4646
* Returns an instance of this class.
4747
*/
4848
public static function get_instance() {
49-
if ( null == self::$instance ) {
49+
if ( null === self::$instance ) {
5050
self::$instance = new Visualizer_Gutenberg_Block();
5151
}
5252
return self::$instance;
@@ -297,19 +297,19 @@ public function format_chart_data( $data, $series ) {
297297
continue;
298298
}
299299

300-
if ( $row['type'] == 'number' ) {
300+
if ( $row['type'] === 'number' ) {
301301
foreach ( $data as $o => $col ) {
302302
$data[ $o ][ $i ] = ( is_numeric( $col[ $i ] ) ) ? floatval( $col[ $i ] ) : ( is_numeric( str_replace( ',', '', $col[ $i ] ) ) ? floatval( str_replace( ',', '', $col[ $i ] ) ) : null );
303303
}
304304
}
305305

306-
if ( $row['type'] == 'boolean' ) {
306+
if ( $row['type'] === 'boolean' ) {
307307
foreach ( $data as $o => $col ) {
308308
$data[ $o ][ $i ] = ! empty( $col[ $i ] ) ? filter_validate( $col[ $i ], FILTER_VALIDATE_BOOLEAN ) : null;
309309
}
310310
}
311311

312-
if ( $row['type'] == 'timeofday' ) {
312+
if ( $row['type'] === 'timeofday' ) {
313313
foreach ( $data as $o => $col ) {
314314
$date = new DateTime( '1984-03-16T' . $col[ $i ] );
315315
if ( $date ) {
@@ -323,7 +323,7 @@ public function format_chart_data( $data, $series ) {
323323
}
324324
}
325325

326-
if ( $row['type'] == 'string' ) {
326+
if ( $row['type'] === 'string' ) {
327327
foreach ( $data as $o => $col ) {
328328
$data[ $o ][ $i ] = $this->toUTF8( $col[ $i ] );
329329
}

classes/Visualizer/Module.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function _getDataAs( $chart_id, $type ) {
159159
$success = false;
160160
if ( $chart_id ) {
161161
$chart = get_post( $chart_id );
162-
$success = $chart && $chart->post_type == Visualizer_Plugin::CPT_VISUALIZER;
162+
$success = $chart && $chart->post_type === Visualizer_Plugin::CPT_VISUALIZER;
163163
}
164164
if ( $success ) {
165165
$settings = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS, true );

classes/Visualizer/Module/Admin.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public function restoreRevision( $post_id, $revision_id ) {
133133
* @access public
134134
*/
135135
public function init() {
136+
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
136137
if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) && 'true' == get_user_option( 'rich_editing' ) ) {
137138
$this->_addFilter( 'mce_external_languages', 'add_tinymce_lang', 10, 1 );
138139
$this->_addFilter( 'mce_external_plugins', 'tinymce_plugin', 10, 1 );
@@ -465,7 +466,7 @@ private static function handleDeprecatedCharts( $types, $enabledOnly, $get2Darra
465466
*/
466467
public function renderTemplates() {
467468
global $pagenow;
468-
if ( 'post.php' != $pagenow && 'post-new.php' != $pagenow ) {
469+
if ( 'post.php' !== $pagenow && 'post-new.php' !== $pagenow ) {
469470
return;
470471
}
471472
$render = new Visualizer_Render_Templates();
@@ -485,7 +486,7 @@ public function renderTemplates() {
485486
* @param string $suffix The current page suffix.
486487
*/
487488
public function enqueueLibraryScripts( $suffix ) {
488-
if ( $suffix == $this->_libraryPage ) {
489+
if ( $suffix === $this->_libraryPage ) {
489490
wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION );
490491
$this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' );
491492
wp_enqueue_media();
@@ -579,7 +580,7 @@ private function getQuery() {
579580
);
580581
// add chart type filter to the query arguments
581582
$filter = filter_input( INPUT_GET, 'type' );
582-
if ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes() ) ) {
583+
if ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes(), true ) ) {
583584
$query_args['meta_query'] = array(
584585
array(
585586
'key' => Visualizer_Plugin::CF_CHART_TYPE,
@@ -631,7 +632,7 @@ public function renderLibraryPage() {
631632
);
632633
// add chart type filter to the query arguments
633634
$filter = filter_input( INPUT_GET, 'type' );
634-
if ( ! ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes() ) ) ) {
635+
if ( ! ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes(), true ) ) ) {
635636
$filter = 'all';
636637
}
637638

@@ -738,7 +739,7 @@ public function renderLibraryPage() {
738739
* @return array Updated array of action links.
739740
*/
740741
public function getPluginActionLinks( $links, $file ) {
741-
if ( $file == plugin_basename( VISUALIZER_BASEFILE ) ) {
742+
if ( $file === plugin_basename( VISUALIZER_BASEFILE ) ) {
742743
array_unshift(
743744
$links,
744745
sprintf(
@@ -765,7 +766,7 @@ public function getPluginActionLinks( $links, $file ) {
765766
* @return array Updated array of plugin meta links.
766767
*/
767768
public function getPluginMetaLinks( $plugin_meta, $plugin_file ) {
768-
if ( $plugin_file == plugin_basename( VISUALIZER_BASEFILE ) ) {
769+
if ( $plugin_file === plugin_basename( VISUALIZER_BASEFILE ) ) {
769770
// knowledge base link
770771
$plugin_meta[] = sprintf(
771772
'<a href="https://github.com/codeinwp/visualizer/wiki" target="_blank">%s</a>',

classes/Visualizer/Module/Chart.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function getCharts() {
9494
$filter = filter_input( INPUT_GET, 'filter', FILTER_SANITIZE_STRING );
9595
}
9696

97-
if ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes() ) ) {
97+
if ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes(), true ) ) {
9898
$query_args['meta_query'] = array(
9999
array(
100100
'key' => Visualizer_Plugin::CF_CHART_TYPE,
@@ -201,7 +201,7 @@ public static function _sendResponse( $results ) {
201201
* @access public
202202
*/
203203
public function deleteChart() {
204-
$is_post = $_SERVER['REQUEST_METHOD'] == 'POST';
204+
$is_post = $_SERVER['REQUEST_METHOD'] === 'POST';
205205
$input_method = $is_post ? INPUT_POST : INPUT_GET;
206206
$chart_id = $success = false;
207207
$nonce = wp_verify_nonce( filter_input( $input_method, 'nonce' ) );
@@ -219,7 +219,7 @@ public function deleteChart() {
219219
);
220220
if ( $chart_id ) {
221221
$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;
223223
}
224224
}
225225
if ( $success ) {
@@ -248,7 +248,7 @@ public function renderChartPages() {
248248
defined( 'IFRAME_REQUEST' ) || define( 'IFRAME_REQUEST', 1 );
249249
// check chart, if chart not exists, will create new one and redirects to the same page with proper chart id
250250
$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 ) {
252252
$default_type = isset( $_GET['type'] ) && ! empty( $_GET['type'] ) ? $_GET['type'] : 'line';
253253
$source = new Visualizer_Source_Csv( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR . $default_type . '.csv' );
254254
$source->fetch();
@@ -406,8 +406,8 @@ private function _handleDataAndSettingsPage() {
406406
if ( isset( $_POST['map_api_key'] ) ) {
407407
update_option( 'visualizer-map-api-key', $_POST['map_api_key'] );
408408
}
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' ) {
411411
$this->_chart->post_status = 'publish';
412412

413413
// 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() {
434434
$sidebar->__data = $data['data'];
435435
} else {
436436
$sidebar = apply_filters( 'visualizer_pro_chart_type_sidebar', '', $data );
437-
if ( $sidebar != '' ) {
437+
if ( $sidebar !== '' ) {
438438
$sidebar->__series = $data['series'];
439439
$sidebar->__data = $data['data'];
440440
}
@@ -487,10 +487,10 @@ private function _handleDataAndSettingsPage() {
487487
$render->custom_css = $data['css'];
488488
$render->sidebar = $sidebar;
489489
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
491491
? esc_html__( 'Save Chart', 'visualizer' )
492492
: 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 ) {
494494
$render->cancel_button = esc_html__( 'Cancel', 'visualizer' );
495495
}
496496
} else {
@@ -513,9 +513,9 @@ private function _handleDataAndSettingsPage() {
513513
*/
514514
private function _handleTypesPage() {
515515
// 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' ) ) ) {
517517
$type = filter_input( INPUT_POST, 'type' );
518-
if ( in_array( $type, Visualizer_Plugin::getChartTypes() ) ) {
518+
if ( in_array( $type, Visualizer_Plugin::getChartTypes(), true ) ) {
519519
// save new chart type
520520
update_post_meta( $this->_chart->ID, Visualizer_Plugin::CF_CHART_TYPE, $type );
521521
// if the chart has default data, update it with appropriate default data for new type
@@ -578,7 +578,7 @@ public function uploadData() {
578578
// check chart, if chart exists
579579
// do not use filter_input as it does not work for phpunit test cases, use filter_var instead
580580
$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 ) {
582582
if ( ! $can_die ) {
583583
return;
584584
}
@@ -606,6 +606,7 @@ public function uploadData() {
606606
if ( isset( $_POST['vz-import-time'] ) ) {
607607
apply_filters( 'visualizer_pro_chart_schedule', $chart_id, $_POST['remote_data'], $_POST['vz-import-time'] );
608608
}
609+
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
609610
} elseif ( isset( $_FILES['local_data'] ) && $_FILES['local_data']['error'] == 0 ) {
610611
$source = new Visualizer_Source_Csv( $_FILES['local_data']['tmp_name'] );
611612
} elseif ( isset( $_POST['chart_data'] ) && strlen( $_POST['chart_data'] ) > 0 ) {
@@ -671,7 +672,7 @@ public function cloneChart() {
671672
);
672673
if ( $chart_id ) {
673674
$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;
675676
}
676677
}
677678
$redirect = wp_get_referer();

classes/Visualizer/Module/Frontend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public function renderChart( $atts ) {
190190
);
191191

192192
// if empty id or chart does not exists, then return empty string
193-
if ( ! $atts['id'] || ! ( $chart = get_post( $atts['id'] ) ) || $chart->post_type != Visualizer_Plugin::CPT_VISUALIZER ) {
193+
if ( ! $atts['id'] || ! ( $chart = get_post( $atts['id'] ) ) || $chart->post_type !== Visualizer_Plugin::CPT_VISUALIZER ) {
194194
return '';
195195
}
196196

classes/Visualizer/Module/Setup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function activate() {
150150
* On activation of the plugin
151151
*/
152152
public function onActivation( $plugin ) {
153-
if ( $plugin == VISUALIZER_BASENAME ) {
153+
if ( $plugin === VISUALIZER_BASENAME ) {
154154
wp_redirect( admin_url( 'upload.php?page=' . Visualizer_Plugin::NAME ) );
155155
exit();
156156
}

classes/Visualizer/Module/Sources.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ public function addProUpsell( $old, $feature = null ) {
133133
$biz_features = array( 'schedule-chart', 'chart-permissions', 'db-query' );
134134
$return = '';
135135
$feature = strval( $feature );
136-
if ( empty( $feature ) || ( in_array( $feature, $biz_features ) && ! apply_filters( 'visualizer_is_business', false ) ) ) {
136+
if ( empty( $feature ) || ( in_array( $feature, $biz_features, true ) && ! apply_filters( 'visualizer_is_business', false ) ) ) {
137137
$plan = 'PRO';
138-
if ( in_array( $feature, $biz_features ) ) {
138+
if ( in_array( $feature, $biz_features, true ) ) {
139139
$plan = 'DEVELOPER';
140140
}
141141
$return = '<div class="only-pro-content">';

classes/Visualizer/Render/Library.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private function _renderLibrary() {
9999
$link = "<a class=' visualizer-pro-only' href='" . Visualizer_Plugin::PRO_TEASER_URL . "' target='_blank'>";
100100
}
101101
echo '<li class="visualizer-list-item all">';
102-
if ( $type == $this->type ) {
102+
if ( $type === $this->type ) {
103103
echo '<a class=" current" href="', esc_url( add_query_arg( 'vpage', false ) ), '">';
104104
echo $label;
105105
echo '</a>';

classes/Visualizer/Render/Page/Data.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class="visualizer-select">
155155
)
156156
);
157157
foreach ( $schedules as $num => $name ) {
158+
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
158159
$extra = $num == $hours ? 'selected' : '';
159160
?>
160161
<option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
@@ -261,6 +262,7 @@ class="dashicons dashicons-lock"></span></h2>
261262
)
262263
);
263264
foreach ( $schedules as $num => $name ) {
265+
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
264266
$extra = $num == $hours ? 'selected' : '';
265267
?>
266268
<option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>

classes/Visualizer/Render/Page/Types.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function _renderContent() {
5959
echo "<a class='pro-upsell' href='" . Visualizer_Plugin::PRO_TEASER_URL . "' target='_blank'>";
6060
echo "<span class='visualizder-pro-label'>" . __( 'PREMIUM', 'visualizer' ) . '</span>';
6161
}
62-
echo '<label class="type-label', $type == $this->type ? ' type-label-selected' : '', '">';
62+
echo '<label class="type-label', $type === $this->type ? ' type-label-selected' : '', '">';
6363
echo '<span>' . $array['name'] . '</span>';
6464
if ( $array['enabled'] ) {
6565
echo '<input type="radio" class="type-radio" name="type" value="', $type, '"', checked( $type, $this->type, false ), '>';

0 commit comments

Comments
 (0)