Trait_Has_Color_Choices
Trait for providing colour choices based on configured theme colours.
Table of Contents
Methods
- get_color_code_by_slug() : string
- Retrieves a theme color code by color slug.
- get_color_choices() : array<string|int, mixed>
- Returns an ACF choces array of colors to be used within a radio field.
- add_preview_admin_css() : mixed
- Adds CSS to the admin head to style the choice preview element.
- get_theme_colors() : array<string|int, mixed>
- Returns an array of theme color information.
Methods
get_color_code_by_slug()
Retrieves a theme color code by color slug.
public
get_color_code_by_slug(string $slug) : string
Parameters
- $slug : string
-
The slug of the color.
Return values
string —The color code or an empty string if color cannot be found.
get_color_choices()
Returns an ACF choces array of colors to be used within a radio field.
protected
get_color_choices() : array<string|int, mixed>
Return values
array<string|int, mixed> —An ACF choces array of colors.
add_preview_admin_css()
Adds CSS to the admin head to style the choice preview element.
private
add_preview_admin_css() : mixed
Will only add this once, regardless of how many times this function is called.
get_theme_colors()
Returns an array of theme color information.
private
get_theme_colors() : array<string|int, mixed>
Return values
array<string|int, mixed> —Theme color information.