Skip to content

Commit

Permalink
Use only major.minor version in 'Tested up to' field (#635)
Browse files Browse the repository at this point in the history
Co-authored-by: Matias Benedetto <matias.benedetto@gmail.com>
  • Loading branch information
pbking and matiasbenedetto authored May 16, 2024
1 parent cbd0ba9 commit d3ffe65
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions admin/create-theme/theme-readme.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function create( $theme ) {
$author = $theme['author'] ?? '';
$author_uri = $theme['author_uri'] ?? '';
$copy_year = $theme['copyright_year'] ?? gmdate( 'Y' );
$wp_version = $theme['wp_version'] ?? get_bloginfo( 'version' );
$wp_version = $theme['wp_version'] ?? CBT_Theme_Utils::get_current_wordpress_version();
$required_php_version = $theme['required_php_version'] ?? '5.7';
$license = $theme['license'] ?? 'GPLv2 or later';
$license_uri = $theme['license_uri'] ?? 'http://www.gnu.org/licenses/gpl-2.0.html';
Expand Down Expand Up @@ -201,7 +201,7 @@ public static function update( $theme, $readme_content = '' ) {
// Theme data.
$description = $theme['description'] ?? '';
$author = $theme['author'] ?? '';
$wp_version = $theme['wp_version'] ?? get_bloginfo( 'version' );
$wp_version = $theme['wp_version'] ?? CBT_Theme_Utils::get_current_wordpress_version();
$image_credits = $theme['image_credits'] ?? '';
$recommended_plugins = $theme['recommended_plugins'] ?? '';

Expand Down
4 changes: 2 additions & 2 deletions admin/create-theme/theme-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static function update_style_css( $style_css, $theme ) {
$uri = $theme['uri'];
$author = stripslashes( $theme['author'] );
$author_uri = $theme['author_uri'];
$wp_version = get_bloginfo( 'version' );
$wp_version = CBT_Theme_Utils::get_current_wordpress_version();
$wp_min = $current_theme->get( 'RequiresWP' );
$version = $theme['version'];
$requires_php = $current_theme->get( 'RequiresPHP' );
Expand Down Expand Up @@ -67,7 +67,7 @@ public static function build_style_css( $theme ) {
$uri = $theme['uri'];
$author = stripslashes( $theme['author'] );
$author_uri = $theme['author_uri'];
$wp_version = get_bloginfo( 'version' );
$wp_version = CBT_Theme_Utils::get_current_wordpress_version();
$text_domain = sanitize_title( $name );
if ( isset( $theme['template'] ) ) {
$template = $theme['template'];
Expand Down
11 changes: 11 additions & 0 deletions admin/create-theme/theme-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,15 @@ public static function replace_screenshot( $new_screenshot_path ) {
return CBT_Theme_Utils::copy_screenshot( $new_screenshot_path );
}

/**
* Get the current WordPress version.
*
* @return string The current WordPress in the format x.x (major.minor)
* Example: 6.5
*/
public static function get_current_wordpress_version() {
$wp_version = get_bloginfo( 'version' );
$wp_version_parts = explode( '.', $wp_version );
return $wp_version_parts[0] . '.' . $wp_version_parts[1];
}
}
2 changes: 1 addition & 1 deletion tests/CbtThemeReadme/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function test_create( $data ) {
$expected_uri = 'Theme URI: ' . $data['uri'];
$expected_author = 'Contributors: ' . $data['author'];
$expected_author_uri = 'Author URI: ' . $data['author_uri'];
$expected_wp_version = 'Tested up to: ' . $data['wp_version'] ?? get_bloginfo( 'version' );
$expected_wp_version = 'Tested up to: ' . $data['wp_version'] ?? CBT_Theme_Utils::get_current_wordpress_version();
$expected_php_version = 'Requires PHP: ' . $data['required_php_version'];
$expected_license = 'License: ' . $data['license'];
$expected_license_uri = 'License URI: ' . $data['license_uri'];
Expand Down
2 changes: 1 addition & 1 deletion tests/CbtThemeReadme/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test_update( $data ) {
$readme_without_newlines = str_replace( "\n", '', $readme );

$expected_author = 'Contributors: ' . $data['author'];
$expected_wp_version = 'Tested up to: ' . $data['wp_version'] ?? get_bloginfo( 'version' );
$expected_wp_version = 'Tested up to: ' . $data['wp_version'] ?? CBT_Theme_Utils::get_current_wordpress_version();
$expected_image_credits = '== Images ==' . $data['image_credits'];
$expected_recommended_plugins = '== Recommended Plugins ==' . $data['recommended_plugins'];

Expand Down

0 comments on commit d3ffe65

Please sign in to comment.