<?php
/**
 * Custom Functions.
 *
 * @package Training Institute Academy
 */

if( !function_exists( 'training_institute_academy_fonts_url' ) ) :

    //Google Fonts URL
    function training_institute_academy_fonts_url(){

        $training_institute_academy_font_families = array(
            'Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900',
            'Montserrat:ital,wght@0,100..900;1,100..900',
        );

        $training_institute_academy_fonts_url = add_query_arg( array(
            'family' => implode( '&family=', $training_institute_academy_font_families ),
            'display' => 'swap',
        ), 'https://fonts.googleapis.com/css2' );

        return esc_url_raw($training_institute_academy_fonts_url);
    }

endif;

if ( ! function_exists( 'training_institute_academy_sub_menu_toggle_button' ) ) :

    function training_institute_academy_sub_menu_toggle_button( $training_institute_academy_args, $training_institute_academy_item, $depth ) {

        // Add sub menu toggles to the main menu with toggles
        if ( $training_institute_academy_args->theme_location == 'training-institute-academy-primary-menu' && isset( $training_institute_academy_args->show_toggles ) ) {
            
            // Wrap the menu item link contents in a div, used for positioning
            $training_institute_academy_args->before = '<div class="submenu-wrapper">';
            $training_institute_academy_args->after  = '';

            // Add a toggle to items with children
            if ( in_array( 'menu-item-has-children', $training_institute_academy_item->classes ) ) {

                $training_institute_academy_toggle_target_string = '.menu-item.menu-item-' . $training_institute_academy_item->ID . ' > .sub-menu';

                // Add the sub menu toggle
                $training_institute_academy_args->after .= '<button type="button" class="theme-aria-button submenu-toggle" data-toggle-target="' . $training_institute_academy_toggle_target_string . '" data-toggle-type="slidetoggle" data-toggle-duration="250" aria-expanded="false"><span class="btn__content" tabindex="-1"><span class="screen-reader-text">' . esc_html__( 'Show sub menu', 'training-institute-academy' ) . '</span>' . training_institute_academy_get_theme_svg( 'plus' ) . '</span></button>';

            }

            // Close the wrapper
            $training_institute_academy_args->after .= '</div><!-- .submenu-wrapper -->';
            // Add sub menu icons to the main menu without toggles (the fallback menu)

        }elseif( $training_institute_academy_args->theme_location == 'training-institute-academy-primary-menu' ) {

            if ( in_array( 'menu-item-has-children', $training_institute_academy_item->classes ) ) {

                $training_institute_academy_args->before = '<div class="link-icon-wrapper">';
                $training_institute_academy_args->after  = training_institute_academy_get_theme_svg( 'plus' ) . '</div>';

            } else {

                $training_institute_academy_args->before = '';
                $training_institute_academy_args->after  = '';

            }

        }

        return $training_institute_academy_args;

    }

endif;

add_filter( 'nav_menu_item_args', 'training_institute_academy_sub_menu_toggle_button', 10, 3 );

if ( ! function_exists( 'training_institute_academy_the_theme_svg' ) ):
    
    function training_institute_academy_the_theme_svg( $training_institute_academy_svg_name, $training_institute_academy_return = false ) {

        if( $training_institute_academy_return ){

            return training_institute_academy_get_theme_svg( $training_institute_academy_svg_name ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in training_institute_academy_get_theme_svg();.

        }else{

            echo training_institute_academy_get_theme_svg( $training_institute_academy_svg_name ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in training_institute_academy_get_theme_svg();.

        }
    }

endif;

if ( ! function_exists( 'training_institute_academy_get_theme_svg' ) ):

    function training_institute_academy_get_theme_svg( $training_institute_academy_svg_name ) {

        // Make sure that only our allowed tags and attributes are included.
        $training_institute_academy_svg = wp_kses(
            Training_Institute_Academy_SVG_Icons::get_svg( $training_institute_academy_svg_name ),
            array(
                'svg'     => array(
                    'class'       => true,
                    'xmlns'       => true,
                    'width'       => true,
                    'height'      => true,
                    'viewbox'     => true,
                    'aria-hidden' => true,
                    'role'        => true,
                    'focusable'   => true,
                ),
                'path'    => array(
                    'fill'      => true,
                    'fill-rule' => true,
                    'd'         => true,
                    'transform' => true,
                ),
                'polygon' => array(
                    'fill'      => true,
                    'fill-rule' => true,
                    'points'    => true,
                    'transform' => true,
                    'focusable' => true,
                ),
                'polyline' => array(
                    'fill'      => true,
                    'points'    => true,
                ),
                'line' => array(
                    'fill'      => true,
                    'x1'      => true,
                    'x2' => true,
                    'y1'    => true,
                    'y2' => true,
                ),
            )
        );
        if ( ! $training_institute_academy_svg ) {
            return false;
        }
        return $training_institute_academy_svg;

    }

endif;

if( !function_exists( 'training_institute_academy_post_category_list' ) ) :

    // Post Category List.
    function training_institute_academy_post_category_list( $training_institute_academy_select_cat = true ){

        $training_institute_academy_post_cat_lists = get_categories(
            array(
                'hide_empty' => '0',
                'exclude' => '1',
            )
        );

        $training_institute_academy_post_cat_cat_array = array();
        if( $training_institute_academy_select_cat ){

            $training_institute_academy_post_cat_cat_array[''] = esc_html__( '-- Select Category --','training-institute-academy' );

        }

        foreach ( $training_institute_academy_post_cat_lists as $training_institute_academy_post_cat_list ) {

            $training_institute_academy_post_cat_cat_array[$training_institute_academy_post_cat_list->slug] = $training_institute_academy_post_cat_list->name;

        }

        return $training_institute_academy_post_cat_cat_array;
    }

endif;

if( !function_exists('training_institute_academy_single_post_navigation') ):

    function training_institute_academy_single_post_navigation(){

        $training_institute_academy_default = training_institute_academy_get_default_theme_options();
        $training_institute_academy_twp_navigation_type = esc_attr( get_post_meta( get_the_ID(), 'training_institute_academy_twp_disable_ajax_load_next_post', true ) );
        $training_institute_academy_current_id = '';
        $article_wrap_class = '';
        global $post;
        $training_institute_academy_current_id = $post->ID;
        if( $training_institute_academy_twp_navigation_type == '' || $training_institute_academy_twp_navigation_type == 'global-layout' ){
            $training_institute_academy_twp_navigation_type = get_theme_mod('training_institute_academy_twp_navigation_type', $training_institute_academy_default['training_institute_academy_twp_navigation_type']);
        }

        if( $training_institute_academy_twp_navigation_type != 'no-navigation' && 'post' === get_post_type() ){

            if( $training_institute_academy_twp_navigation_type == 'theme-normal-navigation' ){ ?>

                <div class="navigation-wrapper">
                    <?php
                    // Previous/next post navigation.
                    the_post_navigation(array(
                        'prev_text' => '<span class="arrow" aria-hidden="true">' . training_institute_academy_the_theme_svg('arrow-left',$training_institute_academy_return = true ) . '</span><span class="screen-reader-text">' . esc_html__('Previous post:', 'training-institute-academy') . '</span><span class="post-title">%title</span>',
                        'next_text' => '<span class="arrow" aria-hidden="true">' . training_institute_academy_the_theme_svg('arrow-right',$training_institute_academy_return = true ) . '</span><span class="screen-reader-text">' . esc_html__('Next post:', 'training-institute-academy') . '</span><span class="post-title">%title</span>',
                    )); ?>
                </div>
                <?php

            }else{

                $training_institute_academy_next_post = get_next_post();
                if( isset( $training_institute_academy_next_post->ID ) ){

                    $training_institute_academy_next_post_id = $training_institute_academy_next_post->ID;
                    echo '<div loop-count="1" next-post="' . absint( $training_institute_academy_next_post_id ) . '" class="twp-single-infinity"></div>';

                }
            }

        }

    }

endif;

add_action( 'training_institute_academy_navigation_action','training_institute_academy_single_post_navigation',30 );

if( !function_exists('training_institute_academy_content_offcanvas') ):

    // Offcanvas Contents
    function training_institute_academy_content_offcanvas(){ ?>

        <div id="offcanvas-menu">
            <div class="offcanvas-wraper">
                <div class="close-offcanvas-menu">
                    <div class="offcanvas-close">
                        <a href="javascript:void(0)" class="skip-link-menu-start"></a>
                        <button type="button" class="button-offcanvas-close">
                            <span class="offcanvas-close-label">
                                <?php echo esc_html('Close', 'training-institute-academy'); ?>
                            </span>
                        </button>
                    </div>
                </div>
                <div id="primary-nav-offcanvas" class="offcanvas-item offcanvas-main-navigation">
                    <nav class="primary-menu-wrapper" aria-label="<?php esc_attr_e('Horizontal', 'training-institute-academy'); ?>" role="navigation">
                        <ul class="primary-menu theme-menu">
                            <?php
                            if (has_nav_menu('training-institute-academy-primary-menu')) {
                                wp_nav_menu(
                                    array(
                                        'container' => '',
                                        'items_wrap' => '%3$s',
                                        'theme_location' => 'training-institute-academy-primary-menu',
                                        'show_toggles' => true,
                                    )
                                );
                            }else{

                                wp_list_pages(
                                    array(
                                        'match_menu_classes' => true,
                                        'show_sub_menu_icons' => true,
                                        'title_li' => false,
                                        'show_toggles' => true,
                                        'walker' => new Training_Institute_Academy_Walker_Page(),
                                    )
                                );
                            }
                            ?>
                        </ul>
                    </nav><!-- .primary-menu-wrapper -->
                </div>
                <a href="javascript:void(0)" class="skip-link-menu-end"></a>
            </div>
        </div>

    <?php
    }

endif;

add_action( 'training_institute_academy_before_footer_content_action','training_institute_academy_content_offcanvas',30 );

if( !function_exists('training_institute_academy_footer_content_widget') ):

    function training_institute_academy_footer_content_widget(){
        
        $training_institute_academy_default = training_institute_academy_get_default_theme_options();
        
        $training_institute_academy_footer_column_layout = absint(get_theme_mod('training_institute_academy_footer_column_layout', $training_institute_academy_default['training_institute_academy_footer_column_layout']));
        $training_institute_academy_footer_sidebar_class = 12;
        
        if($training_institute_academy_footer_column_layout == 2) {
            $training_institute_academy_footer_sidebar_class = 6;
        }
        
        if($training_institute_academy_footer_column_layout == 3) {
            $training_institute_academy_footer_sidebar_class = 4;
        }
        ?>
        
        <?php if ( get_theme_mod('training_institute_academy_display_footer', true) == true ) : ?>
            <div class="footer-widgetarea">
                <div class="wrapper">
                    <div class="column-row">
                    
                        <?php for ($i = 0; $i < $training_institute_academy_footer_column_layout; $i++) : ?>
                            
                            <div class="column <?php echo 'column-' . absint($training_institute_academy_footer_sidebar_class); ?> column-sm-12">
                                
                                <?php 
                                // If no widgets are assigned, display default widgets
                                if ( ! is_active_sidebar( 'training-institute-academy-footer-widget-' . $i ) ) : 

                                    if ($i === 0) : ?>
                                        <div id="media_image-3" class="widget widget_media_image">
                                            <img src="<?php echo esc_url(get_template_directory_uri() . '/assets/images/logo.png'); ?>" alt="<?php echo esc_attr__( 'Footer Image', 'training-institute-academy' ); ?>" style="max-width: 100%; height: auto;">
                                        </div>
                                        <div id="text-3" class="widget widget_text">
                                            <div class="textwidget">
                                                <p class="widget_text">
                                                    <?php esc_html_e('Training Institute Academy is a powerful and versatile WordPress theme designed for educational institutions, tutoring centers, and private tutors. It caters to a wide range of tutoring services including online tutors, math tutors, English tutors, science tutors, language tutors, vocational training, professional development, skills training, educational academy, certification programs...', 'training-institute-academy'); ?>
                                                </p>
                                            </div>
                                        </div>

                                    <?php elseif ($i === 1) : ?>
                                        <div id="pages-2" class="widget widget_pages">
                                            <h2 class="widget-title"><?php esc_html_e('Calendar', 'training-institute-academy'); ?></h2>
                                            <?php get_calendar(); ?>
                                        </div>

                                    <?php elseif ($i === 2) : ?>
                                        <div id="search-2" class="widget widget_search">
                                            <h2 class="widget-title"><?php esc_html_e('Enter Keywords Here', 'training-institute-academy'); ?></h2>
                                            <?php get_search_form(); ?>
                                        </div>
                                    <?php endif; 
                                    
                                else :
                                    // Display dynamic sidebar widget if assigned
                                    dynamic_sidebar('training-institute-academy-footer-widget-' . $i);
                                endif;
                                ?>
                                
                            </div>
                            
                        <?php endfor; ?>

                    </div>
                </div>
            </div>
        <?php endif; ?> 

    <?php
    }

endif;

add_action( 'training_institute_academy_footer_content_action', 'training_institute_academy_footer_content_widget', 10 );

if( !function_exists('training_institute_academy_footer_content_info') ):

    /**
     * Footer Copyright Area
    **/
    function training_institute_academy_footer_content_info(){

        $training_institute_academy_default = training_institute_academy_get_default_theme_options(); ?>
        <div class="site-info">
            <div class="wrapper">
                <div class="column-row">
                    <div class="column column-9">
                        <div class="footer-credits">
                            <div class="footer-copyright">
                                <?php
                                $training_institute_academy_footer_copyright_text = wp_kses_post( get_theme_mod( 'training_institute_academy_footer_copyright_text', $training_institute_academy_default['training_institute_academy_footer_copyright_text'] ) );
                                    echo esc_html( $training_institute_academy_footer_copyright_text );
                                    echo '<br>';
                                    echo esc_html__('Theme: ', 'training-institute-academy') . '<a href="' . esc_url('https://www.omegathemes.com/products/free-training-institute-wordpress-theme') . '" title="' . esc_attr__('Training Institute Academy', 'training-institute-academy') . '" target="_blank"><span>' . esc_html__('Training Institute Academy', 'training-institute-academy') . '</span></a>' . esc_html__(' By ', 'training-institute-academy') . '  <span>' . esc_html__('OMEGA ', 'training-institute-academy') . '</span>';
                                    echo esc_html__('Powered by ', 'training-institute-academy') . '<a href="' . esc_url('https://wordpress.org') . '" title="' . esc_attr__('WordPress', 'training-institute-academy') . '" target="_blank"><span>' . esc_html__('WordPress.', 'training-institute-academy') . '</span></a>';
                                ?>
                            </div>
                        </div>
                    </div>
                    <div class="column column-3 align-text-right">
                        <a class="to-the-top" href="#site-header">
                            <span class="to-the-top-long">
                                <?php if ( get_theme_mod('training_institute_academy_enable_to_the_top', true) == true ) : ?>
                                    <?php
                                    $training_institute_academy_to_the_top_text = get_theme_mod( 'training_institute_academy_to_the_top_text', __( 'To the Top', 'training-institute-academy' ) );
                                    printf( 
                                        wp_kses( 
                                            /* translators: %s is the arrow icon markup */
                                            '%s %s', 
                                            array( 'span' => array( 'class' => array(), 'aria-hidden' => array() ) ) 
                                        ), 
                                        esc_html( $training_institute_academy_to_the_top_text ),
                                        '<span class="arrow" aria-hidden="true">&uarr;</span>' 
                                    );
                                    ?>
                                <?php endif; ?>
                            </span>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    <?php
    }

endif;

add_action( 'training_institute_academy_footer_content_action','training_institute_academy_footer_content_info',20 );


if( !function_exists( 'training_institute_academy_main_slider' ) ) :

    function training_institute_academy_main_slider(){

        $training_institute_academy_defaults = training_institute_academy_get_default_theme_options();
        $training_institute_academy_header_slider = get_theme_mod( 'training_institute_academy_header_slider', $training_institute_academy_defaults['training_institute_academy_header_slider'] );

        $training_institute_academy_banner_background_image = esc_url( get_theme_mod( 'training_institute_academy_banner_background_image',
        $training_institute_academy_defaults['training_institute_academy_banner_background_image'] ) );

        $training_institute_academy_slider_section_short_title = esc_html( get_theme_mod( 'training_institute_academy_slider_section_short_title',
        $training_institute_academy_defaults['training_institute_academy_slider_section_short_title'] ) );

        $training_institute_academy_slider_section_button = esc_html( get_theme_mod( 'training_institute_academy_slider_section_button',
        $training_institute_academy_defaults['training_institute_academy_slider_section_button'] ) );

        $training_institute_academy_slider_section_button_url = esc_url( get_theme_mod( 'training_institute_academy_slider_section_button_url',
        $training_institute_academy_defaults['training_institute_academy_slider_section_button_url'] ) );

        $training_institute_academy_header_banner_cat = get_theme_mod( 'training_institute_academy_header_banner_cat' );

        if( $training_institute_academy_header_slider ){ $rtl = '';
            if( is_rtl() ){
                $rtl = 'dir="rtl"';
            }

            $training_institute_academy_banner_query = new WP_Query( array('post_type' => 'post', 'posts_per_page' => 4,'post__not_in' => get_option("sticky_posts"), 'category_name' => esc_html( $training_institute_academy_header_banner_cat ) ) );

            if( $training_institute_academy_banner_query->have_posts() ): ?>

                <div id="site-content" class="main-banner">
                    <div class="slider-box" style="background: url(<?php echo esc_url( $training_institute_academy_banner_background_image ); ?>);">
                        <div class="wrapper">
                            <div class="main-slider">
                                <div class="swiper-container theme-main-carousel swiper-container" <?php echo $rtl; ?>>
                                    <div class="swiper-wrapper">
                                        <?php
                                        while( $training_institute_academy_banner_query->have_posts() ):
                                        $training_institute_academy_banner_query->the_post();
                                        $training_institute_academy_featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
                                        $training_institute_academy_default_image = get_template_directory_uri() . '/inc/homepage-setup/assets/homepage-setup-images/slider-img1.png'; // Replace with the actual path to your default image
                                        $training_institute_academy_featured_image = isset( $training_institute_academy_featured_image[0] ) ? $training_institute_academy_featured_image[0] : $training_institute_academy_default_image;?>
                                            <div class="swiper-slide main-carousel-item">                                 
                                                <div class="slider-main">
                                                    <div class="left-box">
                                                        <div class="slide-heading-main">
                                                            <div class="main-carousel-caption">
                                                                <div class="post-content">
                                                                    <header class="entry-header">
                                                                        <?php if( $training_institute_academy_slider_section_short_title ){ ?>
                                                                            <h3><?php echo esc_html( $training_institute_academy_slider_section_short_title ); ?></h3>
                                                                        <?php } ?>
                                                                        <h2 class="slider-heading">
                                                                            <a href="<?php the_permalink(); ?>" rel="bookmark"><span><?php the_title(); ?></span></a>
                                                                        </h2>
                                                                    </header>

                                                                    <a href="<?php the_permalink(); ?>" class="btn-fancy btn-fancy-primary" tabindex="0">
                                                                        <?php echo esc_html__('join for free', 'training-institute-academy'); ?>
                                                                    </a>
                                                                    <?php if( $training_institute_academy_slider_section_button || $training_institute_academy_slider_section_button_url ){ ?>
                                                                        <a href="<?php echo esc_url( $training_institute_academy_slider_section_button_url ); ?>" class="slide-btn-2 btn-fancy btn-fancy-primary" tabindex="0">
                                                                            <?php echo esc_html( $training_institute_academy_slider_section_button ); ?>
                                                                        </a>
                                                                    <?php } ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="right-box">
                                                        <div class="image-main-box">
                                                            <div class="data-bg banner-img" data-background="<?php echo esc_url($training_institute_academy_featured_image); ?>">
                                                            </div>
                                                            <?php training_institute_academy_post_format_icon(); ?>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        <?php endwhile; ?>
                                    </div>
                                    <div class="swiper-pagination"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            <?php
            wp_reset_postdata();
            endif;
        }
    }

endif;

    if( !function_exists( 'training_institute_academy_product_section' ) ) :

    function training_institute_academy_product_section(){ 

        $training_institute_academy_default = training_institute_academy_get_default_theme_options();

        $training_institute_academy_header_about_us = get_theme_mod( 'training_institute_academy_header_about_us', 
        $training_institute_academy_default['training_institute_academy_header_about_us'] );

        $training_institute_academy_about_us_section_title = esc_html( get_theme_mod( 'training_institute_academy_about_us_section_title',
        $training_institute_academy_default['training_institute_academy_about_us_section_title'] ) );

        $training_institute_academy_about_us_section_sub_title = esc_html( get_theme_mod( 'training_institute_academy_about_us_section_sub_title',
        $training_institute_academy_default['training_institute_academy_about_us_section_sub_title'] ) );

        $training_institute_academy_about_us_section_content = esc_html( get_theme_mod( 'training_institute_academy_about_us_section_content',
        $training_institute_academy_default['training_institute_academy_about_us_section_content'] ) );

        $training_institute_academy_about_us_left_image_1 = esc_url( get_theme_mod( 'training_institute_academy_about_us_left_image_1',
        $training_institute_academy_default['training_institute_academy_about_us_left_image_1'] ) );

        $training_institute_academy_about_us_left_image_2 = esc_url( get_theme_mod( 'training_institute_academy_about_us_left_image_2',
        $training_institute_academy_default['training_institute_academy_about_us_left_image_2'] ) );

        $training_institute_academy_about_us_left_image_3 = esc_url( get_theme_mod( 'training_institute_academy_about_us_left_image_3',
        $training_institute_academy_default['training_institute_academy_about_us_left_image_3'] ) );

        $training_institute_academy_about_us_small_image = get_theme_mod( 'training_institute_academy_about_us_small_image' );

        $training_institute_academy_about_us_button_url = esc_html( get_theme_mod( 'training_institute_academy_about_us_button_url',
        $training_institute_academy_default['training_institute_academy_about_us_button_url'] ) );

        $training_institute_academy_about_us_button_title = esc_html( get_theme_mod( 'training_institute_academy_about_us_button_title',
        $training_institute_academy_default['training_institute_academy_about_us_button_title'] ) );
        
        if( $training_institute_academy_header_about_us ){ ?>
            <div class="most-read">
                <div class="wrapper">
                    <div class="most-read-div">
                        <?php if( $training_institute_academy_about_us_left_image_1  || $training_institute_academy_about_us_left_image_2 || $training_institute_academy_about_us_left_image_3 ){ ?>
                            <div class="most-sidebar-box">
                                <img src="<?php echo esc_url( $training_institute_academy_about_us_left_image_1 ); ?>" alt="<?php echo esc_attr__( 'About Us Left Image', 'training-institute-academy' ); ?>">
                                <img src="<?php echo esc_url( $training_institute_academy_about_us_left_image_2 ); ?>" class="about-2-img" alt="<?php echo esc_attr__( 'About Us Left Image', 'training-institute-academy' ); ?>">
                                <img src="<?php echo esc_url( $training_institute_academy_about_us_left_image_3 ); ?>" alt="<?php echo esc_attr__( 'About Us Left Image', 'training-institute-academy' ); ?>">
                            </div>
                        <?php } ?>
                        <div class="blog-main-box">
                            <div class="list-heading-main">
                                <h4 class="list-title">
                                    <?php if( $training_institute_academy_about_us_section_title ){ ?>
                                        <?php echo esc_html($training_institute_academy_about_us_section_title) ?>
                                    <?php } ?>
                                </h4>
                                <h3 class="list-sub-title">
                                    <?php if( $training_institute_academy_about_us_section_sub_title ){ ?>
                                        <?php echo esc_html($training_institute_academy_about_us_section_sub_title) ?>
                                    <?php } ?>
                                </h3>
                                <p class="list-content">
                                    <?php if( $training_institute_academy_about_us_section_content ){ ?>
                                        <?php echo esc_html($training_institute_academy_about_us_section_content) ?>
                                    <?php } ?>
                                </p>
                            </div>
                            <?php if( $training_institute_academy_about_us_button_url || $training_institute_academy_about_us_button_title ){ ?>
                                <div class="about-btn">
                                    <a href="<?php echo esc_url( $training_institute_academy_about_us_button_url); ?>" class="btn-fancy btn-fancy-primary" tabindex="0">
                                        <?php echo esc_html( $training_institute_academy_about_us_button_title ); ?>
                                    </a>
                                </div>
                            <?php } ?>
                        </div>
                    </div>
                </div>
            </div>
        <?php } ?>
    <?php }

endif;

if (!function_exists('training_institute_academy_post_format_icon')):

    // Post Format Icon.
    function training_institute_academy_post_format_icon() {

        $training_institute_academy_format = get_post_format(get_the_ID()) ?: 'standard';
        $training_institute_academy_icon = '';
        $training_institute_academy_title = '';
        if( $training_institute_academy_format == 'video' ){
            $training_institute_academy_icon = training_institute_academy_get_theme_svg( 'video' );
            $training_institute_academy_title = esc_html__('Video','training-institute-academy');
        }elseif( $training_institute_academy_format == 'audio' ){
            $training_institute_academy_icon = training_institute_academy_get_theme_svg( 'audio' );
            $training_institute_academy_title = esc_html__('Audio','training-institute-academy');
        }elseif( $training_institute_academy_format == 'gallery' ){
            $training_institute_academy_icon = training_institute_academy_get_theme_svg( 'gallery' );
            $training_institute_academy_title = esc_html__('Gallery','training-institute-academy');
        }elseif( $training_institute_academy_format == 'quote' ){
            $training_institute_academy_icon = training_institute_academy_get_theme_svg( 'quote' );
            $training_institute_academy_title = esc_html__('Quote','training-institute-academy');
        }elseif( $training_institute_academy_format == 'image' ){
            $training_institute_academy_icon = training_institute_academy_get_theme_svg( 'image' );
            $training_institute_academy_title = esc_html__('Image','training-institute-academy');
        } elseif( $training_institute_academy_format == 'link' ){
            $training_institute_academy_icon = training_institute_academy_get_theme_svg( 'link' );
            $training_institute_academy_title = esc_html__('Link','training-institute-academy');
        } elseif( $training_institute_academy_format == 'status' ){
            $training_institute_academy_icon = training_institute_academy_get_theme_svg( 'status' );
            $training_institute_academy_title = esc_html__('Status','training-institute-academy');
        } elseif( $training_institute_academy_format == 'aside' ){
            $training_institute_academy_icon = training_institute_academy_get_theme_svg( 'aside' );
            $training_institute_academy_title = esc_html__('Aside','training-institute-academy');
        } elseif( $training_institute_academy_format == 'chat' ){
            $training_institute_academy_icon = training_institute_academy_get_theme_svg( 'chat' );
            $training_institute_academy_title = esc_html__('Chat','training-institute-academy');
        }
        
        if (!empty($training_institute_academy_icon)) { ?>
            <div class="theme-post-format">
                <span class="post-format-icom"><?php echo training_institute_academy_svg_escape($training_institute_academy_icon); ?></span>
                <?php if( $training_institute_academy_title ){ echo '<span class="post-format-label">'.esc_html( $training_institute_academy_title ).'</span>'; } ?>
            </div>
        <?php }
    }

endif;

if ( ! function_exists( 'training_institute_academy_svg_escape' ) ):

    /**
     * Get information about the SVG icon.
     *
     * @param string $training_institute_academy_svg_name The name of the icon.
     * @param string $group The group the icon belongs to.
     * @param string $color Color code.
     */
    function training_institute_academy_svg_escape( $training_institute_academy_input ) {

        // Make sure that only our allowed tags and attributes are included.
        $training_institute_academy_svg = wp_kses(
            $training_institute_academy_input,
            array(
                'svg'     => array(
                    'class'       => true,
                    'xmlns'       => true,
                    'width'       => true,
                    'height'      => true,
                    'viewbox'     => true,
                    'aria-hidden' => true,
                    'role'        => true,
                    'focusable'   => true,
                ),
                'path'    => array(
                    'fill'      => true,
                    'fill-rule' => true,
                    'd'         => true,
                    'transform' => true,
                ),
                'polygon' => array(
                    'fill'      => true,
                    'fill-rule' => true,
                    'points'    => true,
                    'transform' => true,
                    'focusable' => true,
                ),
            )
        );

        if ( ! $training_institute_academy_svg ) {
            return false;
        }

        return $training_institute_academy_svg;

    }

endif;

if( !function_exists( 'training_institute_academy_sanitize_sidebar_option_meta' ) ) :

    // Sidebar Option Sanitize.
    function training_institute_academy_sanitize_sidebar_option_meta( $training_institute_academy_input ){

        $training_institute_academy_metabox_options = array( 'global-sidebar','left-sidebar','right-sidebar','no-sidebar' );
        if( in_array( $training_institute_academy_input,$training_institute_academy_metabox_options ) ){

            return $training_institute_academy_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'training_institute_academy_sanitize_pagination_meta' ) ) :

    // Sidebar Option Sanitize.
    function training_institute_academy_sanitize_pagination_meta( $training_institute_academy_input ){

        $training_institute_academy_metabox_options = array( 'Center','Right','Left');
        if( in_array( $training_institute_academy_input,$training_institute_academy_metabox_options ) ){

            return $training_institute_academy_input;

        }else{

            return '';

        }
    }

endif;


if( !function_exists( 'training_institute_academy_sanitize_footer_widget_title_alignment' ) ) :

    // Footer Option Sanitize.
    function training_institute_academy_sanitize_footer_widget_title_alignment( $training_institute_academy_input ){

        $training_institute_academy_metabox_options = array( 'left','center','right');
        if( in_array( $training_institute_academy_input,$training_institute_academy_metabox_options ) ){

            return $training_institute_academy_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'training_institute_academy_sanitize_page_content_alignment' ) ) :

    // Sidebar Option Sanitize.
    function training_institute_academy_sanitize_page_content_alignment( $training_institute_academy_input ){

        $training_institute_academy_metabox_options = array( 'left','center','right');
        if( in_array( $training_institute_academy_input,$training_institute_academy_metabox_options ) ){

            return $training_institute_academy_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'training_institute_academy_sanitize_pagination_type' ) ) :

    /**
     * Sanitize the pagination type setting.
     *
     * @param string $training_institute_academy_input The input value from the Customizer.
     * @return string The sanitized value.
     */
    function training_institute_academy_sanitize_pagination_type( $training_institute_academy_input ) {
        // Define valid options for the pagination type.
        $training_institute_academy_valid_options = array( 'numeric', 'newer_older' ); // Update valid options to include 'newer_older'

        // If the input is one of the valid options, return it. Otherwise, return the default option ('numeric').
        if ( in_array( $training_institute_academy_input, $training_institute_academy_valid_options, true ) ) {
            return $training_institute_academy_input;
        } else {
            // Return 'numeric' as the fallback if the input is invalid.
            return 'numeric';
        }
    }

endif;


// Sanitize the enable/disable setting for pagination
if( !function_exists('training_institute_academy_sanitize_enable_pagination') ) :
    function training_institute_academy_sanitize_enable_pagination( $training_institute_academy_input ) {
        return (bool) $training_institute_academy_input;
    }
endif;

if( !function_exists( 'training_institute_academy_sanitize_menu_transform' ) ) :

    // Sidebar Option Sanitize.
    function training_institute_academy_sanitize_menu_transform( $training_institute_academy_input ){

        $training_institute_academy_metabox_options = array( 'capitalize','uppercase','lowercase');
        if( in_array( $training_institute_academy_input,$training_institute_academy_metabox_options ) ){

            return $training_institute_academy_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'training_institute_academy_sanitize_copyright_alignment_meta' ) ) :

    // Sidebar Option Sanitize.
    function training_institute_academy_sanitize_copyright_alignment_meta( $training_institute_academy_input ){

        $training_institute_academy_metabox_options = array( 'Default','Reverse','Center');
        if( in_array( $training_institute_academy_input,$training_institute_academy_metabox_options ) ){

            return $training_institute_academy_input;

        }else{

            return '';

        }
    }

endif;

/**
 * Sidebar Layout Function
 */
function training_institute_academy_get_final_sidebar_layout() {
	$training_institute_academy_defaults       = training_institute_academy_get_default_theme_options();
	$training_institute_academy_global_layout  = get_theme_mod('training_institute_academy_global_sidebar_layout', $training_institute_academy_defaults['training_institute_academy_global_sidebar_layout']);
	$training_institute_academy_page_layout    = get_theme_mod('training_institute_academy_page_sidebar_layout', $training_institute_academy_global_layout);
	$training_institute_academy_post_layout    = get_theme_mod('training_institute_academy_post_sidebar_layout', $training_institute_academy_global_layout);
	$training_institute_academy_meta_layout    = get_post_meta(get_the_ID(), 'training_institute_academy_post_sidebar_option', true);

	if (!empty($training_institute_academy_meta_layout) && $training_institute_academy_meta_layout !== 'default') {
		return $training_institute_academy_meta_layout;
	}
	if (is_page() || (function_exists('is_shop') && is_shop())) {
		return $training_institute_academy_page_layout;
	}
	if (is_single()) {
		return $training_institute_academy_post_layout;
	}
	return $training_institute_academy_global_layout;
}