WordPress.org

Make WordPress Core

Changeset 10835


Ignore:
Timestamp:
03/25/2009 04:51:08 PM (9 years ago)
Author:
ryan
Message:

Show template files in subdirs. Props DD32. fixes #4131

Location:
trunk
Files:
3 edited

Legend:

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

    r10715 r10835  
    140140
    141141            if ( !empty( $name ) ) {
    142                 $page_templates[trim( $name )] = basename( $template );
     142                $page_templates[trim( $name )] = theme_basename( $template );
    143143            }
    144144        }
  • trunk/wp-admin/theme-editor.php

    r10792 r10835  
    152152    $template_mapping = array();
    153153    $template_dir = $themes[$theme]['Template Dir'];
    154     foreach($themes[$theme]['Template Files'] as $template_file) {
     154    foreach ( $themes[$theme]['Template Files'] as $template_file ) {
    155155        $description = trim( get_file_description($template_file) );
    156156        $template_show = basename($template_file);
     
    178178<?php
    179179    $template_mapping = array();
    180     foreach($themes[$theme]['Stylesheet Files'] as $style_file) {
     180    foreach ( $themes[$theme]['Stylesheet Files'] as $style_file ) {
    181181        $description = trim( get_file_description($style_file) );
    182182        $style_show = basename($style_file);
     
    205205    <?php if ( isset($functions ) && count($functions) ) { ?>
    206206        <div id="documentation">
    207         <label for="docs-list">Documentation:</label>
     207        <label for="docs-list"><?php _e('Documentation:') ?></label>
    208208        <?php echo $docs_select; ?>
    209209        <input type="button" class="button" value=" <?php _e( 'Lookup' ); ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&locale=<?php echo urlencode( get_locale() ) ?>&version=<?php echo urlencode( $wp_version ) ?>&redirect=true'); }" />
  • trunk/wp-includes/theme.php

    r10825 r10835  
    373373                }
    374374            }
    375         }
    376 
     375            @ $stylesheet_dir->close();
     376        }
     377       
    377378        $template_dir = @ dir("$theme_root/$template");
    378379        if ( $template_dir ) {
    379             while(($file = $template_dir->read()) !== false) {
    380                 if ( !preg_match('|^\.+$|', $file) && preg_match('|\.php$|', $file) )
     380            while ( ($file = $template_dir->read()) !== false ) {
     381                if ( preg_match('|^\.+$|', $file) )
     382                    continue;
     383                if ( preg_match('|\.php$|', $file) ) {
    381384                    $template_files[] = "$theme_loc/$template/$file";
     385                } elseif ( is_dir("$theme_root/$template/$file") ) {
     386                    $template_subdir = @ dir("$theme_root/$template/$file");
     387                    while ( ($subfile = $template_subdir->read()) !== false ) {
     388                        if ( preg_match('|^\.+$|', $subfile) )
     389                            continue;
     390                        if ( preg_match('|\.php$|', $subfile) )
     391                            $template_files[] = "$theme_loc/$template/$file/$subfile";
     392                    }
     393                    @ $template_subdir->close();
     394                }
    382395            }
     396            @ $template_dir->close();
    383397        }
    384398
     
    11181132}
    11191133
     1134/**
     1135 * Get the basename of a theme.
     1136 *
     1137 * This method extracts the filename of a theme file from a path
     1138 *
     1139 * @package WordPress
     1140 * @subpackage Plugin
     1141 * @since 2.8.0
     1142 *
     1143 * @access private
     1144 *
     1145 * @param string $file The filename of a theme file
     1146 * @return string The filename relative to the themes folder
     1147 */
     1148function theme_basename($file) {
     1149    $file = str_replace('\\','/',$file); // sanitize for Win32 installs
     1150    $file = preg_replace('|/+|','/', $file); // remove any duplicate slash
     1151    $theme_dir = str_replace('\\','/', get_theme_root()); // sanitize for Win32 installs
     1152    $theme_dir = preg_replace('|/+|','/', $theme_dir); // remove any duplicate slash
     1153    $file = preg_replace('|^.*/themes/.*?/|','',$file); // get relative path from theme dir
     1154    return $file;
     1155}
     1156
    11201157?>
Note: See TracChangeset for help on using the changeset viewer.