From 3b9bb77cec975fa2491927e8c640405c791d5415 Mon Sep 17 00:00:00 2001 From: Ella <4710635+ellatrix@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:55:57 +0100 Subject: [PATCH] Site editor: preload post if needed (#66631) Co-authored-by: ellatrix Co-authored-by: ntsekouras --- backport-changelog/6.8/7695.md | 3 +++ lib/compat/wordpress-6.8/preload.php | 7 +++++++ 2 files changed, 10 insertions(+) create mode 100644 backport-changelog/6.8/7695.md diff --git a/backport-changelog/6.8/7695.md b/backport-changelog/6.8/7695.md new file mode 100644 index 0000000000000..095c058e6fd10 --- /dev/null +++ b/backport-changelog/6.8/7695.md @@ -0,0 +1,3 @@ +https://github.com/WordPress/wordpress-develop/pull/7695 + +* https://github.com/WordPress/gutenberg/pull/66631 diff --git a/lib/compat/wordpress-6.8/preload.php b/lib/compat/wordpress-6.8/preload.php index b9e03802a58e9..2b2994b6f9be8 100644 --- a/lib/compat/wordpress-6.8/preload.php +++ b/lib/compat/wordpress-6.8/preload.php @@ -10,6 +10,13 @@ */ function gutenberg_block_editor_preload_paths_6_8( $paths, $context ) { if ( 'core/edit-site' === $context->name ) { + if ( ! empty( $_GET['postId'] ) ) { + $route_for_post = rest_get_route_for_post( $_GET['postId'] ); + if ( $route_for_post ) { + $paths[] = add_query_arg( 'context', 'edit', $route_for_post ); + } + } + // Core already preloads both of these for `core/edit-post`. $paths[] = '/wp/v2/settings'; $paths[] = array( '/wp/v2/settings', 'OPTIONS' );