Open notnownikki opened 5 years ago
cc @ockham, our block registration master :)
I just rebased the PR where I'm seeing this issue, and it's only happening for admin users. Authors and editors, no problems at all.
I just rebased the PR where I'm seeing this issue, and it's only happening for admin users. Authors and editors, no problems at all.
I just tried to repro this and see it for admins, editors, and authors alike.
Your analysis makes a lot of sense, but wouldn't that mean that it should be up to Gutenberg to prevent that something like this happens? (I.e. running wp-blocks
before relevant filters are run)
In other words, is this an instance of https://github.com/WordPress/gutenberg/issues/9757?
Yes, it does seem to be that behaviour.
Ok, I'll have to come up with a workaround. Thanks for looking into it.
Description
Jetpack enqueues scripts that depend on
wp-blocks
. When we have plugins that need to register filters used bywp-blocks
, they end up loading and running after Jetpack, which has loadedwp-blocks
and so the filters aren't registered in time to run.Steps to reproduce the issue
This uses my WIP PR for extending the embed blocks to highlight the issue, but it should be reproducable with a simpler plugin, look at the
extend-embeds
plugin in the PR.extend-embeds
pluginhttps://www.reddit.com/r/stevenuniverse/comments/ax0u5i/innocence/
This will trigger the test plugin's behaviour, and you'll see a very boring "custom preview" message, and the block will be "Reddit with extra stuff"Analysis so far
This doesn't seem specific to this code or plugin. Scrips that need to load before
wp-blocks
end up loading after the code inwp-blocks
has been run, once Jetpack is enabled, because Jetpack has already required it.The test plugin in the PR enqueues its scripts like this:
That works when Jetpack isn't present, the script is loaded before
wp-blocks
and registers the filter before the core blocks are registered, allowing the plugin to use the hooks thatwp-blocks
uses.There isn't a way (that I can see) to say "make sure this loads BEFORE wp-blocks" and so when Jetpack does this in
class.jetpack-gutenberg.php
then
wp-blocks
before Jetpack'sblocks/editor.js
, and it's too late for other plugins to do what they need to do.