Make WordPress Core

Ticket #61752: plugin-theme-editor-alpha-order.patch

File plugin-theme-editor-alpha-order.patch, 2.0 KB (added by iflairwebtechnologies, 6 weeks ago)

Editor: Sort theme and plugin editor files alphabetically by filename

  • src/wp-admin/theme-editor.php

     
    9898        }
    9999}
    100100
    101 // Move functions.php and style.css to the top.
    102 if ( isset( $allowed_files['functions.php'] ) ) {
    103         $allowed_files = array( 'functions.php' => $allowed_files['functions.php'] ) + $allowed_files;
    104 }
    105 if ( isset( $allowed_files['style.css'] ) ) {
    106         $allowed_files = array( 'style.css' => $allowed_files['style.css'] ) + $allowed_files;
    107 }
     101ksort( $allowed_files );
    108102
    109103if ( empty( $file ) ) {
    110104        $relative_file = 'style.css';
  • src/wp-admin/includes/misc.php

     
    364364 * @param array $allowed_files List of theme file paths.
    365365 * @return array Tree structure for listing theme files.
    366366 */
     367function _wp_sort_file_tree( $tree ) {
     368        if ( ! is_array( $tree ) ) {
     369                return $tree;
     370        }
     371
     372        $folders = array();
     373        $files   = array();
     374
     375        foreach ( $tree as $key => $value ) {
     376                if ( is_array( $value ) ) {
     377                        $folders[ $key ] = _wp_sort_file_tree( $value );
     378                } else {
     379                        $files[ $key ] = $value;
     380                }
     381        }
     382
     383        ksort( $folders );
     384        ksort( $files );
     385
     386        return $folders + $files;
     387}
     388
    367389function wp_make_theme_file_tree( $allowed_files ) {
    368390        $tree_list = array();
    369391
     
    378400                $last_dir = $file_name;
    379401        }
    380402
    381         return $tree_list;
     403        return _wp_sort_file_tree( $tree_list );
    382404}
    383405
    384406/**
     
    483505                $last_dir = $plugin_file;
    484506        }
    485507
    486         return $tree_list;
     508        return _wp_sort_file_tree( $tree_list );
    487509}
    488510
    489511/**
     
    10801102                );
    10811103        }
    10821104
    1083         echo '<script>var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ";</script>\n";
     1105        echo '<script type="text/javascript">var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ";</script>\n";
    10841106}
    10851107
    10861108/**