-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Reusable Blocks: Preload user permissions #15061
Conversation
af879fc
to
8d1f833
Compare
Rebased in mind of the merge of #15059, and unskipped the affected test described in #15059 (comment) to reflect the stability improved by these changes. |
For future consideration: The implementation of diff --git a/lib/client-assets.php b/lib/client-assets.php
index d9fcc8105..cde1ae0fb 100644
--- a/lib/client-assets.php
+++ b/lib/client-assets.php
@@ -582,10 +582,8 @@ function gutenberg_extend_block_editor_preload_paths( $preload_paths ) {
* This is present in WordPress 5.2 and should be removed from Gutenberg
* once WordPress 5.2 is the minimum supported version.
*/
- if ( ! in_array( array( '/wp/v2/blocks', 'OPTIONS' ), $preload_paths ) ) {
- $preload_paths[] = array( '/wp/v2/blocks', 'OPTIONS' );
- }
+ $preload_paths[] = array( '/wp/v2/blocks', 'OPTIONS' );
- return $preload_paths;
+ return array_unique( $preload_paths, SORT_REGULAR );
}
add_filter( 'block_editor_preload_paths', 'gutenberg_extend_block_editor_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.
I can confirm it is preloaded properly and I can see the menu item immediately 👍
Previously: #12378
This pull request seeks to add the blocks permissions REST API request as a preloaded path, for two reasons:
It appears this was already added in #12378 and exists in WordPress 5.2 (WordPress/wordpress-develop@79a3abc), but should remain in the Gutenberg plugin until WordPress 5.2 is the minimum supported version. It could be considered as erroneously removed via #13569.
Testing Instructions:
Verify that when clicking the block settings menu for the first time in a page session, the "Add to Reusable Blocks" is shown immediately if the user has permissions to undertake this operation (i.e. there is no delay in its appearance).
Ensure unit tests pass: