From 71d299ee8ceba1017103419e8c3f27e6a7c5b54f Mon Sep 17 00:00:00 2001 From: Jason Crist Date: Mon, 6 Nov 2023 11:20:49 -0500 Subject: [PATCH 1/2] Use the existing theme name when exporting an existing CHILD theme. --- admin/class-create-theme.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/admin/class-create-theme.php b/admin/class-create-theme.php index 7a7c3d1b..c4300693 100644 --- a/admin/class-create-theme.php +++ b/admin/class-create-theme.php @@ -79,7 +79,13 @@ function save_variation( $export_type, $theme ) { * Export activated child theme */ function export_child_theme( $theme ) { - $theme['slug'] = Theme_Utils::get_theme_slug( $theme['name'] ); + if ( $theme['name'] ) { + // Used when CREATING a child theme + $theme['slug'] = Theme_Utils::get_theme_slug( $theme['name'] ); + } else { + // Used with EXPORTING a child theme + $theme['slug'] = wp_get_theme()->get( 'TextDomain' ); + } // Create ZIP file in the temporary directory. $filename = tempnam( get_temp_dir(), $theme['slug'] ); From ba9bfa1c884731c9754434a9f6300590c4b344a6 Mon Sep 17 00:00:00 2001 From: Jason Crist Date: Mon, 6 Nov 2023 11:21:44 -0500 Subject: [PATCH 2/2] When exporting a CHILD them only export the child resources. --- includes/class-create-block-theme-api.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/class-create-block-theme-api.php b/includes/class-create-block-theme-api.php index 096bc3ac..ca2c4804 100644 --- a/includes/class-create-block-theme-api.php +++ b/includes/class-create-block-theme-api.php @@ -339,8 +339,14 @@ function rest_export_theme( $request ) { $zip = Theme_Zip::create_zip( $filename ); $zip = Theme_Zip::copy_theme_to_zip( $zip, null, null ); - $zip = Theme_Zip::add_templates_to_zip( $zip, 'all', null ); - $zip = Theme_Zip::add_theme_json_to_zip( $zip, 'all' ); + + if ( is_child_theme() ) { + $zip = Theme_Zip::add_templates_to_zip( $zip, 'current', $theme_slug ); + $zip = Theme_Zip::add_theme_json_to_zip( $zip, 'current' ); + } else { + $zip = Theme_Zip::add_templates_to_zip( $zip, 'all', null ); + $zip = Theme_Zip::add_theme_json_to_zip( $zip, 'all' ); + } $zip->close();