Make WordPress Core

Ticket #8236: theme-editor2.diff

File theme-editor2.diff, 1.4 KB (added by roganty, 17 years ago)

Updated patch for theme-editor.php revision 9903

  • theme-editor.php

     
    135135        <ul>
    136136<?php
    137137        $template_mapping = array();
     138        $template_dir = $themes[$theme]['Template Dir']; //Or would it be better to use 'Stylesheet Dir'
    138139        foreach($themes[$theme]['Template Files'] as $template_file) {
    139140                $description = trim( get_file_description($template_file) );
    140141                $template_show = basename($template_file);
    141142                $filedesc = ( $description != $template_file ) ? "$description <span class='nonessential'>($template_show)</span>" : "$description";
    142143                $filedesc = ( $template_file == $file ) ? "<span class='highlight'>$description <span class='nonessential'>($template_show)</span></span>" : $filedesc;
    143                 $template_mapping[ $description ] = array( $template_file, $filedesc );
     144
     145                if( array_key_exists($description, $template_mapping) ){ //If it already exists in the array
     146                        $pos = strpos($template_file, $template_dir);
     147                        //If the 'Template Dir' was found in the $template_file
     148                        if( $pos !== false ) $template_mapping[ $description ] = array( $template_file, $filedesc );
     149                }else $template_mapping[ $description ] = array( $template_file, $filedesc );
     150
    144151        }
    145152        ksort( $template_mapping );
    146153        while ( list( $template_sorted_key, list( $template_file, $filedesc ) ) = each( $template_mapping ) ) :