Skip to content

Commit

Permalink
Editor: Preload template lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Mar 6, 2025
1 parent 22329a9 commit 0c00473
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/wp-admin/edit-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ static function ( $classes ) {

$active_theme = get_stylesheet();
$global_styles_endpoint_context = current_user_can( 'edit_theme_options' ) ? 'edit' : 'view';
$template_lookup_slug = 'page' === $post->post_type ? 'page' : 'single-' . $post->post_type;
if ( ! empty( $post->post_name ) ) {
$template_lookup_slug .= '-' . $post->post_name;
}
// Preload common data.
$preload_paths = array(
'/wp/v2/types?context=view',
Expand Down Expand Up @@ -99,6 +103,12 @@ static function ( $classes ) {
'show_on_front',
)
),
$paths[] = add_query_arg(
'slug',
// @see https://github.com/WordPress/gutenberg/blob/e093fefd041eb6cc4a4e7f67b92ab54fd75c8858/packages/core-data/src/private-selectors.ts#L244-L254
$template_lookup_slug,
'/wp/v2/templates/lookup'
),
);

block_editor_rest_api_preload( $preload_paths, $block_editor_context );
Expand Down

0 comments on commit 0c00473

Please sign in to comment.