Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds minimum WordPress version to theme metadata #715

Merged
merged 12 commits into from
Sep 20, 2024
Merged
21 changes: 12 additions & 9 deletions includes/create-theme/theme-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ public static function update_style_css( $style_css, $theme ) {
$author_uri = $theme['author_uri'];
$wp_version = CBT_Theme_Utils::get_current_wordpress_version();
$wp_min = $current_theme->get( 'RequiresWP' );
$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 = '';
if ( ! $wp_min ) {
mikachan marked this conversation as resolved.
Show resolved Hide resolved
$wp_min = '5.9';
mikachan marked this conversation as resolved.
Show resolved Hide resolved
}
$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];
Expand Down
14 changes: 14 additions & 0 deletions src/editor-sidebar/metadata-editor-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
description: '',
uri: '',
version: '',
wp_version: '',
author: '',
author_uri: '',
tags_custom: '',
Expand All @@ -65,6 +66,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
description: themeData.description.raw,
uri: themeData.theme_uri.raw,
version: themeData.version,
wp_version: themeData.requires_wp,
author: themeData.author.raw,
author_uri: themeData.author_uri.raw,
tags_custom: themeData.tags.rendered,
Expand Down Expand Up @@ -212,6 +214,18 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
'create-block-theme'
) }
/>
<TextControl
label={ __(
'Minimum WordPress version',
'create-block-theme'
) }
value={ theme.wp_version }
onChange={ ( value ) =>
setTheme( { ...theme, wp_version: value } )
}
/* translators: %s: minimum WordPress version required. */
placeholder={ __( '5.9', 'create-block-theme' ) }
/>
<FormTokenField
label={ __( 'Theme tags', 'create-block-theme' ) }
value={
Expand Down
Loading