l10n = wp_parse_args( $this->l10n, array( 'family' => esc_html__( 'Font Family', 'articlewave' ), 'weight' => esc_html__( 'Font Weight', 'articlewave' ), 'style' => esc_html__( 'Font Style', 'articlewave' ), 'transform' => esc_html__( 'Font Transform', 'articlewave' ), 'decoration' => esc_html__( 'Font Decoration', 'articlewave' ) ) ); } /** * Enqueue scripts/styles. * * @since 1.0.0 * @access public * @return void */ public function enqueue() { wp_enqueue_script( 'articlewave-google-webfont', get_template_directory_uri() . '/inc/customizer/custom-controls/typography/webfontloader.js', array( 'jquery' ) ); wp_enqueue_script( 'articlewave-typo-ajax-script', get_template_directory_uri() . '/inc/customizer/custom-controls/typography/typo-ajax.js', array( 'jquery', 'select2' ), false, true ); wp_localize_script( 'articlewave-typo-ajax-script', 'ajax_script', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); } /** * 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. 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 ] : '', ); $this->json[$setting_key]['setid'] = $this->settings[ $setting_key ]->id; switch ( $setting_key ) { case 'family': $this->json[ $setting_key ]['choices'] = $this->get_font_families(); break; case 'weight': $this->json[ $setting_key ]['choices'] = $this->get_font_weight_choices(); break; case 'style': $this->json[ $setting_key ]['choices'] = $this->get_font_style_choices(); break; case 'transform': $this->json[ $setting_key ]['choices'] = $this->get_font_transform_choices(); break; case 'decoration': $this->json[ $setting_key ]['choices'] = $this->get_font_decoration_choices(); break; default: break; } } } /** * 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 }}} <# } #> $value ) { $mt_fonts[esc_attr( $key )] = esc_html( $key ); } return $mt_fonts; } /** * Returns the available font weights. * * @since 1.0.0 * @access public * @return array */ public function get_font_weight_choices() { if ( $this->settings['family']->id ) { $articlewave_font_list = get_option( 'articlewave_google_font' ); $font_family_id = $this->settings['family']->id; $get_font_family = articlewave_get_customizer_option_value( $font_family_id ); $variants_array = $articlewave_font_list[$get_font_family]['0']; if ( is_array( $variants_array ) ) { $options_array = array( 'inherit' => __( 'Inherit', 'articlewave' ) ); foreach ( $variants_array as $variants ) { $options_array[$variants] = articlewave_convert_font_variants( $variants ); } return $options_array; } else { return array( 'inherit' => esc_html__( 'Inherit', 'articlewave' ), '400' => esc_html__( 'Normal 400', 'articlewave' ), '700' => esc_html__( 'Bold 700', 'articlewave' ), ); } } else { return array( 'inherit' => esc_html__( 'Inherit', 'articlewave' ), '400' => esc_html__( 'Normal 400', 'articlewave' ), '700' => esc_html__( 'Bold 700', 'articlewave' ), ); } } /** * Returns the available font style. * * @since 1.0.0 * @access public * @return array */ public function get_font_style_choices() { $font_style_choices = apply_filters( 'articlewave_font_style_choices', array( 'inherit' => __( 'Inherit', 'articlewave' ), 'normal' => __( 'Normal', 'articlewave' ), 'italic' => __( 'Italic', 'articlewave' ), ) ); return $font_style_choices; } /** * Returns the available font transform. * * @since 1.0.0 * @access public * @return array */ public function get_font_transform_choices() { $font_transform_choices = apply_filters( 'articlewave_font_transform_choices', array( 'inherit' => __( 'Inherit', 'articlewave' ), 'lowercase' => __( 'Lowercase', 'articlewave' ), 'capitalize' => __( 'Capitalize', 'articlewave' ), 'uppercase' => __( 'Uppercase', 'articlewave' ), ) ); return $font_transform_choices; } /** * Returns the available font decoration. * * @since 1.0.0 * @access public * @return array */ public function get_font_decoration_choices() { $font_decoration_choices = apply_filters( 'articlewave_font_decoration_choices', array( 'inherit' => __( 'Inherit', 'articlewave' ), 'underline' => __( 'Underline', 'articlewave' ), 'line-through' => __( 'Line-through', 'articlewave' ), ) ); return $font_decoration_choices; } } }