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

wp-now: don't expect a full wp-content directory in wp-content mode #244

Open
Tracked by #238
adamziel opened this issue Apr 17, 2024 · 6 comments
Open
Tracked by #238
Labels
Enhancement New feature or request wp-now

Comments

@adamziel
Copy link
Collaborator

adamziel commented Apr 17, 2024

wp-now in wp-content mode expects a theme to be in place and won't apply the default WordPress theme.

I had to use the installTheme step to install twentytwentyfour. The assumption seems to be that my wp-content directory is complete and contains all it needs, but in https://github.com/adamziel/playground-docs-workflow I'm shipping just a subset of the files.

I see two solutions:

  • Add CLI options to run a vanilla WordPress server where specific wp-content/* subdirectories would be mounted via --mount= or so flags (or do that via Blueprints v2)
  • Instead of mounting the entire wp-content, mount specific plugins and directories found inside wp-content.

Context: The work on static site generator

@adamziel adamziel changed the title wp-now in wp-content mode expects a theme to be in place and won't apply the default WordPress theme. I had to use the installTheme step to install twentytwentyfour. The assumption seems to be that my wp-content directory is complete and contains all it needs, but I'm shipping just a subset of the files in this repo. Instead of mounting wp-content, wp-now could perhaps mount specific plugins and directories found inside wp-content. wp-now: don't expect a full wp-content directory in wp-content mode Apr 17, 2024
@adamziel adamziel added Enhancement New feature or request wp-now labels Apr 17, 2024
@mhsdef
Copy link

mhsdef commented Apr 25, 2024

Yeah, this was one of the first things I tried, and I ran into this. wp-content with just a plugins directory.

I like option two in UX. Mount what you find and fill in anything missing.

@adamziel
Copy link
Collaborator Author

@mhsdef I'm exploring a Playground CLI tool that doesn't make any assumptions and only mounts and serves what you tell it to – maybe that would be useful.

@mhsdef
Copy link

mhsdef commented Apr 25, 2024

@adamziel No worries, ten minutes later, I realized i could just do this one liner and it met our needs for that particular item. 💪

{
	"step": "writeFile",
	"path": "wp-content/mu-plugins/cors.php",
	"data": "<?php add_action('send_headers', function() { header('Access-Control-Allow-Origin: *'); });"
}

wp-now's current behavior of effectively expecting an explicitly theme too just surprised me as first time user so I saw and plus one'd this thread.

@flexseth
Copy link

@adamziel No worries, ten minutes later, I realized i could just do this one liner and it met our needs for that particular item. 💪

{
	"step": "writeFile",
	"path": "wp-content/mu-plugins/cors.php",
	"data": "<?php add_action('send_headers', function() { header('Access-Control-Allow-Origin: *'); });"
}

wp-now's current behavior of effectively expecting an explicitly theme too just surprised me as first time user so I saw and plus one'd this thread.

@mhsdef - I'm working on some docs about CORS in the Playground, would you mind linking more context to what you're working on so I can take a look at it?

@mhsdef
Copy link

mhsdef commented Apr 28, 2024

@flexseth at the moment, my exact use case isn't public code (yet) and it's hacky exploratory stuff so we may not even need what we're doing now at all in the end.

tl;dr: we're using a seperate frontend to directly query posts and all their HTML/CSS/JS glory on a WP Playground instance.

So we run into two levels of CORS problems immediately.

  1. Typical CORS when hitting PHP pages and loading most linked CSS/JSS.
  2. font static file loads in Firefox which are handled more stringently.

For the first case, shunting in a mu-plugin like you see above opens things up for development purposes just fine. Quick and easy. But, since it doesn't set headers on requests for static files, Firefox nopes out of font file loads.

Soooo, see #249 for more, what we do at the web server level. I think having ways to easily dial CORS both within WP and at the webserver level will be win for all the weird janky stuff we devs do. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request wp-now
Projects
None yet
Development

No branches or pull requests

3 participants