[wp-trac] [WordPress Trac] #25156: get_custom_header() should return false when there is no header

WordPress Trac noreply at wordpress.org
Tue Aug 27 12:34:22 UTC 2013


#25156: get_custom_header() should return false when there is no header
--------------------------+-----------------
 Reporter:  nacin         |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  3.7
Component:  Themes        |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------
 Follow-up to #20871, discovered when working on #14531 (see [25135]).

 When a custom header is removed but a default is specified,
 get_custom_header() will return that default information. This incorrect.

 When the header_image theme mod shows that a header is removed, we should
 immediately return false.

 I am suggesting a `false` return value in lieu of an empty stdClass as
 objects are not false-y, and thus it allows for `if ( get_custom_header()
 ) {`. (Accessing a property of a non-object merely triggers a notice,
 versus a fatal error for methods, so this is backwards compatible.)

 I imagine a `has_custom_header()` function may be a good addition at some
 point.

 This wasn't noticed because Twenty Twelve (and other default themes) check
 get_header_image() first, which returns `false` when there is no custom
 header. (has_custom_header() would probably be a bool cast of either
 get_header_image() or get_custom_header().) Twenty Thirteen doesn't use
 get_custom_header() at all, in part (I'm guessing) because it doesn't
 support variable width or variable height.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25156>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list