Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/test-wp-version-nopatch
Browse files Browse the repository at this point in the history
  • Loading branch information
pbking committed May 16, 2024
2 parents 099d99a + cbd0ba9 commit 91e0b93
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 47 deletions.
42 changes: 24 additions & 18 deletions admin/create-theme/theme-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ class CBT_Theme_Styles {
*/
public static function update_style_css( $style_css, $theme ) {

$style_data = get_file_data(
path_join( get_stylesheet_directory(), 'style.css' ),
array(
'License' => 'License',
'LicenseURI' => 'License URI',
)
);

$current_theme = wp_get_theme();
$css_contents = trim( substr( $style_css, strpos( $style_css, '*/' ) + 2 ) );
$name = stripslashes( $theme['name'] );
Expand All @@ -17,39 +25,37 @@ 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' );
$version = $theme['version'];
$requires_php = $current_theme->get( 'RequiresPHP' );
$template = $current_theme->get( 'Template' );
$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];
}

//TODO: These items don't seem to be available via ->get('License') calls
$license = 'GNU General Public License v2 or later';
$license_uri = 'http://www.gnu.org/licenses/gpl-2.0.html';
$tags = CBT_Theme_Tags::theme_tags_list( $theme );
$css_metadata = "/*
return "/*
Theme Name: {$name}
Theme URI: {$uri}
Author: {$author}
Author URI: {$author_uri}
Description: {$description}
Requires at least: 6.0
Requires at least: {$wp_min}
Tested up to: {$wp_version}
Requires PHP: {$requires_php}
Version: {$version}
License: {$license}
License URI: {$license_uri}
";

if ( ! empty( $template ) ) {
$css_metadata .= "Template: {$template}\n";
}

$css_metadata .= "Text Domain: {$text_domain}
License URI: {$license_uri}{$template}
Text Domain: {$text_domain}
Tags: {$tags}
*/
{$copyright}*/{$css_contents}
";
return $css_metadata . $css_contents;
}

/**
Expand Down
15 changes: 8 additions & 7 deletions includes/class-create-block-theme-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,14 @@ function rest_save_theme( $request ) {

private function sanitize_theme_data( $theme ) {
$sanitized_theme['name'] = sanitize_text_field( $theme['name'] );
$sanitized_theme['description'] = sanitize_text_field( $theme['description'] );
$sanitized_theme['uri'] = sanitize_text_field( $theme['uri'] );
$sanitized_theme['author'] = sanitize_text_field( $theme['author'] );
$sanitized_theme['author_uri'] = sanitize_text_field( $theme['author_uri'] );
$sanitized_theme['tags_custom'] = sanitize_text_field( $theme['tags_custom'] );
$sanitized_theme['subfolder'] = sanitize_text_field( $theme['subfolder'] );
$sanitized_theme['recommended_plugins'] = sanitize_textarea_field( $theme['recommended_plugins'] );
$sanitized_theme['description'] = sanitize_text_field( $theme['description'] ?? '' );
$sanitized_theme['uri'] = sanitize_text_field( $theme['uri'] ?? '' );
$sanitized_theme['author'] = sanitize_text_field( $theme['author'] ?? '' );
$sanitized_theme['author_uri'] = sanitize_text_field( $theme['author_uri'] ?? '' );
$sanitized_theme['tags_custom'] = sanitize_text_field( $theme['tags_custom'] ?? '' );
$sanitized_theme['subfolder'] = sanitize_text_field( $theme['subfolder'] ?? '' );
$sanitized_theme['version'] = sanitize_text_field( $theme['version'] ?? '' );
$sanitized_theme['recommended_plugins'] = sanitize_textarea_field( $theme['recommended_plugins'] ?? '' );
$sanitized_theme['template'] = '';
$sanitized_theme['slug'] = sanitize_title( $theme['name'] );
$sanitized_theme['text_domain'] = $sanitized_theme['slug'];
Expand Down
28 changes: 6 additions & 22 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ If you are having problems, please try the following:
* Add text domain to translation target (#499)

= 1.13.8 =

* Remove the development-only warning

= 1.13.7 =

* docs: Add recent release notes to the changelog

= 1.13.6 =

* Fix manage fonts page

= 1.13.5 =
* Make form files more specific to form page
Expand Down Expand Up @@ -228,27 +228,17 @@ If you are having problems, please try the following:
* Update Google Fonts JSON data from API

= 1.13.0 =
* # Conflicts:
# admin/create-theme/theme-readme.php
# admin/create-theme/theme-zip.php

* Merge branch 'trunk' into fix/resources-credits-on-save
* Merge branch 'trunk' into add/subfolder-to-zip
* Persist copyright info on new theme creation
* Update Google Fonts JSON data from API
* Move check for `download_url` higher up
* Avoid white spaces or other weird characters on font asset paths.
* Merge branch 'trunk' into add/subfolder-to-zip
* Adding files to zip subfolder called as theme slug
* Update Google Fonts JSON data from API

= 1.12.1 =
* Fix double replacement in replace_namespace

= 1.12.0 =
* # Conflicts:
# src/plugin-sidebar.js

* Add image credits input
* Update theme `version` logic to use isset()
* Update Google Fonts JSON data from API
Expand All @@ -258,7 +248,7 @@ If you are having problems, please try the following:
* Add linebreaks before hyphen lists in readme to fix plugin repository display
* Prevent additional white space in font credits in readme.txt
* Google fonts: Change onClick handlers to onChange
* Merge pull request #374 from WordPress/fix/escape-template-text
* Escape special characters to avoid syntax errors
* Update required node version and update dependencies

= 1.10.0 =
Expand All @@ -270,27 +260,25 @@ If you are having problems, please try the following:
* Automatically add font license info for local fonts

= 1.9.0 =
* Merge branch 'trunk' into add/handle-google-font-credits
* Handle Google Font Credits
* Update Google Fonts JSON data from API
* Fix console error in `prepareThemeNameValidation` function
* Add FAQ section to readme.txt
* Automatically add font license info for Google fonts
* Removing donate link

= 1.8.2 =
* Merge branch 'trunk' into update/tested-up-wp-version-62
* Bump tested version
* Updating Tested up to: 6.2 WordPress version
* fix tag duplication in exported theme
* Fixing error checking
* Update Google Fonts JSON data from API
* Refactor react app code for general purpose
* add build directory to php exclude list
* Do not call replace_template_namespace when overwrting theme
* Merge branch 'trunk' into fix/314
* Fix error when switching to template edit mode in the post editor
* Add useRootPaddingAwareAlignments to blank theme
* Update Google Fonts JSON data from API
* Merge branch 'trunk' into fix/314
* Avoid adding Template info to style.css if it's empty
* Fix delete font family/face when name is different from family
* Add theme name validation
Expand Down Expand Up @@ -430,11 +418,7 @@ If you are having problems, please try the following:
* Updating google fonts data
* Force https to load Google fonts preview
* Add the ability to select/unselect all google font variants
* Merge branch 'trunk' into try/manage-fonts
* Update google fonts JSON data automatically using a repo action
* Merge branch 'trunk' into release-action
* Merge branch 'trunk' into try/manage-fonts
* Merge branch 'try/manage-fonts' into release-action
* Manage theme fonts
* Automate release: build, version bump, changelog, deploy to wp.org
* Automate release
Expand Down

0 comments on commit 91e0b93

Please sign in to comment.