- $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( $template_file, $filedesc );
+if ( $allowed_files ) :
+ $previous_file_type = '';
+
+ foreach ( $allowed_files as $filename => $absolute_filename ) :
+ $file_type = substr( $filename, strrpos( $filename, '.' ) );
+
+ if ( $file_type !== $previous_file_type ) {
+ if ( '' !== $previous_file_type ) {
+ echo "\t</ul>\n";
+ }
+
+ switch ( $file_type ) {
+ case '.php':
+ if ( $has_templates || $theme->parent() ) :
+ echo "\t<h2>" . __( 'Templates' ) . "</h2>\n";
+ if ( $theme->parent() ) {
+ echo '<p class="howto">' . sprintf( __( 'This child theme inherits templates from a parent theme, %s.' ),
+ sprintf( '<a href="%s">%s</a>',
+ self_admin_url( 'theme-editor.php?theme=' . urlencode( $theme->get_template() ) ),
+ $theme->parent()->display( 'Name' )
+ )
+ ) . "</p>\n";
+ }
+ endif;
+ break;
+ case '.css':
+ echo "\t<h2>" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "</h2>\n";
+ break;
+ default:
+ /* translators: %s: file extension */
+ echo "\t<h2>" . sprintf( __( '%s files' ), $file_type ) . "</h2>\n";
+ break;