Skip to content

Commit 5a4a061

Browse files
committed
Editor: Preload REST API requests fetched on editor load.
Add four entries to the block editor preload paths in `wp-admin/edit-form-blocks.php`: the front-page template lookup, the taxonomies list, the `OPTIONS` permissions request for the post type collection, and, for post types that support it, the post author's display name. The editor previously requested all of these over the network on first load. Developed in WordPress#11948. Props ellatrix, mamaduka. Fixes #65636. git-svn-id: https://develop.svn.wordpress.org/trunk@62749 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 571dced commit 5a4a061

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/wp-admin/edit-form-blocks.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,18 @@ static function ( $classes ) {
115115
$template_lookup_slug,
116116
'/wp/v2/templates/lookup'
117117
),
118+
'/wp/v2/templates/lookup?slug=front-page',
119+
'/wp/v2/taxonomies?context=edit',
120+
array( rest_get_route_for_post_type_items( $post_type ), 'OPTIONS' ),
118121
);
119122

123+
if ( post_type_supports( $post_type, 'author' ) && $post->post_author > 0 ) {
124+
$preload_paths[] = sprintf(
125+
'/wp/v2/users/%d?context=view&_fields=id,name',
126+
(int) $post->post_author
127+
);
128+
}
129+
120130
block_editor_rest_api_preload( $preload_paths, $block_editor_context );
121131

122132
wp_add_inline_script(

0 commit comments

Comments
 (0)