Editor: Preserve the original template keys when preparing a list of page templates.

Previously, the original "404" template key was lost when "Default template" is merged into the available templates array, as the `array_merge()` function renumbers numeric keys. Later, when we merge templates on the client side, this caused duplicate "404" templates to appear in the dropdown.

By replacing the `array_merge()` call with `array_replace()`, we make sure to keep the original numeric keys.

Props Mamaduka, Toro_Unit, youknowriad.
Fixes #53898.
Built from https://develop.svn.wordpress.org/trunk@51595


git-svn-id: http://core.svn.wordpress.org/trunk@51206 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-08-10 17:56:57 +00:00
parent 74bef46884
commit 78e8a3db65
2 changed files with 2 additions and 2 deletions

View File

@ -119,7 +119,7 @@ wp_add_inline_script(
* besides the default value.
*/
$available_templates = wp_get_theme()->get_page_templates( get_post( $post->ID ) );
$available_templates = ! empty( $available_templates ) ? array_merge(
$available_templates = ! empty( $available_templates ) ? array_replace(
array(
/** This filter is documented in wp-admin/includes/meta-boxes.php */
'' => apply_filters( 'default_page_template_title', __( 'Default template' ), 'rest-api' ),

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-alpha-51594';
$wp_version = '5.9-alpha-51595';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.