Skip to content

Commit

Permalink
Merge branch 'trunk' into 710-check-look-for-duplicated-filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
davidperezgar authored Jan 8, 2025
2 parents 10cb561 + edb13a8 commit 0c229c1
Show file tree
Hide file tree
Showing 6 changed files with 2,214 additions and 1,703 deletions.
19 changes: 19 additions & 0 deletions includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,25 @@ public function run( Check_Result $result ) {
'',
6
);
} else {
$valid_chars_count = preg_match_all( '/[a-z0-9]/i', $plugin_header['Name'] );

if ( intval( $valid_chars_count ) < 5 ) {
$this->add_result_error_for_file(
$result,
sprintf(
/* translators: %s: plugin header field */
__( 'The "%s" header in the plugin file is not valid. It needs to contain at least 5 latin letters (a-Z) and/or numbers. This is necessary because the initial plugin slug is generated from the name.', 'plugin-check' ),
esc_html( $labels['Name'] )
),
'plugin_header_unsupported_plugin_name',
$plugin_main_file,
0,
0,
'https://developer.wordpress.org/plugins/plugin-basics/header-requirements/#header-fields',
7
);
}
}
}

Expand Down
14 changes: 10 additions & 4 deletions includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,20 @@ private function check_headers( Check_Result $result, string $readme_file, Parse
if ( ! in_array( $field['ignore_key'], $ignored_warnings, true ) && ! isset( $parser_warnings[ $field['ignore_key'] ] ) ) {

if ( ! empty( $parser->{$field_key} ) && 'tested' === $field_key ) {
list( $tested_upto, ) = explode( '-', $parser->{$field_key} );

if ( preg_match( '#^\d.\d#', $tested_upto, $matches ) ) {
$tested_upto = $matches[0];
}

$latest_wordpress_version = $this->get_wordpress_stable_version();
if ( version_compare( $parser->{$field_key}, $latest_wordpress_version, '<' ) ) {
if ( version_compare( $tested_upto, $latest_wordpress_version, '<' ) ) {
$this->add_result_error_for_file(
$result,
sprintf(
/* translators: 1: currently used version, 2: latest stable WordPress version, 3: 'Tested up to' */
__( '<strong>Tested up to: %1$s &lt; %2$s.</strong><br>The "%3$s" value in your plugin is not set to the current version of WordPress. This means your plugin will not show up in searches, as we require plugins to be compatible and documented as tested up to the most recent version of WordPress.', 'plugin-check' ),
$parser->{$field_key},
$tested_upto,
$latest_wordpress_version,
'Tested up to'
),
Expand All @@ -225,13 +231,13 @@ private function check_headers( Check_Result $result, string $readme_file, Parse
'https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/#readme-header-information',
7
);
} elseif ( version_compare( $parser->{$field_key}, number_format( (float) $latest_wordpress_version + 0.1, 1 ), '>' ) ) {
} elseif ( version_compare( $tested_upto, number_format( (float) $latest_wordpress_version + 0.1, 1 ), '>' ) ) {
$this->add_result_error_for_file(
$result,
sprintf(
/* translators: 1: currently used version, 2: 'Tested up to' */
__( '<strong>Tested up to: %1$s.</strong><br>The "%2$s" value in your plugin is not valid. This version of WordPress does not exist (yet).', 'plugin-check' ),
$parser->{$field_key},
$tested_upto,
'Tested up to'
),
'nonexistent_tested_upto_header',
Expand Down
Loading

0 comments on commit 0c229c1

Please sign in to comment.