Reusable Blocks: Preload user permissions#15061
Merged
Conversation
af879fc to
8d1f833
Compare
Member
Author
|
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. |
Member
Author
|
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' );
|
gziolo
approved these changes
Apr 19, 2019
Member
gziolo
left a comment
There was a problem hiding this comment.
I can confirm it is preloaded properly and I can see the menu item immediately 👍
This was referenced Apr 26, 2019
16 tasks
14 tasks
6 tasks
This was referenced Sep 12, 2024
This was referenced Sep 14, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: