Skip to content

Commit c550a59

Browse files
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
1 parent 2af80e6 commit c550a59

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/wp-admin/edit-form-blocks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function( $classes ) {
119119
* besides the default value.
120120
*/
121121
$available_templates = wp_get_theme()->get_page_templates( get_post( $post->ID ) );
122-
$available_templates = ! empty( $available_templates ) ? array_merge(
122+
$available_templates = ! empty( $available_templates ) ? array_replace(
123123
array(
124124
/** This filter is documented in wp-admin/includes/meta-boxes.php */
125125
'' => apply_filters( 'default_page_template_title', __( 'Default template' ), 'rest-api' ),

0 commit comments

Comments
 (0)