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

git-svn-id: http://svn.automattic.com/wordpress/trunk@12253 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2009-11-21 10:05:19 +00:00
parent 8b56354285
commit 3e9c8dd010
1 changed files with 10 additions and 2 deletions

View File

@ -127,10 +127,18 @@ function get_page_templates() {
$themes = get_themes();
$theme = get_current_theme();
$templates = $themes[$theme]['Template Files'];
$page_templates = array ();
$page_templates = array();
if ( is_array( $templates ) ) {
$base = array( trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory()) );
foreach ( $templates as $template ) {
$basename = str_replace($base, '', $template);
// don't allow template files in subdirectories
if ( false !== strpos($basename, '/') )
continue;
$template_data = implode( '', file( $template ));
$name = '';
@ -138,7 +146,7 @@ function get_page_templates() {
$name = _cleanup_header_comment($name[1]);
if ( !empty( $name ) ) {
$page_templates[trim( $name )] = basename( $template ); ;
$page_templates[trim( $name )] = $basename;
}
}
}