l10n = wp_parse_args(
$this->l10n, array(
'family' => esc_html__('Font Family', 'bigmart'),
'style' => esc_html__('Font Weight/Style', 'bigmart'),
'text_transform' => esc_html__('Text Transform', 'bigmart'),
'text_decoration' => esc_html__('Text Decoration', 'bigmart'),
'size' => esc_html__('Font Size', 'bigmart'),
'line_height' => esc_html__('Line Height', 'bigmart'),
'letter_spacing' => esc_html__('Letter Spacing', 'bigmart'),
'typocolor' => esc_html__('Font Color', 'bigmart')
)
);
}
/**
* Enqueue scripts/styles.
*
* @since 1.0.0
* @access public
* @return void
*/
public function enqueue() {
wp_enqueue_script('bigmart-customize-typograhpy-controls', get_template_directory_uri() . '/inc/theme-options/custom-controls/typography/js/customize-controls.js', array('jquery'), BIGMART_VERSION, true);
wp_enqueue_style('bigmart-customize-typograhpy-controls', get_template_directory_uri() . '/inc/theme-options/custom-controls/typography/css/customize-controls.css', array(), BIGMART_VERSION);
}
/**
* Add custom parameters to pass to the JS via JSON.
*
* @since 1.0.0
* @access public
* @return void
*/
public function to_json() {
parent::to_json();
// Loop through each of the settings and set up the data for it.
$this->json['inputAttrs'] = '';
foreach ($this->input_attrs as $attr => $value) {
$this->json['inputAttrs'] .= esc_attr($attr) . '="' . esc_attr($value) . '" ';
}
foreach ($this->settings as $setting_key => $setting_id) {
$this->json[$setting_key] = array(
'link' => $this->get_link($setting_key),
'value' => $this->value($setting_key),
'label' => isset($this->l10n[$setting_key]) ? $this->l10n[$setting_key] : ''
);
if ('family' === $setting_key) {
$this->json[$setting_key]['default_choices'] = $this->bigmart_get_default_font_families();
$this->json[$setting_key]['google_choices'] = $this->bigmart_get_google_font_families();
$this->json[$setting_key]['standard_choices'] = $this->bigmart_get_standard_font_families();
} elseif ('style' === $setting_key) {
$this->json[$setting_key]['choices'] = $this->bigmart_get_font_weight_choices();
} elseif ('text_transform' === $setting_key) {
$this->json[$setting_key]['choices'] = $this->bigmart_get_text_transform_choices();
} elseif ('text_decoration' === $setting_key) {
$this->json[$setting_key]['choices'] = $this->bigmart_get_text_decoration_choices();
}
}
}
/**
* Underscore JS template to handle the control's output.
*
* @since 1.0.0
* @access public
* @return void
*/
public function content_template() {
?>
<# if ( data.label ) { #>
{{ data.label }}
<# } #>
<# if ( data.description ) { #>
{{{ data.description }}}
<# } #>
<# if ( data.family && (data.family.standard_choices || data.family.google_choices) ) { #>
-
<# if ( data.family.label ) { #>
{{ data.family.label }}
<# } #>
<# } #>
<# if ( data.style && data.style.choices ) { #>
-
<# if ( data.style.label ) { #>
{{ data.style.label }}
<# } #>
<# } #>
<# if ( data.text_transform && data.text_transform.choices ) { #>
-
<# if ( data.text_transform.label ) { #>
{{ data.text_transform.label }}
<# } #>
<# } #>
<# if ( data.text_decoration && data.text_decoration.choices ) { #>
-
<# if ( data.text_decoration.label ) { #>
{{ data.text_decoration.label }}
<# } #>
<# } #>
<# if ( data.size ) { #>
-
<# if ( data.size.label ) { #>
{{ data.size.label }}
<# } #>
<# } #>
<# if ( data.letter_spacing ) { #>
-
<# if ( data.letter_spacing.label ) { #>
{{ data.letter_spacing.label }}
<# } #>
<# } #>
<# if ( data.line_height ) { #>
-
<# if ( data.line_height.label ) { #>
{{ data.line_height.label }}
<# } #>
<# } #>
<# if ( data.typocolor ) { #>
-
<# if ( data.typocolor.label ) { #>
{{{ data.typocolor.label }}}
<# } #>
<# } #>
$value) {
$font_family[$value['family']] = $value['family'];
}
return $font_family;
}
/**
* Returns the available Google font families.
*
* @todo Pull families from `get_google_font_families()`.
*
* @since 1.0.0
* @access public
* @return array
*/
function bigmart_get_google_font_families() {
$bigmart_google_font = bigmart_google_font_array();
foreach ($bigmart_google_font as $key => $value) {
$font_family[$value['family']] = $value['family'];
}
return $font_family;
}
/**
* Returns the available standard font families.
*
* @todo Pull families from `get_standard_font_families()`.
*
* @since 1.0.0
* @access public
* @return array
*/
function bigmart_get_standard_font_families() {
$bigmart_standard_font = bigmart_standard_font_array();
foreach ($bigmart_standard_font as $key => $value) {
$font_family[$value['family']] = $value['family'];
}
return $font_family;
}
/**
* Returns the available font weights.
*
* @since 1.0.0
* @access public
* @return array
*/
public function bigmart_get_font_weight_choices() {
if ($this->settings['family']->id) {
$bigmart_default_font = bigmart_default_font_array();
$bigmart_standard_font = bigmart_standard_font_array();
$bigmart_google_font = bigmart_google_font_array();
$bigmart_font = array_merge($bigmart_default_font, $bigmart_standard_font, $bigmart_google_font);
$font_family_id = $this->settings['family']->id;
$default_font_family = $this->settings['family']->default;
$get_font_family = get_theme_mod($font_family_id, $default_font_family);
$font_array = bigmart_search_key($bigmart_font, 'family', $get_font_family);
$variants_array = $font_array['0']['variants'];
return $variants_array;
} else {
return array(
'400' => esc_html__('Normal', 'bigmart'),
'700' => esc_html__('Bold', 'bigmart')
);
}
}
/**
* Returns the available font text decoration.
*
* @since 1.0.0
* @access public
* @return array
*/
public function bigmart_get_text_decoration_choices() {
return array(
'none' => esc_html__('None', 'bigmart'),
'underline' => esc_html__('Underline', 'bigmart'),
'line-through' => esc_html__('Line-through', 'bigmart'),
'overline' => esc_html__('Overline', 'bigmart')
);
}
/**
* Returns the available font text transform.
*
* @since 1.0.0
* @access public
* @return array
*/
public function bigmart_get_text_transform_choices() {
return array(
'none' => esc_html__('None', 'bigmart'),
'uppercase' => esc_html__('Uppercase', 'bigmart'),
'lowercase' => esc_html__('Lowercase', 'bigmart'),
'capitalize' => esc_html__('Capitalize', 'bigmart')
);
}
}