Skip to content

Commit

Permalink
Fix/child export (#471)
Browse files Browse the repository at this point in the history
* Use the existing theme name when exporting an existing CHILD theme.

* When exporting a CHILD them only export the child resources.
  • Loading branch information
pbking authored Nov 13, 2023
1 parent f1bc21d commit a692b6b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion admin/class-create-theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] );
Expand Down
10 changes: 8 additions & 2 deletions includes/class-create-block-theme-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit a692b6b

Please sign in to comment.