Make WordPress Core

Ticket #8236: theme-editor.diff

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

This is a better patch for theme-editor.php

  • theme-editor.php

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