l10n = wp_parse_args( $this->l10n, array( 'family' => esc_html__( 'Font Family', 'digifly' ), 'size' => esc_html__( 'Font Size', 'digifly' ), 'weight' => esc_html__( 'Font Weight', 'digifly' ), 'style' => esc_html__( 'Font Style', 'digifly' ), 'line_height' => esc_html__( 'Line Height', 'digifly' ), ) ); } /** * Enqueue scripts/styles. * * @since 1.0.0 * @access public * @return void */ public function enqueue() { wp_enqueue_script( 'digifly-customize-controls' ); wp_enqueue_style( 'digifly-customize-controls' ); } /** * 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 ] : '', ); if ( 'family' === $setting_key ) { $this->json[ $setting_key ]['choices'] = $this->get_font_families(); } elseif ( 'weight' === $setting_key ) { $this->json[ $setting_key ]['choices'] = $this->get_font_weight_choices(); } elseif ( 'style' === $setting_key ) { $this->json[ $setting_key ]['choices'] = $this->get_font_style_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 }}} <# } #> 'Montserrat', 'Arial' => 'Arial', 'Helvetica' => 'Helvetica', ); } /** * Returns the available font weights. * * @since 1.0.0 * @access public * @return array */ public function get_font_weight_choices() { return array( '100' => esc_html__( 'Thin', 'digifly' ), '300' => esc_html__( 'Light', 'digifly' ), '400' => esc_html__( 'Normal', 'digifly' ), '500' => esc_html__( 'Medium', 'digifly' ), '700' => esc_html__( 'Bold', 'digifly' ), '900' => esc_html__( 'Ultra Bold', 'digifly' ), ); } /** * Returns the available font styles. * * @since 1.0.0 * @access public * @return array */ public function get_font_style_choices() { return array( 'normal' => esc_html__( 'Normal', 'digifly' ), 'italic' => esc_html__( 'Italic', 'digifly' ), 'oblique' => esc_html__( 'Oblique', 'digifly' ), ); } }