From c550a592b9f2ffb6262ad6de07bc645095a77e98 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 10 Aug 2021 17:55:37 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@51595 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/edit-form-blocks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index 3a399c2fcd..fa4b8a9dd1 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/wp-admin/edit-form-blocks.php @@ -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' ),