Skip to content

Commit

Permalink
Make Requires Plugins header check stricter (#810)
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar authored Nov 26, 2024
1 parent 16e2b61 commit f68dc26
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function run( Check_Result $result ) {

if ( ! empty( $plugin_header['RequiresPlugins'] ) ) {
if ( ! preg_match( '/^[a-z0-9-]+(?:,\s*[a-z0-9-]+)*$/', $plugin_header['RequiresPlugins'] ) ) {
$this->add_result_warning_for_file(
$this->add_result_error_for_file(
$result,
sprintf(
/* translators: %s: plugin header field */
Expand All @@ -248,7 +248,7 @@ public function run( Check_Result $result ) {
0,
0,
'',
6
7
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: https://github.com/WordPress/plugin-check
* Description: Test plugin for the Localhost check.
* Requires at least: 6.0
* Requires PHP: 5.6
* Requires PHP: latest
* Version: 1.0.0
* Author: WordPress Performance Team
* Author URI: https://make.wordpress.org/performance/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function test_run_with_errors() {
$this->assertCount( 1, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'plugin_header_invalid_network' ) ) );

if ( is_wp_version_compatible( '6.5' ) ) {
$this->assertCount( 1, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'plugin_header_invalid_requires_plugins' ) ) );
$this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_requires_plugins' ) ) );
}
}

Expand All @@ -52,10 +52,10 @@ public function test_run_with_valid_requires_plugins_header() {

$check->run( $check_result );

$warnings = $check_result->get_warnings();
$errors = $check_result->get_errors();

if ( is_wp_version_compatible( '6.5' ) ) {
$this->assertCount( 0, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'plugin_header_invalid_requires_plugins' ) ) );
$this->assertCount( 0, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_requires_plugins' ) ) );
}
}

Expand Down

0 comments on commit f68dc26

Please sign in to comment.