Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

if ( ! empty( $plugin_header['Name'] ) ) {
if ( in_array( $plugin_header['Name'], array( 'Plugin Name', 'My Basics Plugin' ), true ) ) {
$this->add_result_warning_for_file(
$this->add_result_error_for_file(

Check warning on line 86 in includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php

View check run for this annotation

Codecov / codecov/patch

includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php#L86

Added line #L86 was not covered by tests
$result,
sprintf(
/* translators: %s: plugin header field */
Expand All @@ -95,7 +95,7 @@
0,
0,
'',
6
7

Check warning on line 98 in includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php

View check run for this annotation

Codecov / codecov/patch

includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php#L98

Added line #L98 was not covered by tests
);
} else {
$valid_chars_count = preg_match_all( '/[a-z0-9]/i', $plugin_header['Name'] );
Expand All @@ -121,7 +121,7 @@

if ( ! empty( $plugin_header['PluginURI'] ) ) {
if ( true !== $this->is_valid_url( $plugin_header['PluginURI'] ) ) {
$this->add_result_warning_for_file(
$this->add_result_error_for_file(

Check warning on line 124 in includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php

View check run for this annotation

Codecov / codecov/patch

includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php#L124

Added line #L124 was not covered by tests
$result,
sprintf(
/* translators: %s: plugin header field */
Expand All @@ -132,11 +132,11 @@
$plugin_main_file,
0,
0,
'',
6
'https://developer.wordpress.org/plugins/plugin-basics/header-requirements/#header-fields',
7

Check warning on line 136 in includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php

View check run for this annotation

Codecov / codecov/patch

includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php#L135-L136

Added lines #L135 - L136 were not covered by tests
);
} elseif ( preg_match( '/\/\/(example\.com|example\.net|example\.org)\//', $plugin_header['PluginURI'], $matches ) ) {
$this->add_result_warning_for_file(
$this->add_result_error_for_file(
$result,
sprintf(
/* translators: 1: plugin header field, 2: domain */
Expand All @@ -149,7 +149,7 @@
0,
0,
'https://developer.wordpress.org/plugins/plugin-basics/header-requirements/#header-fields',
6
7
);
}
}
Expand All @@ -175,7 +175,7 @@
|| str_contains( $plugin_header['Description'], 'Here is a short description of the plugin' )
|| str_contains( $plugin_header['Description'], 'Handle the basics with this plugin' )
) {
$this->add_result_warning_for_file(
$this->add_result_error_for_file(
$result,
sprintf(
/* translators: %s: plugin header field */
Expand All @@ -186,8 +186,8 @@
$plugin_main_file,
0,
0,
'',
6
'https://developer.wordpress.org/plugins/plugin-basics/header-requirements/#header-fields',
7
);
}
}
Expand Down Expand Up @@ -239,15 +239,15 @@
$plugin_main_file,
0,
0,
'',
'https://developer.wordpress.org/plugins/plugin-basics/header-requirements/#header-fields',
7
);
}
}

if ( ! empty( $plugin_header['Network'] ) ) {
if ( 'true' !== strtolower( $plugin_header['Network'] ) ) {
$this->add_result_warning_for_file(
$this->add_result_error_for_file(
$result,
sprintf(
/* translators: %s: plugin header field */
Expand All @@ -259,7 +259,7 @@
0,
0,
'https://developer.wordpress.org/plugins/plugin-basics/header-requirements/#header-fields',
6
7
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public function test_run_with_errors() {
$this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_no_license' ) ) );
$this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_missing_plugin_version' ) ) );
$this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_author_uri' ) ) );
$this->assertCount( 1, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'plugin_header_invalid_plugin_uri_domain' ) ) );
$this->assertCount( 1, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'plugin_header_invalid_plugin_description' ) ) );
$this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_plugin_uri_domain' ) ) );
$this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_plugin_description' ) ) );
$this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_network' ) ) );
$this->assertCount( 1, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'textdomain_mismatch' ) ) );
$this->assertCount( 1, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'plugin_header_nonexistent_domain_path' ) ) );
$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( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_requires_plugins' ) ) );
Expand Down Expand Up @@ -179,9 +179,10 @@ public function test_run_with_errors_duplicated_protocol_is_valid_url() {
$errors = $check_result->get_errors();

$filtered_items = wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_author_uri' ) );
$filtered_items = array_values( $filtered_items );

$this->assertCount( 1, $filtered_items );
$this->assertStringContainsString( 'Author URI', $filtered_items[1]['message'] );
$this->assertStringContainsString( 'is not valid', $filtered_items[1]['message'] );
$this->assertStringContainsString( 'Author URI', $filtered_items[0]['message'] );
$this->assertStringContainsString( 'is not valid', $filtered_items[0]['message'] );
}
}
Loading