create-block-theme icon indicating copy to clipboard operation
create-block-theme copied to clipboard

Update `get_theme_slug` to allow theme names with hyphens

Open mikachan opened this issue 2 years ago • 1 comments

Currently, the get_theme_slug function is removing hyphens from a new theme name based on the following logic:

When the source theme has a single-word slug but the new theme has a multi-word slug (e.g. cloning twentytwentythree and then naming the new theme tt3-clone would change the new theme name to 'tt3clone').

This can be confusing, as the .zip file has a different name to the chosen theme name, and it results in some discrepancies throughout the theme code where the slug is referenced, such as in pattern blocks and the Text Domain.

I believe this was to prevent hyphens from being used in theme support functions (e.g. tt3-clone_support()), but perhaps this logic could be more specific to the function name creation, rather than the theme slug itself. Could we replace the hyphens with underscores just for function names?

This issue came up while testing https://github.com/WordPress/create-block-theme/pull/213.

mikachan avatar Feb 16 '23 18:02 mikachan

This is a very difficult problem to solve. I would love to but I'm not sure how.

You're correct; the spaces in slugs are removed since we are unable to 100% determine when a slug should be slug-name or slug_name.

The zip file SHOULD match the slug now so at least that aspect of this task is complete (no spaces in that either). However it would be much MORE correct if the correct slug were used instead.

pbking avatar Apr 29 '24 13:04 pbking

👏 Thank you!!

iamtakashi avatar May 10 '24 14:05 iamtakashi