WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 months ago

#33387 assigned defect (bug)

get_file_data() should handle a <?php prefixed header

Reported by: dd32 Owned by: m_uysl
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: General Keywords: good-first-bug has-patch
Focuses: Cc:

Description (last modified by dd32)

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'

Attachments (2)

33387.diff (637 bytes) - added by m_uysl 2 years ago.
33387.2.diff (690 bytes) - added by Thomas Vitale 3 months ago.
Patch refreshed

Download all attachments as: .zip

Change History (8)

#1 @dd32
3 years ago

  • Description modified (diff)

#2 @ocean90
2 years ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to Future Release

@m_uysl
2 years ago

#3 @m_uysl
2 years ago

patch added. +1 for #33388

#4 @DrewAPicture
2 years ago

  • Keywords has-patch added; needs-patch removed
  • Owner set to m_uysl
  • Status changed from new to assigned

Assigning to mark the good-first-bug as "claimed".

#5 @Thomas Vitale
3 months ago

  • Keywords needs-refresh added

@Thomas Vitale
3 months ago

Patch refreshed

#6 @Thomas Vitale
3 months ago

  • Keywords needs-refresh removed
Note: See TracTickets for help on using tickets.