Directory

Update `get_theme_slug` to allow theme names with hyphens/spaces · Issue #228 · WordPress/create-block-theme · GitHub
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

Update get_theme_slug to allow theme names with hyphens/spaces #228

Closed
mikachan opened this issue Feb 16, 2023 · 2 comments · Fixed by #622
Closed

Update get_theme_slug to allow theme names with hyphens/spaces #228

mikachan opened this issue Feb 16, 2023 · 2 comments · Fixed by #622
Labels
enhancement New feature or request

Comments

@mikachan
Copy link
Member

mikachan commented Feb 16, 2023

Any theme name that includes a space needs to either have the space removed or replaced with a hyphen for use in the directory name and the text domain.

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 #213.

@mikachan mikachan added the enhancement New feature or request label Feb 16, 2023
@pbking
Copy link
Contributor

pbking commented Apr 29, 2024

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.

@mikachan mikachan changed the title Update get_theme_slug to allow theme names with hyphens Update get_theme_slug to allow theme names with hyphens/spaces May 2, 2024
@iamtakashi
Copy link

👏 Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

3 participants