<?php
/**
 * Custom Functions.
 *
 * @package Car Rental Service
 */

if( !function_exists( 'car_rental_service_fonts_url' ) ) :

    //Google Fonts URL
    function car_rental_service_fonts_url(){

        $car_rental_service_font_families = array(
            'Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900',
        );

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

        return esc_url_raw($car_rental_service_fonts_url);
    }

endif;

if ( ! function_exists( 'car_rental_service_sub_menu_toggle_button' ) ) :

    function car_rental_service_sub_menu_toggle_button( $car_rental_service_args, $car_rental_service_item, $depth ) {

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

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

                $toggle_target_string = '.menu-item.menu-item-' . $car_rental_service_item->ID . ' > .sub-menu';

                // Add the sub menu toggle
                $car_rental_service_args->after .= '<button type="button" class="theme-aria-button submenu-toggle" data-toggle-target="' . $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', 'car-rental-service' ) . '</span>' . car_rental_service_get_theme_svg( 'chevron-down' ) . '</span></button>';

            }

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

        }elseif( $car_rental_service_args->theme_location == 'car-rental-service-primary-menu' ) {

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

                $car_rental_service_args->before = '<div class="link-icon-wrapper">';
                $car_rental_service_args->after  = car_rental_service_get_theme_svg( 'chevron-down' ) . '</div>';

            } else {

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

            }

        }

        return $car_rental_service_args;

    }

endif;

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

if ( ! function_exists( 'car_rental_service_the_theme_svg' ) ):
    
    function car_rental_service_the_theme_svg( $car_rental_service_svg_name, $car_rental_service_return = false ) {

        if( $car_rental_service_return ){

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

        }else{

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

        }
    }

endif;

if ( ! function_exists( 'car_rental_service_get_theme_svg' ) ):

    function car_rental_service_get_theme_svg( $car_rental_service_svg_name ) {

        // Make sure that only our allowed tags and attributes are included.
        $car_rental_service_svg = wp_kses(
            car_rental_service_SVG_Icons::get_svg( $car_rental_service_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 ( ! $car_rental_service_svg ) {
            return false;
        }
        return $car_rental_service_svg;

    }

endif;

if( !function_exists( 'car_rental_service_post_category_list' ) ) :

    // Post Category List.
    function car_rental_service_post_category_list( $car_rental_service_select_cat = true ){

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

        $car_rental_service_post_cat_cat_array = array();
        if( $car_rental_service_select_cat ){

            $car_rental_service_post_cat_cat_array[''] = esc_html__( '-- Select Category --','car-rental-service' );

        }

        foreach ( $car_rental_service_post_cat_lists as $car_rental_service_post_cat_list ) {

            $car_rental_service_post_cat_cat_array[$car_rental_service_post_cat_list->slug] = $car_rental_service_post_cat_list->name;

        }

        return $car_rental_service_post_cat_cat_array;
    }

endif;

if( !function_exists('car_rental_service_single_post_navigation') ):

    function car_rental_service_single_post_navigation(){

        $car_rental_service_default = car_rental_service_get_default_theme_options();
        $car_rental_service_twp_navigation_type = esc_attr( get_post_meta( get_the_ID(), 'twp_disable_ajax_load_next_post', true ) );
        $car_rental_service_current_id = '';
        $article_wrap_class = '';
        global $post;
        $car_rental_service_current_id = $post->ID;
        if( $car_rental_service_twp_navigation_type == '' || $car_rental_service_twp_navigation_type == 'global-layout' ){
            $car_rental_service_twp_navigation_type = get_theme_mod('twp_navigation_type', $car_rental_service_default['twp_navigation_type']);
        }

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

            if( $car_rental_service_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">' . car_rental_service_the_theme_svg('arrow-left',$car_rental_service_return = true ) . '</span><span class="screen-reader-text">' . esc_html__('Previous post:', 'car-rental-service') . '</span><span class="post-title">%title</span>',
                        'next_text' => '<span class="arrow" aria-hidden="true">' . car_rental_service_the_theme_svg('arrow-right',$car_rental_service_return = true ) . '</span><span class="screen-reader-text">' . esc_html__('Next post:', 'car-rental-service') . '</span><span class="post-title">%title</span>',
                    )); ?>
                </div>
                <?php

            }else{

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

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

                }
            }

        }

    }

endif;

add_action( 'car_rental_service_navigation_action','car_rental_service_single_post_navigation',30 );

if( !function_exists('car_rental_service_content_offcanvas') ):

    // Offcanvas Contents
    function car_rental_service_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', 'car-rental-service'); ?>
                            </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', 'car-rental-service'); ?>" role="navigation">
                        <ul class="primary-menu theme-menu">
                            <?php
                            if (has_nav_menu('car-rental-service-primary-menu')) {
                                wp_nav_menu(
                                    array(
                                        'container' => '',
                                        'items_wrap' => '%3$s',
                                        'theme_location' => 'car-rental-service-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 car_rental_service_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( 'car_rental_service_before_footer_content_action','car_rental_service_content_offcanvas',30 );

if( !function_exists('car_rental_service_footer_content_widget') ):

    function car_rental_service_footer_content_widget(){
        
        $car_rental_service_default = car_rental_service_get_default_theme_options();
        
        $car_rental_service_footer_column_layout = absint(get_theme_mod('car_rental_service_footer_column_layout', $car_rental_service_default['car_rental_service_footer_column_layout']));
        $car_rental_service_footer_sidebar_class = 12;
        
        if($car_rental_service_footer_column_layout == 2) {
            $car_rental_service_footer_sidebar_class = 6;
        }
        
        if($car_rental_service_footer_column_layout == 3) {
            $car_rental_service_footer_sidebar_class = 4;
        }
        ?>
        
        <?php if ( get_theme_mod('car_rental_service_display_footer', true) == true ) : ?>
            <div class="footer-widgetarea">
                <div class="wrapper">
                    <div class="column-row">
                    
                        <?php for ($i = 0; $i < $car_rental_service_footer_column_layout; $i++) : ?>
                            
                            <div class="column <?php echo 'column-' . absint($car_rental_service_footer_sidebar_class); ?> column-sm-12">
                                
                                <?php 
                                // If no widgets are assigned, display default widgets
                                if ( ! is_active_sidebar( 'car-rental-service-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', 'car-rental-service' ); ?>" 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('The Car Rental Service WordPress Theme is a user-friendly solution designed for car rental companies, vehicle hire agencies, and travel businesses. It provides a sleek, responsive, and modern design, making it easy to showcase rental cars, luxury car rental services, and corporate car hire options. Built for seamless online car booking, it allows businesses to offer short-term car rental, long-term car rental, and self-drive car rental with just a few clicks. Whether you\'re running an airport car rental, SUV rental, or budget car rental service, this theme is optimized to highlight car rental deals, car rental discounts, and special weekend car offers.', 'car-rental-service'); ?>
                                                </p>
                                            </div>
                                        </div>

                                    <?php elseif ($i === 1) : ?>
                                        <div id="pages-2" class="widget widget_pages">
                                            <h2 class="widget-title"><?php esc_html_e('Calendar', 'car-rental-service'); ?></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', 'car-rental-service'); ?></h2>
                                            <?php get_search_form(); ?>
                                        </div>
                                    <?php endif; 
                                    
                                else :
                                    // Display dynamic sidebar widget if assigned
                                    dynamic_sidebar('car-rental-service-footer-widget-' . $i);
                                endif;
                                ?>
                                
                            </div>
                            
                        <?php endfor; ?>

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

    <?php
    }

endif;

add_action( 'car_rental_service_footer_content_action', 'car_rental_service_footer_content_widget', 10 );

if( !function_exists('car_rental_service_footer_content_info') ):

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

        $car_rental_service_default = car_rental_service_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
                                $car_rental_service_footer_copyright_text = wp_kses_post( get_theme_mod( 'car_rental_service_footer_copyright_text', $car_rental_service_default['car_rental_service_footer_copyright_text'] ) );
                                    echo esc_html( $car_rental_service_footer_copyright_text );
                                    echo '<br>';
                                    echo esc_html__('Theme: ', 'car-rental-service') . '<a href="' . esc_url('https://www.omegathemes.com/products/free-car-rental-wordpress-theme') . '" title="' . esc_attr__('Car Rental Service', 'car-rental-service') . '" target="_blank"><span>' . esc_html__('Car Rental Service ', 'car-rental-service') . '</span></a>' . esc_html__(' By ', 'car-rental-service') . '  <span>' . esc_html__('OMEGA ', 'car-rental-service') . '</span>';

                                    echo esc_html__('Powered by ', 'car-rental-service') . '<a href="' . esc_url('https://wordpress.org') . '" title="' . esc_attr__('WordPress', 'car-rental-service') . '" target="_blank"><span>' . esc_html__('WordPress.', 'car-rental-service') . '</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('car_rental_service_enable_to_the_top', true) == true ) : ?>
                                    <?php
                                    $car_rental_service_to_the_top_text = get_theme_mod( 'car_rental_service_to_the_top_text', __( 'To the Top', 'car-rental-service' ) );
                                    printf( 
                                        wp_kses( 
                                            /* translators: %s is the arrow icon markup */
                                            '%s %s', 
                                            array( 'span' => array( 'class' => array(), 'aria-hidden' => array() ) ) 
                                        ), 
                                        esc_html( $car_rental_service_to_the_top_text ),
                                        '<span class="arrow" aria-hidden="true">&uarr;</span>' 
                                    );
                                    ?>
                                <?php endif; ?>
                            </span>
                        </a>

                    </div>
                </div>
            </div>
        </div>

    <?php
    }

endif;

add_action( 'car_rental_service_footer_content_action','car_rental_service_footer_content_info',20 );


if( !function_exists( 'car_rental_service_main_slider' ) ) :

    function car_rental_service_main_slider(){

        $car_rental_service_defaults = car_rental_service_get_default_theme_options();
        $car_rental_service_header_banner = get_theme_mod( 'car_rental_service_header_banner', $car_rental_service_defaults['car_rental_service_header_banner'] );
        $car_rental_service_header_banner_cat = get_theme_mod( 'car_rental_service_header_banner_cat' );

        if( $car_rental_service_header_banner ){

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

            $car_rental_service_banner_query = new WP_Query( array('post_type' => 'post', 'posts_per_page' => 4,'post__not_in' => get_option("sticky_posts"), 'category_name' => esc_html( $car_rental_service_header_banner_cat ) ) );
            $car_rental_service_slider_section_short_title = get_theme_mod( 'car_rental_service_slider_section_short_title', 
            $car_rental_service_defaults['car_rental_service_slider_section_short_title'] );
            $car_rental_service_banner_background_image = get_theme_mod( 'car_rental_service_banner_background_image', 
            $car_rental_service_defaults['car_rental_service_banner_background_image'] );

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

            <div class="theme-custom-block theme-banner-block" style="background: url(<?php echo esc_url( $car_rental_service_banner_background_image ); ?>);">
                <div class="slider-box">
                    <div class="wrapper">
                        <div class="swiper-container theme-main-carousel swiper-container" <?php echo $car_rental_service_rtl; ?>>
                            <div class="swiper-wrapper">
                              <?php
                              while( $car_rental_service_banner_query->have_posts() ):
                                $car_rental_service_banner_query->the_post();
                                $car_rental_service_featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
                                $car_rental_service_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
                                $car_rental_service_featured_image = isset( $car_rental_service_featured_image[0] ) ? $car_rental_service_featured_image[0] : $car_rental_service_default_image;?>

                                <div class="swiper-slide main-carousel-item">
                                    <div class="theme-article-post">
                                        <div class="main-carousel-caption">
                                            <div class="post-content ">
                                                <?php if( $car_rental_service_slider_section_short_title ){ ?>
                                                    <h6><?php echo esc_html( $car_rental_service_slider_section_short_title ); ?></h6>
                                                <?php } ?>
                                                <header class="entry-header">
                                                    <h2 class="entry-title entry-title-big">
                                                        <a href="<?php the_permalink(); ?>" rel="bookmark"><span><?php the_title(); ?></span></a>
                                                    </h2>
                                                </header>
                                                <div class="entry-content">
                                                    <?php
                                                        if (has_excerpt()) {

                                                            the_excerpt();

                                                        } else {

                                                        echo esc_html(wp_trim_words(get_the_content(), 25, '...'));

                                                    } ?>
                                                </div>

                                                <a href="<?php the_permalink(); ?>" class="btn-fancy btn-fancy-primary" tabindex="0">
                                                  <?php echo esc_html__('Rent Now', 'car-rental-service'); ?>
                                                </a>

                                            </div>
                                        </div>
                                        <div class="entry-thumbnail">
                                            <div class="data-bg data-bg-large" data-background="<?php echo esc_url($car_rental_service_featured_image); ?>">
                                                <a href="<?php the_permalink(); ?>" class="theme-image-responsive" tabindex="0"></a>
                                            </div>
                                          <?php car_rental_service_post_format_icon(); ?>
                                        </div>
                                    </div>
                                </div>

                              <?php endwhile; ?>

                            </div>

                            <div class="swiper-pagination"></div>                  
                        </div>
                    </div>
                </div>
            </div>

          <?php
          wp_reset_postdata();
          endif;

        }

    }

endif;

if (!function_exists('car_rental_service_post_format_icon')):

    // Post Format Icon.
    function car_rental_service_post_format_icon() {

        $car_rental_service_format = get_post_format(get_the_ID()) ?: 'standard';
        $car_rental_service_icon = '';
        $car_rental_service_title = '';
        if( $car_rental_service_format == 'video' ){
            $car_rental_service_icon = car_rental_service_get_theme_svg( 'video' );
            $car_rental_service_title = esc_html__('Video','car-rental-service');
        }elseif( $car_rental_service_format == 'audio' ){
            $car_rental_service_icon = car_rental_service_get_theme_svg( 'audio' );
            $car_rental_service_title = esc_html__('Audio','car-rental-service');
        }elseif( $car_rental_service_format == 'gallery' ){
            $car_rental_service_icon = car_rental_service_get_theme_svg( 'gallery' );
            $car_rental_service_title = esc_html__('Gallery','car-rental-service');
        }elseif( $car_rental_service_format == 'quote' ){
            $car_rental_service_icon = car_rental_service_get_theme_svg( 'quote' );
            $car_rental_service_title = esc_html__('Quote','car-rental-service');
        }elseif( $car_rental_service_format == 'image' ){
            $car_rental_service_icon = car_rental_service_get_theme_svg( 'image' );
            $car_rental_service_title = esc_html__('Image','car-rental-service');
        } elseif( $car_rental_service_format == 'link' ){
            $car_rental_service_icon = car_rental_service_get_theme_svg( 'link' );
            $car_rental_service_title = esc_html__('Link','car-rental-service');
        } elseif( $car_rental_service_format == 'status' ){
            $car_rental_service_icon = car_rental_service_get_theme_svg( 'status' );
            $car_rental_service_title = esc_html__('Status','car-rental-service');
        } elseif( $car_rental_service_format == 'aside' ){
            $car_rental_service_icon = car_rental_service_get_theme_svg( 'aside' );
            $car_rental_service_title = esc_html__('Aside','car-rental-service');
        } elseif( $car_rental_service_format == 'chat' ){
            $car_rental_service_icon = car_rental_service_get_theme_svg( 'chat' );
            $car_rental_service_title = esc_html__('Chat','car-rental-service');
        }
        
        if (!empty($car_rental_service_icon)) { ?>
            <div class="theme-post-format">
                <span class="post-format-icom"><?php echo car_rental_service_svg_escape($car_rental_service_icon); ?></span>
                <?php if( $car_rental_service_title ){ echo '<span class="post-format-label">'.esc_html( $car_rental_service_title ).'</span>'; } ?>
            </div>
        <?php }
    }

endif;

if ( ! function_exists( 'car_rental_service_svg_escape' ) ):

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

        // Make sure that only our allowed tags and attributes are included.
        $car_rental_service_svg = wp_kses(
            $car_rental_service_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 ( ! $car_rental_service_svg ) {
            return false;
        }

        return $car_rental_service_svg;

    }

endif;

if( !function_exists( 'car_rental_service_sanitize_sidebar_option_meta' ) ) :

    // Sidebar Option Sanitize.
    function car_rental_service_sanitize_sidebar_option_meta( $car_rental_service_input ){

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

            return $car_rental_service_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'car_rental_service_sanitize_pagination_meta' ) ) :

    // Sidebar Option Sanitize.
    function car_rental_service_sanitize_pagination_meta( $car_rental_service_input ){

        $car_rental_service_metabox_options = array( 'Center','Right','Left');
        if( in_array( $car_rental_service_input,$car_rental_service_metabox_options ) ){

            return $car_rental_service_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'car_rental_service_aboutus_slider' ) ) :

    function car_rental_service_aboutus_slider(){

        $car_rental_service_defaults = car_rental_service_get_default_theme_options();

        $car_rental_service_services = get_theme_mod( 'car_rental_service_services', $car_rental_service_defaults['car_rental_service_services'] );

        $car_rental_service_services_section_title = get_theme_mod( 'car_rental_service_services_section_title', 
        $car_rental_service_defaults['car_rental_service_services_section_title'] );

        $car_rental_service_services_section_text = get_theme_mod( 'car_rental_service_services_section_text', 
        $car_rental_service_defaults['car_rental_service_services_section_text'] );

        $car_rental_service_services_section_short_title = get_theme_mod( 'car_rental_service_services_section_short_title', 
        $car_rental_service_defaults['car_rental_service_services_section_short_title'] );

        $car_rental_service_services_section_image = get_theme_mod( 'car_rental_service_services_section_image', 
        $car_rental_service_defaults['car_rental_service_services_section_image'] );

        
        if( $car_rental_service_services ){ ?>

        <div class="theme-custom-block theme-services-block">
            <div class="wrapper">
                <div class="aboutus-box">
                    <div class="progress-box">
                        <?php if( $car_rental_service_services_section_short_title ){ ?>
                            <h6><?php echo esc_html( $car_rental_service_services_section_short_title ); ?></h6>
                        <?php } ?>

                        <?php if( $car_rental_service_services_section_title ){ ?>
                            <h2><?php echo esc_html( $car_rental_service_services_section_title ); ?></h2>
                        <?php } ?>

                        <div class="progress-bar-box">

                            <?php if( $car_rental_service_services_section_text ){ ?>
                                <p><?php echo esc_html( $car_rental_service_services_section_text ); ?></p>
                            <?php } ?>

                            <?php for ($car_rental_service_i=1; $car_rental_service_i <= 3; $car_rental_service_i++) {

                                // Set default values for name and count
                                $car_rental_service_default_name = 'Car Rentals';
                                $car_rental_service_default_count = '50%';

                                // Get theme mod with default fallback values
                                $car_rental_service_services_section_progress_name = esc_html( get_theme_mod( 'car_rental_service_services_section_progress_name'.$car_rental_service_i, $car_rental_service_default_name ) );

                                $car_rental_service_services_section_progress_count = esc_html( get_theme_mod( 'car_rental_service_services_section_progress_count'.$car_rental_service_i, $car_rental_service_default_count ) );
                                
                                
                                ?>

                                <?php if( $car_rental_service_services_section_progress_name ){ ?>
                                    <h3 class="progress-title"><?php echo esc_html( $car_rental_service_services_section_progress_name ); ?><span class="progressbar-value"><?php echo esc_html( $car_rental_service_services_section_progress_count ); ?></span></h3>
                                <?php } ?>
                                <?php if( $car_rental_service_services_section_progress_count ){ ?>
                                    <div class="progress pink">
                                        <div class="progress-bar" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width:<?php echo esc_attr( $car_rental_service_services_section_progress_count ); ?>;  background:var(--global-colorr);"></div>
                                    </div>
                                <?php } ?>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="about-image-box">
                        <?php if( $car_rental_service_services_section_image ){ ?>
                            <img src="<?php echo esc_url( $car_rental_service_services_section_image ); ?>">
                        <?php } ?>
                    </div>
                </div>
            </div>
        </div>

        <?php } ?>
            
    <?php }


endif;

if( !function_exists( 'car_rental_service_sanitize_menu_transform' ) ) :

    // Sidebar Option Sanitize.
    function car_rental_service_sanitize_menu_transform( $car_rental_service_input ){

        $car_rental_service_metabox_options = array( 'capitalize','uppercase','lowercase');
        if( in_array( $car_rental_service_input,$car_rental_service_metabox_options ) ){

            return $car_rental_service_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'car_rental_service_sanitize_page_content_alignment' ) ) :

    // Sidebar Option Sanitize.
    function car_rental_service_sanitize_page_content_alignment( $car_rental_service_input ){

        $car_rental_service_metabox_options = array( 'left','center','right');
        if( in_array( $car_rental_service_input,$car_rental_service_metabox_options ) ){

            return $car_rental_service_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'car_rental_service_sanitize_footer_widget_title_alignment' ) ) :

    // Footer Option Sanitize.
    function car_rental_service_sanitize_footer_widget_title_alignment( $car_rental_service_input ){

        $car_rental_service_metabox_options = array( 'left','center','right');
        if( in_array( $car_rental_service_input,$car_rental_service_metabox_options ) ){

            return $car_rental_service_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'car_rental_service_sanitize_pagination_type' ) ) :

    /**
     * Sanitize the pagination type setting.
     *
     * @param string $car_rental_service_input The input value from the Customizer.
     * @return string The sanitized value.
     */
    function car_rental_service_sanitize_pagination_type( $car_rental_service_input ) {
        // Define valid options for the pagination type.
        $car_rental_service_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( $car_rental_service_input, $car_rental_service_valid_options, true ) ) {
            return $car_rental_service_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('car_rental_service_sanitize_enable_pagination') ) :
    function car_rental_service_sanitize_enable_pagination( $car_rental_service_input ) {
        return (bool) $car_rental_service_input;
    }
endif;

if( !function_exists( 'car_rental_service_sanitize_copyright_alignment_meta' ) ) :

    // Sidebar Option Sanitize.
    function car_rental_service_sanitize_copyright_alignment_meta( $car_rental_service_input ){

        $car_rental_service_metabox_options = array( 'Default','Reverse','Center');
        if( in_array( $car_rental_service_input,$car_rental_service_metabox_options ) ){

            return $car_rental_service_input;

        }else{

            return '';

        }
    }

endif;

/**
 * Sidebar Layout Function
 */
function car_rental_service_get_final_sidebar_layout() {
	$car_rental_service_defaults       = car_rental_service_get_default_theme_options();
	$car_rental_service_global_layout  = get_theme_mod('car_rental_service_global_sidebar_layout', $car_rental_service_defaults['car_rental_service_global_sidebar_layout']);
	$car_rental_service_page_layout    = get_theme_mod('car_rental_service_page_sidebar_layout', $car_rental_service_global_layout);
	$car_rental_service_post_layout    = get_theme_mod('car_rental_service_post_sidebar_layout', $car_rental_service_global_layout);
	$car_rental_service_meta_layout    = get_post_meta(get_the_ID(), 'car_rental_service_post_sidebar_option', true);

	if (!empty($car_rental_service_meta_layout) && $car_rental_service_meta_layout !== 'default') {
		return $car_rental_service_meta_layout;
	}
	if (is_page() || (function_exists('is_shop') && is_shop())) {
		return $car_rental_service_page_layout;
	}
	if (is_single()) {
		return $car_rental_service_post_layout;
	}
	return $car_rental_service_global_layout;
}