Make WordPress Core


Ignore:
Timestamp:
12/04/2008 09:29:55 PM (16 years ago)
Author:
westi
Message:

Ensure that the theme-editor displays the correct files when a child theme overrides templates. Fixes #8236 props roganty.

File:
1 edited

Legend:

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

    r9903 r10047  
    136136<?php
    137137    $template_mapping = array();
     138    $template_dir = $themes[$theme]['Template Dir'];
    138139    foreach($themes[$theme]['Template Files'] as $template_file) {
    139140        $description = trim( get_file_description($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 we have two files of the same name prefer the one in the Template Directory
     146        // This means that we display the correct files for child themes which overload Templates as well as Styles
     147        if( array_key_exists($description, $template_mapping ) ) {
     148            if ( false !== strpos( $template_file, $template_dir ) )  {
     149                $template_mapping[ $description ] = array( $template_file, $filedesc );
     150            }
     151        } else {
     152            $template_mapping[ $description ] = array( $template_file, $filedesc );
     153        }
    144154    }
    145155    ksort( $template_mapping );
Note: See TracChangeset for help on using the changeset viewer.