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

Fix/child export #471

Merged
merged 2 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading