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 theme slug and textdomain for cloned, child and sibling themes. #301

Merged
merged 5 commits into from
Apr 5, 2023

Conversation

matiasbenedetto
Copy link
Contributor

@matiasbenedetto matiasbenedetto commented Apr 4, 2023

What?

This PR should fix set correctly the theme slug, textdomain, and 'template for cloned, child, and sibling themes.

Why?

Currently, that's not working OK because in some cases the textdomain , slug and template remain unchanged when you create a clone, child or sibling theme using the plugin.

How to test

  • Create a theme using clone, child, and sibling options.

  • Test that the theme slug, textdomain and template for the created theme are updated on every file of the theme (style.css, templates, template parts, and patterns).

  • Check that all other options still work as expected.

Fixes: #275
Fixes: https://wordpress.org/support/topic/creating-child-theme-forgets-to-replace-parent-theme-references-in-templates/

@matiasbenedetto matiasbenedetto changed the title Fix/child themes slugs Fix theme slug and textdomain for cloned, child and sibling themes. Apr 4, 2023
@matiasbenedetto matiasbenedetto marked this pull request as ready for review April 4, 2023 18:46
@matiasbenedetto
Copy link
Contributor Author

If you want to test this fix you can uninstall your current version of the plugin and install this .zip that contains the changes done in this branch: create-block-theme.zip

@porg
Copy link

porg commented Apr 4, 2023

✅ Tested successfully

  1. Disabled, uninstalled current plugin.
  2. Installed plugin via "Upload plugin".
  3. Activated the plugin, disabled auto-updates to avoid unintended auto updates.
  4. Switched from my child theme tt3dd to the parent theme twentytwentythree.
  5. Made a clear noticeable alteration: Styles → Layout → Content width: 400px.
  6. WordPress → Appearance → Create Block Theme → Create child theme with the Theme Name tt3dd2tt3dd2.zip got created and downloaded.
  7. WordPress → Appearance → Themes → Upload Theme → Uploading tt3dd2.zip ends with success message:
    Unpacking the package…
    Installing the theme…
    This theme requires a parent theme. Checking if it is installed…
    The parent theme, Twenty Twenty-Three 1.1, is currently installed.
    Theme installed successfully.
    
  8. Activating theme.
  • ✅ Frontend output visual check: Narrow modification is there. Header and footer are there.
  • Code Inspections:
    • ✅ All files in wp-content/themes/tt3dd2/templates/*.html instead of previously falsely referring to the parent theme now all use the proper child-theme reference "theme":"tt3dd2" everywhere.
    • ✅ Customization in the parent theme that I made in step 5 made it to wp-content/themes/tt3dd2/theme.json with "layout": { "contentSize": "400px".
  • 👍 Seems to be all working as it should now.

Copy link
Member

@mikachan mikachan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working well for me!

Tested:

  • Clone
  • Child
  • Sibling

The textdomain and slug are correct in all options ✅

@matiasbenedetto
Copy link
Contributor Author

Thanks, @porg and @mikachan for reviewing and testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Child Themes: template-parts links should include the child theme slug and not the parent theme slug.
3 participants