Skip to content

Commit

Permalink
Merge pull request #563 from WordPress/562-make-description-and-url-f…
Browse files Browse the repository at this point in the history
…or-checks-and-individual-errorwarning-messages

Make description and url for checks and individual error/warning messages
  • Loading branch information
davidperezgar authored Aug 7, 2024
2 parents 26b0fc4 + 8c0becf commit 7d5480f
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 49 deletions.
3 changes: 3 additions & 0 deletions includes/CLI/Plugin_Check_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ private function flatten_file_results( $file_errors, $file_warnings ) {
foreach ( $line_warnings as $column => $column_warnings ) {
foreach ( $column_warnings as $column_warning ) {

$column_warning['message'] = str_replace( '<br>', "\n", $column_warning['message'] );
$column_warning['message'] = wp_strip_all_tags( $column_warning['message'] );

$file_results[] = array_merge(
$column_warning,
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ protected function look_for_zendguard( Check_Result $result, array $php_files )
'obfuscated_code_detected',
$file['file'],
$file['line'],
$file['column']
$file['column'],
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#gpl-no-publicly-documented-resource'
);
}
}
Expand Down Expand Up @@ -138,7 +139,8 @@ protected function look_for_sourceguardian( Check_Result $result, array $php_fil
'obfuscated_code_detected',
$file['file'],
$file['line'],
$file['column']
$file['column'],
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#gpl-no-publicly-documented-resource'
);
}
}
Expand Down Expand Up @@ -167,7 +169,8 @@ protected function look_for_ioncube( Check_Result $result, array $php_files ) {
'obfuscated_code_detected',
$file['file'],
$file['line'],
$file['column']
$file['column'],
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#gpl-no-publicly-documented-resource'
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ protected function check_files( Check_Result $result, array $files ) {
$result,
sprintf(
/* translators: %s: ALLOW_UNFILTERED_UPLOADS */
__( '%s is not permitted.', 'plugin-check' ),
__( '<strong>%s is not permitted.</strong><br>Setting this constant to true will allow the user to upload any type of file (including PHP and other executables), creating serious potential security risks.', 'plugin-check' ),
'<code>ALLOW_UNFILTERED_UPLOADS</code>'
),
'allow_unfiltered_uploads_detected',
$file
$file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#files-unfiltered-uploads'
);
}
}
Expand Down
110 changes: 74 additions & 36 deletions includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,33 @@ protected function check_files( Check_Result $result, array $files ) {
*/
private function check_name( Check_Result $result, string $readme_file, Parser $parser ) {
if ( isset( $parser->warnings['invalid_plugin_name_header'] ) && false === $parser->name ) {
$message = sprintf(
/* translators: %s: Example plugin name header */
__( 'Plugin name header in your readme is missing or invalid. Please update your readme with a valid plugin name header. Eg: "%s"', 'plugin-check' ),
'=== Example Name ==='
$this->add_result_error_for_file(
$result,
sprintf(
/* translators: %s: Example plugin name header */
__( 'Plugin name header in your readme is missing or invalid. Please update your readme with a valid plugin name header. Eg: "%s"', 'plugin-check' ),
'=== Example Name ==='
),
'invalid_plugin_name',
$readme_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#incomplete-readme'
);

$this->add_result_error_for_file( $result, $message, 'invalid_plugin_name', $readme_file );
} elseif ( empty( $parser->name ) ) {
$message = sprintf(
/* translators: %s: Example plugin name header */
__( 'We cannot find a plugin name in your readme. Please update your readme with a valid plugin name header. Eg: "%s"', 'plugin-check' ),
'=== Example Name ==='
$this->add_result_error_for_file(
$result,
sprintf(
/* translators: %s: Example plugin name header */
__( 'We cannot find a plugin name in your readme. Please update your readme with a valid plugin name header. Eg: "%s"', 'plugin-check' ),
'=== Example Name ==='
),
'empty_plugin_name',
$readme_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#incomplete-readme'
);

$this->add_result_error_for_file( $result, $message, 'empty_plugin_name', $readme_file );
}
}

Expand Down Expand Up @@ -181,11 +193,14 @@ private function check_headers( Check_Result $result, string $readme_file, Parse
$result,
sprintf(
/* translators: %s: plugin header tag */
__( 'The "%s" field is missing.', 'plugin-check' ),
__( '<strong>Your readme is either missing or incomplete.</strong><br>The "%s" field is missing. Your readme has to have headers as well as a proper description and documentation as to how it works and how one can use it.', 'plugin-check' ),
$field['label']
),
'missing_readme_header',
$readme_file
$readme_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#incomplete-readme'
);
}
}
Expand Down Expand Up @@ -214,9 +229,12 @@ private function check_default_text( Check_Result $result, string $readme_file,
) {
$this->add_result_warning_for_file(
$result,
__( 'The readme appears to contain default text.', 'plugin-check' ),
__( '<strong>The readme appears to contain default text.</strong><br>This means your readme has to have headers as well as a proper description and documentation as to how it works and how one can use it.', 'plugin-check' ),
'default_readme_text',
$readme_file
$readme_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#incomplete-readme'
);
}
}
Expand All @@ -239,9 +257,12 @@ private function check_license( Check_Result $result, string $readme_file, Parse
if ( empty( $license ) ) {
$this->add_result_error_for_file(
$result,
__( 'Your plugin has no license declared. Please update your readme with a GPLv2 (or later) compatible license.', 'plugin-check' ),
__( '<strong>Your plugin has no license declared.</strong><br>Please update your readme with a GPLv2 (or later) compatible license. It is necessary to declare the license of this plugin. You can do this by using the fields available both in the plugin readme and in the plugin headers.', 'plugin-check' ),
'no_license',
$readme_file
$readme_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#no-gpl-compatible-license-declared'
);

return;
Expand All @@ -253,9 +274,12 @@ private function check_license( Check_Result $result, string $readme_file, Parse
if ( ! preg_match( '/^([a-z0-9\-\+\.]+)(\sor\s([a-z0-9\-\+\.]+))*$/i', $license ) ) {
$this->add_result_warning_for_file(
$result,
__( 'Your plugin has an invalid license declared. Please update your readme with a valid SPDX license identifier.', 'plugin-check' ),
__( '<strong>Your plugin has an invalid license declared.</strong><br>Please update your readme with a valid SPDX license identifier.', 'plugin-check' ),
'invalid_license',
$readme_file
$readme_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#no-gpl-compatible-license-declared'
);
}

Expand All @@ -264,9 +288,12 @@ private function check_license( Check_Result $result, string $readme_file, Parse
if ( ! $has_license ) {
$this->add_result_error_for_file(
$result,
__( 'Your plugin has no license declared in Plugin Header. Please update your plugin header with a GPLv2 (or later) compatible license.', 'plugin-check' ),
__( '<strong>Your plugin has no license declared in Plugin Header.</strong><br>Please update your plugin header with a GPLv2 (or later) compatible license. It is necessary to declare the license of this plugin. You can do this by using the fields available both in the plugin readme and in the plugin headers.', 'plugin-check' ),
'no_license',
$plugin_main_file
$plugin_main_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#no-gpl-compatible-license-declared'
);
} else {
$plugin_license = $this->normalize_licenses( $matches_license[1] );
Expand All @@ -276,19 +303,25 @@ private function check_license( Check_Result $result, string $readme_file, Parse
if ( ! empty( $plugin_license ) && ! preg_match( '/GPL|GNU|MIT|FreeBSD|New BSD|BSD-3-Clause|BSD 3 Clause|OpenLDAP|Expat/im', $plugin_license ) ) {
$this->add_result_error_for_file(
$result,
__( 'Your plugin has an invalid license declared in Plugin Header. Please update your readme with a valid GPL license identifier.', 'plugin-check' ),
__( '<strong>Your plugin has an invalid license declared in Plugin Header.</strong><br>Please update your readme with a valid GPL license identifier. It is necessary to declare the license of this plugin. You can do this by using the fields available both in the plugin readme and in the plugin headers.', 'plugin-check' ),
'invalid_license',
$plugin_main_file
$plugin_main_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#no-gpl-compatible-license-declared'
);
}

// Check different license types.
if ( ! empty( $plugin_license ) && ! empty( $license ) && $license !== $plugin_license ) {
$this->add_result_warning_for_file(
$result,
__( 'Your plugin has a different license declared in the readme file and plugin header. Please update your readme with a valid GPL license identifier.', 'plugin-check' ),
__( '<strong>Your plugin has a different license declared in the readme file and plugin header.</strong><br>Please update your readme with a valid GPL license identifier.', 'plugin-check' ),
'license_mismatch',
$readme_file
$readme_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#declared-license-mismatched'
);
}
}
Expand Down Expand Up @@ -351,13 +384,12 @@ private function check_stable_tag( Check_Result $result, string $readme_file, Pa
if ( empty( $stable_tag ) ) {
$this->add_result_error_for_file(
$result,
sprintf(
/* translators: %s: plugin header tag */
__( 'The "%s" field is missing.', 'plugin-check' ),
'Stable Tag'
),
__( '<strong>Incorrect Stable Tag.</strong><br>Your Stable Tag is meant to be the stable version of your plugin, not of WordPress. For your plugin to be properly downloaded from WordPress.org, those values need to be the same. If they’re out of sync, your users won’t get the right version of your code.', 'plugin-check' ),
'no_stable_tag',
$readme_file
$readme_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#incorrect-stable-tag'
);

return;
Expand All @@ -366,9 +398,12 @@ private function check_stable_tag( Check_Result $result, string $readme_file, Pa
if ( 'trunk' === $stable_tag ) {
$this->add_result_error_for_file(
$result,
__( "It's recommended not to use 'Stable Tag: trunk'.", 'plugin-check' ),
__( "<strong>Incorrect Stable Tag.</strong><br>It's recommended not to use 'Stable Tag: trunk'. Your Stable Tag is meant to be the stable version of your plugin, not of WordPress. For your plugin to be properly downloaded from WordPress.org, those values need to be the same. If they’re out of sync, your users won’t get the right version of your code.", 'plugin-check' ),
'trunk_stable_tag',
$readme_file
$readme_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#incorrect-stable-tag'
);
}

Expand All @@ -381,9 +416,12 @@ private function check_stable_tag( Check_Result $result, string $readme_file, Pa
) {
$this->add_result_error_for_file(
$result,
__( 'The Stable Tag in your readme file does not match the version in your main plugin file.', 'plugin-check' ),
__( '<strong>The Stable Tag in your readme file does not match the version in your main plugin file.</strong><br>Your Stable Tag is meant to be the stable version of your plugin, not of WordPress. For your plugin to be properly downloaded from WordPress.org, those values need to be the same. If they’re out of sync, your users won’t get the right version of your code.', 'plugin-check' ),
'stable_tag_mismatch',
$readme_file
$readme_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#incorrect-stable-tag'
);
}
}
Expand Down
25 changes: 17 additions & 8 deletions includes/Checker/Checks/Plugin_Repo/Plugin_Updater_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ protected function look_for_update_uri_header( Check_Result $result ) {
if ( ! empty( $plugin_header['UpdateURI'] ) ) {
$this->add_result_error_for_file(
$result,
__( 'Plugin Updater detected. Use of the Update URI header is not helpful in plugins hosted on WordPress.org.', 'plugin-check' ),
__( '<strong>Including An Update Checker / Changing Updates functionality.</strong><br>Plugin Updater detected. Use of the Update URI header is not allowed in plugins hosted on WordPress.org.', 'plugin-check' ),
'plugin_updater_detected',
$plugin_main_file
$plugin_main_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#update-checker'
);
}
}
Expand All @@ -139,11 +142,14 @@ protected function look_for_updater_file( Check_Result $result, array $php_files
$result,
sprintf(
/* translators: %s: The match updater file name. */
__( 'Plugin Updater detected. These are not permitted in WordPress.org hosted plugins. Detected: %s', 'plugin-check' ),
__( '<strong>Plugin Updater detected.</strong><br>These are not permitted in WordPress.org hosted plugins. Detected: %s', 'plugin-check' ),
basename( $file )
),
'plugin_updater_detected',
$file
$file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#update-checker'
);
}
}
Expand Down Expand Up @@ -175,8 +181,8 @@ protected function look_for_plugin_updaters( Check_Result $result, array $php_fi
$this->add_result_error_for_file(
$result,
sprintf(
/* translators: %s: The match updater string. */
__( 'Plugin Updater detected. These are not permitted in WordPress.org hosted plugins. Detected: %s', 'plugin-check' ),
/* translators: %s: The match updater file name. */
__( '<strong>Plugin Updater detected.</strong><br>These are not permitted in WordPress.org hosted plugins. Detected: %s', 'plugin-check' ),
esc_attr( $matches[0] )
),
'plugin_updater_detected',
Expand Down Expand Up @@ -210,11 +216,14 @@ protected function look_for_updater_routines( Check_Result $result, array $php_f
$result,
sprintf(
/* translators: %s: The match file name. */
__( 'Detected code which may be altering WordPress update routines. Detected: %s', 'plugin-check' ),
__( '<strong>Plugin Updater detected.</strong><br>Detected code which may be altering WordPress update routines. Detected: %s', 'plugin-check' ),
esc_html( $matches[0] )
),
'update_modification_detected',
$updater_file
$updater_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#update-checker'
);
}
}
Expand Down

0 comments on commit 7d5480f

Please sign in to comment.