Automattic\WooCommerce\Internal\Email
EmailStyleSync::get_theme_colors
Get theme colors from theme.json.
Method of the class: EmailStyleSync{}
No Hooks.
Returns
Array
. Array of theme colors.
Usage
// protected - for code of main (parent) or child class $result = $this->get_theme_colors( ?array $override_styles );
- ?array $override_styles
- .
Default: null
EmailStyleSync::get_theme_colors() EmailStyleSync::get theme colors code WC 9.9.3
protected function get_theme_colors( ?array $override_styles = null ) { if ( ! function_exists( 'wp_get_global_styles' ) ) { return array(); } $global_styles = $override_styles ?: wp_get_global_styles( array(), array( 'transforms' => array( 'resolve-variables' ) ) ); $default_colors = EmailColors::get_default_colors(); $base_color_default = $default_colors['base_color_default']; $bg_color_default = $default_colors['bg_color_default']; $body_bg_color_default = $default_colors['body_bg_color_default']; $body_text_color_default = $default_colors['body_text_color_default']; $footer_text_color_default = $default_colors['footer_text_color_default']; $base_color = ! empty( $global_styles['elements']['button']['color']['background'] ) ? sanitize_hex_color( $global_styles['elements']['button']['color']['background'] ) : $base_color_default; $bg_color = ! empty( $global_styles['color']['background'] ) ? sanitize_hex_color( $global_styles['color']['background'] ) : $bg_color_default; $body_bg_color = ! empty( $global_styles['color']['background'] ) ? sanitize_hex_color( $global_styles['color']['background'] ) : $body_bg_color_default; $body_text_color = ! empty( $global_styles['color']['text'] ) ? sanitize_hex_color( $global_styles['color']['text'] ) : $body_text_color_default; $footer_text_color = ! empty( $global_styles['elements']['caption']['color']['text'] ) ? sanitize_hex_color( $global_styles['elements']['caption']['color']['text'] ) : $footer_text_color_default; return array( 'base_color' => $base_color, 'bg_color' => $bg_color, 'body_bg_color' => $body_bg_color, 'body_text_color' => $body_text_color, 'footer_text_color' => $footer_text_color, ); }