diff --git a/admin/class-create-block-theme-admin.php b/admin/class-create-block-theme-admin.php index 1348415a..86bd2757 100644 --- a/admin/class-create-block-theme-admin.php +++ b/admin/class-create-block-theme-admin.php @@ -71,14 +71,14 @@ function save_variation( $export_type, $theme ) { * Export activated child theme */ function export_child_theme( $theme ) { - $theme['slug'] = wp_get_theme()->get( 'TextDomain' ); + $theme['slug'] = Theme_Utils::get_theme_slug( $theme['name'] ); // Create ZIP file in the temporary directory. $filename = tempnam( get_temp_dir(), $theme['slug'] ); $zip = Theme_Zip::create_zip( $filename ); $zip = Theme_Zip::copy_theme_to_zip( $zip, null, null ); - $zip = Theme_Zip::add_templates_to_zip( $zip, 'current', null ); + $zip = Theme_Zip::add_templates_to_zip( $zip, 'current', $theme['slug'] ); $zip = Theme_Zip::add_theme_json_to_zip( $zip, 'current' ); $zip->close(); @@ -95,6 +95,8 @@ function export_child_theme( $theme ) { * Create a sibling theme of the activated theme */ function create_sibling_theme( $theme, $screenshot ) { + $theme_slug = Theme_Utils::get_theme_slug( $theme['name'] ); + // Sanitize inputs. $theme['name'] = sanitize_text_field( $theme['name'] ); $theme['description'] = sanitize_text_field( $theme['description'] ); @@ -102,8 +104,9 @@ function create_sibling_theme( $theme, $screenshot ) { $theme['author'] = sanitize_text_field( $theme['author'] ); $theme['author_uri'] = sanitize_text_field( $theme['author_uri'] ); $theme['tags_custom'] = sanitize_text_field( $theme['tags_custom'] ); - $theme['slug'] = Theme_Utils::get_theme_slug( $theme['name'] ); + $theme['slug'] = $theme_slug; $theme['template'] = wp_get_theme()->get( 'Template' ); + $theme['text_domain'] = $theme_slug; // Create ZIP file in the temporary directory. $filename = tempnam( get_temp_dir(), $theme['slug'] ); @@ -152,6 +155,8 @@ function create_sibling_theme( $theme, $screenshot ) { * Clone the activated theme to create a new theme */ function clone_theme( $theme, $screenshot ) { + $theme_slug = Theme_Utils::get_theme_slug( $theme['name'] ); + // Sanitize inputs. $theme['name'] = sanitize_text_field( $theme['name'] ); $theme['description'] = sanitize_text_field( $theme['description'] ); @@ -159,9 +164,10 @@ function clone_theme( $theme, $screenshot ) { $theme['author'] = sanitize_text_field( $theme['author'] ); $theme['author_uri'] = sanitize_text_field( $theme['author_uri'] ); $theme['tags_custom'] = sanitize_text_field( $theme['tags_custom'] ); - $theme['slug'] = Theme_Utils::get_theme_slug( $theme['name'] ); - $theme['template'] = wp_get_theme()->get( 'Template' ); + $theme['slug'] = $theme_slug; + $theme['template'] = ''; $theme['original_theme'] = wp_get_theme()->get( 'Name' ); + $theme['text_domain'] = $theme_slug; // Use previous theme's tags if custom tags are empty. if ( empty( $theme['tags_custom'] ) ) { @@ -236,6 +242,10 @@ public function register_theme_export() { * Create a child theme of the activated theme */ function create_child_theme( $theme, $screenshot ) { + + $parent_theme_slug = Theme_Utils::get_theme_slug( wp_get_theme()->get( 'Name' ) ); + $child_theme_slug = Theme_Utils::get_theme_slug( $theme['name'] ); + // Sanitize inputs. $theme['name'] = sanitize_text_field( $theme['name'] ); $theme['description'] = sanitize_text_field( $theme['description'] ); @@ -243,14 +253,16 @@ function create_child_theme( $theme, $screenshot ) { $theme['author'] = sanitize_text_field( $theme['author'] ); $theme['author_uri'] = sanitize_text_field( $theme['author_uri'] ); $theme['tags_custom'] = sanitize_text_field( $theme['tags_custom'] ); - $theme['slug'] = Theme_Utils::get_theme_slug( $theme['name'] ); - $theme['template'] = wp_get_theme()->get( 'TextDomain' ); + + $theme['text_domain'] = $child_theme_slug; + $theme['template'] = $parent_theme_slug; + $theme['slug'] = $child_theme_slug; // Create ZIP file in the temporary directory. $filename = tempnam( get_temp_dir(), $theme['slug'] ); $zip = Theme_Zip::create_zip( $filename ); - $zip = Theme_Zip::add_templates_to_zip( $zip, 'user', null ); + $zip = Theme_Zip::add_templates_to_zip( $zip, 'user', $theme['slug'] ); $zip = Theme_Zip::add_theme_json_to_zip( $zip, 'user' ); // Add readme.txt. @@ -308,6 +320,8 @@ function export_theme( $theme ) { } function create_blank_theme( $theme, $screenshot ) { + $theme_slug = Theme_Utils::get_theme_slug( $theme['name'] ); + // Sanitize inputs. $theme['name'] = sanitize_text_field( $theme['name'] ); $theme['description'] = sanitize_text_field( $theme['description'] ); @@ -316,7 +330,8 @@ function create_blank_theme( $theme, $screenshot ) { $theme['author_uri'] = sanitize_text_field( $theme['author_uri'] ); $theme['tags_custom'] = sanitize_text_field( $theme['tags_custom'] ); $theme['template'] = ''; - $theme['slug'] = Theme_Utils::get_theme_slug( $theme['name'] ); + $theme['slug'] = $theme_slug; + $theme['text_domain'] = $theme_slug; // Create theme directory. $source = plugin_dir_path( __DIR__ ) . 'assets/boilerplate'; diff --git a/admin/create-theme/theme-blocks.php b/admin/create-theme/theme-blocks.php index 3e95cdb2..833daf98 100644 --- a/admin/create-theme/theme-blocks.php +++ b/admin/create-theme/theme-blocks.php @@ -188,4 +188,5 @@ static function clean_serialized_markup( $markup ) { $markup = html_entity_decode( $markup, ENT_QUOTES | ENT_XML1, 'UTF-8' ); return $markup; } + } diff --git a/admin/create-theme/theme-form.php b/admin/create-theme/theme-form.php index 2995852b..45ce70da 100644 --- a/admin/create-theme/theme-form.php +++ b/admin/create-theme/theme-form.php @@ -53,8 +53,7 @@ public static function create_admin_form_page() {
-

-
+