Skip to content

Commit

Permalink
Editor: Optimize preload paths for post and site editors.
Browse files Browse the repository at this point in the history
This patch optimizes preload paths in post and site editors so that they match the real requests:

- Remove the `/` preload as the payload is very big and the response is not needed on any critical path.
- Modify the preloaded path for `/wp/v2/taxonomies` so that it corresponds to what `loadTaxonomyEntities` requests. After Gutenberg PR 37685 was merged to core, these preloads need to be modified to use `context=view` instead of `context=edit`.
- Modify the `/wp/v2/users/me` path so that it matches the real request (no query params).
- Add a preload of `/wp/v2/settings` because it is requested on critical path (editor boot). Site editor already preloads this, the changeset is only adding it to the post editor.

This is related to Gutenberg PR 39256 which introduces compatibility code to modify the preload paths with a filter, when the Gutenberg plugin is active.
See WordPress/gutenberg#39256.

Props jsnajdr, noisysocks.
Merges [52995] to the 5.9 branch.

Built from https://develop.svn.wordpress.org/branches/5.9@53005


git-svn-id: http://core.svn.wordpress.org/branches/5.9@52594 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
audrasjb committed Mar 28, 2022
1 parent 2f4d408 commit 7d4e457
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions wp-admin/edit-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ static function( $classes ) {

// Preload common data.
$preload_paths = array(
'/',
'/wp/v2/types?context=edit',
'/wp/v2/taxonomies?per_page=-1&context=edit',
'/wp/v2/taxonomies?context=edit',
'/wp/v2/themes?status=active',
add_query_arg( 'context', 'edit', $rest_path ),
sprintf( '/wp/v2/types/%s?context=edit', $post_type ),
sprintf( '/wp/v2/users/me?post_type=%s&context=edit', $post_type ),
'/wp/v2/users/me',
array( rest_get_route_for_post_type_items( 'attachment' ), 'OPTIONS' ),
array( rest_get_route_for_post_type_items( 'wp_block' ), 'OPTIONS' ),
sprintf( '%s/autosaves?context=edit', $rest_path ),
'/wp/v2/settings',
);

block_editor_rest_api_preload( $preload_paths, $block_editor_context );
Expand Down
1 change: 0 additions & 1 deletion wp-admin/site-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ static function( $classes ) {
$active_theme = wp_get_theme()->get_stylesheet();
$preload_paths = array(
array( '/wp/v2/media', 'OPTIONS' ),
'/',
'/wp/v2/types?context=edit',
'/wp/v2/types/wp_template?context=edit',
'/wp/v2/types/wp_template-part?context=edit',
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9.3-alpha-52920';
$wp_version = '5.9.3-alpha-53005';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit 7d4e457

Please sign in to comment.