Skip to content

Commit

Permalink
Merge pull request #244 from WordPress/fix/remove-white-spaces-in-the…
Browse files Browse the repository at this point in the history
…me-name

Remove white spaces from theme slugs
  • Loading branch information
matiasbenedetto authored Feb 27, 2023
2 parents d682cd0 + 6e1a9ae commit cd9905d
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions admin/class-create-block-theme-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ function get_theme_slug( $new_theme_name ) {

$old_slug = wp_get_theme()->get( 'TextDomain' );
$new_slug = sanitize_title( $new_theme_name );
$new_slug = preg_replace('/\s+/', '', $new_slug); // Remove spaces

if( ! str_contains( $old_slug , '-') && str_contains( $new_slug, '-' ) ) {
return str_replace( '-', '', $new_slug );
Expand All @@ -499,7 +500,6 @@ function filter_theme_template( $template, $export_type, $path, $old_slug, $new_
return false;
}

$template->content = _remove_theme_attribute_in_block_template_content( $template->content );

// NOTE: Dashes are encoded as \u002d in the content that we get (noteably in things like css variables used in templates)
// This replaces that with dashes again. We should consider decoding the entire string but that is proving difficult.
Expand Down Expand Up @@ -709,15 +709,6 @@ function make_mediatext_block_local ( $block ) {
return $block;
}

function add_theme_attr_to_template_part_block ( $block ) {
// The template parts included in the patterns need to indicate the theme they belong to
if ( 'core/template-part' === $block[ 'blockName' ] ) {
$block['attrs']['theme'] = ( $_POST['theme']['type'] === "export" || $_POST['theme']['type'] === "save" )
? strtolower( wp_get_theme()->get( 'Name' ) )
: $_POST['theme']['name'];
}
return $block;
}

function make_media_blocks_local ( $nested_blocks ) {
$new_blocks = [];
Expand All @@ -734,9 +725,6 @@ function make_media_blocks_local ( $nested_blocks ) {
case 'core/media-text':
$block = $this->make_mediatext_block_local( $block );
break;
case 'core/template-part':
$block = $this->add_theme_attr_to_template_part_block( $block );
break;
}
// recursive call for inner blocks
if ( !empty ( $block['innerBlocks'] ) ) {
Expand Down

0 comments on commit cd9905d

Please sign in to comment.