Make WordPress Core


Ignore:
Timestamp:
06/27/2023 06:36:02 AM (3 years ago)
Author:
isabel_brison
Message:

Editor: navigation post preloading.

Adds a hook for preloading navigation posts in site editor.

Props get_dave, spacedmonkey, audrasjb, ramonopoly.
Fixes #58556.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/site-editor.php

    r56029 r56054  
    7777$active_global_styles_id = WP_Theme_JSON_Resolver::get_user_global_styles_post_id();
    7878$active_theme            = get_stylesheet();
    79 $preload_paths           = array(
     79
     80$navigation_rest_route = rest_get_route_for_post_type_items(
     81        'wp_navigation'
     82);
     83
     84$preload_paths = array(
    8085        array( '/wp/v2/media', 'OPTIONS' ),
    8186        '/wp/v2/types?context=view',
    … …  
    8893        '/wp/v2/global-styles/' . $active_global_styles_id,
    8994        '/wp/v2/global-styles/themes/' . $active_theme,
     95        array( $navigation_rest_route, 'OPTIONS' ),
     96        array(
     97                add_query_arg(
     98                        array(
     99                                'context'   => 'edit',
     100                                'per_page'  => 100,
     101                                'order'     => 'desc',
     102                                'orderby'   => 'date',
     103                                '_locale'   => 'user',
     104                                // array indices are required to avoid query being encoded and not matching in cache.
     105                                'status[0]' => 'publish',
     106                                'status[1]' => 'draft',
     107                        ),
     108                        $navigation_rest_route
     109                ),
     110                'GET',
     111        ),
     112        $preload_paths[] = array(
     113                add_query_arg(
     114                        array(
     115                                'context'   => 'edit',
     116                                'per_page'  => 100,
     117                                'order'     => 'desc',
     118                                'orderby'   => 'date',
     119                                'status[0]' => 'publish',
     120                                'status[1]' => 'draft',
     121                        ),
     122                        $navigation_rest_route
     123                ),
     124                'GET',
     125        ),
    90126);
    91127
Note: See TracChangeset for help on using the changeset viewer.