Themes: Make sure `get_file_data()` recognizes headers prefixed by `<?php` tag.

This allows for using headers in the format of `<?php // Template Name: Something ?>`, which previously could not be recognized correctly.

Props dd32, m_uysl, thomas-vitale, boblinthorst.
Fixes #33387.
Built from https://develop.svn.wordpress.org/trunk@51182


git-svn-id: http://core.svn.wordpress.org/trunk@50791 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-06-18 14:03:58 +00:00
parent 87c740b086
commit e127bcde70
2 changed files with 2 additions and 2 deletions

View File

@ -6287,7 +6287,7 @@ function get_file_data( $file, $default_headers, $context = '' ) {
}
foreach ( $all_headers as $field => $regex ) {
if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) {
if ( preg_match( '/^(?:[ \t]*<\?php)?[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) {
$all_headers[ $field ] = _cleanup_header_comment( $match[1] );
} else {
$all_headers[ $field ] = '';

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.8-beta2-51181';
$wp_version = '5.8-beta2-51182';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.