From 4d33587bdcfd14cb0d55e93d1fb6e2d7f978a327 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 25 Jun 2012 21:07:07 +0000 Subject: [PATCH] Revert detection of page templates to 3.3 functionality. WP_Theme in 3.4.0 used get_file_data(), which is far too strict when compared to the original regular expression in get_page_templates(). This causes missing templates when, for example, the PHP comment starts on the same line as the header. see #20955 for trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@21117 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/class-wp-theme.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php index b07e0b5fbd..049bfb4bd2 100644 --- a/wp-includes/class-wp-theme.php +++ b/wp-includes/class-wp-theme.php @@ -930,10 +930,9 @@ final class WP_Theme implements ArrayAccess { $files = (array) $this->get_files( 'php', 1 ); foreach ( $files as $file => $full_path ) { - $headers = get_file_data( $full_path, array( 'Template Name' => 'Template Name' ) ); - if ( empty( $headers['Template Name'] ) ) + if ( ! preg_match( '|Template Name:(.*)$|mi', file_get_contents( $full_path ), $header ) ) continue; - $page_templates[ $file ] = $headers['Template Name']; + $page_templates[ $file ] = _cleanup_header_comment( $header[1] ); } $this->cache_add( 'page_templates', $page_templates );