From 45c3843cd748d7775b10e875bf2c82cc82678508 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Thu, 6 Mar 2025 18:47:45 +0100 Subject: [PATCH] dynamic example version --- .../Plugin_Repo/Plugin_Readme_Check.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php index c4f4d47a..adcd421b 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php @@ -214,12 +214,18 @@ private function check_headers( Check_Result $result, string $readme_file, Parse if ( ! empty( $parser->{$field_key} ) && 'tested' === $field_key ) { list( $tested_upto, ) = explode( '-', $parser->{$field_key} ); + $tested_upto_major = $tested_upto; + if ( preg_match( '#^\d.\d#', $tested_upto, $matches ) ) { + $tested_upto_major = $matches[0]; + } + if ( preg_match( '/^\d+\.\d+\.\d+/', $tested_upto ) ) { $this->add_result_error_for_file( $result, sprintf( /* translators: %s: currently used version */ - __( 'Tested up to: %s
The version number should only include major versions (e.g. 6.7), not minor versions (e.g. 6.7.1).', 'plugin-check' ), + __( 'Tested up to:
The version number should only include major versions %1$s, not minor versions %2$s.', 'plugin-check' ), + $tested_upto_major, $tested_upto ), 'invalid_tested_upto_minor', @@ -231,18 +237,14 @@ private function check_headers( Check_Result $result, string $readme_file, Parse ); } - if ( preg_match( '#^\d.\d#', $tested_upto, $matches ) ) { - $tested_upto = $matches[0]; - } - $latest_wordpress_version = $this->get_wordpress_stable_version(); - if ( version_compare( $tested_upto, $latest_wordpress_version, '<' ) ) { + if ( version_compare( $tested_upto_major, $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' */ __( 'Tested up to: %1$s < %2$s.
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' ), - $tested_upto, + $tested_upto_major, $latest_wordpress_version, 'Tested up to' ), @@ -253,13 +255,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( $tested_upto, number_format( (float) $latest_wordpress_version + 0.1, 1 ), '>' ) ) { + } elseif ( version_compare( $tested_upto_major, 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' */ __( 'Tested up to: %1$s.
The "%2$s" value in your plugin is not valid. This version of WordPress does not exist (yet).', 'plugin-check' ), - $tested_upto, + $tested_upto_major, 'Tested up to' ), 'nonexistent_tested_upto_header',