<?php
/**
 * Custom Functions.
 *
 * @package Beauty Parlour Salon
 */

if( !function_exists( 'beauty_parlour_salon_fonts_url' ) ) :

    //Google Fonts URL
    function beauty_parlour_salon_fonts_url(){

        $beauty_parlour_salon_font_families = array(
            'Cormorant:ital,wght@0,300..700;1,300..700',
            'Montserrat:ital,wght@0,100..900;1,100..900',
        );

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

        return esc_url_raw($beauty_parlour_salon_fonts_url);
    }

endif;

if ( ! function_exists( 'beauty_parlour_salon_sub_menu_toggle_button' ) ) :

    function beauty_parlour_salon_sub_menu_toggle_button( $beauty_parlour_salon_args, $beauty_parlour_salon_item, $depth ) {

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

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

                $beauty_parlour_salon_toggle_target_string = '.menu-item.menu-item-' . $beauty_parlour_salon_item->ID . ' > .sub-menu';

                // Add the sub menu toggle
                $beauty_parlour_salon_args->after .= '<button type="button" class="theme-aria-button submenu-toggle" data-toggle-target="' . $beauty_parlour_salon_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', 'beauty-parlour-salon' ) . '</span>' . beauty_parlour_salon_get_theme_svg( 'chevron-down' ) . '</span></button>';

            }

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

        }elseif( $beauty_parlour_salon_args->theme_location == 'beauty-parlour-salon-primary-menu' ) {

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

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

            } else {

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

            }

        }

        return $beauty_parlour_salon_args;

    }

endif;

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

if ( ! function_exists( 'beauty_parlour_salon_the_theme_svg' ) ):
    
    function beauty_parlour_salon_the_theme_svg( $beauty_parlour_salon_svg_name, $beauty_parlour_salon_return = false ) {

        if( $beauty_parlour_salon_return ){

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

        }else{

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

        }
    }

endif;

if ( ! function_exists( 'beauty_parlour_salon_get_theme_svg' ) ):

    function beauty_parlour_salon_get_theme_svg( $beauty_parlour_salon_svg_name ) {

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

    }

endif;

if( !function_exists( 'beauty_parlour_salon_post_category_list' ) ) :

    // Post Category List.
    function beauty_parlour_salon_post_category_list( $beauty_parlour_salon_select_cat = true ){

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

        $beauty_parlour_salon_post_cat_cat_array = array();
        if( $beauty_parlour_salon_select_cat ){

            $beauty_parlour_salon_post_cat_cat_array[''] = esc_html__( '-- Select Category --','beauty-parlour-salon' );

        }

        foreach ( $beauty_parlour_salon_post_cat_lists as $beauty_parlour_salon_post_cat_list ) {

            $beauty_parlour_salon_post_cat_cat_array[$beauty_parlour_salon_post_cat_list->slug] = $beauty_parlour_salon_post_cat_list->name;

        }

        return $beauty_parlour_salon_post_cat_cat_array;
    }

endif;

if( !function_exists('beauty_parlour_salon_single_post_navigation') ):

    function beauty_parlour_salon_single_post_navigation(){

        $beauty_parlour_salon_default = beauty_parlour_salon_get_default_theme_options();
        $beauty_parlour_salon_twp_navigation_type = esc_attr( get_post_meta( get_the_ID(), 'beauty_parlour_salon_twp_disable_ajax_load_next_post', true ) );
        $beauty_parlour_salon_current_id = '';
        $article_wrap_class = '';
        global $post;
        $beauty_parlour_salon_current_id = $post->ID;
        if( $beauty_parlour_salon_twp_navigation_type == '' || $beauty_parlour_salon_twp_navigation_type == 'global-layout' ){
            $beauty_parlour_salon_twp_navigation_type = get_theme_mod('beauty_parlour_salon_twp_navigation_type', $beauty_parlour_salon_default['beauty_parlour_salon_twp_navigation_type']);
        }

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

            if( $beauty_parlour_salon_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">' . beauty_parlour_salon_the_theme_svg('arrow-left',$beauty_parlour_salon_return = true ) . '</span><span class="screen-reader-text">' . esc_html__('Previous post:', 'beauty-parlour-salon') . '</span><span class="post-title">%title</span>',
                        'next_text' => '<span class="arrow" aria-hidden="true">' . beauty_parlour_salon_the_theme_svg('arrow-right',$beauty_parlour_salon_return = true ) . '</span><span class="screen-reader-text">' . esc_html__('Next post:', 'beauty-parlour-salon') . '</span><span class="post-title">%title</span>',
                    )); ?>
                </div>
                <?php

            }else{

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

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

                }
            }

        }

    }

endif;

add_action( 'beauty_parlour_salon_navigation_action','beauty_parlour_salon_single_post_navigation',30 );

if( !function_exists('beauty_parlour_salon_content_offcanvas') ):

    // Offcanvas Contents
    function beauty_parlour_salon_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', 'beauty-parlour-salon'); ?>
                            </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', 'beauty-parlour-salon'); ?>" role="navigation">
                        <ul class="primary-menu theme-menu">
                            <?php
                            if (has_nav_menu('beauty-parlour-salon-primary-menu')) {
                                wp_nav_menu(
                                    array(
                                        'container' => '',
                                        'items_wrap' => '%3$s',
                                        'theme_location' => 'beauty-parlour-salon-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 Beauty_Parlour_Salon_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( 'beauty_parlour_salon_before_footer_content_action','beauty_parlour_salon_content_offcanvas',30 );

if( !function_exists('beauty_parlour_salon_footer_content_widget') ):

    function beauty_parlour_salon_footer_content_widget(){
        
        $beauty_parlour_salon_default = beauty_parlour_salon_get_default_theme_options();
        
        $beauty_parlour_salon_footer_column_layout = absint(get_theme_mod('beauty_parlour_salon_footer_column_layout', $beauty_parlour_salon_default['beauty_parlour_salon_footer_column_layout']));
        $beauty_parlour_salon_footer_sidebar_class = 12;
        
        if($beauty_parlour_salon_footer_column_layout == 2) {
            $beauty_parlour_salon_footer_sidebar_class = 6;
        }
        
        if($beauty_parlour_salon_footer_column_layout == 3) {
            $beauty_parlour_salon_footer_sidebar_class = 4;
        }
        ?>
        
        <?php if ( get_theme_mod('beauty_parlour_salon_display_footer', true) == true ) : ?>
            <div class="footer-widgetarea">
                <div class="wrapper">
                    <div class="column-row">
                    
                        <?php for ($i = 0; $i < $beauty_parlour_salon_footer_column_layout; $i++) : ?>
                            
                            <div class="column <?php echo 'column-' . absint($beauty_parlour_salon_footer_sidebar_class); ?> column-sm-12">
                                
                                <?php 
                                // If no widgets are assigned, display default widgets
                                if ( ! is_active_sidebar( 'beauty-parlour-salon-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', 'beauty-parlour-salon' ); ?>" 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 Beauty Parlour Salon WordPress Theme is a sleek, professional, and visually stunning website template designed for modern beauty parlours, hair salons, and makeup studios. It’s ideal for showcasing services like bridal makeup, hair styling, nail art, skin treatments, waxing services, facial services, and more. Built for beauty experts, makeup artists, and grooming professionals, this theme helps establish a strong digital presence with a focus on elegance, user-friendliness, and performance.', 'beauty-parlour-salon'); ?>
                                                </p>
                                            </div>
                                        </div>

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

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

    <?php
    }

endif;

add_action( 'beauty_parlour_salon_footer_content_action', 'beauty_parlour_salon_footer_content_widget', 10 );

if( !function_exists('beauty_parlour_salon_footer_content_info') ):

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

        $beauty_parlour_salon_default = beauty_parlour_salon_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
                                    $beauty_parlour_salon_footer_copyright_text = wp_kses_post( get_theme_mod( 'beauty_parlour_salon_footer_copyright_text', $beauty_parlour_salon_default['beauty_parlour_salon_footer_copyright_text'] ) );
                                    echo esc_html( $beauty_parlour_salon_footer_copyright_text );
                                    echo '<br>';

                                    echo esc_html__('Theme: ', 'beauty-parlour-salon') . '<a href="' . esc_url('https://www.omegathemes.com/products/beauty-parlour-salon') . '" title="' . esc_attr__('Beauty Parlour Salon', 'beauty-parlour-salon') . '" target="_blank"><span>' . esc_html__('Beauty Parlour Salon ', 'beauty-parlour-salon') . '</span></a>' . esc_html__(' By ', 'beauty-parlour-salon') . '  <span>' . esc_html__('OMEGA ', 'beauty-parlour-salon') . '</span>';
                                    echo esc_html__('Powered by ', 'beauty-parlour-salon') . '<a href="' . esc_url('https://wordpress.org') . '" title="' . esc_attr__('WordPress', 'beauty-parlour-salon') . '" target="_blank"><span>' . esc_html__('WordPress.', 'beauty-parlour-salon') . '</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('beauty_parlour_salon_enable_to_the_top', true) == true ) : ?>
                                    <?php
                                    $beauty_parlour_salon_to_the_top_text = get_theme_mod( 'beauty_parlour_salon_to_the_top_text', __( 'To the Top', 'beauty-parlour-salon' ) );
                                    printf( 
                                        wp_kses( 
                                            /* translators: %s is the arrow icon markup */
                                            '%s %s', 
                                            array( 'span' => array( 'class' => array(), 'aria-hidden' => array() ) ) 
                                        ), 
                                        esc_html( $beauty_parlour_salon_to_the_top_text ),
                                        '<span class="arrow" aria-hidden="true">&uarr;</span>' 
                                    );
                                    ?>
                                <?php endif; ?>
                            </span>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    <?php
    }

endif;

add_action( 'beauty_parlour_salon_footer_content_action','beauty_parlour_salon_footer_content_info',20 );


if( !function_exists( 'beauty_parlour_salon_main_slider' ) ) :

    function beauty_parlour_salon_main_slider() {
        $output = '';
        $beauty_parlour_salon_defaults = beauty_parlour_salon_get_default_theme_options();
        $beauty_parlour_salon_header_slider = get_theme_mod( 'beauty_parlour_salon_header_slider', $beauty_parlour_salon_defaults['beauty_parlour_salon_header_slider'] );

        $beauty_parlour_salon_slider_section_short_title = esc_html( get_theme_mod( 'beauty_parlour_salon_slider_section_short_title',
        $beauty_parlour_salon_defaults['beauty_parlour_salon_slider_section_short_title'] ) );

        $beauty_parlour_salon_slider_content_bg_image = esc_url( get_theme_mod( 'beauty_parlour_salon_slider_content_bg_image',
        $beauty_parlour_salon_defaults['beauty_parlour_salon_slider_content_bg_image'] ) );

        $beauty_parlour_salon_header_banner_cat = get_theme_mod( 'beauty_parlour_salon_header_banner_cat' );

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

        ob_start();  // Start output buffering
         if ( $beauty_parlour_salon_header_slider ) {
        ?>

        <div id="site-content" class="main-banner">
            <div class="slider-box">
                <div class="main-slider">
                    <div class="swiper-container theme-main-carousel" <?php echo is_rtl() ? 'dir="rtl"' : ''; ?>>
                        <div class="swiper-wrapper">
                            <?php while ( $banner_query->have_posts() ) : $banner_query->the_post();
                                $beauty_parlour_salon_featured_image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' )[0] ?? get_template_directory_uri() . '/assets/images/default.png';
                                ?>
                                <div class="swiper-slide main-carousel-item">
                                    <div class="slider-main">
                                        <div class="slider-image">
                                            <div class="data-bg banner-img" data-background="<?php echo esc_url( $beauty_parlour_salon_featured_image ); ?>">
                                                <a href="<?php the_permalink(); ?>" class="theme-image-responsive"></a>
                                            </div>
                                            <?php beauty_parlour_salon_post_format_icon(); ?>
                                        </div>
                                        <div class="slide-heading-main">
                                            <div class="content-image">
                                                <?php if( $beauty_parlour_salon_slider_content_bg_image ){ ?>
                                                    <img class="slider-images" src="<?php echo esc_url( $beauty_parlour_salon_slider_content_bg_image ); ?>">
                                                <?php } ?>
                                            </div>
                                            <div class="main-carousel-caption">
                                                <div class="post-content">
                                                    <header class="entry-header">
                                                        <?php if( $beauty_parlour_salon_slider_section_short_title ){ ?>
                                                            <h6 class="slider-short"><?php echo esc_html( $beauty_parlour_salon_slider_section_short_title ); ?></h6>
                                                        <?php } ?>
                                                        <h2 class="slider-heading">
                                                            <a href="<?php the_permalink(); ?>" rel="bookmark"><span><?php echo esc_html( get_the_title() ); ?></span></a>
                                                        </h2>
                                                    </header>
                                                    <div class="slide-btn">
                                                        <a href="<?php the_permalink(); ?>" class="btn-fancy btn-fancy-primary">
                                                            <?php echo esc_html__( 'Know More', 'beauty-parlour-salon' ); ?>
                                                            <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6 .1 34zm192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8z"/></svg>
                                                        </a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            <?php endwhile; ?>
                        </div>
                        <div class="custom-navigation">
                            <div class="swiper-button-prev custom-prev">
                                <span class="arrow"><svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M257.5 445.1l-22.2 22.2c-9.4 9.4-24.6 9.4-33.9 0L7 273c-9.4-9.4-9.4-24.6 0-33.9L201.4 44.7c9.4-9.4 24.6-9.4 33.9 0l22.2 22.2c9.5 9.5 9.3 25-.4 34.3L136.6 216H424c13.3 0 24 10.7 24 24v32c0 13.3-10.7 24-24 24H136.6l120.5 114.8c9.8 9.3 10 24.8 .4 34.3z"/></svg></span>
                            </div>
                            <div class="swiper-button-next custom-next">
                                <span class="arrow"><svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"/></svg></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <?php }
        wp_reset_postdata();
        $output = ob_get_clean(); // Get buffered output and clean buffer
        return $output; // Return the output instead of echoing
    }

endif;

if( !function_exists( 'beauty_parlour_salon_about_section' ) ) :

    function beauty_parlour_salon_about_section(){

        $beauty_parlour_salon_defaults = beauty_parlour_salon_get_default_theme_options();

        $beauty_parlour_salon_about_us_section_short_title = esc_html( get_theme_mod( 'beauty_parlour_salon_about_us_section_short_title',
        $beauty_parlour_salon_defaults['beauty_parlour_salon_about_us_section_short_title'] ) );

        $beauty_parlour_salon_about_us_section_title = esc_html( get_theme_mod( 'beauty_parlour_salon_about_us_section_title',
        $beauty_parlour_salon_defaults['beauty_parlour_salon_about_us_section_title'] ) );

        $beauty_parlour_salon_team_section_subtitle = esc_html( get_theme_mod( 'beauty_parlour_salon_team_section_subtitle',
        $beauty_parlour_salon_defaults['beauty_parlour_salon_team_section_subtitle'] ) );

        $beauty_parlour_salon_about_us_list_text_1 = esc_html( get_theme_mod( 'beauty_parlour_salon_about_us_list_text_1',
        $beauty_parlour_salon_defaults['beauty_parlour_salon_about_us_list_text_1'] ) );

        $beauty_parlour_salon_about_us_list_text_2 = esc_html( get_theme_mod( 'beauty_parlour_salon_about_us_list_text_2',
        $beauty_parlour_salon_defaults['beauty_parlour_salon_about_us_list_text_2'] ) );

        $beauty_parlour_salon_about_us_list_text_3 = esc_html( get_theme_mod( 'beauty_parlour_salon_about_us_list_text_3',
        $beauty_parlour_salon_defaults['beauty_parlour_salon_about_us_list_text_3'] ) );

        $beauty_parlour_salon_about_us_list_text_4 = esc_html( get_theme_mod( 'beauty_parlour_salon_about_us_list_text_4',
        $beauty_parlour_salon_defaults['beauty_parlour_salon_about_us_list_text_4'] ) );

        $beauty_parlour_salon_team_section_button_text = esc_html( get_theme_mod( 'beauty_parlour_salon_team_section_button_text',
        $beauty_parlour_salon_defaults['beauty_parlour_salon_team_section_button_text'] ) );

        $beauty_parlour_salon_team_section_button_url = esc_url( get_theme_mod( 'beauty_parlour_salon_team_section_button_url',
        $beauty_parlour_salon_defaults['beauty_parlour_salon_team_section_button_url'] ) );

        $beauty_parlour_salon_about_us_image_1 = esc_url( get_theme_mod( 'beauty_parlour_salon_about_us_image_1',
        $beauty_parlour_salon_defaults['beauty_parlour_salon_about_us_image_1'] ) );

        $beauty_parlour_salon_about_us_image_2 = esc_url( get_theme_mod( 'beauty_parlour_salon_about_us_image_2',
        $beauty_parlour_salon_defaults['beauty_parlour_salon_about_us_image_2'] ) ); ?>
            <div class="theme-product-block">
                <div class="wrapper">
                    <div class="services-box">
                        <div class="about-us-left">
                            <div class="package-content">
                                <?php if( $beauty_parlour_salon_about_us_section_short_title ){ ?>
                                    <h6><?php echo esc_html( $beauty_parlour_salon_about_us_section_short_title ); ?></h6>
                                <?php } ?>
                                <?php if( $beauty_parlour_salon_about_us_section_title ){ ?>
                                    <h4><?php echo esc_html( $beauty_parlour_salon_about_us_section_title ); ?></h4>
                                <?php } ?>
                                <?php if( $beauty_parlour_salon_team_section_subtitle ){ ?>
                                    <p><?php echo esc_html( $beauty_parlour_salon_team_section_subtitle ); ?></p>
                                <?php } ?>
                                <div class="about-list">
                                    <?php if( $beauty_parlour_salon_about_us_list_text_1 ){ ?>
                                        <div class="list-text">
                                            <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M173.9 439.4l-166.4-166.4c-10-10-10-26.2 0-36.2l36.2-36.2c10-10 26.2-10 36.2 0L192 312.7 432.1 72.6c10-10 26.2-10 36.2 0l36.2 36.2c10 10 10 26.2 0 36.2l-294.4 294.4c-10 10-26.2 10-36.2 0z"/></svg><?php echo esc_html( $beauty_parlour_salon_about_us_list_text_1 ); ?>
                                        </div>
                                    <?php } ?>
                                    <?php if( $beauty_parlour_salon_about_us_list_text_2 ){ ?>
                                        <div class="list-text">
                                            <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M173.9 439.4l-166.4-166.4c-10-10-10-26.2 0-36.2l36.2-36.2c10-10 26.2-10 36.2 0L192 312.7 432.1 72.6c10-10 26.2-10 36.2 0l36.2 36.2c10 10 10 26.2 0 36.2l-294.4 294.4c-10 10-26.2 10-36.2 0z"/></svg><?php echo esc_html( $beauty_parlour_salon_about_us_list_text_2 ); ?>
                                        </div>
                                    <?php } ?>
                                </div>
                                <div class="about-list">
                                    <?php if( $beauty_parlour_salon_about_us_list_text_3 ){ ?>
                                        <div class="list-text">
                                            <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M173.9 439.4l-166.4-166.4c-10-10-10-26.2 0-36.2l36.2-36.2c10-10 26.2-10 36.2 0L192 312.7 432.1 72.6c10-10 26.2-10 36.2 0l36.2 36.2c10 10 10 26.2 0 36.2l-294.4 294.4c-10 10-26.2 10-36.2 0z"/></svg><?php echo esc_html( $beauty_parlour_salon_about_us_list_text_3); ?>
                                        </div>
                                    <?php } ?>
                                    <?php if( $beauty_parlour_salon_about_us_list_text_4 ){ ?>
                                        <div class="list-text">
                                            <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M173.9 439.4l-166.4-166.4c-10-10-10-26.2 0-36.2l36.2-36.2c10-10 26.2-10 36.2 0L192 312.7 432.1 72.6c10-10 26.2-10 36.2 0l36.2 36.2c10 10 10 26.2 0 36.2l-294.4 294.4c-10 10-26.2 10-36.2 0z"/></svg><?php echo esc_html( $beauty_parlour_salon_about_us_list_text_4); ?>
                                        </div>
                                    <?php } ?>
                                </div>
                            </div>
                            <?php if( $beauty_parlour_salon_team_section_button_text || $beauty_parlour_salon_team_section_button_url ){ ?>
                                <div class="package-button">
                                    <a class="package-btn" href="<?php echo esc_url( $beauty_parlour_salon_team_section_button_url ); ?>"><?php echo esc_html( $beauty_parlour_salon_team_section_button_text ); ?><svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6 .1 34zm192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8z"/></svg></a>
                                </div>
                            <?php } ?>
                        </div>
                        <div class="about-us-right">
                            <div class="image-box-1">
                                <?php if( $beauty_parlour_salon_about_us_image_1 ){ ?>
                                    <img class="team-images" src="<?php echo esc_url( $beauty_parlour_salon_about_us_image_1 ); ?>">
                                <?php } ?>
                                <?php if( $beauty_parlour_salon_about_us_image_2 ){ ?>
                                    <img class="about-us-2" src="<?php echo esc_url( $beauty_parlour_salon_about_us_image_2 ); ?>">
                                <?php } ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
    <?php }

endif;


if (!function_exists('beauty_parlour_salon_post_format_icon')):

    // Post Format Icon.
    function beauty_parlour_salon_post_format_icon() {

        $beauty_parlour_salon_format = get_post_format(get_the_ID()) ?: 'standard';
        $beauty_parlour_salon_icon = '';
        $beauty_parlour_salon_title = '';
        if( $beauty_parlour_salon_format == 'video' ){
            $beauty_parlour_salon_icon = beauty_parlour_salon_get_theme_svg( 'video' );
            $beauty_parlour_salon_title = esc_html__('Video','beauty-parlour-salon');
        }elseif( $beauty_parlour_salon_format == 'audio' ){
            $beauty_parlour_salon_icon = beauty_parlour_salon_get_theme_svg( 'audio' );
            $beauty_parlour_salon_title = esc_html__('Audio','beauty-parlour-salon');
        }elseif( $beauty_parlour_salon_format == 'gallery' ){
            $beauty_parlour_salon_icon = beauty_parlour_salon_get_theme_svg( 'gallery' );
            $beauty_parlour_salon_title = esc_html__('Gallery','beauty-parlour-salon');
        }elseif( $beauty_parlour_salon_format == 'quote' ){
            $beauty_parlour_salon_icon = beauty_parlour_salon_get_theme_svg( 'quote' );
            $beauty_parlour_salon_title = esc_html__('Quote','beauty-parlour-salon');
        }elseif( $beauty_parlour_salon_format == 'image' ){
            $beauty_parlour_salon_icon = beauty_parlour_salon_get_theme_svg( 'image' );
            $beauty_parlour_salon_title = esc_html__('Image','beauty-parlour-salon');
        } elseif( $beauty_parlour_salon_format == 'link' ){
            $beauty_parlour_salon_icon = beauty_parlour_salon_get_theme_svg( 'link' );
            $beauty_parlour_salon_title = esc_html__('Link','beauty-parlour-salon');
        } elseif( $beauty_parlour_salon_format == 'status' ){
            $beauty_parlour_salon_icon = beauty_parlour_salon_get_theme_svg( 'status' );
            $beauty_parlour_salon_title = esc_html__('Status','beauty-parlour-salon');
        } elseif( $beauty_parlour_salon_format == 'aside' ){
            $beauty_parlour_salon_icon = beauty_parlour_salon_get_theme_svg( 'aside' );
            $beauty_parlour_salon_title = esc_html__('Aside','beauty-parlour-salon');
        } elseif( $beauty_parlour_salon_format == 'chat' ){
            $beauty_parlour_salon_icon = beauty_parlour_salon_get_theme_svg( 'chat' );
            $beauty_parlour_salon_title = esc_html__('Chat','beauty-parlour-salon');
        }
        
        if (!empty($beauty_parlour_salon_icon)) { ?>
            <div class="theme-post-format">
                <span class="post-format-icom"><?php echo beauty_parlour_salon_svg_escape($beauty_parlour_salon_icon); ?></span>
                <?php if( $beauty_parlour_salon_title ){ echo '<span class="post-format-label">'.esc_html( $beauty_parlour_salon_title ).'</span>'; } ?>
            </div>
        <?php }
    }

endif;

if ( ! function_exists( 'beauty_parlour_salon_svg_escape' ) ):

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

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

        return $beauty_parlour_salon_svg;

    }

endif;

if( !function_exists( 'beauty_parlour_salon_sanitize_sidebar_option_meta' ) ) :

    // Sidebar Option Sanitize.
    function beauty_parlour_salon_sanitize_sidebar_option_meta( $beauty_parlour_salon_input ){

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

            return $beauty_parlour_salon_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'beauty_parlour_salon_sanitize_pagination_meta' ) ) :

    // Sidebar Option Sanitize.
    function beauty_parlour_salon_sanitize_pagination_meta( $beauty_parlour_salon_input ){

        $beauty_parlour_salon_metabox_options = array( 'Center','Right','Left');
        if( in_array( $beauty_parlour_salon_input,$beauty_parlour_salon_metabox_options ) ){

            return $beauty_parlour_salon_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'beauty_parlour_salon_sanitize_menu_transform' ) ) :

    // Sidebar Option Sanitize.
    function beauty_parlour_salon_sanitize_menu_transform( $beauty_parlour_salon_input ){

        $beauty_parlour_salon_metabox_options = array( 'capitalize','uppercase','lowercase');
        if( in_array( $beauty_parlour_salon_input,$beauty_parlour_salon_metabox_options ) ){

            return $beauty_parlour_salon_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'beauty_parlour_salon_sanitize_page_content_alignment' ) ) :

    // Sidebar Option Sanitize.
    function beauty_parlour_salon_sanitize_page_content_alignment( $beauty_parlour_salon_input ){

        $beauty_parlour_salon_metabox_options = array( 'left','center','right');
        if( in_array( $beauty_parlour_salon_input,$beauty_parlour_salon_metabox_options ) ){

            return $beauty_parlour_salon_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'beauty_parlour_salon_sanitize_footer_widget_title_alignment' ) ) :

    // Footer Option Sanitize.
    function beauty_parlour_salon_sanitize_footer_widget_title_alignment( $beauty_parlour_salon_input ){

        $beauty_parlour_salon_metabox_options = array( 'left','center','right');
        if( in_array( $beauty_parlour_salon_input,$beauty_parlour_salon_metabox_options ) ){

            return $beauty_parlour_salon_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'beauty_parlour_salon_sanitize_pagination_type' ) ) :

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

if( !function_exists( 'beauty_parlour_salon_sanitize_copyright_alignment_meta' ) ) :

    // Sidebar Option Sanitize.
    function beauty_parlour_salon_sanitize_copyright_alignment_meta( $beauty_parlour_salon_input ){

        $beauty_parlour_salon_metabox_options = array( 'Default','Reverse','Center');
        if( in_array( $beauty_parlour_salon_input,$beauty_parlour_salon_metabox_options ) ){

            return $beauty_parlour_salon_input;

        }else{

            return '';

        }
    }

endif;

/**
 * Sidebar Layout Function
 */
function beauty_parlour_salon_get_final_sidebar_layout() {
	$beauty_parlour_salon_defaults       = beauty_parlour_salon_get_default_theme_options();
	$beauty_parlour_salon_global_layout  = get_theme_mod('beauty_parlour_salon_global_sidebar_layout', $beauty_parlour_salon_defaults['beauty_parlour_salon_global_sidebar_layout']);
	$beauty_parlour_salon_page_layout    = get_theme_mod('beauty_parlour_salon_page_sidebar_layout', $beauty_parlour_salon_global_layout);
	$beauty_parlour_salon_post_layout    = get_theme_mod('beauty_parlour_salon_post_sidebar_layout', $beauty_parlour_salon_global_layout);
	$beauty_parlour_salon_meta_layout    = get_post_meta(get_the_ID(), 'beauty_parlour_salon_post_sidebar_option', true);

	if (!empty($beauty_parlour_salon_meta_layout) && $beauty_parlour_salon_meta_layout !== 'default') {
		return $beauty_parlour_salon_meta_layout;
	}
	if (is_page() || (function_exists('is_shop') && is_shop())) {
		return $beauty_parlour_salon_page_layout;
	}
	if (is_single()) {
		return $beauty_parlour_salon_post_layout;
	}
	return $beauty_parlour_salon_global_layout;
}