choices ) ) {
$this->choices = array();
}
/**
* The csco_customizer_fonts_choices hook.
*
* @since 1.0.0
*/
$this->choices = apply_filters( 'csco_customizer_fonts_choices', wp_parse_args(
$this->choices,
array(
'variant' => array(),
'fonts' => array(
'standard' => array(),
'google' => array(),
),
)
) );
}
/**
* Render the control's content.
*/
protected function render_content() {}
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @see WP_Customize_Control::to_json()
*/
public function to_json() {
parent::to_json();
// Default value.
$this->json['default'] = $this->setting->default;
if ( isset( $this->default ) ) {
$this->json['default'] = $this->default;
}
// Value.
$this->json['value'] = $this->value();
// The link.
$this->json['link'] = $this->get_link();
// Choices.
$this->json['choices'] = $this->choices;
// The ID.
$this->json['id'] = $this->id;
// The filter value.
if ( is_array( $this->json['value'] ) ) {
foreach ( array_keys( $this->json['value'] ) as $key ) {
if ( ! in_array( $key, array( 'variant', 'font-weight', 'font-style' ), true ) && ! isset( $this->json['default'][ $key ] ) ) {
unset( $this->json['value'][ $key ] );
}
if ( ! isset( $this->json['default'][ $key ] ) ) {
unset( $this->json['value'][ $key ] );
}
if ( isset( $this->json['default'][ $key ] ) && false === $this->json['default'][ $key ] ) {
unset( $this->json['value'][ $key ] );
}
}
}
$this->json['show_variants'] = 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 WP_Customize_Control::to_json()}.
*
* @see WP_Customize_Control::print_template()
*/
protected function content_template() {
?>
<# if ( ! _.isUndefined( data.default['font-family'] ) ) { #>
<# data.value['font-family'] = data.value['font-family'] || data['default']['font-family']; #>
<# if ( data.choices['fonts'] ) { data.fonts = data.choices['fonts']; } #>
<# if ( true === data.show_variants || false !== data.default.variant ) { #>
<# } #>
<# } #>
<# if ( ! _.isUndefined( data.default['font-size'] ) ) { #>
<# data.value['font-size'] = data.value['font-size'] || data['default']['font-size']; #>
<# } #>
<# if ( ! _.isUndefined( data.default['line-height'] ) ) { #>
<# data.value['line-height'] = data.value['line-height'] || data['default']['line-height']; #>
<# } #>
<# if ( ! _.isUndefined( data.default['letter-spacing'] ) ) { #>
<# data.value['letter-spacing'] = data.value['letter-spacing'] || data['default']['letter-spacing']; #>
<# } #>
<# if ( ! _.isUndefined( data.default['word-spacing'] ) ) { #>
<# data.value['word-spacing'] = data.value['word-spacing'] || data['default']['word-spacing']; #>
<# } #>
<# if ( ! _.isUndefined( data.default['text-align'] ) ) { #>
<# data.value['text-align'] = data.value['text-align'] || data['default']['text-align']; #>
<# } #>
<# if ( ! _.isUndefined( data.default['text-transform'] ) ) { #>
<# data.value['text-transform'] = data.value['text-transform'] || data['default']['text-transform']; #>
<# } #>
<# if ( ! _.isUndefined( data.default['text-decoration'] ) ) { #>
<# data.value['text-decoration'] = data.value['text-decoration'] || data['default']['text-decoration']; #>
<# } #>