method_sanitize_theme_color()

 
 
 
 

method_sanitize_theme_color( $color )

Converts theme color slugs to hex values.


Description

Checks if the provided color string matches a known theme color slug and returns the corresponding hex value. Non‑slug values pass through unchanged.


Parameters

$color (string) :
A color value — either a hex/rgba string or a theme color slug.


Return

(string) The resolved hex color value.


Default Color Map

SlugHex
method-cabaret#D94A64
method-fuchsia#865EBF
method-orange#F28729
method-pomegranate#F24C27
method-cocoa#592222
light#ffffff
dark#25282A

Source

File: lib/class-method-css-collector.php


Notes

  • These slugs should match the colors declared in theme.json.
  • Called internally by method_get_block_css_declarations() for all color properties.

Changelog

VersionDescription
2.0.0Introduced.