Skip to content

Commit

Permalink
Site Editor: Pages: Preload template lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Oct 31, 2024
1 parent 489f606 commit 65ca48f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/compat/wordpress-6.8/preload.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@
*/
function gutenberg_block_editor_preload_paths_6_8( $paths, $context ) {
if ( 'core/edit-site' === $context->name ) {
if ( ! empty( $_GET['postId'] ) ) {
if ( ! empty( $_GET['postId'] ) && ! empty( $_GET['postType'] ) ) {
$route_for_post = rest_get_route_for_post( $_GET['postId'] );
if ( $route_for_post ) {
$paths[] = add_query_arg( 'context', 'edit', $route_for_post );
$post = get_post( $_GET['postId'] );
if ( 'page' === $_GET['postType'] && $post ) {
$paths[] = add_query_arg(
'slug',
'page-' . $post->post_name,
'/wp/v2/templates/lookup'
);
}
}
}

Expand Down

0 comments on commit 65ca48f

Please sign in to comment.