Automattic / gutenberg-ramp

Control conditions under which Gutenberg loads - either from your theme code or from a UI
https://wordpress.org/plugins/gutenberg-ramp/
76 stars 15 forks source link

wpcom_vip_load_gutenberg doesn't allow meta boxes to be loaded #69

Closed andrewfleming closed 5 years ago

andrewfleming commented 5 years ago

Originally reported by @micahwave

The priority of the plugins_loaded hooks is currently set in a way that makes it so no custom meta boxes get loaded.

If you use wpcom_vip_load_gutenberg, it's going to enable gutenberg here:

https://github.com/Automattic/gutenberg-ramp/blob/8017c04609a9589b380b09fb66da5ea81acf4f8a/inc/class-gutenberg-ramp.php#L40

The issue is that gutenberg itself registers a plugins_loaded hook at a lower priority:

https://github.com/WordPress/gutenberg/blob/master/lib/register.php#L27

With the current setup, the gutenberg_trick_plugins_into_registering_meta_boxes function is never called because ramp isn't activated in time.

If you change the load_decision hook priority to 5 it seems to fix the issue.

micahwave commented 5 years ago

Here's a PR that fixes this issue: https://github.com/Automattic/gutenberg-ramp/pull/68

pyronaur commented 5 years ago

It seems to me that the priority 20 wasn't an accident, but rather added deliberately, so I think it'd be best not to tamper with the priority

The Gutenberg plugin meta box trick comment says that it's trying to register as late as possible, but it's not clear to me whether plugins_loaded, priority = 10 is as late as possible or whether the priority wasn't considered. If the priority wasn't considered - we could patch this either directly in Gutenberg or by removing and re-adding that function on a later stage of plugins_init, like priority 1000.

I tried reaching @BE-Webdesign on the Gutenberg repository https://github.com/WordPress/gutenberg/pull/2804 two weeks ago, but haven't yet received a response, which is why this issue is a bit delayed.

@micahwave if this is a time pressing issue for you - you could try to remove and re-add technique in your own project - that wouldn't require direct modification of neither Ramp nor Gutenberg. If you do try it - please let me know the results and whether or not something broke as a result of that.

maevelander commented 5 years ago

This issue is resolved by #70 - the plugins_loaded hook priority no longer exists in 1.1