Skip to content

Commit

Permalink
Site editor: preload post if needed (#66631)
Browse files Browse the repository at this point in the history
Co-authored-by: ellatrix <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
  • Loading branch information
3 people authored Oct 31, 2024
1 parent 7387fd0 commit 3b9bb77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backport-changelog/6.8/7695.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/7695

* https://github.com/WordPress/gutenberg/pull/66631
7 changes: 7 additions & 0 deletions lib/compat/wordpress-6.8/preload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down

0 comments on commit 3b9bb77

Please sign in to comment.