From c326f4855c5e5e6539f3f31fc6a20096b47959ad Mon Sep 17 00:00:00 2001 From: isabel_brison Date: Tue, 27 Jun 2023 06:38:26 +0000 Subject: [PATCH] Editor: navigation post preloading. Adds a hook for preloading navigation posts in site editor. Props get_dave, spacedmonkey, audrasjb, ramonopoly. Fixes #58556. Built from https://develop.svn.wordpress.org/trunk@56054 git-svn-id: http://core.svn.wordpress.org/trunk@55566 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/site-editor.php | 38 +++++++++++++++++++++++++++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/wp-admin/site-editor.php b/wp-admin/site-editor.php index f56e1f1fd2..c66c91f099 100644 --- a/wp-admin/site-editor.php +++ b/wp-admin/site-editor.php @@ -76,7 +76,12 @@ if ( isset( $_GET['postType'] ) && ! isset( $_GET['postId'] ) ) { $active_global_styles_id = WP_Theme_JSON_Resolver::get_user_global_styles_post_id(); $active_theme = get_stylesheet(); -$preload_paths = array( + +$navigation_rest_route = rest_get_route_for_post_type_items( + 'wp_navigation' +); + +$preload_paths = array( array( '/wp/v2/media', 'OPTIONS' ), '/wp/v2/types?context=view', '/wp/v2/types/wp_template?context=edit', @@ -87,6 +92,37 @@ $preload_paths = array( '/wp/v2/global-styles/' . $active_global_styles_id . '?context=edit', '/wp/v2/global-styles/' . $active_global_styles_id, '/wp/v2/global-styles/themes/' . $active_theme, + array( $navigation_rest_route, 'OPTIONS' ), + array( + add_query_arg( + array( + 'context' => 'edit', + 'per_page' => 100, + 'order' => 'desc', + 'orderby' => 'date', + '_locale' => 'user', + // array indices are required to avoid query being encoded and not matching in cache. + 'status[0]' => 'publish', + 'status[1]' => 'draft', + ), + $navigation_rest_route + ), + 'GET', + ), + $preload_paths[] = array( + add_query_arg( + array( + 'context' => 'edit', + 'per_page' => 100, + 'order' => 'desc', + 'orderby' => 'date', + 'status[0]' => 'publish', + 'status[1]' => 'draft', + ), + $navigation_rest_route + ), + 'GET', + ), ); block_editor_rest_api_preload( $preload_paths, $block_editor_context ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 6b425e49c5..daf4a3c9e7 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-56053'; +$wp_version = '6.3-alpha-56054'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.