<?php
/**
 * Add or expand custom function related to the Enrollment Theme.
 *
 * @package CodeVibrant
 * @subpackage Enrollment
 * @since 1.0.0
 */

/**
 * Adds custom classes to the array of body classes.
 *
 * @param array $classes Classes for the body element.
 * @return array
 */
function enrollment_body_classes( $classes ) {

    wp_reset_postdata();
    
    global $post;

    // Adds a class of group-blog to blogs with more than 1 published author.
    if ( is_multi_author() ) {
        $classes[] = 'group-blog';
    }

    // Adds a class of hfeed to non-singular pages.
    if ( ! is_singular() ) {
        $classes[] = 'hfeed';
    }

    // Adds a class of boxed-layout for whole site
    $enrollment_site_layout = get_theme_mod( 'enrollment_site_layout', 'wide_layout' );
    if ( $enrollment_site_layout == 'boxed_layout' ) {
        $classes[] = 'boxed-layout';
    }

    //Adds a archive layout class
    $enrollment_archive_layout = get_theme_mod( 'enrollment_archive_layout', 'classic' );
    if ( is_archive() || is_home() || is_search() ) {
        $classes[] = $enrollment_archive_layout.'-archive-layout';
    }

    /**
     * Sidebar option for post/page/archive
     */
    if ( 'post' === get_post_type() ) {
        $sidebar_meta_option = get_post_meta( $post->ID, 'single_post_sidebar', true );
    }

    if ( 'page' === get_post_type() ) {
        $sidebar_meta_option = get_post_meta( $post->ID, 'single_page_sidebar', true );
    }
     
    if ( is_home() ) {
        $home_id = get_option( 'page_for_posts' );
        $sidebar_meta_option = get_post_meta( $home_id, 'single_page_sidebar', true );
    }
    
    if ( empty( $sidebar_meta_option ) || is_archive() || is_search() ) {
        $sidebar_meta_option = 'default_sidebar';
    }
    $archive_sidebar = get_theme_mod( 'enrollment_archive_sidebar', 'right_sidebar' );
    $post_default_sidebar = get_theme_mod( 'enrollment_default_post_sidebar', 'right_sidebar' );
    $page_default_sidebar = get_theme_mod( 'enrollment_default_page_sidebar', 'right_sidebar' );
    
    if ( $sidebar_meta_option == 'default_sidebar' ) {
        if ( is_single() ) {
            if ( $post_default_sidebar == 'right_sidebar' ) {
                $classes[] = 'right-sidebar';
            } elseif ( $post_default_sidebar == 'left_sidebar' ) {
                $classes[] = 'left-sidebar';
            } elseif ( $post_default_sidebar == 'no_sidebar' ) {
                $classes[] = 'no-sidebar';
            } elseif ( $post_default_sidebar == 'no_sidebar_center' ) {
                $classes[] = 'no-sidebar-center';
            }
        } elseif ( is_page() && !is_page_template( 'templates/template-home.php' ) ) {
            if ( $page_default_sidebar == 'right_sidebar' ) {
                $classes[] = 'right-sidebar';
            } elseif ( $page_default_sidebar == 'left_sidebar' ) {
                $classes[] = 'left-sidebar';
            } elseif ( $page_default_sidebar == 'no_sidebar' ) {
                $classes[] = 'no-sidebar';
            } elseif ( $page_default_sidebar == 'no_sidebar_center' ) {
                $classes[] = 'no-sidebar-center';
            }
        } elseif ( $archive_sidebar == 'right_sidebar' ) {
            $classes[] = 'right-sidebar';
        } elseif ( $archive_sidebar == 'left_sidebar' ) {
            $classes[] = 'left-sidebar';
        } elseif ( $archive_sidebar == 'no_sidebar' ) {
            $classes[] = 'no-sidebar';
        } elseif ( $archive_sidebar == 'no_sidebar_center' ) {
            $classes[] = 'no-sidebar-center';
        }
    } elseif ( $sidebar_meta_option == 'right_sidebar' ) {
        $classes[] = 'right-sidebar';
    } elseif ( $sidebar_meta_option == 'left_sidebar' ) {
        $classes[] = 'left-sidebar';
    } elseif ( $sidebar_meta_option == 'no_sidebar' ) {
        $classes[] = 'no-sidebar';
    } elseif ( $sidebar_meta_option == 'no_sidebar_center' ) {
        $classes[] = 'no-sidebar-center';
    }

    return $classes;
}
add_filter( 'body_class', 'enrollment_body_classes' );

/*------------------------------------------------------------------------------------------------------------*/

if ( ! function_exists( 'enrollment_fonts_url' ) ) :

    /**
     * Register Google fonts for Enrollment.
     *
     * @return string Google fonts URL for the theme.
     * @since 1.0.0
     */

    function enrollment_fonts_url() {
        $fonts_url = '';
        $font_families = array();

        /*
         * Translators: If there are characters in your language that are not supported
         * by Roboto Condensed, translate this to 'off'. Do not translate into your own language.
         */
        if ( 'off' !== _x( 'on', 'Roboto font: on or off', 'enrollment' ) ) {
            $font_families[] = 'Roboto:300italic,400italic,700italic,400,300,700,900';
        }      

        if ( $font_families ) {
            $query_args = array(
                'family' => urlencode( implode( '|', $font_families ) ),
                'subset' => urlencode( 'latin,latin-ext' ),
            );

            $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
        }

        return $fonts_url;
    }
    
endif;

/*------------------------------------------------------------------------------------------------------------*/
/**
 * Enqueue Scripts and styles for admin
 *
 * @since 1.0.0
 */
function enrollment_admin_scripts_style( $hook ) {

    if ( 'widgets.php' != $hook && 'edit.php' != $hook && 'post.php' != $hook && 'post-new.php' != $hook ) {
        return;
    }

    global $enrollment_version;

    if ( function_exists( 'wp_enqueue_media' ) ) {
        wp_enqueue_media();
    }

    wp_enqueue_script( 'jquery-ui-button' );

    wp_enqueue_script( 'jquery-ui-slider' );

    wp_enqueue_script( 'enrollment-admin-script', get_template_directory_uri() .'/assets/js/admin-scripts.js', array('jquery'), esc_attr( $enrollment_version ), true );

    wp_enqueue_style( 'jquery-ui', get_template_directory_uri() . '/assets/css/jquery-ui.css' );

    wp_enqueue_style( 'enrollment-admin-style', get_template_directory_uri() .'/assets/css/admin-styles.css', esc_attr( $enrollment_version ) );
}
add_action( 'admin_enqueue_scripts', 'enrollment_admin_scripts_style' );

/*------------------------------------------------------------------------------------------------------------*/
/**
 * Enqueue scripts and styles.
 */
function enrollment_scripts() {

    global $enrollment_version;
    
    wp_enqueue_script( 'jquery-lightslider', get_template_directory_uri() . '/assets/library/lightslider/js/lightslider.min.js', array('jquery'), '20180605', true );
    wp_enqueue_script( 'enrollment-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array(), esc_attr( $enrollment_version ), true );

    $enrollment_header_sticky_option = get_theme_mod( 'enrollment_header_sticky_option', true );

    if ( $enrollment_header_sticky_option === true ) {

        wp_enqueue_script( 'jquery-sticky', get_template_directory_uri() .'/assets/library/sticky/jquery.sticky.js', array( 'jquery' ), '1.0.2', true );

        wp_enqueue_script( 'enrollment-sticky-setting', get_template_directory_uri() .'/assets/library/sticky/sticky-setting.js', array( 'jquery-sticky' ), esc_attr( $enrollment_version ), true );

    }

    wp_enqueue_script( 'enrollment-custom-script', get_template_directory_uri(). '/assets/js/custom-script.js', array( 'jquery' ), esc_attr( $enrollment_version ), true );

    wp_enqueue_style( 'font-awesome', get_template_directory_uri().'/assets/library/font-awesome/css/font-awesome.min.css', array(), '4.5.0' );

    wp_enqueue_style( 'enrollment-fonts', enrollment_fonts_url(), array(), null );

    wp_enqueue_style( 'lightslider-style', get_template_directory_uri() .'/assets/library/lightslider/css/lightslider.min.css', array(), '1.1.5' );

    wp_enqueue_style( 'enrollment-style', get_stylesheet_uri(), array(), esc_attr( $enrollment_version ) );

    wp_enqueue_style( 'enrollment-preloader', get_template_directory_uri(). '/assets/css/cv-preloaders.css', array(), '1.1.2' );

    wp_enqueue_style( 'enrollment-responsive-style', get_template_directory_uri() .'/assets/css/enrollment-responsive.css', array(), esc_attr( $enrollment_version ) );

    $make_sidebar_sticky = apply_filters( 'enable_sticky_sidebar', true );
    if ( $make_sidebar_sticky ) {
        wp_enqueue_script( 'theia-sticky-sidebar', get_template_directory_uri() . '/assets/library/sticky-sidebar/theia-sticky-sidebar.min.js', array( 'jquery' ), '1.4.0', true );
    }

    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
        wp_enqueue_script( 'comment-reply' );
    }
}
add_action( 'wp_enqueue_scripts', 'enrollment_scripts' );

/*------------------------------------------------------------------------------------------------------------*/

if ( !function_exists( 'enrollment_categories_lists' ) ):

    /**
     * category list
     *
     * @return array();
     */
    function enrollment_categories_lists() {
        $enrollment_cat_args = array(
            'type'       => 'post',
            'child_of'   => 0,
            'orderby'    => 'name',
            'order'      => 'ASC',
            'hide_empty' => 1,
            'taxonomy'   => 'category',
        );
        $enrollment_categories = get_categories( $enrollment_cat_args );
        $enrollment_categories_lists = array();
        foreach( $enrollment_categories as $category ) {
            $enrollment_categories_lists[$category->slug] = $category->name;
        }
        return $enrollment_categories_lists;
    }

endif;

/*------------------------------------------------------------------------------------------------------------*/

if ( ! function_exists( 'enrollment_get_sidebar' ) ):

    /**
     * Function define about page/post/archive sidebar
     *
     * @since 1.0.0
     */
    function enrollment_get_sidebar() {
        global $post;

        if ( 'post' === get_post_type() ) {
            $sidebar_meta_option = get_post_meta( $post->ID, 'single_post_sidebar', true );
        }

        if ( 'page' === get_post_type() ) {
            $sidebar_meta_option = get_post_meta( $post->ID, 'single_page_sidebar', true );
        }
         
        if ( is_home() ) {
            $set_id = get_option( 'page_for_posts' );
            $sidebar_meta_option = get_post_meta( $set_id, 'single_page_sidebar', true );
        }
        
        if ( empty( $sidebar_meta_option ) || is_archive() || is_search() ) {
            $sidebar_meta_option = 'default_sidebar';
        }
        
        $archive_sidebar = get_theme_mod( 'enrollment_archive_sidebar', 'right_sidebar' );
        $post_default_sidebar = get_theme_mod( 'enrollment_default_post_sidebar', 'right_sidebar' );
        $page_default_sidebar = get_theme_mod( 'enrollment_default_page_sidebar', 'right_sidebar' );
        
        if ( $sidebar_meta_option == 'default_sidebar' ) {
            if ( is_single() ) {
                if ( $post_default_sidebar == 'right_sidebar' ) {
                    get_sidebar();
                } elseif ( $post_default_sidebar == 'left_sidebar' ) {
                    get_sidebar( 'left' );
                }
            } elseif ( is_page() ) {
                if ( $page_default_sidebar == 'right_sidebar' ) {
                    get_sidebar();
                } elseif ( $page_default_sidebar == 'left_sidebar' ) {
                    get_sidebar( 'left' );
                }
            } elseif ( $archive_sidebar == 'right_sidebar' ) {
                get_sidebar();
            } elseif ( $archive_sidebar == 'left_sidebar' ) {
                get_sidebar( 'left' );
            }
        } elseif ( $sidebar_meta_option == 'right_sidebar' ) {
            get_sidebar();
        } elseif ( $sidebar_meta_option == 'left_sidebar' ) {
            get_sidebar( 'left' );
        }
    }

endif;

/*------------------------------------------------------------------------------------------------------------*/

if ( ! function_exists( 'enrollment_get_excerpt' ) ):

    /**
     * homepage excerpt
     */
    function enrollment_get_excerpt( $content, $limit ) {
        $striped_content = strip_tags( $content );
        $striped_content = strip_shortcodes( $striped_content );
        $limit_content = mb_substr( $striped_content, 0 , $limit );
        if ( $limit_content < $content ) {
            $limit_content .= "..."; 
        }
        return $limit_content;
    }

endif;

/*------------------------------------------------------------------------------------------------------------*/

if ( ! function_exists( 'enrollment_archive_excerpt' ) ):

    /**
     * Function to get excerpt content according to define length
     */
    function enrollment_archive_excerpt( $content, $limit ) {
        $content = strip_tags( $content );
        $content = strip_shortcodes( $content );
        $words = explode( ' ', $content );    
        return implode( ' ', array_slice( $words, 0, $limit ) );
    }

endif;

/*------------------------------------------------------------------------------------------------------------*/

if ( ! function_exists( 'enrollment_font_awesome_social_icon_array' ) ) :

    /**
     * Define font awesome social media icons
     *
     * @return array();
     * @since 1.0.0
     */

    function enrollment_font_awesome_social_icon_array() {
        return array(
            "fa fa-facebook-square","fa fa-facebook-f","fa fa-facebook","fa fa-facebook-official","fa fa-twitter-square","fa fa-twitter","fa fa-yahoo","fa fa-google","fa fa-google-wallet","fa fa-google-plus-circle","fa fa-google-plus-official","fa fa-instagram","fa fa-linkedin-square","fa fa-linkedin","fa fa-pinterest-p","fa fa-pinterest","fa fa-pinterest-square","fa fa-google-plus-square","fa fa-google-plus","fa fa-youtube-square","fa fa-youtube","fa fa-youtube-play","fa fa-vimeo","fa fa-vimeo-square",
        );
    }

endif;

/*------------------------------------------------------------------------------------------------------------*/

if ( ! function_exists( 'enrollment_social_icons' ) ):

    /**
     * Social media function
     *
     * @since 1.0.0
     */
    function enrollment_social_icons() {
        $get_social_media_icons = get_theme_mod( 'social_media_icons', '' );
        $get_decode_social_media = json_decode( $get_social_media_icons );
        if ( ! empty( $get_decode_social_media ) ) {
            echo '<div class="cv-social-icons-wrapper">';
            foreach ( $get_decode_social_media as $single_icon ) {
                $icon_class = $single_icon->cv_icon_list;
                $icon_url = $single_icon->cv_url_field;
                if ( !empty( $icon_url ) ) {
                    echo '<span class="social-link"><a href="'. esc_url( $icon_url ) .'" target="_blank"><i class="'. esc_attr( $icon_class ) .'"></i></a></span>';
                }
            }
            echo '</div><!-- .cv-social-icons-wrapper -->';
        }
    }

endif;

/*------------------------------------------------------------------------------------------------------------*/

if ( ! function_exists( 'enrollment_get_hex2rgba' ) ) :

    /**
     * Get rgba color from hex
     *
     * @since 1.0.0
     */
    function enrollment_get_hex2rgba( $color, $opacity ) {
        if ( $color[0] == '#' ) {
            $color = substr( $color, 1 );
        }
        $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
        $rgb =  array_map( 'hexdec', $hex );
        $output = 'rgba( '.implode( ",", $rgb ).','.$opacity.' )';
        return $output;
    }

endif;

/*------------------------------------------------------------------------------------------------------------*/

add_action( "wp_ajax_get_google_font_variants", "get_google_font_variants" );

if ( ! function_exists( 'get_google_font_variants' ) ) :

    /**
     * get Google font variants
     *
     * @since 1.0.0
     */
    function get_google_font_variants() {
        $enrollment_font_list = get_option( 'enrollment_google_font', '' );
        
        $font_family = $_REQUEST['font_family'];
        
        $font_array = enrollment_search_key( $enrollment_font_list, 'family', $font_family );
        
        $variants_array = $font_array['0']['variants'] ;
        $options_array = array();
        foreach ( $variants_array  as $key=>$variants ) {
            $options_array .= '<option value="'. esc_attr( $key ).'">'. esc_html( $variants ).'</option>';
        }
        echo $options_array;
        die();
    }

endif;

if ( ! function_exists( 'enrollment_search_key' ) ) :

    /**
     * function for getting search key of google fonts
     */
    function enrollment_search_key( $array, $key, $value ) {
        $results = array();

        if ( is_array( $array ) ) {
            if ( isset($array[$key]) && $array[$key] == $value ) {
                $results[] = $array;
            }

            foreach ( $array as $subarray ) {
                $results = array_merge( $results, enrollment_search_key( $subarray, $key, $value ) );
            }
        }

        return $results;
    }

endif;

/*------------------------------------------------------------------------------------------------------------*/

if ( ! function_exists( 'enrollment_css_strip_whitespace' ) ) :

    /**
     * Get minified css and removed space
     *
     * @since 1.0.0
     */
    function enrollment_css_strip_whitespace( $css ) {
        $replace = array(
            "#/\*.*?\*/#s" => "",  // Strip C style comments.
            "#\s\s+#"      => " ", // Strip excess whitespace.
        );
        $search = array_keys( $replace );
        $css = preg_replace( $search, $replace, $css );

        $replace = array(
            ": "  => ":",
            "; "  => ";",
            " {"  => "{",
            " }"  => "}",
            ", "  => ",",
            "{ "  => "{",
            ";}"  => "}", // Strip optional semicolons.
            ",\n" => ",", // Don't wrap multiple selectors.
            "\n}" => "}", // Don't wrap closing braces.
            "} "  => "}\n", // Put each rule on it's own line.
        );
        $search = array_keys( $replace );
        $css = str_replace( $search, $replace, $css );

        return trim( $css );
    }

endif;

/*------------------------------------------------------------------------------------------------------------*/

add_action( 'wp_enqueue_scripts', 'enrollment_dynamic_styles' );

if ( ! function_exists( 'enrollment_dynamic_styles' ) ):

    /**
     * Dynamic theme color option
     *
     * @since 1.0.0
     */
    function enrollment_dynamic_styles() {

        $enrollment_title_option = get_theme_mod( 'enrollment_title_option', true );
        $enrollment_primary_theme_color = get_theme_mod( 'enrollment_primary_theme_color', '#ecb101' );
        $enrollment_title_color = get_theme_mod( 'enrollment_title_color', '#333333' );

        $output_css = '';
        $output_css .=" a,a:hover,a:focus,a:active,.entry-footer a:hover,.header-elements-holder .top-info:after,.header-search-wrapper .search-main:hover,.widget a:hover,.widget a:hover:before,.widget li:hover:before,.enrollment_service .post-title a:hover,.team-title-wrapper .post-title a:hover,.testimonial-content:before,.enrollment_testimonials .client-name,.latest-posts-wrapper .byline a:hover,.latest-posts-wrapper .posted-on a:hover,.latest-posts-wrapper .news-title a:hover,.enrollment_latest_blog .news-more,.enrollment_latest_blog .news-more:hover,.search-results .entry-title a:hover,.archive .entry-title a:hover,.single .entry-title a:hover,.home.blog .archive-content-wrapper .entry-title a:hover,.archive-content-wrapper .entry-title a:hover,.entry-meta span a:hover,.post-readmore a:hover,#top-footer .widget_archive a:hover:before, #top-footer .widget_categories a:hover:before, #top-footer .widget_recent_entries a:hover:before, #top-footer .widget_meta a:hover:before, #top-footer .widget_recent_comments li:hover:before, #top-footer .widget_rss li:hover:before, #top-footer .widget_pages li a:hover:before, #top-footer .widget_nav_menu li a:hover:before,#top-footer .widget_archive a:hover, #top-footer .widget_categories a:hover, #top-footer .widget_recent_entries a:hover, #top-footer .widget_meta a:hover, #top-footer .widget_recent_comments li:hover, #top-footer .widget_rss li:hover, #top-footer .widget_pages li a:hover, #top-footer .widget_nav_menu li a:hover,.site-info a:hover,.grid-archive-layout .entry-title a:hover,.menu-toggle a:hover,#cancel-comment-reply-link,#cancel-comment-reply-link:before,.logged-in-as a,.header-search-wrapper .search-main a:hover{
                color:". esc_attr( $enrollment_primary_theme_color ) .";
            }\n";
            
        $output_css .=".navigation .nav-links a:hover,.bttn:hover,button,input[type='button']:hover,input[type='reset']:hover,input[type='submit']:hover,.edit-link .post-edit-link,#site-navigation ul li.current-menu-item>a,#site-navigation ul li.current-menu-ancestor>a,#site-navigation ul li:hover>a,#site-navigation ul li.current_page_ancestor>a,#site-navigation ul li.current_page_item>a,.header-search-wrapper .search-form-main .search-submit:hover,.slider-btn:hover,.enrollment-slider-wrapper .lSAction>a:hover,.widget_search .search-submit,.widget .widget-title:after,.widget_search .search-submit,.widget .enrollment-widget-wrapper .widget-title:before,.widget .enrollment-widget-wrapper .widget-title:after,.enrollment_service .grid-items-wrapper .single-post-wrapper,.cta-btn-wrap a,.cta-btn-wrap a:hover,.courses-block-wrapper .courses-link:hover,.entry-btn:hover,.team-wrapper .team-desc-wrapper,.enrollment_testimonials .lSSlideOuter .lSPager.lSpg>li:hover a,.enrollment_testimonials .lSSlideOuter .lSPager.lSpg>li.active a,#cv-scrollup:hover,#cv-scrollup,.reply .comment-reply-link,.widget_tag_cloud .tagcloud a:hover,.widget.widget_tag_cloud a:hover{
               background:". esc_attr( $enrollment_primary_theme_color ) .";
            }\n";
            
       $output_css .=".navigation .nav-links a,.bttn,button,input[type='button'],input[type='reset'],input[type='submit'],.header-elements-holder .top-info:after,.header-search-wrapper .search-form-main .search-submit:hover,.slider-btn,.widget_search .search-submit,.cta-btn-wrap a:hover,.courses-link,.entry-btn,.widget_tag_cloud .tagcloud a:hover,.widget.widget_tag_cloud a:hover{
              border-color:". esc_attr( $enrollment_primary_theme_color ) .";
           }\n";

        //preloader
          $output_css .= "
        .sk-wave .sk-rect,
        .sk-three-bounce .sk-child,
        .sk-folding-cube .sk-cube:before {
            background-color: ". esc_attr( $enrollment_primary_theme_color ) . " !important;
        } ";
            
       $output_css .="#colophon,.comment-list .comment-body{
              border-top-color:". esc_attr( $enrollment_primary_theme_color ) .";
            }\n";
        
        if ( $enrollment_title_option == true ) {
            $output_css .=".site-title a, .site-description {
                        color:". esc_attr( $enrollment_title_color ) .";
                    }\n";
        } else {
            $output_css .=".site-title, .site-description {
                        position: absolute;
                        clip: rect(1px, 1px, 1px, 1px);
                    }\n";
        }

        $refine_output_css = enrollment_css_strip_whitespace( $output_css );

        wp_add_inline_style( 'enrollment-style', $refine_output_css );
    
        /**
         * Body typography
         */
        $p_font_family      = get_theme_mod( 'p_font_family', 'Roboto' );
        $p_font_style       = get_theme_mod( 'p_font_style', 'regular' );
        $p_text_decoration  = get_theme_mod( 'p_text_decoration', 'none' );
        $p_text_transform   = get_theme_mod( 'p_text_transform', 'none' );
        $p_font_size        = get_theme_mod( 'p_font_size', '14' ) . 'px';
        $p_line_height      = get_theme_mod( 'p_line_height', '2' );
        $p_color            = get_theme_mod( 'p_color', '#666666 ' );

        if ( !empty( $p_font_style ) ) {
            $p_font_style_weight = preg_split( '/(?<=[0-9])(?=[a-z]+)/i', $p_font_style );
            if ( isset( $p_font_style_weight[1] ) ) {
                $p_font_style = $p_font_style_weight[1];
            } else {
                $p_font_style = 'normal';
            }

            if ( isset( $p_font_style_weight[0] ) ) {
                $p_font_weight = $p_font_style_weight[0];
            } else {
                $p_font_weight = 400;
            }
        }
        $output_css .= "body {
            font-family:        $p_font_family;
            font-style:         $p_font_style;
            font-size:          $p_font_size;
            font-weight:        $p_font_weight;
            text-decoration:    $p_text_decoration;
            text-transform:     $p_text_transform;
            line-height:        $p_line_height;
            color:              $p_color;
        }\n";

        /**
         * H1 typography
         */
        $h1_font_family     = get_theme_mod( 'h1_font_family', 'Roboto' );
        $h1_font_style      = get_theme_mod( 'h1_font_style', '700' );
        $h1_text_decoration = get_theme_mod( 'h1_text_decoration', 'none' );
        $h1_text_transform  = get_theme_mod( 'h1_text_transform', 'none' );
        $h1_font_size       = get_theme_mod( 'h1_font_size', '36' ) . 'px';
        $h1_line_height     = get_theme_mod( 'h1_line_height', '1.3' );
        $h1_color           = get_theme_mod( 'h1_color', '#3d3d3d' );

        if ( !empty( $h1_font_style ) ) {
            $h1_font_style_weight = preg_split( '/(?<=[0-9])(?=[a-z]+)/i', $h1_font_style );
            if ( isset( $h1_font_style_weight[1] ) ) {
                $h1_font_style = $h1_font_style_weight[1];
            } else {
                $h1_font_style = 'normal';
            }

            if ( isset( $h1_font_style_weight[0] ) ) {
                $h1_font_weight = $h1_font_style_weight[0];
            } else {
                $h1_font_weight = 700;
            }
        }
        $output_css .= "h1, 
            .single .entry-title{
                font-family:        $h1_font_family;
                font-style:         $h1_font_style;
                font-size:          $h1_font_size;
                font-weight:        $h1_font_weight;
                text-decoration:    $h1_text_decoration;
                text-transform:     $h1_text_transform;
                line-height:        $h1_line_height;
                color:              $h1_color;
            }\n";

        /**
         * H2 typography
         */
        $h2_font_family     = get_theme_mod( 'h2_font_family', 'Roboto' );
        $h2_font_style      = get_theme_mod( 'h2_font_style', '700' );
        $h2_text_decoration = get_theme_mod( 'h2_text_decoration', 'none' );
        $h2_text_transform  = get_theme_mod( 'h2_text_transform', 'none' );
        $h2_font_size       = get_theme_mod( 'h2_font_size', '30' ) . 'px';
        $h2_line_height     = get_theme_mod( 'h2_line_height', '1.3' );
        $h2_color           = get_theme_mod( 'h2_color', '#3d3d3d' );

        if ( !empty( $h2_font_style ) ) {
            $h2_font_style_weight = preg_split( '/(?<=[0-9])(?=[a-z]+)/i', $h2_font_style );
            if ( isset( $h2_font_style_weight[1] ) ) {
                $h2_font_style = $h2_font_style_weight[1];
            } else {
                $h2_font_style = 'normal';
            }

            if ( isset( $h2_font_style_weight[0] ) ) {
                $h2_font_weight = $h2_font_style_weight[0];
            } else {
                $h2_font_weight = 700;
            }
        }
        $output_css .= "h2,.entry-title a,
        .search-results .entry-title, 
            .archive .entry-title {
            font-family:        $h2_font_family;
            font-style:         $h2_font_style;
            font-size:          $h2_font_size;
            font-weight:        $h2_font_weight;
            text-decoration:    $h2_text_decoration;
            text-transform:     $h2_text_transform;
            line-height:        $h2_line_height;
            color:              $h2_color;
        }\n";

        /**
         * H3 typography
         */
        $h3_font_family     = get_theme_mod( 'h3_font_family', 'Roboto' );
        $h3_font_style      = get_theme_mod( 'h3_font_style', '700' );
        $h3_text_decoration = get_theme_mod( 'h3_text_decoration', 'none' );
        $h3_text_transform  = get_theme_mod( 'h3_text_transform', 'none' );
        $h3_font_size       = get_theme_mod( 'h3_font_size', '26' ) . 'px';
        $h3_line_height     = get_theme_mod( 'h3_line_height', '1.3' );
        $h3_color           = get_theme_mod( 'h3_color', '#3d3d3d' );

        if ( !empty( $h3_font_style ) ) {
            $h3_font_style_weight = preg_split( '/(?<=[0-9])(?=[a-z]+)/i', $h3_font_style );
            if ( isset( $h3_font_style_weight[1] ) ) {
                $h3_font_style = $h3_font_style_weight[1];
            } else {
                $h3_font_style = 'normal';
            }

            if ( isset( $h3_font_style_weight[0] ) ) {
                $h3_font_weight = $h3_font_style_weight[0];
            } else {
                $h3_font_weight = 700;
            }
        }
        $output_css .= "h3,.cv-featured-items-wrapper.layout2 .cv-featured-single-item .item-title a {
            font-family:        $h3_font_family;
            font-style:         $h3_font_style;
            font-size:          $h3_font_size;
            font-weight:        $h3_font_weight;
            text-decoration:    $h3_text_decoration;
            text-transform:     $h3_text_transform;
            line-height:        $h3_line_height;
            color:              $h3_color;
        }\n";

        /**
         * H4 typography
         */
        $h4_font_family     = get_theme_mod( 'h4_font_family', 'Roboto' );
        $h4_font_style      = get_theme_mod( 'h4_font_style', '700' );
        $h4_text_decoration = get_theme_mod( 'h4_text_decoration', 'none' );
        $h4_text_transform  = get_theme_mod( 'h4_text_transform', 'none' );
        $h4_font_size       = get_theme_mod( 'h4_font_size', '20' ) . 'px';
        $h4_line_height     = get_theme_mod( 'h4_line_height', '1.3' );
        $h4_color           = get_theme_mod( 'h4_color', '#3d3d3d' );

        if ( !empty( $h4_font_style ) ) {
            $h4_font_style_weight = preg_split( '/(?<=[0-9])(?=[a-z]+)/i', $h4_font_style );
            if ( isset( $h4_font_style_weight[1] ) ) {
                $h4_font_style = $h4_font_style_weight[1];
            } else {
                $h4_font_style = 'normal';
            }

            if ( isset( $h4_font_style_weight[0] ) ) {
                $h4_font_weight = $h4_font_style_weight[0];
            } else {
                $h4_font_weight = 700;
            }
        }
        $output_css .= "h4 {
            font-family:        $h4_font_family;
            font-style:         $h4_font_style;
            font-size:          $h4_font_size;
            font-weight:        $h4_font_weight;
            text-decoration:    $h4_text_decoration;
            text-transform:     $h4_text_transform;
            line-height:        $h4_line_height;
            color:              $h4_color;
        }\n";

        /**
         * H5 typography
         */
        $h5_font_family     = get_theme_mod( 'h5_font_family', 'Roboto' );
        $h5_font_style      = get_theme_mod( 'h5_font_style', '700' );
        $h5_text_decoration = get_theme_mod( 'h5_text_decoration', 'none' );
        $h5_text_transform  = get_theme_mod( 'h5_text_transform', 'none' );
        $h5_font_size       = get_theme_mod( 'h5_font_size', '18' ) . 'px';
        $h5_line_height     = get_theme_mod( 'h5_line_height', '1.3' );
        $h5_color           = get_theme_mod( 'h5_color', '#3d3d3d' );

        if ( !empty( $h5_font_style ) ) {
            $h5_font_style_weight = preg_split( '/(?<=[0-9])(?=[a-z]+)/i', $h5_font_style );
            if ( isset( $h5_font_style_weight[1] ) ) {
                $h5_font_style = $h5_font_style_weight[1];
            } else {
                $h5_font_style = 'normal';
            }

            if ( isset( $h5_font_style_weight[0] ) ) {
                $h5_font_weight = $h5_font_style_weight[0];
            } else {
                $h5_font_weight = 700;
            }
        }
        $output_css .= "h5 {
            font-family:        $h5_font_family;
            font-style:         $h5_font_style;
            font-size:          $h5_font_size;
            font-weight:        $h5_font_weight;
            text-decoration:    $h5_text_decoration;
            text-transform:     $h5_text_transform;
            line-height:        $h5_line_height;
            color:              $h5_color;
        }\n";

        /**
         * H6 typography
         */
        $h6_font_family     = get_theme_mod( 'h6_font_family', 'Roboto' );
        $h6_font_style      = get_theme_mod( 'h6_font_style', '700' );
        $h6_text_decoration = get_theme_mod( 'h6_text_decoration', 'none' );
        $h6_text_transform  = get_theme_mod( 'h6_text_transform', 'none' );
        $h6_font_size       = get_theme_mod( 'h6_font_size', '16' ) . 'px';
        $h6_line_height     = get_theme_mod( 'h6_line_height', '1.3' );
        $h6_color           = get_theme_mod( 'h6_color', '#3d3d3d' );

        if ( !empty( $h6_font_style ) ) {
            $h6_font_style_weight = preg_split( '/(?<=[0-9])(?=[a-z]+)/i', $h6_font_style );
            if ( isset( $h6_font_style_weight[1] ) ) {
                $h6_font_style = $h6_font_style_weight[1];
            } else {
                $h6_font_style = 'normal';
            }

            if ( isset( $h6_font_style_weight[0] ) ) {
                $h6_font_weight = $h6_font_style_weight[0];
            } else {
                $h6_font_weight = 700;
            }
        }
        $output_css .= "h6 {
            font-family:        $h6_font_family;
            font-style:         $h6_font_style;
            font-size:          $h6_font_size;
            font-weight:        $h6_font_weight;
            text-decoration:    $h6_text_decoration;
            text-transform:     $h6_text_transform;
            line-height:        $h6_line_height;
            color:              $h6_color;
        }\n";

        wp_add_inline_style( 'enrollment-style', $output_css );
    }

endif;