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
This commit is contained in:
nacin 2012-06-25 21:07:07 +00:00
parent 25183988dc
commit 6c62701b8f

View File

@ -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 );