Make WordPress Core


Ignore:
Timestamp:
11/21/2009 10:05:19 AM (15 years ago)
Author:
westi
Message:

Don't show page templates in the drop down if they are in a subdirectory. Fixes #10959 props scribu.

File:
1 edited

Legend:

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

    r12225 r12253  
    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 )] = basename( $template ); ;
     149                $page_templates[trim( $name )] = $basename;
    142150            }
    143151        }
Note: See TracChangeset for help on using the changeset viewer.