show_font_family = $args['show_font_family']; } if ( isset( $args['show_font_size'] ) ) { $this->show_font_size = $args['show_font_size']; } if ( isset( $args['show_font_weight'] ) ) { $this->show_font_weight = $args['show_font_weight']; } if ( isset( $args['show_line_height'] ) ) { $this->show_line_height = $args['show_line_height']; } if ( isset( $args['show_letter_spacing'] ) ) { $this->show_letter_spacing = $args['show_letter_spacing']; } if ( isset( $args['show_text_transform'] ) ) { $this->show_text_transform = $args['show_text_transform']; } } /** * Enqueue control related scripts/styles */ public function enqueue() { wp_enqueue_script( 'accepta-typography-control', get_template_directory_uri() . '/inc/customizer-controls/js/typography-control.js', array( 'jquery', 'customize-base' ), wp_get_theme()->get( 'Version' ), true ); wp_enqueue_style( 'accepta-typography-control', get_template_directory_uri() . '/inc/customizer-controls/css/typography-control.css', array(), wp_get_theme()->get( 'Version' ) ); // Load Google Fonts data from JSON file $fonts_file = get_template_directory() . '/inc/customizer-controls/google-fonts.json'; $google_fonts_data = array(); if ( file_exists( $fonts_file ) ) { $fonts_json = file_get_contents( $fonts_file ); $fonts_data = json_decode( $fonts_json, true ); if ( isset( $fonts_data['items'] ) && is_array( $fonts_data['items'] ) ) { $google_fonts_data = $fonts_data['items']; } } // Localize script with minimal data for font styling wp_localize_script( 'accepta-typography-control', 'acceptaTypographyL10n', array( 'systemFonts' => $this->get_system_fonts(), 'googleFonts' => $this->get_google_fonts(), ) ); } /** * Render the control's content */ public function render_content() { $input_id = '_customize-input-' . $this->id; $description_id = '_customize-description-' . $this->id; $describedby_attr = ( ! empty( $this->description ) ) ? ' aria-describedby="' . esc_attr( $description_id ) . '"' : ''; $value = $this->value(); // Parse value if it's JSON if ( is_string( $value ) ) { $value = json_decode( $value, true ); } // Set defaults if ( ! is_array( $value ) ) { $value = array(); } $defaults = array( 'font_family' => '', 'font_size' => '', 'font_size_desktop' => '', 'font_size_tablet' => '', 'font_size_mobile' => '', 'font_weight' => '', 'line_height' => '', 'letter_spacing' => '', 'text_transform' => '', ); $value = wp_parse_args( $value, $defaults ); ?>