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:
parent
8b56354285
commit
3e9c8dd010
|
@ -127,10 +127,18 @@ function get_page_templates() {
|
||||||
$themes = get_themes();
|
$themes = get_themes();
|
||||||
$theme = get_current_theme();
|
$theme = get_current_theme();
|
||||||
$templates = $themes[$theme]['Template Files'];
|
$templates = $themes[$theme]['Template Files'];
|
||||||
$page_templates = array ();
|
$page_templates = array();
|
||||||
|
|
||||||
if ( is_array( $templates ) ) {
|
if ( is_array( $templates ) ) {
|
||||||
|
$base = array( trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory()) );
|
||||||
|
|
||||||
foreach ( $templates as $template ) {
|
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 ));
|
$template_data = implode( '', file( $template ));
|
||||||
|
|
||||||
$name = '';
|
$name = '';
|
||||||
|
@ -138,7 +146,7 @@ function get_page_templates() {
|
||||||
$name = _cleanup_header_comment($name[1]);
|
$name = _cleanup_header_comment($name[1]);
|
||||||
|
|
||||||
if ( !empty( $name ) ) {
|
if ( !empty( $name ) ) {
|
||||||
$page_templates[trim( $name )] = basename( $template ); ;
|
$page_templates[trim( $name )] = $basename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue