From 6c62701b8f843608d62b0063736f149d3a26bf43 Mon Sep 17 00:00:00 2001 From: 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: http://core.svn.wordpress.org/trunk@21117 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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 );