<?php
/**
 * Custom Functions.
 *
 * @package Omega Hair Salon
 */

if( !function_exists( 'omega_hair_salon_fonts_url' ) ) :

    //Google Fonts URL
    function omega_hair_salon_fonts_url(){

        $omega_hair_salon_font_families = array(
            'Outfit:wght@100..900',
        );

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

        return esc_url_raw($omega_hair_salon_fonts_url);
    }

endif;

if ( ! function_exists( 'omega_hair_salon_sub_menu_toggle_button' ) ) :

    function omega_hair_salon_sub_menu_toggle_button( $omega_hair_salon_args, $omega_hair_salon_item, $depth ) {

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

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

                $omega_hair_salon_toggle_target_string = '.menu-item.menu-item-' . $omega_hair_salon_item->ID . ' > .sub-menu';

                // Add the sub menu toggle
                $omega_hair_salon_args->after .= '<button type="button" class="theme-aria-button submenu-toggle" data-toggle-target="' . $omega_hair_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', 'omega-hair-salon' ) . '</span>' . omega_hair_salon_get_theme_svg( 'chevron-down' ) . '</span></button>';

            }

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

        }elseif( $omega_hair_salon_args->theme_location == 'omega-hair-salon-primary-menu' ) {

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

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

            } else {

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

            }

        }

        return $omega_hair_salon_args;

    }

endif;

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

if ( ! function_exists( 'omega_hair_salon_the_theme_svg' ) ):
    
    function omega_hair_salon_the_theme_svg( $omega_hair_salon_svg_name, $omega_hair_salon_return = false ) {

        if( $omega_hair_salon_return ){

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

        }else{

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

        }
    }

endif;

if ( ! function_exists( 'omega_hair_salon_get_theme_svg' ) ):

    function omega_hair_salon_get_theme_svg( $omega_hair_salon_svg_name ) {

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

    }

endif;

if( !function_exists( 'omega_hair_salon_post_category_list' ) ) :

    // Post Category List.
    function omega_hair_salon_post_category_list( $omega_hair_salon_select_cat = true ){

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

        $omega_hair_salon_post_cat_cat_array = array();
        if( $omega_hair_salon_select_cat ){

            $omega_hair_salon_post_cat_cat_array[''] = esc_html__( '-- Select Category --','omega-hair-salon' );

        }

        foreach ( $omega_hair_salon_post_cat_lists as $omega_hair_salon_post_cat_list ) {

            $omega_hair_salon_post_cat_cat_array[$omega_hair_salon_post_cat_list->slug] = $omega_hair_salon_post_cat_list->name;

        }

        return $omega_hair_salon_post_cat_cat_array;
    }

endif;

if( !function_exists('omega_hair_salon_single_post_navigation') ):

    function omega_hair_salon_single_post_navigation(){

        $omega_hair_salon_default_theme_options = omega_hair_salon_get_default_theme_options();
        $omega_hair_salon_twp_navigation_type = esc_attr( get_post_meta( get_the_ID(), 'omega_hair_salon_twp_disable_ajax_load_next_post', true ) );
        $omega_hair_salon_current_id = '';
        $article_wrap_class = '';
        global $post;
        $omega_hair_salon_current_id = $post->ID;
        if( $omega_hair_salon_twp_navigation_type == '' || $omega_hair_salon_twp_navigation_type == 'global-layout' ){
            $omega_hair_salon_twp_navigation_type = get_theme_mod('omega_hair_salon_twp_navigation_type', $omega_hair_salon_default_theme_options['omega_hair_salon_twp_navigation_type']);
        }

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

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

            }else{

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

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

                }
            }

        }

    }

endif;

add_action( 'omega_hair_salon_navigation_action','omega_hair_salon_single_post_navigation',30 );

if( !function_exists('omega_hair_salon_content_offcanvas') ):

    // Offcanvas Contents
    function omega_hair_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', 'omega-hair-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', 'omega-hair-salon'); ?>" role="navigation">
                        <ul class="primary-menu theme-menu">
                            <?php
                            if (has_nav_menu('omega-hair-salon-primary-menu')) {
                                wp_nav_menu(
                                    array(
                                        'container' => '',
                                        'items_wrap' => '%3$s',
                                        'theme_location' => 'omega-hair-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 Omega_Hair_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( 'omega_hair_salon_before_footer_content_action','omega_hair_salon_content_offcanvas',30 );

if( !function_exists('omega_hair_salon_footer_content_widget') ):

    function omega_hair_salon_footer_content_widget(){
        
        $omega_hair_salon_default = omega_hair_salon_get_default_theme_options();
        
        $omega_hair_salon_footer_column_layout = absint(get_theme_mod('omega_hair_salon_footer_column_layout', $omega_hair_salon_default['omega_hair_salon_footer_column_layout']));
        $omega_hair_salon_footer_sidebar_class = 12;
        
        if($omega_hair_salon_footer_column_layout == 2) {
            $omega_hair_salon_footer_sidebar_class = 6;
        }
        
        if($omega_hair_salon_footer_column_layout == 3) {
            $omega_hair_salon_footer_sidebar_class = 4;
        }
        ?>
        
        <?php if ( get_theme_mod('omega_hair_salon_display_footer', true) == true ) : ?>
            <div class="footer-widgetarea">
                <div class="wrapper">
                    <div class="column-row">
                    
                        <?php for ($i = 0; $i < $omega_hair_salon_footer_column_layout; $i++) : ?>
                            
                            <div class="column <?php echo 'column-' . absint($omega_hair_salon_footer_sidebar_class); ?> column-sm-12">
                                
                                <?php 
                                // If no widgets are assigned, display default widgets
                                if ( ! is_active_sidebar( 'omega-hair-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', 'omega-hair-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('Omega Hair Salon is a chic and user-friendly WordPress theme tailored for hair salons and beauty professionals. Designed with simplicity in mind, this theme offers an easy way for hair stylists, beauty professionals, and salon owners to create an elegant online presence without diving into complex technicalities. Ideal for businesses specializing in haircuts, hair styling, hair coloring, hair extensions, hair treatments, bridal hair, men’s haircuts, women’s haircuts, balayage, highlights, lowlights...', 'omega-hair-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', 'omega-hair-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', 'omega-hair-salon'); ?></h2>
                                            <?php get_search_form(); ?>
                                        </div>
                                    <?php endif; 
                                    
                                else :
                                    // Display dynamic sidebar widget if assigned
                                    dynamic_sidebar('omega-hair-salon-footer-widget-' . $i);
                                endif;
                                ?>
                                
                            </div>
                            
                        <?php endfor; ?>

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

    <?php
    }

endif;

add_action( 'omega_hair_salon_footer_content_action', 'omega_hair_salon_footer_content_widget', 10 );

if( !function_exists('omega_hair_salon_footer_content_info') ):

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

        $omega_hair_salon_default_theme_options = omega_hair_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
                                $omega_hair_salon_footer_copyright_text = wp_kses_post( get_theme_mod( 'omega_hair_salon_footer_copyright_text', $omega_hair_salon_default_theme_options['omega_hair_salon_footer_copyright_text'] ) );
                                    echo esc_html( $omega_hair_salon_footer_copyright_text );
                                    echo '<br>';
                                    echo esc_html__('Theme: ', 'omega-hair-salon') . '<a href="' . esc_url('https://www.omegathemes.com/products/free-salon-wordpress-theme') . '" title="' . esc_attr__('Omega Hair Salon', 'omega-hair-salon') . '" target="_blank"><span>' . esc_html__('Omega Hair Salon', 'omega-hair-salon') . '</span></a>' . esc_html__(' By ', 'omega-hair-salon') . '  <span>' . esc_html__('OMEGA ', 'omega-hair-salon') . '</span>';
                                    echo esc_html__('Powered by ', 'omega-hair-salon') . '<a href="' . esc_url('https://wordpress.org') . '" title="' . esc_attr__('WordPress', 'omega-hair-salon') . '" target="_blank"><span>' . esc_html__('WordPress.', 'omega-hair-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('omega_hair_salon_enable_to_the_top', true) == true ) : ?>
                                    <?php
                                    $omega_hair_salon_to_the_top_text = get_theme_mod( 'omega_hair_salon_to_the_top_text', __( 'To the Top', 'omega-hair-salon' ) );
                                    printf( 
                                        wp_kses( 
                                            /* translators: %s is the arrow icon markup */
                                            '%s %s', 
                                            array( 'span' => array( 'class' => array(), 'aria-hidden' => array() ) ) 
                                        ), 
                                        esc_html( $omega_hair_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( 'omega_hair_salon_footer_content_action','omega_hair_salon_footer_content_info',20 );


if( !function_exists( 'omega_hair_salon_main_slider' ) ) :

    function omega_hair_salon_main_slider(){

        $omega_hair_salon_default_theme_options = omega_hair_salon_get_default_theme_options();
        $omega_hair_salon_header_banner = get_theme_mod( 'omega_hair_salon_header_banner', $omega_hair_salon_default_theme_options['omega_hair_salon_header_banner'] );
        $omega_hair_salon_header_banner_cat = get_theme_mod( 'omega_hair_salon_header_banner_cat','Slider' );
        $omega_hair_salon_banner_left_image = get_theme_mod( 'omega_hair_salon_banner_left_image', 
        $omega_hair_salon_default_theme_options['omega_hair_salon_banner_left_image'] );

        $omega_hair_salon_banner_short_heading = esc_html( get_theme_mod( 'omega_hair_salon_banner_short_heading',
        $omega_hair_salon_default_theme_options['omega_hair_salon_banner_short_heading'] ) );

        if( $omega_hair_salon_header_banner ){ ?>
            <div class="slider-box">
                <div class="slider-main">
                    <div class="right-box">
                        <?php if( $omega_hair_salon_banner_left_image ){ ?>
                            <img src="<?php echo esc_url( $omega_hair_salon_banner_left_image ); ?>" alt="Banner Left Image">
                        <?php } ?>
                    </div>
                    <div class="main-banner">
                        <?php
                        $omega_hair_salon_rtl = '';
                        if( is_rtl() ){
                            $omega_hair_salon_rtl = 'dir="rtl"';
                        }
                        $omega_hair_salon_banner_query = new WP_Query( array('post_type' => 'post', 'posts_per_page' => 4,'post__not_in' => get_option("sticky_posts"), 'category_name' => esc_html( $omega_hair_salon_header_banner_cat ) ) );
                        if( $omega_hair_salon_banner_query->have_posts() ): ?>
                            <div class="theme-custom-block theme-banner-block">
                                <div class="swiper-container theme-main-carousel swiper-container" <?php echo $omega_hair_salon_rtl; ?>>
                                    <div class="swiper-wrapper">
                                        <?php
                                        while( $omega_hair_salon_banner_query->have_posts() ):
                                        $omega_hair_salon_banner_query->the_post();
                                        $omega_hair_salon_featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
                                        $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  
                                        $omega_hair_salon_featured_image = isset( $omega_hair_salon_featured_image[0] ) ? $omega_hair_salon_featured_image[0] : $default_image;?>
                                            <div class="swiper-slide main-carousel-item">                                 
                                                <div class="theme-article-post">
                                                    <div class="entry-thumbnail">
                                                        <div class="data-bg data-bg-large" data-background="<?php echo esc_url($omega_hair_salon_featured_image); ?>">
                                                            <a href="<?php the_permalink(); ?>" class="theme-image-responsive" tabindex="0"></a>
                                                        </div>
                                                        <?php omega_hair_salon_post_format_icon(); ?>
                                                    </div>
                                                    <div class="main-carousel-caption">
                                                        <div class="post-content">
                                                            <header class="entry-header">
                                                                <h3 class="entry-title entry-title-small">
                                                                    <?php if( $omega_hair_salon_banner_short_heading ){ ?>
                                                                        <?php echo esc_html($omega_hair_salon_banner_short_heading) ?>
                                                                    <?php } ?>
                                                                </h3>
                                                                <h2 class="entry-title">
                                                                    <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
                                                                </h2>
                                                            </header>
                                                            <a href="<?php the_permalink(); ?>" class="btn-fancy btn-fancy-primary" tabindex="0">
                                                                <?php echo esc_html__('Read More', 'omega-hair-salon'); ?>
                                                            </a>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        <?php endwhile; ?>
                                    </div>
                                    <div class="swiper-pagination"></div>
                                </div>
                            </div>
                            <?php
                            wp_reset_postdata();
                            endif;

                        } ?>
                    </div>
                </div>
            </div>
    <?php }

endif;

if( !function_exists( 'omega_hair_salon_pricing_plans_section' ) ) :

    function omega_hair_salon_pricing_plans_section(){ 

        $omega_hair_salon_default_theme_options = omega_hair_salon_get_default_theme_options();

        $omega_hair_salon_pricing_plans_section_title = esc_html( get_theme_mod( 'omega_hair_salon_pricing_plans_section_title',
        $omega_hair_salon_default_theme_options['omega_hair_salon_pricing_plans_section_title'] ) );

        $omega_hair_salon_pricing_plans_section_sub_title = esc_html( get_theme_mod( 'omega_hair_salon_pricing_plans_section_sub_title',
        $omega_hair_salon_default_theme_options['omega_hair_salon_pricing_plans_section_sub_title'] ) );
        $omega_hair_salon_tab_section_right_image = get_theme_mod( 'omega_hair_salon_tab_section_right_image', 
        $omega_hair_salon_default_theme_options['omega_hair_salon_tab_section_right_image'] );

        ?>

        <div class="price-list-tabs">
            <div class="wrapper">
                <div class="list-heading-main">
                    <h3 class="list-title">
                        <?php if( $omega_hair_salon_pricing_plans_section_title ){ ?>
                            <?php echo esc_html($omega_hair_salon_pricing_plans_section_title) ?>
                        <?php } ?>
                    </h3>
                    <h4 class="list-sub-title">
                        <?php if( $omega_hair_salon_pricing_plans_section_sub_title ){ ?>
                            <?php echo esc_html($omega_hair_salon_pricing_plans_section_sub_title) ?>
                        <?php } ?>
                    </h4>
                </div>
                <div class="main-price-box">
                    <div class="tab-box">
                        <!-- Tab Header -->
                        <div class="tab-header">
                            <?php
                            for ($i = 1; $i <= 2; $i++) {
                                $omega_hair_salon_tab_title = get_theme_mod('omega_hair_salon_price_list_tab_title' . $i);
                                if (empty($omega_hair_salon_tab_title)) {
                                    $omega_hair_salon_tab_title = 'Collection ' . $i; // Default value
                                }
                                if ($omega_hair_salon_tab_title) {
                                    echo '<div class="tab-item ' . (($i == 1) ? 'active' : '') . '" onclick="showTabContent(' . $i . ')">' . esc_html($omega_hair_salon_tab_title) . '</div>';
                                }
                                
                            }
                            ?>
                        </div>
                        <!-- Tab Content -->
                        <?php if( get_theme_mod('omega_hair_salon_category_tab1','uncategorized')  || get_theme_mod('omega_hair_salon_category_tab2','uncategorized')) { ?>
                        <div class="tabcontent">
                            <?php

                            // Separate post query outside the tab content loop
                            $omega_hair_salon_header_pricing_plans_cats = array(
                                get_theme_mod('omega_hair_salon_category_tab1','uncategorized'),
                                get_theme_mod('omega_hair_salon_category_tab2','uncategorized')
                            );

                            for ($i = 1; $i <= 2; $i++) {
                                $category_slug = esc_html($omega_hair_salon_header_pricing_plans_cats[$i - 1]);

                                $omega_hair_salon_tab_banner_query = new WP_Query(array(
                                    'post_type' => 'post',
                                    'posts_per_page' => 6,
                                    'post__not_in' => get_option("sticky_posts"),
                                    'category_name' => $category_slug
                                ));

                                if ($omega_hair_salon_tab_banner_query->have_posts()) :
                                    echo '<div class="tab-content" id="tab-content-' . $i . '">';
                                    while ($omega_hair_salon_tab_banner_query->have_posts()) :
                                        $omega_hair_salon_tab_banner_query->the_post();
                                        $omega_hair_salon_featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
                                        $omega_hair_salon_featured_image = isset($omega_hair_salon_featured_image[0]) ? $omega_hair_salon_featured_image[0] : ''; ?>
                                        <div class="post-content">
                                            <header class="entry-header">
                                                <div class="content-box">
                                                    <h2 class="entry-title entry-title-big">
                                                        <a href="<?php the_permalink(); ?>" rel="bookmark"><span><?php the_title(); ?></span></a>
                                                    </h2>
                                                    <div class="entry-content">
                                                        <?php
                                                        if (has_excerpt()) {

                                                            the_excerpt();

                                                        } else {

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

                                                        } ?> 
                                                    </div>
                                                </div>
                                                <div class="service-price">
                                                    <?php 
                                                    $price = get_post_meta(get_the_ID(), 'omega_hair_salon_price', true);
                                                    if ($price) {
                                                        echo '<span>' . esc_html($price) . '</span>';
                                                    } else {
                                                        echo '<span>$' . esc_html(25) . '</span>'; // Default value
                                                    }
                                                    ?>
                                                </div>
                                            </header>
                                        </div>
                                    <?php endwhile;
                                    echo '</div>';
                                    wp_reset_postdata();
                                endif;
                            } ?>
                        </div>
                        <?php } ?>
                    </div>
                    <div class="tab-image">
                        <?php if( $omega_hair_salon_tab_section_right_image ){ ?>
                            <img src="<?php echo esc_url( $omega_hair_salon_tab_section_right_image ); ?>" alt="Banner Left Image">
                        <?php } ?>
                    </div>
                </div>
            </div>
        </div>
    <?php }

endif;


if (!function_exists('omega_hair_salon_post_format_icon')):

    // Post Format Icon.
    function omega_hair_salon_post_format_icon() {

        $omega_hair_salon_format = get_post_format(get_the_ID()) ?: 'standard';
        $omega_hair_salon_icon = '';
        $omega_hair_salon_title = '';
        if( $omega_hair_salon_format == 'video' ){
            $omega_hair_salon_icon = omega_hair_salon_get_theme_svg( 'video' );
            $omega_hair_salon_title = esc_html__('Video','omega-hair-salon');
        }elseif( $omega_hair_salon_format == 'audio' ){
            $omega_hair_salon_icon = omega_hair_salon_get_theme_svg( 'audio' );
            $omega_hair_salon_title = esc_html__('Audio','omega-hair-salon');
        }elseif( $omega_hair_salon_format == 'gallery' ){
            $omega_hair_salon_icon = omega_hair_salon_get_theme_svg( 'gallery' );
            $omega_hair_salon_title = esc_html__('Gallery','omega-hair-salon');
        }elseif( $omega_hair_salon_format == 'quote' ){
            $omega_hair_salon_icon = omega_hair_salon_get_theme_svg( 'quote' );
            $omega_hair_salon_title = esc_html__('Quote','omega-hair-salon');
        }elseif( $omega_hair_salon_format == 'image' ){
            $omega_hair_salon_icon = omega_hair_salon_get_theme_svg( 'image' );
            $omega_hair_salon_title = esc_html__('Image','omega-hair-salon');
        } elseif( $omega_hair_salon_format == 'link' ){
            $omega_hair_salon_icon = omega_hair_salon_get_theme_svg( 'link' );
            $omega_hair_salon_title = esc_html__('Link','omega-hair-salon');
        } elseif( $omega_hair_salon_format == 'status' ){
            $omega_hair_salon_icon = omega_hair_salon_get_theme_svg( 'status' );
            $omega_hair_salon_title = esc_html__('Status','omega-hair-salon');
        } elseif( $omega_hair_salon_format == 'aside' ){
            $omega_hair_salon_icon = omega_hair_salon_get_theme_svg( 'aside' );
            $omega_hair_salon_title = esc_html__('Aside','omega-hair-salon');
        } elseif( $omega_hair_salon_format == 'chat' ){
            $omega_hair_salon_icon = omega_hair_salon_get_theme_svg( 'chat' );
            $omega_hair_salon_title = esc_html__('Chat','omega-hair-salon');
        }
        
        if (!empty($omega_hair_salon_icon)) { ?>
            <div class="theme-post-format">
                <span class="post-format-icom"><?php echo omega_hair_salon_svg_escape($omega_hair_salon_icon); ?></span>
                <?php if( $omega_hair_salon_title ){ echo '<span class="post-format-label">'.esc_html( $omega_hair_salon_title ).'</span>'; } ?>
            </div>
        <?php }
    }

endif;

if ( ! function_exists( 'omega_hair_salon_svg_escape' ) ):

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

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

        return $omega_hair_salon_svg;

    }

endif;

if( !function_exists( 'omega_hair_salon_sanitize_sidebar_option_meta' ) ) :

    // Sidebar Option Sanitize.
    function omega_hair_salon_sanitize_sidebar_option_meta( $omega_hair_salon_input ){

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

            return $omega_hair_salon_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'omega_hair_salon_sanitize_pagination_meta' ) ) :

    // Sidebar Option Sanitize.
    function omega_hair_salon_sanitize_pagination_meta( $omega_hair_salon_input ){

        $omega_hair_salon_metabox_options = array( 'Center','Right','Left');
        if( in_array( $omega_hair_salon_input,$omega_hair_salon_metabox_options ) ){

            return $omega_hair_salon_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'omega_hair_salon_sanitize_menu_transform' ) ) :

    // Sidebar Option Sanitize.
    function omega_hair_salon_sanitize_menu_transform( $omega_hair_salon_input ){

        $omega_hair_salon_metabox_options = array( 'capitalize','uppercase','lowercase');
        if( in_array( $omega_hair_salon_input,$omega_hair_salon_metabox_options ) ){

            return $omega_hair_salon_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'omega_hair_salon_sanitize_page_content_alignment' ) ) :

    // Sidebar Option Sanitize.
    function omega_hair_salon_sanitize_page_content_alignment( $omega_hair_salon_input ){

        $omega_hair_salon_metabox_options = array( 'left','center','right');
        if( in_array( $omega_hair_salon_input,$omega_hair_salon_metabox_options ) ){

            return $omega_hair_salon_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'omega_hair_salon_sanitize_footer_widget_title_alignment' ) ) :

    // Footer Option Sanitize.
    function omega_hair_salon_sanitize_footer_widget_title_alignment( $omega_hair_salon_input ){

        $omega_hair_salon_metabox_options = array( 'left','center','right');
        if( in_array( $omega_hair_salon_input,$omega_hair_salon_metabox_options ) ){

            return $omega_hair_salon_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'omega_hair_salon_sanitize_pagination_meta' ) ) :

    // Sidebar Option Sanitize.
    function omega_hair_salon_sanitize_pagination_meta( $omega_hair_salon_input ){

        $omega_hair_salon_metabox_options = array( 'Center','Right','Left');
        if( in_array( $omega_hair_salon_input,$omega_hair_salon_metabox_options ) ){

            return $omega_hair_salon_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'omega_hair_salon_sanitize_pagination_type' ) ) :

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

if( !function_exists( 'omega_hair_salon_sanitize_copyright_alignment_meta' ) ) :

    // Sidebar Option Sanitize.
    function omega_hair_salon_sanitize_copyright_alignment_meta( $omega_hair_salon_input ){

        $omega_hair_salon_metabox_options = array( 'Default','Reverse','Center');
        if( in_array( $omega_hair_salon_input,$omega_hair_salon_metabox_options ) ){

            return $omega_hair_salon_input;

        }else{

            return '';

        }
    }

endif;

/**
 * Sidebar Layout Function
 */
function omega_hair_salon_get_final_sidebar_layout() {
	$omega_hair_salon_defaults       = omega_hair_salon_get_default_theme_options();
	$omega_hair_salon_global_layout  = get_theme_mod('omega_hair_salon_global_sidebar_layout', $omega_hair_salon_defaults['omega_hair_salon_global_sidebar_layout']);
	$omega_hair_salon_page_layout    = get_theme_mod('omega_hair_salon_page_sidebar_layout', $omega_hair_salon_global_layout);
	$omega_hair_salon_post_layout    = get_theme_mod('omega_hair_salon_post_sidebar_layout', $omega_hair_salon_global_layout);
	$omega_hair_salon_meta_layout    = get_post_meta(get_the_ID(), 'omega_hair_salon_post_sidebar_option', true);

	if (!empty($omega_hair_salon_meta_layout) && $omega_hair_salon_meta_layout !== 'default') {
		return $omega_hair_salon_meta_layout;
	}
	if (is_page() || (function_exists('is_shop') && is_shop())) {
		return $omega_hair_salon_page_layout;
	}
	if (is_single()) {
		return $omega_hair_salon_post_layout;
	}
	return $omega_hair_salon_global_layout;
}