WordPress.org

Make WordPress Core

Changeset 8717


Ignore:
Timestamp:
08/23/2008 09:28:39 AM (10 years ago)
Author:
westi
Message:

Sort templates alphabetically in the theme editor. See #7576 props Terragg.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/theme-editor.php

    r8656 r8717  
    133133    <h4><?php _e('Templates'); ?></h4>
    134134    <ul>
    135 <?php foreach($themes[$theme]['Template Files'] as $template_file) :
    136         $description = get_file_description($template_file);
     135<?php
     136    $template_mapping = array();
     137    foreach($themes[$theme]['Template Files'] as $template_file) {
     138        $description = trim( get_file_description($template_file) );
    137139        $template_show = basename($template_file);
    138140        $filedesc = ( $description != $template_file ) ? "$description <span class='nonessential'>($template_show)</span>" : "$description";
    139141        $filedesc = ( $template_file == $file ) ? "<span class='highlight'>$description <span class='nonessential'>($template_show)</span></span>" : $filedesc;
    140         ?>
     142        $template_mapping[ $description ] = array( $template_file, $filedesc );
     143    }
     144    ksort( $template_mapping );
     145    while ( list( $template_sorted_key, list( $template_file, $filedesc ) ) = each( $template_mapping ) ) :
     146    ?>
    141147        <li><a href="theme-editor.php?file=<?php echo "$template_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>"><?php echo $filedesc ?></a></li>
    142 <?php endforeach; ?>
     148<?php endwhile; ?>
    143149    </ul>
    144150    <h4><?php echo _c('Styles|Theme stylesheets in theme editor'); ?></h4>
    145151    <ul>
    146 <?php foreach($themes[$theme]['Stylesheet Files'] as $style_file) :
    147         $description = get_file_description($style_file);
     152<?php
     153    $template_mapping = array();
     154    foreach($themes[$theme]['Stylesheet Files'] as $style_file) {
     155        $description = trim( get_file_description($style_file) );
    148156        $style_show = basename($style_file);
    149157        $filedesc = ( $description != $style_file ) ? "$description <span class='nonessential'>($style_show)</span>" : "$description";
    150158        $filedesc = ( $style_file == $file ) ? "<span class='highlight'>$description <span class='nonessential'>($style_show)</span></span>" : $filedesc;
     159        $template_mapping[ $description ] = array( $style_file, $filedesc );
     160    }
     161    ksort( $template_mapping );
     162    while ( list( $template_sorted_key, list( $style_file, $filedesc ) ) = each( $template_mapping ) ) :
    151163        ?>
    152164        <li><a href="theme-editor.php?file=<?php echo "$style_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>"><?php echo $filedesc ?></a></li>
    153 <?php endforeach; ?>
     165<?php endwhile; ?>
    154166    </ul>
    155167<?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.