[wp-trac] [WordPress Trac] #38557: Format for registering a default header image is ambiguous

WordPress Trac noreply at wordpress.org
Fri Oct 28 23:33:04 UTC 2016


#38557: Format for registering a default header image is ambiguous
--------------------------+-----------------------------
 Reporter:  bradyvercher  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When registering a custom header with a default image, most resources seem
 to recommend using an absolute URL
 ([https://developer.wordpress.org/themes/functionality/custom-headers/
 Handbook], [https://codex.wordpress.org/Custom_Headers Codex],
 [https://make.wordpress.org/themes/2012/04/06/updating-custom-backgrounds-
 and-custom-headers-for-wordpress-3-4/ Make post]). However, it can be
 registered with `sprintf` placeholders, which is what the old
 `HEADER_IMAGE`
 [https://themes.trac.wordpress.org/browser/twentyten/1.0.3/functions.php#L106
 constant accepted]. It's registered that way in
 [https://themes.trac.wordpress.org/browser/twentythirteen/2.0/inc/custom-
 header.php#L27 Twenty Thirteen] as well.

 Any time core references the default image URL, it needs to account for
 the replacements. The problem is it doesn't take this into consideration
 in at least a couple places and obscures the replacement a bit by passing
 the default string through `get_theme_mod()` in some cases, which handles
 the replacement itself.

 Here are a couple of places where the replacement isn't handled in core:
 *
 [https://github.com/WordPress/WordPress/blob/f7552bbf53c183753eb8ac0e723f79e0d98260ae
 /wp-includes/class-wp-customize-manager.php#L3438 wp-includes/class-wp-
 customize-manager.php]
 *
 [https://github.com/WordPress/WordPress/blob/f7552bbf53c183753eb8ac0e723f79e0d98260ae
 /wp-admin/custom-header.php#L642-L643 wp-admin/custom-header.php]

 To see how this manifests itself:
 1. Switch to Twenty Ten or Twenty Thirteen
 2. Delete the `header_image` and `header_image_data` theme mods
 3. Access the Customizer
 4. Open the Header Image section

 In either theme, the default image that was visible on the front end is
 missing in the Customizer preview and the "Current header" control doesn't
 show an image as being set.

 If you access the old Custom Header screen in the admin panel (wp-
 admin/themes.php?page=custom-header), the option to reset the image is
 visible when it shouldn't be.

 I imagine this also affects default images for the custom background
 feature as well.

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


More information about the wp-trac mailing list