From b1d1558edea9a222483ba08bb7953c9565ab723c Mon Sep 17 00:00:00 2001 From: Jeff Ong Date: Thu, 5 Sep 2024 15:47:21 -0400 Subject: [PATCH] Sanitize the requires_wp attribute. --- includes/class-create-block-theme-api.php | 1 + includes/create-theme/theme-styles.php | 24 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/includes/class-create-block-theme-api.php b/includes/class-create-block-theme-api.php index 1593ebe0..3e50b574 100644 --- a/includes/class-create-block-theme-api.php +++ b/includes/class-create-block-theme-api.php @@ -458,6 +458,7 @@ private function sanitize_theme_data( $theme ) { $sanitized_theme['subfolder'] = sanitize_text_field( $theme['subfolder'] ?? '' ); $sanitized_theme['version'] = sanitize_text_field( $theme['version'] ?? '' ); $sanitized_theme['screenshot'] = sanitize_text_field( $theme['screenshot'] ?? '' ); + $sanitized_theme['requires_wp'] = sanitize_text_field( $theme['requires_wp'] ?? '' ); $sanitized_theme['recommended_plugins'] = sanitize_textarea_field( $theme['recommended_plugins'] ?? '' ); $sanitized_theme['font_credits'] = sanitize_textarea_field( $theme['font_credits'] ?? '' ); $sanitized_theme['image_credits'] = sanitize_textarea_field( $theme['image_credits'] ?? '' ); diff --git a/includes/create-theme/theme-styles.php b/includes/create-theme/theme-styles.php index 0865c9df..ca31e9fd 100644 --- a/includes/create-theme/theme-styles.php +++ b/includes/create-theme/theme-styles.php @@ -25,19 +25,17 @@ 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(); - $wp_min = $current_theme->get( 'RequiresWP' ); - if ( ! $wp_min ) { - $wp_min = '5.9'; - } - $version = $theme['version']; - $requires_php = $current_theme->get( 'RequiresPHP' ); - $text_domain = $theme['slug']; - $template = $current_theme->get( 'Template' ) ? "\n" . 'Template: ' . $current_theme->get( 'Template' ) : ''; - $license = $style_data['License'] ? $style_data['License'] : 'GNU General Public License v2 or later'; - $license_uri = $style_data['LicenseURI'] ? $style_data['LicenseURI'] : 'http://www.gnu.org/licenses/gpl-2.0.html'; - $tags = CBT_Theme_Tags::theme_tags_list( $theme ); - $css_contents = $css_contents ? "\n\n" . $css_contents : ''; - $copyright = ''; + $wp_min = $theme['requires_wp']; + $wp_min = $wp_min ? $wp_min : '6.0'; + $version = $theme['version']; + $requires_php = $current_theme->get( 'RequiresPHP' ); + $text_domain = $theme['slug']; + $template = $current_theme->get( 'Template' ) ? "\n" . 'Template: ' . $current_theme->get( 'Template' ) : ''; + $license = $style_data['License'] ? $style_data['License'] : 'GNU General Public License v2 or later'; + $license_uri = $style_data['LicenseURI'] ? $style_data['LicenseURI'] : 'http://www.gnu.org/licenses/gpl-2.0.html'; + $tags = CBT_Theme_Tags::theme_tags_list( $theme ); + $css_contents = $css_contents ? "\n\n" . $css_contents : ''; + $copyright = ''; preg_match( '/^\s*\n((?s).*?)\*\/\s*$/m', $style_css, $matches ); if ( isset( $matches[1] ) ) { $copyright = "\n" . $matches[1];