Skip to content

Commit

Permalink
Check for empty string and use current wordpress version as fallback.
Browse files Browse the repository at this point in the history
  • Loading branch information
jffng committed Sep 18, 2024
1 parent 52bbdb5 commit b3b3386
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions includes/create-theme/theme-readme.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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'] ?? '';
Expand Down
4 changes: 2 additions & 2 deletions includes/create-theme/theme-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
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'];
$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'] ) ) {
Expand Down
3 changes: 3 additions & 0 deletions tests/CbtThemeReadme/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
),
Expand All @@ -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",
Expand Down

0 comments on commit b3b3386

Please sign in to comment.