Make WordPress Core

Ticket #49194: 49194-sort-page-templates-by-title.patch

File 49194-sort-page-templates-by-title.patch, 935 bytes (added by sachinrajcp123, 3 months ago)
  • src/wp-includes/class-wp-theme.php

    diff --git a/src/wp-includes/class-wp-theme.php b/src/wp-includes/class-wp-theme.php
    index 6c9b7a1d9f..b41a9f1b2a 100644
    a b final class WP_Theme implements ArrayAccess { 
    13261326       if ( empty( $page_templates ) ) {
    13271327               return array();
    13281328       }
     1329
     1330       /*
     1331        * Sort page templates by their human-readable template name
     1332        * instead of by filename.
     1333        *
     1334        * This ensures the Page Template dropdown in the editor UI
     1335        * is ordered alphabetically by template label.
     1336        *
     1337        * @see https://core.trac.wordpress.org/ticket/49194
     1338        */
     1339       uasort(
     1340               $page_templates,
     1341               static function ( $a, $b ) {
     1342                       return strnatcasecmp( $a, $b );
     1343               }
     1344       );
     1345
    13291346       return $page_templates;
    13301347}