<?php
/**
 * Custom Functions.
 *
 * @package Wind Energy
 */

if( !function_exists( 'wind_energy_fonts_url' ) ) :

    //Google Fonts URL
    function wind_energy_fonts_url(){

        $wind_energy_font_families = array(
            'Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900',
        );

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

        return esc_url_raw($wind_energy_fonts_url);

    }

endif;

if ( ! function_exists( 'wind_energy_sub_menu_toggle_button' ) ) :

    function wind_energy_sub_menu_toggle_button( $wind_energy_args, $wind_energy_item, $depth ) {

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

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

                $wind_energy_toggle_target_string = '.menu-item.menu-item-' . $wind_energy_item->ID . ' > .sub-menu';

                // Add the sub menu toggle
                $wind_energy_args->after .= '<button type="button" class="theme-aria-button submenu-toggle" data-toggle-target="' . $wind_energy_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', 'wind-energy' ) . '</span>' . wind_energy_get_theme_svg( 'chevron-down' ) . '</span></button>';

            }

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

        }elseif( $wind_energy_args->theme_location == 'wind-energy-primary-menu' ) {

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

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

            } else {

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

            }

        }

        return $wind_energy_args;

    }

endif;

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

if ( ! function_exists( 'wind_energy_the_theme_svg' ) ):
    
    function wind_energy_the_theme_svg( $wind_energy_svg_name, $wind_energy_return = false ) {

        if( $wind_energy_return ){

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

        }else{

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

        }
    }

endif;

if ( ! function_exists( 'wind_energy_get_theme_svg' ) ):

    function wind_energy_get_theme_svg( $wind_energy_svg_name ) {

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

    }

endif;


if( !function_exists( 'wind_energy_post_category_list' ) ) :

    // Post Category List.
    function wind_energy_post_category_list( $wind_energy_select_cat = true ){

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

        $wind_energy_post_cat_cat_array = array();
        if( $wind_energy_select_cat ){

            $wind_energy_post_cat_cat_array[''] = esc_html__( '-- Select Category --','wind-energy' );

        }

        foreach ( $wind_energy_post_cat_lists as $wind_energy_post_cat_list ) {

            $wind_energy_post_cat_cat_array[$wind_energy_post_cat_list->slug] = $wind_energy_post_cat_list->name;

        }

        return $wind_energy_post_cat_cat_array;
    }

endif;

if( !function_exists('wind_energy_single_post_navigation') ):

    function wind_energy_single_post_navigation(){

        $wind_energy_default = wind_energy_get_default_theme_options();
        $wind_energy_twp_navigation_type = esc_attr( get_post_meta( get_the_ID(), 'twp_disable_ajax_load_next_post', true ) );
        $wind_energy_current_id = '';
        $article_wrap_class = '';
        global $post;
        $wind_energy_current_id = $post->ID;
        if( $wind_energy_twp_navigation_type == '' || $wind_energy_twp_navigation_type == 'global-layout' ){
            $wind_energy_twp_navigation_type = get_theme_mod('wind_energy_twp_navigation_type', $wind_energy_default['wind_energy_twp_navigation_type']);
        }

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

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

            }else{

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

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

                }
            }

        }

    }

endif;

add_action( 'wind_energy_navigation_action','wind_energy_single_post_navigation',30 );

if( !function_exists('wind_energy_content_offcanvas') ):

    // Offcanvas Contents
    function wind_energy_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', 'wind-energy'); ?>
                            </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', 'wind-energy'); ?>" role="navigation">
                        <ul class="primary-menu theme-menu">
                            <?php
                            if (has_nav_menu('wind-energy-primary-menu')) {
                                wp_nav_menu(
                                    array(
                                        'container' => '',
                                        'items_wrap' => '%3$s',
                                        'theme_location' => 'wind-energy-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 wind_energy_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( 'wind_energy_before_footer_content_action','wind_energy_content_offcanvas',30 );

if( !function_exists('wind_energy_footer_content_widget') ):

    function wind_energy_footer_content_widget(){
        
        $wind_energy_default = wind_energy_get_default_theme_options();
        
        $wind_energy_footer_column_layout = absint(get_theme_mod('wind_energy_footer_column_layout', $wind_energy_default['wind_energy_footer_column_layout']));
        $wind_energy_footer_sidebar_class = 12;
        
        if($wind_energy_footer_column_layout == 2) {
            $wind_energy_footer_sidebar_class = 6;
        }
        
        if($wind_energy_footer_column_layout == 3) {
            $wind_energy_footer_sidebar_class = 4;
        }
        ?>
        
        <?php if ( get_theme_mod('wind_energy_display_footer', true) == true ) : ?>
            <div class="footer-widgetarea">
                <div class="wrapper">
                    <div class="column-row">
                    
                        <?php for ($i = 0; $i < $wind_energy_footer_column_layout; $i++) : ?>
                            
                            <div class="column <?php echo 'column-' . absint($wind_energy_footer_sidebar_class); ?> column-sm-12">
                                
                                <?php 
                                // If no widgets are assigned, display default widgets
                                if ( ! is_active_sidebar( 'wind-energy-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', 'wind-energy' ); ?>" 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 Wind Energy WordPress Theme is a modern, responsive website template designed specifically for businesses and organizations within the wind energy industry. This theme provides a professional platform for showcasing wind energy production, renewable energy solutions, and sustainable wind energy projects. It is ideal for companies involved in wind power generation, wind turbine farms, and onshore wind energy projects, offering an easy way to present services, innovations, and research related to wind energy.', 'wind-energy'); ?>
                                                </p>
                                            </div>
                                        </div>

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

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

    <?php
    }

endif;

add_action( 'wind_energy_footer_content_action', 'wind_energy_footer_content_widget', 10 );

if( !function_exists('wind_energy_footer_content_info') ):

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

        $wind_energy_default = wind_energy_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
                                $wind_energy_footer_copyright_text = wp_kses_post( get_theme_mod( 'wind_energy_footer_copyright_text', $wind_energy_default['wind_energy_footer_copyright_text'] ) );
                                    echo esc_html( $wind_energy_footer_copyright_text );
                                    echo '<br>';
                                    echo esc_html__('Theme: ', 'wind-energy') . '<a href="' . esc_url('https://www.omegathemes.com/products/free-energy-wordpress-theme') . '" title="' . esc_attr__('Wind Energy', 'wind-energy') . '" target="_blank"><span>' . esc_html__('Wind Energy', 'wind-energy') . '</span></a>' . esc_html__(' By ', 'wind-energy') . '  <span>' . esc_html__('OMEGA ', 'wind-energy') . '</span>';
                                    echo esc_html__('Powered by ', 'wind-energy') . '<a href="' . esc_url('https://wordpress.org') . '" title="' . esc_attr__('WordPress', 'wind-energy') . '" target="_blank"><span>' . esc_html__('WordPress.', 'wind-energy') . '</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('wind_energy_enable_to_the_top', true) == true ) : ?>
                                    <?php
                                    $wind_energy_to_the_top_text = get_theme_mod( 'wind_energy_to_the_top_text', __( 'To the Top', 'wind-energy' ) );
                                    printf( 
                                        wp_kses( 
                                            /* translators: %s is the arrow icon markup */
                                            '%s %s', 
                                            array( 'span' => array( 'class' => array(), 'aria-hidden' => array() ) ) 
                                        ), 
                                        esc_html( $wind_energy_to_the_top_text ),
                                        '<span class="arrow" aria-hidden="true">&uarr;</span>' 
                                    );
                                    ?>
                                <?php endif; ?>
                            </span>
                        </a>
                    </div>
                </div>
            </div>
        </div>

    <?php
    }

endif;

add_action( 'wind_energy_footer_content_action','wind_energy_footer_content_info',20 );


if( !function_exists( 'wind_energy_main_slider' ) ) :

    function wind_energy_main_slider(){

        $wind_energy_default = wind_energy_get_default_theme_options();
        $wind_energy_header_banner = get_theme_mod( 'wind_energy_header_banner', $wind_energy_default['wind_energy_header_banner'] );
        $wind_energy_header_banner_cat = get_theme_mod( 'wind_energy_header_banner_cat' );

        $wind_energy_installation_number = esc_html( get_theme_mod( 'wind_energy_installation_number',
        $wind_energy_default['wind_energy_installation_number'] ) );

        $wind_energy_installation_text = esc_html( get_theme_mod( 'wind_energy_installation_text',
        $wind_energy_default['wind_energy_installation_text'] ) );

        if( $wind_energy_header_banner ){

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

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

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

            <div id="site-content" class="theme-custom-block theme-banner-block">
                <div class="swiper-container theme-main-carousel swiper-container" <?php echo $wind_energy_rtl; ?>>

                    <div class="swiper-wrapper">

                      <?php
                      while( $wind_energy_banner_query->have_posts() ):
                        $wind_energy_banner_query->the_post();
                        $wind_energy_featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
                        $wind_energy_default_image = get_template_directory_uri() . '/assets/images/slider1.png'; // Replace with the actual path to your default image  
                        $wind_energy_featured_image = isset( $wind_energy_featured_image[0] ) ? $wind_energy_featured_image[0] : $wind_energy_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($wind_energy_featured_image); ?>">
                                          <a href="<?php the_permalink(); ?>" class="theme-image-responsive" tabindex="0"></a>
                                      </div>
                                      <?php wind_energy_post_format_icon(); ?>
                                  </div>
                            
                                  <div class="main-carousel-caption">
                                      <div class="post-content ">
                                          <header class="entry-header">
                                                <h2 class="entry-title entry-title-big">
                                                    <a href="<?php the_permalink(); ?>" rel="bookmark"><span><?php the_title(); ?></span></a>
                                                </h2>
                                          </header>
                                          <div class="entry-content">
                                              <?php
                                              if (has_excerpt()) {
                                                  the_excerpt();
                                              } else {
                                                  echo esc_html(wp_trim_words(get_the_content(), 25, '...'));
                                              } ?>
                                          </div>
                                          <a href="<?php the_permalink(); ?>" class="btn-fancy btn-fancy-primary" tabindex="0">
                                              <?php echo esc_html__('Request A Quote', 'wind-energy'); ?>
                                          </a>
                                            <?php if( get_theme_mod( 'wind_energy_video_button_link' ) != 'https://www.youtube.com/watch?v=9xwazD5SyVg&pp=ygULZHVtbXkgdmlkZW8%3D') { ?>
                                                <div class="slider-video">
                                                    <a target="_blank" href="<?php echo esc_url( get_theme_mod( 'wind_energy_video_button_link','https://www.youtube.com/watch?v=9xwazD5SyVg&pp=ygULZHVtbXkgdmlkZW8%3D' ) ); ?>"><svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 448 512"><path d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"/></svg></a><span class="watch-text"><?php esc_html_e('Connect the inverter to Consumer Unit','wind-energy'); ?></span>
                                                </div>
                                          <?php } ?>
                                      </div>
                                  </div>
                                  </div>
                                <?php if( $wind_energy_installation_number || $wind_energy_installation_text ){ ?>
                                  <div class="installation-box">
                                      <div class="install-icon">
                                        <svg xmlns="http://www.w3.org/2000/svg" height="1.3em" viewBox="0 0 640 512"><path d="M432 448l-48 .1V416h-128v32.2l-48 .1c-8.8 0-16 7.2-16 16l-.1 31.7c0 8.9 7.2 16 16 16l224-.3c8.8 0 16-7.2 16-16l0-31.7c0-8.9-7.2-16-16-16zM585.2 26.7C582.6 11.3 569 0 553.1 0H86.9C71 0 57.4 11.3 54.8 26.7-3.3 369.2 0 348.1 0 352c0 17.3 14.3 32 32.6 32h574.7c18.2 0 32.5-14.6 32.6-31.8 0-4.1 3.4 17-54.8-325.5zM259.8 64h120.3l9.8 96H250.1l9.8-96zm-75.2 256H71.1L90.1 208h106l-11.4 112zm16.3-160H98.2l16.3-96h96.2l-9.8 96zm32.8 160l11.4-112h149.7l11.4 112H233.8zm195.5-256h96.2l16.3 96H439l-9.8-96zm26.1 256l-11.4-112H549.9l19 112H455.3z"/></svg>
                                        </div>
                                      <h6><?php echo esc_html( $wind_energy_installation_number ); ?></h6>
                                      <p><?php echo esc_html( $wind_energy_installation_text ); ?></p>
                                  </div>
                                <?php } ?>
                          </div>
                      <?php endwhile; ?>
                    </div>
                    <div class="swiper-pagination"></div>
                    <div class="swiper-control swiper-control_center">
                            <div class="theme-carousel-control">
                            <div class="swiper-button-prev">
                            <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="45.0282" height="9" viewBox="0 0 45.0282 9.0371"><polyline points="4.825 0.354 0.707 4.471 4.92 8.684"></polyline><line x1="0.9028" y1="4.513" x2="45.0278" y2="4.5405"></line></svg>
                            </div>
                            
                            <div class="swiper-button-next">
                            <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="45.0277" height="9" viewBox="0 0 45.0277 9.0373"><polyline points="40.108 8.684 44.321 4.471 40.203 0.354"></polyline><line x1="0.0003" y1="4.5409" x2="44.1253" y2="4.5134"></line></svg>
                            </div>
                            </div>
                    </div>

                </div>
            </div>

          <?php
          wp_reset_postdata();
          endif;

        }

    }

endif;

if (!function_exists('wind_energy_post_format_icon')):

    // Post Format Icon.
    function wind_energy_post_format_icon() {

        $wind_energy_format = get_post_format(get_the_ID()) ?: 'standard';
        $wind_energy_icon = '';
        $wind_energy_title = '';
        if( $wind_energy_format == 'video' ){
            $wind_energy_icon = wind_energy_get_theme_svg( 'video' );
            $wind_energy_title = esc_html__('Video','wind-energy');
        }elseif( $wind_energy_format == 'audio' ){
            $wind_energy_icon = wind_energy_get_theme_svg( 'audio' );
            $wind_energy_title = esc_html__('Audio','wind-energy');
        }elseif( $wind_energy_format == 'gallery' ){
            $wind_energy_icon = wind_energy_get_theme_svg( 'gallery' );
            $wind_energy_title = esc_html__('Gallery','wind-energy');
        }elseif( $wind_energy_format == 'quote' ){
            $wind_energy_icon = wind_energy_get_theme_svg( 'quote' );
            $wind_energy_title = esc_html__('Quote','wind-energy');
        }elseif( $wind_energy_format == 'image' ){
            $wind_energy_icon = wind_energy_get_theme_svg( 'image' );
            $wind_energy_title = esc_html__('Image','wind-energy');
        } elseif( $wind_energy_format == 'link' ){
            $wind_energy_icon = wind_energy_get_theme_svg( 'link' );
            $wind_energy_title = esc_html__('Link','wind-energy');
        } elseif( $wind_energy_format == 'status' ){
            $wind_energy_icon = wind_energy_get_theme_svg( 'status' );
            $wind_energy_title = esc_html__('Status','wind-energy');
        } elseif( $wind_energy_format == 'aside' ){
            $wind_energy_icon = wind_energy_get_theme_svg( 'aside' );
            $wind_energy_title = esc_html__('Aside','wind-energy');
        } elseif( $wind_energy_format == 'chat' ){
            $wind_energy_icon = wind_energy_get_theme_svg( 'chat' );
            $wind_energy_title = esc_html__('Chat','wind-energy');
        }
        
        if (!empty($wind_energy_icon)) { ?>
            <div class="theme-post-format">
                <span class="post-format-icom"><?php echo wind_energy_svg_escape($wind_energy_icon); ?></span>
                <?php if( $wind_energy_title ){ echo '<span class="post-format-label">'.esc_html( $wind_energy_title ).'</span>'; } ?>
            </div>
        <?php }
    }

endif;

if ( ! function_exists( 'wind_energy_svg_escape' ) ):

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

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

        return $wind_energy_svg;

    }

endif;

if( !function_exists( 'wind_energy_sanitize_sidebar_option_meta' ) ) :

    // Sidebar Option Sanitize.
    function wind_energy_sanitize_sidebar_option_meta( $wind_energy_input ){

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

            return $wind_energy_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'wind_energy_sanitize_pagination_meta' ) ) :

    // Sidebar Option Sanitize.
    function wind_energy_sanitize_pagination_meta( $wind_energy_input ){

        $wind_energy_metabox_options = array( 'Center','Right','Left');
        if( in_array( $wind_energy_input,$wind_energy_metabox_options ) ){

            return $wind_energy_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists('wind_energy_category_carousel') ):

    // Single Posts Related Posts.
    function wind_energy_category_carousel(){

        $wind_energy_default = wind_energy_get_default_theme_options();

        $wind_energy_category_section = absint( get_theme_mod( 'wind_energy_category_section',
        $wind_energy_default['wind_energy_category_section'] ) );

        $wind_energy_cat_short_title = esc_html( get_theme_mod( 'wind_energy_cat_short_title',
        $wind_energy_default['wind_energy_cat_short_title'] ) );

        $wind_energy_cat_main_title = esc_html( get_theme_mod( 'wind_energy_cat_main_title',
        $wind_energy_default['wind_energy_cat_main_title'] ) );

        $wind_energy_cat_main_content = esc_html( get_theme_mod( 'wind_energy_cat_main_content',
        $wind_energy_default['wind_energy_cat_main_content'] ) );

        $wind_energy_about_button_text = esc_html( get_theme_mod( 'wind_energy_about_button_text',
        $wind_energy_default['wind_energy_about_button_text'] ) );

        $wind_energy_about_button_url = esc_url( get_theme_mod( 'wind_energy_about_button_url',
        $wind_energy_default['wind_energy_about_button_url'] ) );

        $wind_energy_about_us_image = get_theme_mod( 'wind_energy_about_us_image', 
        $wind_energy_default['wind_energy_about_us_image'] );

        $wind_energy_about_us_right_small_image = get_theme_mod( 'wind_energy_about_us_right_small_image', 
        $wind_energy_default['wind_energy_about_us_right_small_image'] );

        $wind_energy_about_us_phone_number = esc_attr( get_theme_mod( 'wind_energy_about_us_phone_number',
        $wind_energy_default['wind_energy_about_us_phone_number'] ) );

        $wind_energy_about_us_layout_email_id = esc_attr( get_theme_mod( 'wind_energy_about_us_layout_email_id',
        $wind_energy_default['wind_energy_about_us_layout_email_id'] ) );

        if( $wind_energy_category_section ){
            $wind_energy_rtl = '';
            if( is_rtl() ){
                $wind_energy_rtl = 'dir="rtl"';
            } ?>

            <div class="theme-custom-block featured-categories-block">

                <div class="wrapper">
                    <div class="about-main">
                        <div class="about-image">
                            <img src="<?php echo esc_url( $wind_energy_about_us_image ); ?>">
                        </div>
                        <div class="featureheading-1">
                           <?php if( $wind_energy_cat_short_title ){ ?>
                                <h6 class="entry-title"><?php echo esc_html( $wind_energy_cat_short_title ); ?></h6>
                            <?php } ?>
                            <?php if( $wind_energy_cat_main_title ){ ?>
                                <h2 class="entry-title"><?php echo esc_html( $wind_energy_cat_main_title ); ?></h2>
                            <?php } ?>
                            <?php if( $wind_energy_cat_main_content){ ?>
                                <p class="entry-content"><?php echo esc_html( $wind_energy_cat_main_content ); ?></p>
                            <?php } ?>
                            <div class="button-box">
                                <?php if( $wind_energy_about_button_text || $wind_energy_about_button_url){ ?>
                                    <div class="about-btn">
                                        <a class="about-btn" href="<?php echo esc_url( $wind_energy_about_button_url ); ?>"><?php echo esc_html( $wind_energy_about_button_text ); ?></a>
                                    </div>
                                <?php } ?>
                                <div class="about-small-image">
                                    <img src="<?php echo esc_url( $wind_energy_about_us_right_small_image ); ?>">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="contact-main-box">
                        <div class="theme-header-areas header-areas-left suport-box">
                            <?php if( $wind_energy_about_us_phone_number ){ ?>
                                <span class="call-header">
                                    <svg xmlns="http://www.w3.org/2000/svg" height="1.8em" 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>
                                    <span class="contact-box">
                                        <span><?php echo esc_html( 'Call Us','wind-energy' ); ?></span>
                                        <span><a href="tell:<?php echo esc_attr( $wind_energy_about_us_phone_number ); ?>"><?php echo esc_html( $wind_energy_about_us_phone_number ); ?></a>
                                        </span>
                                    </span>
                                </span>
                            <?php } ?>
                        </div>
                        <div class="theme-header-areas header-areas-left suport-box">
                            <?php if( $wind_energy_about_us_layout_email_id ){ ?>
                                <span class="call-header">
                                    <svg xmlns="http://www.w3.org/2000/svg" height="1.8em" 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="M176 216h160c8.8 0 16-7.2 16-16v-16c0-8.8-7.2-16-16-16H176c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16zm-16 80c0 8.8 7.2 16 16 16h160c8.8 0 16-7.2 16-16v-16c0-8.8-7.2-16-16-16H176c-8.8 0-16 7.2-16 16v16zm96 121.1c-16.4 0-32.8-5.1-46.9-15.2L0 250.9V464c0 26.5 21.5 48 48 48h416c26.5 0 48-21.5 48-48V250.9L302.9 401.9c-14 10.1-30.4 15.2-46.9 15.2zm237.6-254.2c-8.9-6.9-17.2-13.5-29.6-22.8V96c0-26.5-21.5-48-48-48h-77.6c-3-2.2-5.9-4.3-9-6.6C312.6 29.2 279.2-.4 256 0c-23.2-.4-56.6 29.2-73.4 41.4-3.2 2.3-6 4.4-9 6.6H96c-26.5 0-48 21.5-48 48v44.1c-12.4 9.3-20.8 15.9-29.6 22.8A48 48 0 0 0 0 200.7v10.7l96 69.4V96h320v184.7l96-69.4v-10.7c0-14.7-6.8-28.7-18.4-37.8z"/></svg>
                                    <span class="contact-box">
                                        <span><?php echo esc_html( 'Mail Us','wind-energy' ); ?></span>
                                        <span>
                                            <a href="mailto:<?php echo esc_attr( $wind_energy_about_us_layout_email_id ); ?>"><?php echo esc_html( $wind_energy_about_us_layout_email_id ); ?></a> 
                                        </span>
                                    </span>
                                </span>
                            <?php } ?>
                        </div>
                    </div>
                </div>
            </div>
        <?php
        }

    }

endif;

if( !function_exists( 'wind_energy_sanitize_menu_transform' ) ) :

    // Sidebar Option Sanitize.
    function wind_energy_sanitize_menu_transform( $wind_energy_input ){

        $wind_energy_metabox_options = array( 'capitalize','uppercase','lowercase');
        if( in_array( $wind_energy_input,$wind_energy_metabox_options ) ){

            return $wind_energy_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'wind_energy_sanitize_page_content_alignment' ) ) :

    // Sidebar Option Sanitize.
    function wind_energy_sanitize_page_content_alignment( $wind_energy_input ){

        $wind_energy_metabox_options = array( 'left','center','right');
        if( in_array( $wind_energy_input,$wind_energy_metabox_options ) ){

            return $wind_energy_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'wind_energy_sanitize_footer_widget_title_alignment' ) ) :

    // Footer Option Sanitize.
    function wind_energy_sanitize_footer_widget_title_alignment( $wind_energy_input ){

        $wind_energy_metabox_options = array( 'left','center','right');
        if( in_array( $wind_energy_input,$wind_energy_metabox_options ) ){

            return $wind_energy_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'wind_energy_sanitize_pagination_type' ) ) :

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

if( !function_exists( 'wind_energy_sanitize_copyright_alignment_meta' ) ) :

    // Sidebar Option Sanitize.
    function wind_energy_sanitize_copyright_alignment_meta( $wind_energy_input ){

        $wind_energy_metabox_options = array( 'Default','Reverse','Center');
        if( in_array( $wind_energy_input,$wind_energy_metabox_options ) ){

            return $wind_energy_input;

        }else{

            return '';

        }
    }

endif;

/**
 * Sidebar Layout Function
 */
function wind_energy_get_final_sidebar_layout() {
	$wind_energy_defaults       = wind_energy_get_default_theme_options();
	$wind_energy_global_layout  = get_theme_mod('wind_energy_global_sidebar_layout', $wind_energy_defaults['wind_energy_global_sidebar_layout']);
	$wind_energy_page_layout    = get_theme_mod('wind_energy_page_sidebar_layout', $wind_energy_global_layout);
	$wind_energy_post_layout    = get_theme_mod('wind_energy_post_sidebar_layout', $wind_energy_global_layout);
	$wind_energy_meta_layout    = get_post_meta(get_the_ID(), 'wind_energy_post_sidebar_option', true);

	if (!empty($wind_energy_meta_layout) && $wind_energy_meta_layout !== 'default') {
		return $wind_energy_meta_layout;
	}
	if (is_page() || (function_exists('is_shop') && is_shop())) {
		return $wind_energy_page_layout;
	}
	if (is_single()) {
		return $wind_energy_post_layout;
	}
	return $wind_energy_global_layout;
}