Make WordPress Core


Ignore:
Timestamp:
06/18/2021 02:02:44 PM (7 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r51055 r51182  
    62886288
    62896289    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] ) {
    62916291            $all_headers[ $field ] = _cleanup_header_comment( $match[1] );
    62926292        } else {
Note: See TracChangeset for help on using the changeset viewer.