Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r12187 r12253  
    122122 * @since unknown
    123123 *
    124  * @return array Key is template name, Value is path within the theme folder
     124 * @return array Key is template name, Value is template name
    125125 */
    126126function get_page_templates() {
     
    128128    $theme = get_current_theme();
    129129    $templates = $themes[$theme]['Template Files'];
    130     $page_templates = array ();
     130    $page_templates = array();
    131131
    132132    if ( is_array( $templates ) ) {
     133        $base = array( trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory()) );
     134
    133135        foreach ( $templates as $template ) {
     136            $basename = str_replace($base, '', $template);
     137
     138            // don't allow template files in subdirectories
     139            if ( false !== strpos($basename, '/') )
     140                continue;
     141
    134142            $template_data = implode( '', file( $template ));
    135143
     
    139147
    140148            if ( !empty( $name ) ) {
    141                 $page_templates[trim( $name )] = str_replace(get_template_directory(), '', $template);
     149                $page_templates[trim( $name )] = $basename;
    142150            }
    143151        }
Note: See TracChangeset for help on using the changeset viewer.