[wp-trac] [WordPress Trac] #33387: get_file_data() should handle a <?php prefixed header

WordPress Trac noreply at wordpress.org
Mon Aug 17 08:40:01 UTC 2015


#33387: get_file_data() should handle a <?php prefixed header
--------------------------+-----------------------------
 Reporter:  dd32          |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Currently `get_file_data()` fails when a file contains a header in the
 format `<?php // Template Name: Something ?>`.

 WP_Theme currently doesn't use `get_file_data()` (but should IMHO: #33388)
 so isn't affected by this, but this feels like a common-enough case
 amongst themes that we should consider supporting, even if only to have a
 single method of extracting header data.

 One method could be to use this as the regular expression, which allows
 for a PHP opening tag to start off the line (allowing for spaces/tabs
 before hand)
 {{{
 '/^(?:[ \t]*<\?php)[ \t\/*#@]*' . preg_quote( $header, '/' ) . ':(.*)$/mi'
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33387>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list