Skip to content

Commit

Permalink
Reset changelog and version on clone and theme creation (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
pbking authored May 10, 2024
1 parent 0524255 commit b496fc0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion admin/create-theme/theme-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ class Theme_Create {

public static function clone_current_theme( $theme ) {

$theme['version'] = '1.0';
$theme['tags_custom'] = implode( ', ', wp_get_theme()->get( 'Tags' ) );

// Create theme directory.
$new_theme_path = get_theme_root() . DIRECTORY_SEPARATOR . $theme['slug'];

Expand All @@ -29,7 +32,9 @@ public static function clone_current_theme( $theme ) {
);
Theme_Utils::clone_theme_to_folder( $new_theme_path, $theme['slug'], $theme['name'] );
Theme_Templates::add_templates_to_local( 'all', $new_theme_path, $theme['slug'], $template_options );
file_put_contents( $new_theme_path . DIRECTORY_SEPARATOR . 'theme.json', MY_Theme_JSON_Resolver::export_theme_data( 'all' ) );
file_put_contents( path_join( $new_theme_path, 'theme.json' ), MY_Theme_JSON_Resolver::export_theme_data( 'all' ) );
file_put_contents( path_join( $new_theme_path, 'readme.txt' ), Theme_Readme::build_readme_txt( $theme ) );
file_put_contents( path_join( $new_theme_path, 'style.css' ), Theme_Styles::update_style_css( file_get_contents( path_join( $new_theme_path, 'style.css' ) ), $theme ) );

if ( $theme['subfolder'] ) {
switch_theme( $theme['subfolder'] . '/' . $theme['slug'] );
Expand Down
2 changes: 1 addition & 1 deletion admin/create-theme/theme-readme.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function build_readme_txt( $theme ) {
== Changelog ==
= 1.0.0 =
= 1.0 =
* Initial release
{$recommended_plugins_section}
{$copyright_section}
Expand Down
6 changes: 3 additions & 3 deletions admin/create-theme/theme-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static function update_style_css( $style_css, $theme ) {

$current_theme = wp_get_theme();
$css_contents = trim( substr( $style_css, strpos( $style_css, '*/' ) + 2 ) );
$name = $current_theme->get( 'Name' );
$name = stripslashes( $theme['name'] );
$description = stripslashes( $theme['description'] );
$uri = $theme['uri'];
$author = stripslashes( $theme['author'] );
Expand All @@ -20,7 +20,7 @@ public static function update_style_css( $style_css, $theme ) {
$version = $theme['version'];
$requires_php = $current_theme->get( 'RequiresPHP' );
$template = $current_theme->get( 'Template' );
$text_domain = $current_theme->get( 'TextDomain' );
$text_domain = $theme['slug'];

//TODO: These items don't seem to be available via ->get('License') calls
$license = 'GNU General Public License v2 or later';
Expand Down Expand Up @@ -66,7 +66,7 @@ public static function build_style_css( $theme ) {
if ( isset( $theme['template'] ) ) {
$template = $theme['template'];
}
$version = '1.0.0';
$version = '1.0';
$tags = Theme_Tags::theme_tags_list( $theme );

if ( isset( $theme['version'] ) ) {
Expand Down

0 comments on commit b496fc0

Please sign in to comment.