From dc863574713350f930e316ee98d751fc31028f9e Mon Sep 17 00:00:00 2001 From: audrasjb Date: Fri, 3 Dec 2021 15:30:08 +0000 Subject: [PATCH] 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 --- wp-includes/block-editor.php | 11 +++++++++++ wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/wp-includes/block-editor.php b/wp-includes/block-editor.php index aaa249cb7b..a861ba3006 100644 --- a/wp-includes/block-editor.php +++ b/wp-includes/block-editor.php @@ -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', diff --git a/wp-includes/version.php b/wp-includes/version.php index a95b9b8511..b18f14e4ab 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.