+ <h4><?php _e('Templates'); ?></h4>
+ <ul>
+<?php
+ $template_mapping = array();
+ $template_dir = $themes[$theme]['Template Dir'];
+ foreach ( $themes[$theme]['Template Files'] as $template_file ) {
+ $description = trim( get_file_description($template_file) );
+ $template_show = basename($template_file);
+ $filedesc = ( $description != $template_file ) ? "$description <span class='nonessential'>($template_show)</span>" : "$description";
+ $filedesc = ( $template_file == $file ) ? "<span class='highlight'>$description <span class='nonessential'>($template_show)</span></span>" : $filedesc;
+
+ // If we have two files of the same name prefer the one in the Template Directory
+ // This means that we display the correct files for child themes which overload Templates as well as Styles
+ if( array_key_exists($description, $template_mapping ) ) {
+ if ( false !== strpos( $template_file, $template_dir ) ) {
+ $template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc );
+ }
+ } else {
+ $template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc );
+ }
+ }
+ ksort( $template_mapping );
+ while ( list( $template_sorted_key, list( $template_file, $filedesc ) ) = each( $template_mapping ) ) :
+ ?>
+ <li><a href="theme-editor.php?file=<?php echo "$template_file"; ?>&theme=<?php echo urlencode($theme) ?>&dir=theme"><?php echo $filedesc ?></a></li>
+<?php endwhile; ?>
+ </ul>
+ <h4><?php /* translators: Theme stylesheets in theme editor */ echo _x('Styles', 'Theme stylesheets in theme editor'); ?></h4>
+ <ul>
+<?php
+ $template_mapping = array();
+ $stylesheet_dir = $themes[$theme]['Stylesheet Dir'];
+ foreach ( $themes[$theme]['Stylesheet Files'] as $style_file ) {
+ $description = trim( get_file_description($style_file) );
+ $style_show = basename($style_file);
+ $filedesc = ( $description != $style_file ) ? "$description <span class='nonessential'>($style_show)</span>" : "$description";
+ $filedesc = ( $style_file == $file ) ? "<span class='highlight'>$description <span class='nonessential'>($style_show)</span></span>" : $filedesc;
+ $template_mapping[ $description ] = array( _get_template_edit_filename($style_file, $stylesheet_dir), $filedesc );
+ }
+ ksort( $template_mapping );
+ while ( list( $template_sorted_key, list( $style_file, $filedesc ) ) = each( $template_mapping ) ) :
+ ?>
+ <li><a href="theme-editor.php?file=<?php echo "$style_file"; ?>&theme=<?php echo urlencode($theme) ?>&dir=style"><?php echo $filedesc ?></a></li>
+<?php endwhile; ?>
+ </ul>