Skip to content

Commit 108af60

Browse files
committed
Themes: Avoid double hashed value for background-color in custom backgrounds.
This changeset replaces the hardcoded hash symbol with running `maybe_hash_hex_color()` on the full `background-color` value provided via the custom background feature, so the hash is only added if it is needed. By doing so, if a theme developer sets a background color value that uses a hash (#), WordPress won't add an additional hash anymore when outputting the relevant CSS. Duplicate hash symbols (##) can break CSS background color declarations. Props hovhanneshovakimyan, joyously, poena, Fixes #40057. git-svn-id: https://develop.svn.wordpress.org/trunk@59813 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8cc8eb5 commit 108af60

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/wp-admin/includes/class-custom-background.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public function admin_page() {
288288
$background_styles = '';
289289
$bgcolor = get_background_color();
290290
if ( $bgcolor ) {
291-
$background_styles .= 'background-color: #' . $bgcolor . ';';
291+
$background_styles .= 'background-color: ' . maybe_hash_hex_color( $bgcolor ) . ';';
292292
}
293293

294294
$background_image_thumb = get_background_image();

src/wp-includes/theme.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,7 @@ function _custom_background_cb() {
18931893
return;
18941894
}
18951895

1896-
$style = $color ? "background-color: #$color;" : '';
1896+
$style = $color ? 'background-color: ' . maybe_hash_hex_color( $color ) . ';' : '';
18971897

18981898
if ( $background ) {
18991899
$image = ' background-image: url("' . sanitize_url( $background ) . '");';

0 commit comments

Comments
 (0)