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

Local Environment: Child theme can't be activated #33

Closed
danielbachhuber opened this issue May 9, 2023 · 10 comments
Closed

Local Environment: Child theme can't be activated #33

danielbachhuber opened this issue May 9, 2023 · 10 comments
Assignees
Labels
Bug Something isn't working wp-now

Comments

@danielbachhuber
Copy link
Member

If you run wp-now --path=/path/to/child-theme, the theme can't be activated because the parent theme is missing.

The parent theme is missing because it isn't mounted into the filesystem.

Done is:

  • We're processing the style.css file for the parent them.
  • If there is a parent theme, we mount the corresponding directory to the filesystem.
@sejas
Copy link
Collaborator

sejas commented May 15, 2023

@katinthehatsite, Do you want to take this one?

@katinthehatsite
Copy link
Contributor

let's do this - or at least attempt 😅

@danielbachhuber
Copy link
Member Author

@katinthehatsite I'm going to pick this up so you can focus on your upcoming project.

@danielbachhuber danielbachhuber removed their assignment May 18, 2023
@danielbachhuber
Copy link
Member Author

With some more reflection, I actually want to hold off on fixing this for now:

  • Allow a configuration to map other folders and files #19 might be a more durable fix, because the parent theme can be located in other theme directories.
  • It might be nice to automatically install the parent theme from WordPress.org, but I don't know if this is a safe assumption to make.

I'd love to hear more reports from folks who run into this in the wild, and what their scenario is.

@cpapazoglou
Copy link

  • It might be nice to automatically install the parent theme from WordPress.org, but I don't know if this is a safe assumption to make.

If it doesn't exist locally and if it's a .org theme, yes, it would be nice!

@dmsnell
Copy link
Member

dmsnell commented May 19, 2023

Noting here that WordPress also fails if the parent theme is missing. If we can mirror WordPress behavior that seems sufficient. If WordPress can auto-install then that seems reasonable, but for many themes we know this is impossible because they don't exist in the registry.

For those cases it seems sufficient to scope-limit this tool to not solve problems WordPress itself doesn't solve.

@danielbachhuber
Copy link
Member Author

I'm also not sure if we can know definitively that a given theme is a WordPress.org theme.

@cpapazoglou
Copy link

I'm also not sure if we can know definitively that a given theme is a WordPress.org theme.

3pd themes usually don't have a slug used in .org. For example

https://api.wordpress.org/themes/info/1.1/?action=theme_information&request%5Bslug%5D=astra returns data for astra theme.

@wojtekn
Copy link
Collaborator

wojtekn commented May 19, 2023

For those cases it seems sufficient to scope-limit this tool to not solve problems WordPress itself doesn't solve.

I agree with @dmsnell , local environment tool shouldn't solve WordPress problems that way.

Activating the parent theme would be enough, assuming we use 'wp-content' mode with both themes available or we have support for paths mapping.

@danielbachhuber
Copy link
Member Author

This came up again with #39

For now, let's mount the parent theme directory too if it sits alongside the child theme. More complex configurations can be handled with #19

danielbachhuber added a commit that referenced this issue Jun 6, 2023
## 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](https://github.com/WordPress/playground-tools/assets/497103/a4726567-726e-4c7d-87c8-9e6ec10c864f)


## Why?

This pr is the first attempt to fix that error.
There is plenty of discussion about this problem
[here](#33)

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

---------

Co-authored-by: Daniel Bachhuber <[email protected]>
@kozer kozer assigned wojtekn and sejas and unassigned wojtekn and sejas Jun 7, 2023
@kozer kozer closed this as completed Jun 7, 2023
johnhooks pushed a commit to johnhooks/playground-tools that referenced this issue Oct 11, 2024
* Adds eslint and an npm script npm run lint:js and npm run lint:js:fix
* Adds prettier and an npm script npm run format
* Adds a husky pre-commit hook to run linting and formatting
* Lints and formats the files in the repository
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working wp-now
Projects
None yet
Development

No branches or pull requests

7 participants