From 737185823f00cd6f071ec1b312084b667967f7e2 Mon Sep 17 00:00:00 2001 From: audrasjb Date: Tue, 11 Feb 2025 21:06:25 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@59813 git-svn-id: http://core.svn.wordpress.org/trunk@59155 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-custom-background.php | 2 +- wp-includes/theme.php | 2 +- wp-includes/version.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/class-custom-background.php b/wp-admin/includes/class-custom-background.php index d8500d8570..8027c6a2ce 100644 --- a/wp-admin/includes/class-custom-background.php +++ b/wp-admin/includes/class-custom-background.php @@ -288,7 +288,7 @@ class Custom_Background { $background_styles = ''; $bgcolor = get_background_color(); if ( $bgcolor ) { - $background_styles .= 'background-color: #' . $bgcolor . ';'; + $background_styles .= 'background-color: ' . maybe_hash_hex_color( $bgcolor ) . ';'; } $background_image_thumb = get_background_image(); diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 1a9b2479ad..5b6824b4a1 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1893,7 +1893,7 @@ function _custom_background_cb() { return; } - $style = $color ? "background-color: #$color;" : ''; + $style = $color ? 'background-color: ' . maybe_hash_hex_color( $color ) . ';' : ''; if ( $background ) { $image = ' background-image: url("' . sanitize_url( $background ) . '");'; diff --git a/wp-includes/version.php b/wp-includes/version.php index 01550add5b..14d45e4f52 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59812'; +$wp_version = '6.8-alpha-59813'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.