gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Code Editor does not work when the WordPress installation is located in a separate folder than root

Open paulwilde opened this issue 8 years ago • 4 comments

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( ',' ) }`;

screen shot 2018-03-29 at 23 36 30

paulwilde avatar Mar 29 '18 23:03 paulwilde

WordPress supports this, so Gutenberg should.

greatislander avatar Mar 30 '18 01:03 greatislander

There are a couple solutions I can think of:

  1. Introduce some window.wp.adminUrl JavaScript variable to provide an always accurate URL reference.
  2. 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.

danielbachhuber avatar Apr 10 '18 15:04 danielbachhuber

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

apintocr avatar Apr 21 '18 14:04 apintocr

https://github.com/WordPress/gutenberg/pull/6777 fixed this.

noisysocks avatar May 29 '18 05:05 noisysocks