Make WordPress Core


Ignore:
Timestamp:
03/10/2025 10:32:56 AM (18 months ago)
Author:
Mamaduka
Message:

Editor: Update preload paths for post and site editor.

Preloading all blocking requests ensures that the editor canvas becomes responsive quickly and that the browser avoids unnecessary client-side requests.

Props mamaduka, joemcgill, audrasjb, peterwilsoncc.
Fixes #63050.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-blocks.php

    r59795 r59958  
    5454$active_theme                   = get_stylesheet();
    5555$global_styles_endpoint_context = current_user_can( 'edit_theme_options' ) ? 'edit' : 'view';
     56$template_lookup_slug           = 'page' === $post->post_type ? 'page' : 'single-' . $post->post_type;
     57if ( ! empty( $post->post_name ) ) {
     58        $template_lookup_slug .= '-' . $post->post_name;
     59}
    5660// Preload common data.
    5761$preload_paths = array(
     
    8084         */
    8185        '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id() . '?context=' . $global_styles_endpoint_context,
     86        // Used by getBlockPatternCategories in useBlockEditorSettings.
     87        '/wp/v2/block-patterns/categories',
     88        // @see packages/core-data/src/entities.js
     89        '/?_fields=' . implode(
     90                ',',
     91                array(
     92                        'description',
     93                        'gmt_offset',
     94                        'home',
     95                        'name',
     96                        'site_icon',
     97                        'site_icon_url',
     98                        'site_logo',
     99                        'timezone_string',
     100                        'url',
     101                        'page_for_posts',
     102                        'page_on_front',
     103                        'show_on_front',
     104                )
     105        ),
     106        $paths[] = add_query_arg(
     107                'slug',
     108                // @see https://github.com/WordPress/gutenberg/blob/e093fefd041eb6cc4a4e7f67b92ab54fd75c8858/packages/core-data/src/private-selectors.ts#L244-L254
     109                $template_lookup_slug,
     110                '/wp/v2/templates/lookup'
     111        ),
    82112);
    83113
Note: See TracChangeset for help on using the changeset viewer.