How to enqueue google fonts if we use directly in style.css

Question

My theme has “selecting differrent google fonts options” So for that we need to load several .woff2 files. So i have added 2 type of woff2 files in Top of CSS file (Bitter & Lora). but i don’t know How to change in funtions.php

Here is my Funtions.php font code:-

/**
 * Enqueue scripts and styles
 *
 * @since Cazuela 1.0
 */
function thsp_theme_scripts() {
    /*
     * Enqueue Google Fonts
     *
     * Check if fonts set in theme options require loading
     * of Google scripts
     */
    $theme_options = thsp_cbp_get_options_values();
    $theme_options_fields = thsp_cbp_get_fields();
    $body_font_value = $theme_options['body_font'];
    $heading_font_value = $theme_options['heading_font'];
    $body_font_options = $theme_options_fields['thsp_typography_section']['fields']['body_font']['control_args']['choices'];
    $heading_font_options = $theme_options_fields['thsp_typography_section']['fields']['heading_font']['control_args']['choices'];

    // Check if it's a Google Font
    if( isset( $body_font_options[$body_font_value]['google_font'] ) ) {
        wp_enqueue_style(
            'font_' . $body_font_value,
            'http://fonts.googleapis.com/css?family=' . $body_font_options[$body_font_value]['google_font']
        );
    }   
    // Check if it's a Google Font
    if( isset( $heading_font_options[$heading_font_value]['google_font'] ) ) {
        wp_enqueue_style(
            'font_' . $heading_font_value,
            'http://fonts.googleapis.com/css?family=' . $heading_font_options[$heading_font_value]['google_font']
        );
    }
    wp_enqueue_style( 'style', get_stylesheet_uri() );
0
Yashveer Arya 4 years 2020-02-11T08:39:11-05:00 0 Answers 55 views 0

Leave an answer

Browse
Browse