From b3b33861b5a1621dde5bb278cca3ba99e62f804b Mon Sep 17 00:00:00 2001 From: Jeff Ong Date: Wed, 18 Sep 2024 13:53:58 -0400 Subject: [PATCH] Check for empty string and use current wordpress version as fallback. --- includes/create-theme/theme-readme.php | 4 ++-- includes/create-theme/theme-styles.php | 4 ++-- tests/CbtThemeReadme/update.php | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/includes/create-theme/theme-readme.php b/includes/create-theme/theme-readme.php index 6c3136c9..be428bbc 100644 --- a/includes/create-theme/theme-readme.php +++ b/includes/create-theme/theme-readme.php @@ -50,7 +50,7 @@ public static function create( $theme ) { $author_uri = $theme['author_uri'] ?? ''; $copy_year = $theme['copyright_year'] ?? gmdate( 'Y' ); $wp_version = $theme['wp_version'] ?? CBT_Theme_Utils::get_current_wordpress_version(); - $requires_wp = $theme['requires_wp'] ?? CBT_Theme_Utils::get_current_wordpress_version(); + $requires_wp = ( '' === $theme['requires_wp'] ) ? CBT_Theme_Utils::get_current_wordpress_version() : $theme['requires_wp']; $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'; @@ -211,7 +211,7 @@ public static function update( $theme, $readme_content = '' ) { $description = $theme['description'] ?? ''; $author = $theme['author'] ?? ''; $wp_version = $theme['wp_version'] ?? CBT_Theme_Utils::get_current_wordpress_version(); - $requires_wp = $theme['requires_wp'] ?? CBT_Theme_Utils::get_current_wordpress_version(); + $requires_wp = ( '' === $theme['requires_wp'] ) ? CBT_Theme_Utils::get_current_wordpress_version() : $theme['requires_wp']; $image_credits = $theme['image_credits'] ?? ''; $recommended_plugins = $theme['recommended_plugins'] ?? ''; $font_credits = $theme['font_credits'] ?? ''; diff --git a/includes/create-theme/theme-styles.php b/includes/create-theme/theme-styles.php index 3bd70e4c..e1fb4cb7 100644 --- a/includes/create-theme/theme-styles.php +++ b/includes/create-theme/theme-styles.php @@ -25,7 +25,7 @@ public static function update_style_css( $style_css, $theme ) { $author = stripslashes( $theme['author'] ); $author_uri = $theme['author_uri']; $wp_version = CBT_Theme_Utils::get_current_wordpress_version(); - $requires_wp = $theme['requires_wp'] ?? CBT_Theme_Utils::get_current_wordpress_version(); + $requires_wp = ( '' === $theme['requires_wp'] ) ? CBT_Theme_Utils::get_current_wordpress_version() : $theme['requires_wp']; $version = $theme['version']; $requires_php = $current_theme->get( 'RequiresPHP' ); $text_domain = $theme['slug']; @@ -67,7 +67,7 @@ public static function build_style_css( $theme ) { $uri = $theme['uri']; $author = stripslashes( $theme['author'] ); $author_uri = $theme['author_uri']; - $requires_wp = $theme['requires_wp'] ?? CBT_Theme_Utils::get_current_wordpress_version(); + $requires_wp = ( '' === $theme['requires_wp'] ) ? CBT_Theme_Utils::get_current_wordpress_version() : $theme['requires_wp']; $wp_version = CBT_Theme_Utils::get_current_wordpress_version(); $text_domain = sanitize_title( $name ); if ( isset( $theme['template'] ) ) { diff --git a/tests/CbtThemeReadme/update.php b/tests/CbtThemeReadme/update.php index d6ca9012..6144f47e 100644 --- a/tests/CbtThemeReadme/update.php +++ b/tests/CbtThemeReadme/update.php @@ -48,6 +48,7 @@ public function data_test_update() { 'description' => 'New theme description', 'author' => 'New theme author', 'wp_version' => '12.12', + 'requires_wp' => '', 'image_credits' => 'New image credits', 'recommended_plugins' => 'New recommended plugins', 'font_credits' => 'Example font credits text', @@ -58,6 +59,7 @@ public function data_test_update() { 'description' => 'New theme description', 'author' => 'New theme author', 'wp_version' => '12.12', + 'requires_wp' => '', 'image_credits' => 'New image credits', 'recommended_plugins' => 'New recommended plugins', ), @@ -71,6 +73,7 @@ public function data_test_update() { 'description' => 'New theme description', 'author' => 'New theme author', 'wp_version' => '12.12', + 'requires_wp' => '', 'image_credits' => "New image credits \r\n New image credits 2", 'recommended_plugins' => "Plugin1 \r\n Plugin2 \r\n Plugin3", 'font_credits' => "Font1 \r\n Font2 \r\n Font3",