diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index 0ba059ba8e..71a0522139 100644
|
a
|
b
|
function get_file_data( $file, $default_headers, $context = '' ) {
|
| 6287 | 6287 | } |
| 6288 | 6288 | |
| 6289 | 6289 | foreach ( $all_headers as $field => $regex ) { |
| 6290 | | if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) { |
| | 6290 | if ( preg_match( '/^(?:[ \t]*<\?php)?[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) { |
| 6291 | 6291 | $all_headers[ $field ] = _cleanup_header_comment( $match[1] ); |
| 6292 | 6292 | } else { |
| 6293 | 6293 | $all_headers[ $field ] = ''; |
diff --git a/tests/phpunit/data/formatting/php-open-tag-prefixed-file-header.php b/tests/phpunit/data/formatting/php-open-tag-prefixed-file-header.php
new file mode 100644
index 0000000000..dc078607c3
|
-
|
+
|
|
| | 1 | <?php // Template Name: Something ?> |
diff --git a/tests/phpunit/tests/file.php b/tests/phpunit/tests/file.php
index 730d72c5c1..a281028d37 100644
|
a
|
b
|
class Tests_File extends WP_UnitTestCase {
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| | 68 | /** |
| | 69 | * @group plugins |
| | 70 | * @group themes |
| | 71 | */ |
| | 72 | function test_get_file_data_header_with_php_open_tag_prefix() { |
| | 73 | $headers = array( |
| | 74 | 'TemplateName' => 'Template Name', |
| | 75 | ); |
| | 76 | $actual = get_file_data( DIR_TESTDATA . '/formatting/spaces-before-php-tag-file-header.php', $headers ); |
| | 77 | |
| | 78 | $expected = array( |
| | 79 | 'TemplateName' => 'Something', |
| | 80 | ); |
| | 81 | |
| | 82 | foreach ( $actual as $header => $value ) { |
| | 83 | $this->assertSame( $expected[ $header ], $value, $header ); |
| | 84 | } |
| | 85 | } |
| | 86 | |
| 68 | 87 | function is_unique_writable_file( $path, $filename ) { |
| 69 | 88 | $fullpath = $path . DIRECTORY_SEPARATOR . $filename; |
| 70 | 89 | |