<?php
/**
 * Custom Functions.
 *
 * @package Omega Refrigeration
 */

if( !function_exists( 'omega_refrigeration_fonts_url' ) ) :

    //Google Fonts URL
    function omega_refrigeration_fonts_url(){

        $font_families = array(
            'Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900', //  font-family: "Inter", sans-serif;
        );

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

        return esc_url_raw($fonts_url);

    }

endif;

if ( ! function_exists( 'omega_refrigeration_sub_menu_toggle_button' ) ) :

    function omega_refrigeration_sub_menu_toggle_button( $args, $item, $depth ) {

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

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

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

                // Add the sub menu toggle
                $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', 'omega-refrigeration' ) . '</span>' . omega_refrigeration_get_theme_svg( 'chevron-down' ) . '</span></button>';

            }

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

        }elseif( $args->theme_location == 'omega-refrigeration-primary-menu' ) {

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

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

            } else {

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

            }

        }

        return $args;

    }

endif;

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

if ( ! function_exists( 'omega_refrigeration_the_theme_svg' ) ):
    
    function omega_refrigeration_the_theme_svg( $omega_refrigeration_svg_name, $return = false ) {

        if( $return ){

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

        }else{

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

        }
    }

endif;

if ( ! function_exists( 'omega_refrigeration_get_theme_svg' ) ):

    function omega_refrigeration_get_theme_svg( $omega_refrigeration_svg_name ) {

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

    }

endif;

if( !function_exists( 'omega_refrigeration_post_category_list' ) ) :

    // Post Category List.
    function omega_refrigeration_post_category_list( $select_cat = true ){

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

        $post_cat_cat_array = array();
        if( $select_cat ){

            $post_cat_cat_array[''] = esc_html__( '-- Select Category --','omega-refrigeration' );

        }

        foreach ( $post_cat_lists as $post_cat_list ) {

            $post_cat_cat_array[$post_cat_list->slug] = $post_cat_list->name;

        }

        return $post_cat_cat_array;
    }

endif;

if( !function_exists('omega_refrigeration_single_post_navigation') ):

    function omega_refrigeration_single_post_navigation(){

        $omega_refrigeration_default = omega_refrigeration_get_default_theme_options();
        $twp_navigation_type = esc_attr( get_post_meta( get_the_ID(), 'twp_disable_ajax_load_next_post', true ) );
        $current_id = '';
        $article_wrap_class = '';
        global $post;
        $current_id = $post->ID;
        if( $twp_navigation_type == '' || $twp_navigation_type == 'global-layout' ){
            $twp_navigation_type = get_theme_mod('twp_navigation_type', $omega_refrigeration_default['twp_navigation_type']);
        }

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

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

            }else{

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

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

                }
            }

        }

    }

endif;

add_action( 'omega_refrigeration_navigation_action','omega_refrigeration_single_post_navigation',30 );

if( !function_exists('omega_refrigeration_content_offcanvas') ):

    // Offcanvas Contents
    function omega_refrigeration_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-refrigeration'); ?>
                            </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-refrigeration'); ?>" role="navigation">
                        <ul class="primary-menu theme-menu">
                            <?php
                            if (has_nav_menu('omega-refrigeration-primary-menu')) {
                                wp_nav_menu(
                                    array(
                                        'container' => '',
                                        'items_wrap' => '%3$s',
                                        'theme_location' => 'omega-refrigeration-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_Refrigeration_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_refrigeration_before_footer_content_action','omega_refrigeration_content_offcanvas',30 );

if( !function_exists('omega_refrigeration_footer_content_widget') ):

    function omega_refrigeration_footer_content_widget(){
        
        $omega_refrigeration_default = omega_refrigeration_get_default_theme_options();
        
        $omega_refrigeration_footer_column_layout = absint(get_theme_mod('omega_refrigeration_footer_column_layout', $omega_refrigeration_default['omega_refrigeration_footer_column_layout']));
        $omega_refrigeration_footer_sidebar_class = 12;
        
        if($omega_refrigeration_footer_column_layout == 2) {
            $omega_refrigeration_footer_sidebar_class = 6;
        }
        
        if($omega_refrigeration_footer_column_layout == 3) {
            $omega_refrigeration_footer_sidebar_class = 4;
        }
        ?>
        
        <?php if ( get_theme_mod('omega_refrigeration_display_footer', true) == true ) : ?>
            <div class="footer-widgetarea">
                <div class="wrapper">
                    <div class="column-row">
                    
                        <?php for ($i = 0; $i < $omega_refrigeration_footer_column_layout; $i++) : ?>
                            
                            <div class="column <?php echo 'column-' . absint($omega_refrigeration_footer_sidebar_class); ?> column-sm-12">
                                
                                <?php 
                                // If no widgets are assigned, display default widgets
                                if ( ! is_active_sidebar( 'omega-refrigeration-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-refrigeration' ); ?>" 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 Omega Refrigeration WordPress Theme is a specialized template designed for businesses in the refrigerator repair and maintenance industry. This theme is tailored specifically for appliance repair companies that provide a wide range of services, including fridge repair, emergency refrigerator repair, and same-day refrigerator repair.', 'omega-refrigeration'); ?>
                                                </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-refrigeration'); ?></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-refrigeration'); ?></h2>
                                            <?php get_search_form(); ?>
                                        </div>
                                    <?php endif; 
                                    
                                else :
                                    // Display dynamic sidebar widget if assigned
                                    dynamic_sidebar('omega-refrigeration-footer-widget-' . $i);
                                endif;
                                ?>
                                
                            </div>
                            
                        <?php endfor; ?>

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

    <?php
    }

endif;

add_action( 'omega_refrigeration_footer_content_action', 'omega_refrigeration_footer_content_widget', 10 );

if( !function_exists('omega_refrigeration_footer_content_info') ):

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

        $omega_refrigeration_default = omega_refrigeration_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_refrigeration_footer_copyright_text = wp_kses_post( get_theme_mod( 'omega_refrigeration_footer_copyright_text', $omega_refrigeration_default['omega_refrigeration_footer_copyright_text'] ) );
                                        echo esc_html( $omega_refrigeration_footer_copyright_text );
                                        echo '<br>';
                                        echo esc_html__('Theme: ', 'omega-refrigeration') . '<a href="' . esc_url('https://www.omegathemes.com/products/free-refrigerator-wordpress-theme') . '" title="' . esc_attr__('OMEGA REFRIGERATION', 'omega-refrigeration') . '" target="_blank"><span>' . esc_html__('OMEGA REFRIGERATION', 'omega-refrigeration') . '</span></a>' . esc_html__(' By ', 'omega-refrigeration') . '  <span>' . esc_html__('OMEGA ', 'omega-refrigeration') . '</span>';
                                        echo esc_html__('Powered by ', 'omega-refrigeration') . '<a href="' . esc_url('https://wordpress.org') . '" title="' . esc_attr__('WordPress', 'omega-refrigeration') . '" target="_blank"><span>' . esc_html__('WordPress.', 'omega-refrigeration') . '</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_refrigeration_enable_to_the_top', true) == true ) : ?>
                                    <?php
                                    $omega_refrigeration_to_the_top_text = get_theme_mod( 'omega_refrigeration_to_the_top_text', __( 'To the Top', 'omega-refrigeration' ) );
                                    printf( 
                                        wp_kses( 
                                            /* translators: %s is the arrow icon markup */
                                            '%s %s', 
                                            array( 'span' => array( 'class' => array(), 'aria-hidden' => array() ) ) 
                                        ), 
                                        esc_html( $omega_refrigeration_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_refrigeration_footer_content_action','omega_refrigeration_footer_content_info',20 );


if( !function_exists( 'omega_refrigeration_main_slider' ) ) :

    function omega_refrigeration_main_slider(){

        $omega_refrigeration_default = omega_refrigeration_get_default_theme_options();

        $omega_refrigeration_header_banner = get_theme_mod( 'omega_refrigeration_header_banner', $omega_refrigeration_default['omega_refrigeration_header_banner'] );

        $omega_refrigeration_banner_section_subtitle = esc_html( get_theme_mod( 'omega_refrigeration_banner_section_subtitle',
        $omega_refrigeration_default['omega_refrigeration_banner_section_subtitle'] ) );

        $omega_refrigeration_banner_section_title = esc_html( get_theme_mod( 'omega_refrigeration_banner_section_title',
        $omega_refrigeration_default['omega_refrigeration_banner_section_title'] ) );

        $omega_refrigeration_banner_section_button_title = esc_html( get_theme_mod( 'omega_refrigeration_banner_section_button_title',
        $omega_refrigeration_default['omega_refrigeration_banner_section_button_title'] ) );

        $omega_refrigeration_banner_section_button_url = esc_html( get_theme_mod( 'omega_refrigeration_banner_section_button_url',
        $omega_refrigeration_default['omega_refrigeration_banner_section_button_url'] ) );

        $omega_refrigeration_banner_background_image = esc_url(get_theme_mod( 'omega_refrigeration_banner_background_image',
        $omega_refrigeration_default['omega_refrigeration_banner_background_image']) );

        $omega_refrigeration_client_section_logo_image_1 = esc_url( get_theme_mod( 'omega_refrigeration_client_section_logo_image_1',
        $omega_refrigeration_default['omega_refrigeration_client_section_logo_image_1'] ) );

        $omega_refrigeration_client_number = esc_html( get_theme_mod( 'omega_refrigeration_client_number',
        $omega_refrigeration_default['omega_refrigeration_client_number'] ) );

        $omega_refrigeration_client_text = esc_html( get_theme_mod( 'omega_refrigeration_client_text',
        $omega_refrigeration_default['omega_refrigeration_client_text'] ) );

        $omega_refrigeration_banner_phone_number = esc_html( get_theme_mod( 'omega_refrigeration_banner_phone_number',
        $omega_refrigeration_default['omega_refrigeration_banner_phone_number'] ) );

        $omega_refrigeration_right_box_heading = esc_html( get_theme_mod( 'omega_refrigeration_right_box_heading',
        $omega_refrigeration_default['omega_refrigeration_right_box_heading'] ) );

        $omega_refrigeration_right_box_text = esc_html( get_theme_mod( 'omega_refrigeration_right_box_text',
        $omega_refrigeration_default['omega_refrigeration_right_box_text'] ) );

        $omega_refrigeration_right_team_number = esc_html( get_theme_mod( 'omega_refrigeration_right_team_number',
        $omega_refrigeration_default['omega_refrigeration_right_team_number'] ) );

        $omega_refrigeration_right_team_text = esc_html( get_theme_mod( 'omega_refrigeration_right_team_text',
        $omega_refrigeration_default['omega_refrigeration_right_team_text'] ) );

        if( $omega_refrigeration_header_banner ){ ?>
                <div class="theme-custom-block theme-banner-block" >
                    <div class="slider-box" style="background: url(<?php echo esc_url( $omega_refrigeration_banner_background_image ); ?>);">
                        <div class="main-slider">
                            <div class="banner-left-box">
                                <div class="client-box">
                                    <?php if( $omega_refrigeration_client_number ){ ?>
                                        <h6><?php echo esc_html( $omega_refrigeration_client_number ); ?></h6>
                                    <?php }?>
                                    <?php if( $omega_refrigeration_client_text ){ ?>
                                        <p><?php echo esc_html( $omega_refrigeration_client_text ); ?></p>
                                    <?php }?>
                                </div>
                                <div class="support-box">
                                    <div class="call-icon">
                                        <svg xmlns="http://www.w3.org/2000/svg" height="2em" viewBox="0 0 512 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M497.4 361.8l-112-48a24 24 0 0 0 -28 6.9l-49.6 60.6A370.7 370.7 0 0 1 130.6 204.1l60.6-49.6a23.9 23.9 0 0 0 6.9-28l-48-112A24.2 24.2 0 0 0 122.6 .6l-104 24A24 24 0 0 0 0 48c0 256.5 207.9 464 464 464a24 24 0 0 0 23.4-18.6l24-104a24.3 24.3 0 0 0 -14-27.6z"/></svg>
                                    </div>
                                    <div class="phone-text">
                                        <p class="default-text"><?php echo esc_html( 'Need Help? Call us','omega-refrigeration'); ?></p>
                                        <p><a href="tell:<?php echo esc_html( $omega_refrigeration_banner_phone_number ); ?>"><?php echo esc_html( $omega_refrigeration_banner_phone_number ); ?></a></p>
                                    </div>
                                </div>
                            </div>
                            <div class="banner-center-box">
                                <?php if( $omega_refrigeration_banner_section_subtitle ){ ?>
                                    <h6><?php echo esc_html( $omega_refrigeration_banner_section_subtitle ); ?></h6>
                                <?php } ?>
                                <?php if( $omega_refrigeration_banner_section_title ){ ?>
                                    <h4><?php echo esc_html( $omega_refrigeration_banner_section_title ); ?></h4>
                                <?php } ?>
                                <a href="<?php echo esc_url( $omega_refrigeration_banner_section_button_url ); ?>" class="btn-fancy btn-fancy-primary" tabindex="0">
                                    <?php echo esc_html( $omega_refrigeration_banner_section_button_title ); ?>
                                </a>
                                <div class="banner-image">
                                    <img src="<?php echo esc_url($omega_refrigeration_client_section_logo_image_1); ?>">
                                </div>
                            </div>
                            <div class="banner-right-box">
                                <div class="right-box">
                                    <?php if( $omega_refrigeration_right_box_heading ){ ?>
                                        <h6><?php echo esc_html( $omega_refrigeration_right_box_heading ); ?></h6>
                                    <?php }?>
                                    <?php if( $omega_refrigeration_right_box_text ){ ?>
                                        <p><?php echo esc_html( $omega_refrigeration_right_box_text ); ?></p>
                                    <?php }?>
                                </div>
                                <div class="team-box">
                                    <div class="call-icon">
                                        <svg xmlns="http://www.w3.org/2000/svg" height="2em" viewBox="0 0 512 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4 .6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z"/></svg>
                                    </div>
                                    <div class="team-text">
                                        <p class="team-default-text"><?php echo esc_html( $omega_refrigeration_right_team_number ); ?></p>
                                        <p><?php echo esc_html( $omega_refrigeration_right_team_text ); ?></p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            <?php
        }
    }

endif;


if( !function_exists( 'omega_refrigeration_product_section' ) ) :

    function omega_refrigeration_product_section(){ 

        $omega_refrigeration_default = omega_refrigeration_get_default_theme_options();
        $omega_refrigeration_locations_post = get_theme_mod( 'omega_refrigeration_locations_post', $omega_refrigeration_default['omega_refrigeration_locations_post'] );
        $omega_refrigeration_locations_post_cat = get_theme_mod( 'omega_refrigeration_locations_post_cat' );

        $omega_refrigeration_team_section_subtitle = esc_html( get_theme_mod( 'omega_refrigeration_team_section_subtitle',
        $omega_refrigeration_default['omega_refrigeration_team_section_subtitle'] ) );

        $omega_refrigeration_team_section_title = esc_html( get_theme_mod( 'omega_refrigeration_team_section_title',
        $omega_refrigeration_default['omega_refrigeration_team_section_title'] ) );

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

            if( $omega_refrigeration_locations_query->have_posts() ): ?>
        
            <div class="theme-product-block">
                <div class="wrapper">
                    <div class="section-heading">
                        <?php if( $omega_refrigeration_team_section_subtitle ){ ?>
                            <h6><?php echo esc_html( $omega_refrigeration_team_section_subtitle ); ?></h6>
                        <?php } ?>
                        <?php if( $omega_refrigeration_team_section_title ){ ?>
                            <h4><?php echo esc_html( $omega_refrigeration_team_section_title ); ?></h4>
                        <?php } ?>
                    </div>
                    <div class="owl-carousel" role="listbox">
                        <?php
                            $s=1;
                            while( $omega_refrigeration_locations_query->have_posts() ):
                            $omega_refrigeration_locations_query->the_post();
                            $omega_refrigeration_featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
                            $omega_refrigeration_featured_image = isset( $omega_refrigeration_featured_image[0] ) ? $omega_refrigeration_featured_image[0] : ''; 

                            $omega_refrigeration_team_section_designation = esc_html( get_theme_mod( 'omega_refrigeration_team_section_designation'.$s ) );

                            ?>                                
                            <div class="theme-article-post slider-post-content">
                                <div class="entry-thumbnail">
                                    <div class="data-bg featured-img" data-background="<?php echo esc_url($omega_refrigeration_featured_image ? $omega_refrigeration_featured_image : get_template_directory_uri() . '/assets/images/default.png'); ?>">
                                        <a href="<?php the_permalink(); ?>" class="theme-image-responsive" tabindex="0"></a>
                                    </div>
                                    <?php omega_refrigeration_post_format_icon(); ?>
                                </div>
                                <div class="main-owl-caption">
                                    <div class="post-content-location">
                                        <header class="entry-header">
                                            <?php if( $omega_refrigeration_team_section_designation ){ ?>
                                                <p><?php echo esc_html( $omega_refrigeration_team_section_designation ); ?></p>
                                            <?php } ?>
                                            <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> 
                                            <a class="banner-btn" href="<?php the_permalink(); ?>"><?php echo esc_html('Read More','omega-refrigeration'); ?></a>
                                        </header>
                                    </div>
                                </div>
                            </div>
                        <?php $s++; endwhile; ?>
                    </div>
                </div>
            </div>
             <?php
            wp_reset_postdata();
            endif;
          ?>
    <?php }

endif;

if (!function_exists('omega_refrigeration_post_format_icon')):

    // Post Format Icon.
    function omega_refrigeration_post_format_icon() {

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

endif;

if ( ! function_exists( 'omega_refrigeration_svg_escape' ) ):

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

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

        return $omega_refrigeration_svg;

    }

endif;

if( !function_exists( 'omega_refrigeration_sanitize_sidebar_option_meta' ) ) :

    // Sidebar Option Sanitize.
    function omega_refrigeration_sanitize_sidebar_option_meta( $omega_refrigeration_input ){

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

            return $omega_refrigeration_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'omega_refrigeration_sanitize_pagination_meta' ) ) :

    // Sidebar Option Sanitize.
    function omega_refrigeration_sanitize_pagination_meta( $omega_refrigeration_input ){

        $omega_refrigeration_metabox_options = array( 'Center','Right','Left');
        if( in_array( $omega_refrigeration_input,$omega_refrigeration_metabox_options ) ){

            return $omega_refrigeration_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'omega_refrigeration_sanitize_pagination_type' ) ) :

    /**
     * Sanitize the pagination type setting.
     *
     * @param string $omega_refrigeration_input The input value from the Customizer.
     * @return string The sanitized value.
     */
    function omega_refrigeration_sanitize_pagination_type( $omega_refrigeration_input ) {
        // Define valid options for the pagination type.
        $omega_refrigeration_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_refrigeration_input, $omega_refrigeration_valid_options, true ) ) {
            return $omega_refrigeration_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_refrigeration_sanitize_enable_pagination') ) :
    function omega_refrigeration_sanitize_enable_pagination( $omega_refrigeration_input ) {
        return (bool) $omega_refrigeration_input;
    }
endif;

if( !function_exists( 'omega_refrigeration_sanitize_menu_transform' ) ) :

    // Sidebar Option Sanitize.
    function omega_refrigeration_sanitize_menu_transform( $omega_refrigeration_input ){

        $omega_refrigeration_metabox_options = array( 'capitalize','uppercase','lowercase');
        if( in_array( $omega_refrigeration_input,$omega_refrigeration_metabox_options ) ){

            return $omega_refrigeration_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'omega_refrigeration_sanitize_page_content_alignment' ) ) :

    // Sidebar Option Sanitize.
    function omega_refrigeration_sanitize_page_content_alignment( $omega_refrigeration_input ){

        $omega_refrigeration_metabox_options = array( 'left','center','right');
        if( in_array( $omega_refrigeration_input,$omega_refrigeration_metabox_options ) ){

            return $omega_refrigeration_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'omega_refrigeration_sanitize_footer_widget_title_alignment' ) ) :

    // Footer Option Sanitize.
    function omega_refrigeration_sanitize_footer_widget_title_alignment( $omega_refrigeration_input ){

        $omega_refrigeration_metabox_options = array( 'left','center','right');
        if( in_array( $omega_refrigeration_input,$omega_refrigeration_metabox_options ) ){

            return $omega_refrigeration_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'omega_refrigeration_sanitize_copyright_alignment_meta' ) ) :

    // Sidebar Option Sanitize.
    function omega_refrigeration_sanitize_copyright_alignment_meta( $omega_refrigeration_input ){

        $omega_refrigeration_metabox_options = array( 'Default','Reverse','Center');
        if( in_array( $omega_refrigeration_input,$omega_refrigeration_metabox_options ) ){

            return $omega_refrigeration_input;

        }else{

            return '';

        }
    }

endif;

/**
 * Sidebar Layout Function
 */
function omega_refrigeration_get_final_sidebar_layout() {
	$omega_refrigeration_defaults       = omega_refrigeration_get_default_theme_options();
	$omega_refrigeration_global_layout  = get_theme_mod('omega_refrigeration_global_sidebar_layout', $omega_refrigeration_defaults['omega_refrigeration_global_sidebar_layout']);
	$omega_refrigeration_page_layout    = get_theme_mod('omega_refrigeration_page_sidebar_layout', $omega_refrigeration_global_layout);
	$omega_refrigeration_post_layout    = get_theme_mod('omega_refrigeration_post_sidebar_layout', $omega_refrigeration_global_layout);
	$omega_refrigeration_meta_layout    = get_post_meta(get_the_ID(), 'omega_refrigeration_post_sidebar_option', true);

	if (!empty($omega_refrigeration_meta_layout) && $omega_refrigeration_meta_layout !== 'default') {
		return $omega_refrigeration_meta_layout;
	}
	if (is_page() || (function_exists('is_shop') && is_shop())) {
		return $omega_refrigeration_page_layout;
	}
	if (is_single()) {
		return $omega_refrigeration_post_layout;
	}
	return $omega_refrigeration_global_layout;
}