Tribe__Customizer__Section::get_rgb_color( string $option, string $section = null )
Utility function for when we need a color in RGB format, since the Customizer always works with hex. Keepin’ it DRY.
Contents
Parameters
- $option
-
(string) (Required) The option slug, like "grid-lines-color"
- $section
-
(string) (Optional) The optional section slug, like 'global_elements'
Default value: null
Return
(string) $color_rgb The hex color expressed as an rgb string, like "255,255,255"
Source
File: src/Tribe/Customizer/Section.php
public function get_rgb_color( $option, $section = null ) {
$color = is_null( $section )
? tribe( 'customizer' )->get_option( [ $this->ID, $option ] )
: tribe( 'customizer' )->get_option( [ $section, $option ] );
$color_obj = new Tribe__Utils__Color( $color );
$color_arr = $color_obj->getRgb();
$color_rgb = $color_arr['R'] . ',' . $color_arr['G'] . ',' . $color_arr['B'];
return $color_rgb;
}
Changelog
| Version | Description |
|---|---|
| 4.14.2 | Introduced. |