WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 2 years ago

#28904 new defect (bug)

custom header stores full URL in database

Reported by: tverlaan Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.9.1
Component: Themes Keywords: dev-feedback needs-patch
Focuses: template Cc:

Description

set_header_image is storing the full URL to the custom header in the database. It should only store the relative path in the database and get_header_image should prepend the relative path with get_bloginfo('url'). This makes migrating your site easier. Or you can have a develop and live environment with an easy database sync (my particular issue).

set_header_image
Replace:

$choice['url'] = esc_url_raw( $choice['url'] );

With:

$choice['url'] = str_replace( get_bloginfo('url'), '', esc_url_raw( $choice['url'] ) );

or find another method of getting the relative URL

header_image
then add the bloginfo URL to header_image (and probably a few other places).

function header_image() {
	echo esc_url( get_bloginfo('url').get_header_image() );
}

Attachments (1)

28904.patch (1.0 KB) - added by michalzuber 4 years ago.

Download all attachments as: .zip

Change History (5)

@michalzuber
4 years ago

#1 @michalzuber
4 years ago

  • Focuses template added
  • Keywords has-patch dev-feedback added

#2 @obenland
4 years ago

Why not use content_url()?
For back compat we'd have to add a check if the URL we're appending is indeed relative.

#4 @chriscct7
2 years ago

  • Keywords needs-patch added; has-patch removed
Note: See TracTickets for help on using tickets.