Skip to content

Commit 4abb596

Browse files
committed
fix: resolve WPCS 3.x lint errors and warnings
1 parent a38b288 commit 4abb596

31 files changed

Lines changed: 133 additions & 157 deletions

components/admin-notification/index.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,55 @@
22

33
switch ( $data['view'] ) {
44
case 'connection_failed':
5-
$template = dirname( __FILE__ ) . '/views/admin-notification-connection-failed.php';
5+
$template = __DIR__ . '/views/admin-notification-connection-failed.php';
66
break;
77

88
case 'get_started':
9-
$template = dirname( __FILE__ ) . '/views/admin-notification-get-started.php';
9+
$template = __DIR__ . '/views/admin-notification-get-started.php';
1010
break;
1111

1212
case 'new_test_added':
13-
$template = dirname( __FILE__ ) . '/views/admin-notification-new-test-added.php';
13+
$template = __DIR__ . '/views/admin-notification-new-test-added.php';
1414
break;
1515

1616
case 'new_test_failed':
17-
$template = dirname( __FILE__ ) . '/views/admin-notification-new-test-failed.php';
17+
$template = __DIR__ . '/views/admin-notification-new-test-failed.php';
1818
break;
1919

2020
case 'new_tests_added':
21-
$template = dirname( __FILE__ ) . '/views/admin-notification-new-tests-added.php';
21+
$template = __DIR__ . '/views/admin-notification-new-tests-added.php';
2222
break;
2323

2424
case 'plugin_activated':
25-
$template = dirname( __FILE__ ) . '/views/admin-notification-plugin-activated.php';
25+
$template = __DIR__ . '/views/admin-notification-plugin-activated.php';
2626
break;
2727

2828
case 'settings_saved':
29-
$template = dirname( __FILE__ ) . '/views/admin-notification-settings-saved.php';
29+
$template = __DIR__ . '/views/admin-notification-settings-saved.php';
3030
break;
3131

3232
case 'license_added':
33-
$template = dirname( __FILE__ ) . '/views/admin-notification-license-added.php';
33+
$template = __DIR__ . '/views/admin-notification-license-added.php';
3434
break;
3535

3636
case 'license_not_added':
37-
$template = dirname( __FILE__ ) . '/views/admin-notification-license-not-added.php';
37+
$template = __DIR__ . '/views/admin-notification-license-not-added.php';
3838
break;
3939

4040
case 'test_disabled':
41-
$template = dirname( __FILE__ ) . '/views/admin-notification-test-disabled.php';
41+
$template = __DIR__ . '/views/admin-notification-test-disabled.php';
4242
break;
4343

4444
case 'test_started':
45-
$template = dirname( __FILE__ ) . '/views/admin-notification-test-started.php';
45+
$template = __DIR__ . '/views/admin-notification-test-started.php';
4646
break;
4747

4848
case 'test_failed':
49-
$template = dirname( __FILE__ ) . '/views/admin-notification-test-failed.php';
49+
$template = __DIR__ . '/views/admin-notification-test-failed.php';
5050
break;
5151

5252
case 'unlock_more_tests':
53-
$template = dirname( __FILE__ ) . '/views/admin-notification-unlock-more-tests.php';
53+
$template = __DIR__ . '/views/admin-notification-unlock-more-tests.php';
5454
break;
5555

5656
default:

components/metabox-classic-editor/index.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
if ( ! $data['is_connected'] ) {
3-
include_once dirname( __FILE__ ) . '/metabox-notifications/metabox-notification-connection-failed.php';
3+
include_once __DIR__ . '/metabox-notifications/metabox-notification-connection-failed.php';
44
return;
55
}
66
?>
@@ -34,13 +34,13 @@
3434

3535
// Notification: New Test added.
3636
if ( true === $data['is_new_test'] ) {
37-
include_once dirname( __FILE__ ) . '/metabox-notifications/metabox-notification-new-test-added.php';
37+
include_once __DIR__ . '/metabox-notifications/metabox-notification-new-test-added.php';
3838
} elseif ( 1 === intval( $data['remaining_tests'] ) ) {
3939
// Notification: Unlock more tests.
40-
include_once dirname( __FILE__ ) . '/metabox-notifications/metabox-notification-unlock-more-tests.php';
40+
include_once __DIR__ . '/metabox-notifications/metabox-notification-unlock-more-tests.php';
4141
} elseif ( 0 === intval( $data['remaining_tests'] ) ) {
4242
// Notification: Unlock more tests.
43-
include_once dirname( __FILE__ ) . '/metabox-notifications/metabox-notification-upgrade-required.php';
43+
include_once __DIR__ . '/metabox-notifications/metabox-notification-upgrade-required.php';
4444
}
4545
?>
4646

components/test-run-receipt/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</div>
3737
<?php
3838
foreach ( $data['tests'] as $test ) :
39-
$alert = array_values( array_filter( $data['alerts'], static function( $alert ) use ( $test ) {
39+
$alert = array_values( array_filter( $data['alerts'], static function ( $alert ) use ( $test ) {
4040
return $alert->post_id === $test['post_id'];
4141
} ) );
4242
$difference = $alert ? ceil( $alert[0]->differences ) : 0;

components/tests-page/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
switch ( $data['action'] ) {
44
default:
5-
$template = dirname( __FILE__ ) . '/views/tests-page-list.php';
5+
$template = __DIR__ . '/views/tests-page-list.php';
66
break;
77
}
88

includes/autoload.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<?php
2-
3-
namespace Vrts;
4-
52
/**
63
* Autoload Core Classes.
74
*
@@ -11,6 +8,7 @@
118
* Vrts\Core\Plugin - includes/core/class-plugin-php
129
* Vrts\Core\Utilities\Assets - includes/core/utilities/class-assets-php
1310
*/
11+
1412
spl_autoload_register( function ( $class_name ) {
1513
$namespace = 'Vrts\\';
1614

includes/core/class-plugin.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,13 @@ protected function features( $features ) {
146146
* Create objects.
147147
*
148148
* @param string $key Array key that the object will be accessible.
149-
* @param object $object object that needs to created.
149+
* @param object $instance object that needs to created.
150150
*
151151
* @return object Created object.
152152
*/
153-
protected function factory( $key, $object ) {
153+
protected function factory( $key, $instance ) {
154154
if ( ! isset( $this->factory[ $key ] ) ) {
155-
$this->factory[ $key ] = $object;
155+
$this->factory[ $key ] = $instance;
156156
}
157157

158158
return $this->factory[ $key ];
@@ -208,13 +208,13 @@ public function get_plugin_info( $info ) {
208208
*
209209
* @throws Exception If there is no file found.
210210
*/
211-
public function get_component( $name, $data = [] ) {
211+
public function get_component( $name, $data = [] ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- $data is used by included template files.
212212
ob_start();
213213

214214
if ( file_exists( $this->get_plugin_path( "components/{$name}/index.php" ) ) ) {
215215
include $this->get_plugin_path( "components/{$name}/index.php" );
216216
} else {
217-
throw new Exception( "Components file 'components/{$name}/index.php' cannot be located" );
217+
throw new Exception( esc_html( "Components file 'components/{$name}/index.php' cannot be located" ) );
218218
}
219219

220220
return ob_get_clean();

includes/core/settings/class-manager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private function add_settings() {
105105
add_settings_field(
106106
$id,
107107
$args['title'] ?? '',
108-
function() use ( $args ) {
108+
function () use ( $args ) {
109109
$this->get_field( $args );
110110
},
111111
$this->get_section_page( $args['section'] ),

includes/core/traits/class-macroable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static function has_macro( $name ) {
6565
*/
6666
public static function __callStatic( $method, $parameters ) {
6767
if ( ! static::has_macro( $method ) ) {
68-
throw new BadMethodCallException( "Method {$method} does not exist." );
68+
throw new BadMethodCallException( esc_html( "Method {$method} does not exist." ) );
6969
}
7070

7171
$macro = static::$macros[ $method ];
@@ -89,7 +89,7 @@ public static function __callStatic( $method, $parameters ) {
8989
*/
9090
public function __call( $method, $parameters ) {
9191
if ( ! static::has_macro( $method ) ) {
92-
throw new BadMethodCallException( "Method {$method} does not exist." );
92+
throw new BadMethodCallException( esc_html( "Method {$method} does not exist." ) );
9393
}
9494

9595
$macro = static::$macros[ $method ];

includes/core/utilities/class-array-helpers.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ class Array_Helpers {
66
/**
77
* Parses the string into variables without the max_input_vars limitation.
88
*
9-
* @param string $string String.
9+
* @param string $str String.
1010
*
1111
* @return array Parsed array.
1212
*/
13-
public static function parse_str( $string ) {
14-
if ( '' === $string ) {
13+
public static function parse_str( $str ) {
14+
if ( '' === $str ) {
1515
return false;
1616
}
1717

1818
$result = [];
19-
$pairs = explode( '&', $string );
19+
$pairs = explode( '&', $str );
2020

2121
foreach ( $pairs as $key => $pair ) {
2222

@@ -91,27 +91,27 @@ public static function parse_args( $args, $defaults ) {
9191
/**
9292
* Implode array keys with desired value.
9393
*
94-
* @param array $array Array to implode.
94+
* @param array $arr Array to implode.
9595
* @param string $value Checked for this value.
9696
* @param string|array $remove Array key or keys to remove before implode.
9797
* @param string $before Value to prepend to array keys.
9898
* @param string $after Value to append to array keys.
9999
*
100100
* @return string Imploded array keys with value.
101101
*/
102-
public static function implode_array_keys( $array, $value, $remove = false, $before = '', $after = '' ) {
102+
public static function implode_array_keys( $arr, $value, $remove = false, $before = '', $after = '' ) {
103103
if ( is_array( $remove ) ) {
104104
foreach ( $remove as $key ) {
105-
unset( $array[ $key ] );
105+
unset( $arr[ $key ] );
106106
}
107107
} elseif ( $remove ) {
108-
unset( $array[ $remove ] );
108+
unset( $arr[ $remove ] );
109109
}
110110

111111
$new_array = [];
112112

113-
foreach ( $array as $key => $item ) {
114-
if ( $array[ $key ] === $value ) {
113+
foreach ( $arr as $key => $item ) {
114+
if ( $arr[ $key ] === $value ) {
115115
$new_array[ $before . $key . $after ] = $item;
116116
}
117117
}

includes/core/utilities/class-background-process.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,6 @@ public function cancel_process() {
464464

465465
wp_clear_scheduled_hook( $this->cron_hook_identifier );
466466
}
467-
468467
}
469468

470469
/**
@@ -478,5 +477,4 @@ public function cancel_process() {
478477
* @return mixed
479478
*/
480479
abstract protected function task( $item );
481-
482480
}

0 commit comments

Comments
 (0)