Skip to content

wp-now: Mount the parent theme when running in a child theme - #58

Merged
danielbachhuber merged 5 commits into
trunkfrom
fix/child_theme_activation
Jun 6, 2023
Merged

danielbachhuber merged 5 commits into
trunkfrom
fix/child_theme_activation

Conversation

@kozer

@kozer kozer commented Jun 2, 2023

Copy link
Copy Markdown
Collaborator

What?

This pr introduces a fix when the user works in a child theme. In this case, the parent theme is not mounted and this creates a "Missing parent theme" error:
child_theme_error

Why?

This pr is the first attempt to fix that error.
There is plenty of discussion about this problem here

How?

As a first step to solve this issue, we try to find the parent theme and mount it in the appropriate folder.
We assume that the parent theme is available in the parent directory, and there is some upcoming work to handle more complex scenarios

Testing Instructions

  1. Create a folder with a theme (eg: test), and a child theme (eg: test-child)
  2. Run wp-now start --path=<your-child-theme-path>
  3. Ensure there is no error in the loaded page
  4. Move to /wp-admin/themes.php and ensure that you:
    • Can activate and deactivate your child theme
    • The parent theme is visible and can be activated and deactivated as well

@kozer kozer self-assigned this Jun 2, 2023
@kozer kozer added the Bug Something isn't working label Jun 2, 2023
@kozer kozer changed the title Fix/child theme activation Wp-now: fix child theme activation Jun 2, 2023
@kozer kozer changed the title Wp-now: fix child theme activation wp-now: fix child theme activation Jun 2, 2023
Comment thread packages/wp-now/src/wp-now.ts Resolved
Comment thread packages/wp-now/src/wp-now.ts Resolved
Comment thread packages/wp-now/src/wp-now.ts Resolved
@danielbachhuber danielbachhuber changed the title wp-now: fix child theme activation wp-now: Mount the parent theme when running in a child theme Jun 2, 2023
@kozer
kozer requested a review from danielbachhuber June 6, 2023 13:00

@danielbachhuber danielbachhuber left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works as expected with one tweak: a479df3

I downloaded https://wordpress.org/themes/moina-blog/, unzipped it, and ran nx preview wp-now start --path=/Users/danielbachhuber/projects/playground-test/child-theme/moina-blog. It was marked as a broken theme because it was missing its parent:

image

When I downloaded the parent theme (https://wordpress.org/themes/moina/) and unzipped it in the same directory, the child theme activated as expected:

image

@danielbachhuber
danielbachhuber merged commit 658b875 into trunk Jun 6, 2023
@danielbachhuber
danielbachhuber deleted the fix/child_theme_activation branch June 6, 2023 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working VS Code wp-now

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants