Make WordPress Core

Opened 10 years ago

Last modified 5 years ago

#28904 new defect (bug)

custom header stores full URL in database

Reported by: tverlaan's profile tverlaan Owned by:
Milestone: 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 10 years ago.

Download all attachments as: .zip

Change History (5)

@michalzuber
10 years ago

#1 @michalzuber
10 years ago

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

#2 @obenland
10 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
9 years ago

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