-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add preload_paths filter for widgets screen and full site editing #28701
Conversation
Thank you for working on it. It feels like it's about time to abstract this editor setup to avoid code duplication but, more importantly, to prevent this type of issue. |
Thanks! |
We could always have someting like: initialize_block_editor( array(
'preload_paths' => array(
// data
),
// more shared settings
) ); Edit: I see there is |
Thanks for working on this. Also related is #24642. edit: I realise this doesn't add any paths for the navigation editor, just the preloading mechanism, so it doesn't actually resolve the above issue. |
Yes! for the navigation editor there was nothing when I worked so I had to implement just the preloading mechanism.
Let me know. |
@gziolo we agree for the block editor, this is the responsability of WordPress core now ? The work in progress here could be also merged in WordPress core in a future release, right ? |
lib/navigation-page.php
Outdated
// most of these are copied from edit-forms-blocks.php. | ||
$preload_paths = array(); | ||
|
||
$preload_paths = apply_filters( 'navigation_editor_preload_paths', $preload_paths ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the navigation screen, I see that there was an attempt to preload certain requests in #24672 (comment) but it didn't work well with the kind of entities managed by the navigation menu.
It looks to me that this PR could land without this part, which can be iterated later if/when we figure how to preload things for this editor.
We can have a follow-up PR with a new method that would get proposed to the core just after it lands in Gutenberg. That means your assumption is all correct. |
As suggested by @gziolo #28701 (comment) I propose a modification to initialize each block-based editor the same way. So I added the I didn't deal with post block editor because, it seems to me that it isn't similar than the other, especially because of the way it is initialized:
I think we can add some other parameters passed to the new For information, I confirm that the preload_paths filter is a real need for us as I described in the initial #28690 issue. |
I rebased on trunk and corrected |
This PR only modify PHP code and doesn't touch anything about React Native. |
It looks like a general issue with the CI job. I see the same failure on |
👋 all.
Hey @gziolo , looking at the logs it looks like the fail here (timing out trying to load some gradle cache) was different than the ones on trunk ( I restarted the job here since it looks like an intermediate CI infra issue. We can investigate more if it persists with the same error. Sorry for the inconvenience! |
…}_preload_paths filter name
…nitialize_editor() function
Pushed again by taking in account the latest @swissspidy review comments. Thanks 😉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests well, and the code is a nice refactoring removing useless duplication, while also allowing for customizable preload_paths. From me,
Awesome work @manooweb, this is a great start towards unifying the way block editor is initialized on all pages 👍🏻 |
Thank you for merging 👍 and your encouragement ☺ |
I started looking into bringing this new helper into WordPress core. It looks like it might be quite a journey, see WordPress/wordpress-develop#1118 :) Trac ticket: https://core.trac.wordpress.org/ticket/52920 |
Description
This PR propose to fix #28690 by adding a filter for widgets screen and full site editing features to be able to preloading datas before the pages is loaded.
Edit: I've just updated this PR and the issue with a comment because I saw I had forgotten the navigation editor.