Editor: Avoid `undefined index` notices in the Template Parts Editor.

This changes adds a leading slash when needed in the `?context=edit` path to avoid an `undefined index` notice in the Template Parts Editor.

Follow-up to [52275].

Props kafleg, costdev, mukesh27, Boniu91.
Fixes #54558.

Built from https://develop.svn.wordpress.org/trunk@52312


git-svn-id: http://core.svn.wordpress.org/trunk@51904 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2021-12-03 15:30:08 +00:00
parent cbadb65a2a
commit dc86357471
2 changed files with 12 additions and 1 deletions

View File

@ -468,6 +468,17 @@ function block_editor_rest_api_preload( array $preload_paths, $block_editor_cont
*/
$backup_global_post = ! empty( $post ) ? clone $post : $post;
foreach ( $preload_paths as &$path ) {
if ( is_string( $path ) && ! str_starts_with( $path, '/' ) ) {
$path = '/' . $path;
continue;
}
if ( is_array( $path ) && is_string( $path[0] ) && ! str_starts_with( $path[0], '/' ) ) {
$path[0] = '/' . $path[0];
}
}
$preload_data = array_reduce(
$preload_paths,
'rest_preload_api_request',

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-beta1-52311';
$wp_version = '5.9-beta1-52312';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.