Code Editor does not work when the WordPress installation is located in a separate folder than root
For all my WordPress sites I use a git submodule for the WordPress installation, and as such its not located in the root of the site, but within a /wp/ subdirectory. WordPress then knows that its the root due to WP_DIR being set as /wp. Whilst not common, this isn't a rare setup, as there is some projects out there which use a similar type of pattern such as Bedrock , although they seem to use an npm package instead.
The error occurs due to the lazy-loading of CodeMirror. The path to the file is hard-coded as such:
script.src = `/wp-admin/load-scripts.php?load=${ handles.join( ',' ) }`;
WordPress supports this, so Gutenberg should.
There are a couple solutions I can think of:
- Introduce some
window.wp.adminUrlJavaScript variable to provide an always accurate URL reference. - Introduce a formal JavaScript API for lazy-loading concatenated scripts.
My preference would be the latter, as that would then allow us to abstract away from load-scripts.php at a future data if we needed to.
Having the same issues.
Any workaround?
I've also posted on Bedrock Discourse for reference.
https://discourse.roots.io/t/continuing-to-have-sage-9-bedrock-gutenberg-errors/12284
https://github.com/WordPress/gutenberg/pull/6777 fixed this.