add_values_backwards_compatibility();
$defaults = array(
'font-family' => false,
'font-size' => false,
'variant' => false,
'line-height' => false,
'letter-spacing' => false,
'color' => false,
'text-align' => false,
);
$this->json['default'] = wp_parse_args( $this->json['default'], $defaults );
$this->json['show_variants'] = ( true === Kirki_Fonts_Google::$force_load_all_variants ) ? false : true;
$this->json['show_subsets'] = ( true === Kirki_Fonts_Google::$force_load_all_subsets ) ? false : true;
}
/**
* 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.tooltip ) { #>
<# } #>
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'] );
}
// Make sure we use "subsets" instead of "subset".
if ( isset( $this->json['value']['subset'] ) ) {
if ( ! empty( $this->json['value']['subset'] ) ) {
if ( ! isset( $this->json['value']['subsets'] ) || empty( $this->json['value']['subsets'] ) ) {
$this->json['value']['subsets'] = $this->json['value']['subset'];
}
}
unset( $this->json['value']['subset'] );
}
}
}
}