From 0f85c957d6274271bf6c3b9f11e40f207a1073dd Mon Sep 17 00:00:00 2001
From: Neil Williams <neil@tailormade.uk>
Date: Mon, 22 Sep 2025 12:27:11 +0100
Subject: [PATCH] get_page_templates(): sort templates by human-readable name
before flipping. Fixes #49194
---
src/wp-admin/includes/theme.php | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/wp-admin/includes/theme.php b/src/wp-admin/includes/theme.php
index 8fc9c00f14..8acf5a4749 100644
|
a
|
b
|
function delete_theme( $stylesheet, $redirect = '' ) { |
| 148 | 148 | * @return string[] Array of template file names keyed by the template header name. |
| 149 | 149 | */ |
| 150 | 150 | function get_page_templates( $post = null, $post_type = 'page' ) { |
| 151 | | return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) ); |
| | 151 | $templates = wp_get_theme()->get_page_templates( $post, $post_type ); |
| | 152 | |
| | 153 | // Sort by template name |
| | 154 | asort( $templates, SORT_NATURAL | SORT_FLAG_CASE ); |
| | 155 | |
| | 156 | // Flip to match expected return: filename => template name |
| | 157 | return array_flip( $templates ); |
| 152 | 158 | } |
| 153 | 159 | |
| 154 | 160 | /** |