add_values_backwards_compatibility(); $defaults = array( 'font-family' => false, 'font-size' => 0, 'variant' => false, 'line-height' => 0, 'color' => '#000000', ); $this->json['default'] = wp_parse_args( $this->json['default'], $defaults ); $this->json['show_variants'] = true; $this->json['l10n'] = array( 'font-family' => esc_html__( 'Font Family', 'vamtam-consulting' ), 'select-font-family' => esc_html__( 'Select Font Family', 'vamtam-consulting' ), 'variant' => esc_html__( 'Variant', 'vamtam-consulting' ), 'font-size' => esc_html__( 'Font Size', 'vamtam-consulting' ), 'line-height' => esc_html__( 'Line Height', 'vamtam-consulting' ), 'color' => esc_html__( 'Color', 'vamtam-consulting' ), ); $this->json['unit'] = 'px'; } /** * An Underscore (JS) template for this control's content (but not its container). * * Class variables for this control class are available in the `data` JS object; * export custom variables by overriding {@see Kirki_Customize_Control::to_json()}. * * @see WP_Customize_Control::print_template() * * @access protected */ protected function content_template() { ?> <# if ( data.label ) { #> {{{ data.label }}} <# } #> <# if ( data.description ) { #> {{{ data.description }}} <# } #>
<# if ( '' == data.value['font-family'] ) { data.value['font-family'] = data.default['font-family']; } #>
{{ data.l10n['font-family'] }}
{{ data.l10n['font-size'] }}
{{data.unit}}
{{ data.l10n['line-height'] }}
{{data.unit}}
{{ data.l10n['color'] }}
<# if ( true === data.show_variants || false !== data.default.variant ) { #>
{{ data.l10n['variant'] }}
<# } #>
value(); $old_values = array( 'font-family' => '', 'font-size' => '', 'variant' => ( isset( $value['font-weight'] ) ) ? $value['font-weight'] : 'regular', 'line-height' => '', 'letter-spacing' => '', 'color' => '', ); // Font-weight is now variant. // All values are the same with the exception of 400 (becomes regular). if ( '400' == $old_values['variant'] ) { $old_values['variant'] = 'regular'; } // Letter spacing was in px, now it requires units. if ( isset( $value['letter-spacing'] ) && is_numeric( $value['letter-spacing'] ) && $value['letter-spacing'] ) { $value['letter-spacing'] .= 'px'; } $this->json['value'] = wp_parse_args( $value, $old_values ); // Cleanup. if ( isset( $this->json['value']['font-weight'] ) ) { unset( $this->json['value']['font-weight'] ); } } /** * Don't render any content for this control from PHP. */ public function render_content() {} }