| @@ -1905,9 +1905,13 @@ | ||
| 1905 | 1905 | [ |
| 1906 | 1906 | 'label' => __('Inherit from the active theme', 'fluent-cart'), |
| 1907 | 1907 | 'value' => ColorPalette::SOURCE_THEME, |
| 1908 | 1908 | 'icon' => 'PaintLine', |
| 1909 | - 'note' => __('FluentCart uses your active theme\'s colors for the storefront. If they don\'t come through as expected, choose Customize to set them yourself.', 'fluent-cart'), | |
| 1909 | + 'note' => sprintf( | |
| 1910 | + '%1$s %2$s', | |
| 1911 | + __('The storefront palette is rebuilt from your theme, and follows it when the theme changes.', 'fluent-cart'), | |
| 1912 | + ThemePalette::sourceLabel() | |
| 1913 | + ), | |
| 1910 | 1914 | ], |
| 1911 | 1915 | [ |
| 1912 | 1916 | 'label' => __('Customize', 'fluent-cart'), |
| 1913 | 1917 | 'value' => ColorPalette::SOURCE_CUSTOM, |
| @@ -2046,13 +2050,10 @@ | ||
| 2046 | 2050 | if (!ThemePalette::hasUsableSource()) { |
| 2047 | 2051 | return __('The active theme publishes nothing to inherit, so the storefront keeps FluentCart\'s own colors.', 'fluent-cart'); |
| 2048 | 2052 | } |
| 2049 | 2053 | |
| 2050 | - // Only a colour with no hex anywhere is unpreviewable. A live | |
| 2051 | - // reference with a hex fallback — what the theme-settings readers and | |
| 2052 | - // Blocksy write — previews as that fallback. | |
| 2053 | 2054 | foreach (ThemePalette::resolve() as $value) { |
| 2054 | - if ((string)$value !== '' && ThemePalette::measurable((string)$value) === '') { | |
| 2055 | + if (!sanitize_hex_color((string)$value)) { | |
| 2055 | 2056 | return __('This theme publishes its palette as CSS variables. The storefront reads them, but they cannot be resolved here — the preview shows FluentCart\'s colors in their place.', 'fluent-cart'); |
| 2056 | 2057 | } |
| 2057 | 2058 | } |
| 2058 | 2059 | |
| @@ -2078,15 +2079,13 @@ | ||
| 2078 | 2079 | |
| 2079 | 2080 | $roles = []; |
| 2080 | 2081 | |
| 2081 | 2082 | foreach (ThemePalette::resolve() as $role => $value) { |
| 2082 | - // A theme that publishes a bare `var(--x)` is written to the | |
| 2083 | - // storefront verbatim and resolved by the browser there, but that | |
| 2084 | - // property is not declared in wp-admin. Unpreviewable, so leave it | |
| 2085 | - // out and let the slot fall back to its own default. A reference | |
| 2086 | - // with a hex fallback (`var(--x, #hex)`) previews as that hex — | |
| 2087 | - // the same colour the storefront measures it by. | |
| 2088 | - $hex = ThemePalette::measurable((string)$value); | |
| 2083 | + // A theme that publishes `var(--x)` is written to the storefront | |
| 2084 | + // verbatim and resolved by the browser there, but that property is | |
| 2085 | + // not declared in wp-admin. Unpreviewable, so leave it out and let | |
| 2086 | + // the slot fall back to its own default. | |
| 2087 | + $hex = sanitize_hex_color((string)$value); | |
| 2089 | 2088 | |
| 2090 | 2089 | if ($hex) { |
| 2091 | 2090 | $roles[$role] = $hex; |
| 2092 | 2091 | } |