<?php
/**
 * Custom Functions.
 *
 * @package Cargo And Shipping Company
 */

if( !function_exists( 'cargo_and_shipping_company_fonts_url' ) ) :

    //Google Fonts URL
    function cargo_and_shipping_company_fonts_url(){

        $cargo_and_shipping_company_font_families = array(
            'Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900',
        );

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

        return esc_url_raw($cargo_and_shipping_company_fonts_url);
    }

endif;

if ( ! function_exists( 'cargo_and_shipping_company_sub_menu_toggle_button' ) ) :

    function cargo_and_shipping_company_sub_menu_toggle_button( $cargo_and_shipping_company_args, $cargo_and_shipping_company_item, $depth ) {

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

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

                $cargo_and_shipping_company_toggle_target_string = '.menu-item.menu-item-' . $cargo_and_shipping_company_item->ID . ' > .sub-menu';

                // Add the sub menu toggle
                $cargo_and_shipping_company_args->after .= '<button type="button" class="theme-aria-button submenu-toggle" data-toggle-target="' . $cargo_and_shipping_company_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', 'cargo-and-shipping-company' ) . '</span>' . cargo_and_shipping_company_get_theme_svg( 'plus' ) . '</span></button>';

            }

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

        }elseif( $cargo_and_shipping_company_args->theme_location == 'cargo-and-shipping-company-primary-menu' ) {

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

                $cargo_and_shipping_company_args->before = '<div class="link-icon-wrapper">';
                $cargo_and_shipping_company_args->after  = cargo_and_shipping_company_get_theme_svg( 'plus' ) . '</div>';

            } else {

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

            }

        }

        return $cargo_and_shipping_company_args;

    }

endif;

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

if ( ! function_exists( 'cargo_and_shipping_company_the_theme_svg' ) ):
    
    function cargo_and_shipping_company_the_theme_svg( $cargo_and_shipping_company_svg_name, $cargo_and_shipping_company_return = false ) {

        if( $cargo_and_shipping_company_return ){

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

        }else{

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

        }
    }

endif;

if ( ! function_exists( 'cargo_and_shipping_company_get_theme_svg' ) ):

    function cargo_and_shipping_company_get_theme_svg( $cargo_and_shipping_company_svg_name ) {

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

    }

endif;

if( !function_exists( 'cargo_and_shipping_company_post_category_list' ) ) :

    // Post Category List.
    function cargo_and_shipping_company_post_category_list( $cargo_and_shipping_company_select_cat = true ){

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

        $cargo_and_shipping_company_post_cat_cat_array = array();
        if( $cargo_and_shipping_company_select_cat ){

            $cargo_and_shipping_company_post_cat_cat_array[''] = esc_html__( '-- Select Category --','cargo-and-shipping-company' );

        }

        foreach ( $cargo_and_shipping_company_post_cat_lists as $cargo_and_shipping_company_post_cat_list ) {

            $cargo_and_shipping_company_post_cat_cat_array[$cargo_and_shipping_company_post_cat_list->slug] = $cargo_and_shipping_company_post_cat_list->name;

        }

        return $cargo_and_shipping_company_post_cat_cat_array;
    }

endif;

if( !function_exists('cargo_and_shipping_company_single_post_navigation') ):

    function cargo_and_shipping_company_single_post_navigation(){

        $cargo_and_shipping_company_footer_column_layout = cargo_and_shipping_company_get_default_theme_options();
        $cargo_and_shipping_company_twp_navigation_type = esc_attr( get_post_meta( get_the_ID(), 'cargo_and_shipping_company_twp_disable_ajax_load_next_post', true ) );
        $cargo_and_shipping_company_current_id = '';
        $article_wrap_class = '';
        global $post;
        $cargo_and_shipping_company_current_id = $post->ID;
        if( $cargo_and_shipping_company_twp_navigation_type == '' || $cargo_and_shipping_company_twp_navigation_type == 'global-layout' ){
            $cargo_and_shipping_company_twp_navigation_type = get_theme_mod('cargo_and_shipping_company_twp_navigation_type', $cargo_and_shipping_company_footer_column_layout['cargo_and_shipping_company_twp_navigation_type']);
        }

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

            if( $cargo_and_shipping_company_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">' . cargo_and_shipping_company_the_theme_svg('arrow-left',$cargo_and_shipping_company_return = true ) . '</span><span class="screen-reader-text">' . esc_html__('Previous post:', 'cargo-and-shipping-company') . '</span><span class="post-title">%title</span>',
                        'next_text' => '<span class="arrow" aria-hidden="true">' . cargo_and_shipping_company_the_theme_svg('arrow-right',$cargo_and_shipping_company_return = true ) . '</span><span class="screen-reader-text">' . esc_html__('Next post:', 'cargo-and-shipping-company') . '</span><span class="post-title">%title</span>',
                    )); ?>
                </div>
                <?php

            }else{

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

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

                }
            }

        }

    }

endif;

add_action( 'cargo_and_shipping_company_navigation_action','cargo_and_shipping_company_single_post_navigation',30 );

if( !function_exists('cargo_and_shipping_company_content_offcanvas') ):

    // Offcanvas Contents
    function cargo_and_shipping_company_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', 'cargo-and-shipping-company'); ?>
                            </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', 'cargo-and-shipping-company'); ?>" role="navigation">
                        <ul class="primary-menu theme-menu">
                            <?php
                            if (has_nav_menu('cargo-and-shipping-company-primary-menu')) {
                                wp_nav_menu(
                                    array(
                                        'container' => '',
                                        'items_wrap' => '%3$s',
                                        'theme_location' => 'cargo-and-shipping-company-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 Cargo_And_Shipping_Company_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( 'cargo_and_shipping_company_before_footer_content_action','cargo_and_shipping_company_content_offcanvas',30 );

if( !function_exists('cargo_and_shipping_company_footer_content_widget') ):

    function cargo_and_shipping_company_footer_content_widget(){
        
        $cargo_and_shipping_company_default = cargo_and_shipping_company_get_default_theme_options();
        
        $cargo_and_shipping_company_footer_column_layout = absint(get_theme_mod('cargo_and_shipping_company_footer_column_layout', $cargo_and_shipping_company_default['cargo_and_shipping_company_footer_column_layout']));
        $cargo_and_shipping_company_footer_sidebar_class = 12;
        
        if($cargo_and_shipping_company_footer_column_layout == 2) {
            $cargo_and_shipping_company_footer_sidebar_class = 6;
        }
        
        if($cargo_and_shipping_company_footer_column_layout == 3) {
            $cargo_and_shipping_company_footer_sidebar_class = 4;
        }
        ?>
        
        <?php if ( get_theme_mod('cargo_and_shipping_company_display_footer', true) == true ) : ?>
            <div class="footer-widgetarea">
                <div class="wrapper">
                    <div class="column-row">
                    
                        <?php for ($i = 0; $i < $cargo_and_shipping_company_footer_column_layout; $i++) : ?>
                            
                            <div class="column <?php echo 'column-' . absint($cargo_and_shipping_company_footer_sidebar_class); ?> column-sm-12">
                                
                                <?php 
                                // If no widgets are assigned, display default widgets
                                if ( ! is_active_sidebar( 'cargo-and-shipping-company-footer-widget-' . $i ) ) : 

                                    if ($i === 0) : ?>
                                        <div id="text-3" class="widget widget_text">
                                            <div class="textwidget">
                                                <h2 class="widget-title"><?php esc_html_e('About Us', 'cargo-and-shipping-company'); ?></h2>
                                                <p class="widget_text">
                                                    <?php esc_html_e('We are dealing cargo shipping, cargo services, global shipping, shipping company, cargo company, freight shipping, ocean freight, air freight, sea cargo, cargo transport, shipping solutions, cargo logistics, freight company, shipping agency, cargo movers, cargo carriers, shipping freight, international shipping, cargo handling, freight logistics, shipping cargo, cargo network, freight services, cargo supply, shipping routes, global freight, export shipping, import shipping, cargo operations, freight transport, shipping lines, container shipping and many more...', 'cargo-and-shipping-company'); ?>
                                                </p>
                                            </div>
                                        </div>

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

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

    <?php
    }

endif;

add_action( 'cargo_and_shipping_company_footer_content_action', 'cargo_and_shipping_company_footer_content_widget', 10 );

if( !function_exists('cargo_and_shipping_company_footer_content_info') ):

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

        $cargo_and_shipping_company_footer_column_layout = cargo_and_shipping_company_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
                                $cargo_and_shipping_company_footer_copyright_text = wp_kses_post( get_theme_mod( 'cargo_and_shipping_company_footer_copyright_text', $cargo_and_shipping_company_footer_column_layout['cargo_and_shipping_company_footer_copyright_text'] ) );
                                    echo esc_html( $cargo_and_shipping_company_footer_copyright_text );
                                    echo '<br>';
                                    echo esc_html__('Theme: ', 'cargo-and-shipping-company') . '<a href="' . esc_url('https://www.omegathemes.com/products/cargo-and-shipping-company') . '" title="' . esc_attr__('Cargo And Shipping Company ', 'cargo-and-shipping-company') . '" target="_blank"><span>' . esc_html__('Cargo And Shipping Company  ', 'cargo-and-shipping-company') . '</span></a>' . esc_html__(' By ', 'cargo-and-shipping-company') . '  <span>' . esc_html__('OMEGA ', 'cargo-and-shipping-company') . '</span>';
                                    echo esc_html__('Powered by ', 'cargo-and-shipping-company') . '<a href="' . esc_url('https://wordpress.org') . '" title="' . esc_attr__('WordPress', 'cargo-and-shipping-company') . '" target="_blank"><span>' . esc_html__('WordPress.', 'cargo-and-shipping-company') . '</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('cargo_and_shipping_company_enable_to_the_top', true) == true ) : ?>
                                    <?php
                                    $cargo_and_shipping_company_to_the_top_text = get_theme_mod( 'cargo_and_shipping_company_to_the_top_text', __( 'To the Top', 'cargo-and-shipping-company' ) );
                                    printf( 
                                        wp_kses( 
                                            /* translators: %s is the arrow icon markup */
                                            '%s %s', 
                                            array( 'span' => array( 'class' => array(), 'aria-hidden' => array() ) ) 
                                        ), 
                                        esc_html( $cargo_and_shipping_company_to_the_top_text ),
                                        '<span class="arrow" aria-hidden="true">&uarr;</span>' 
                                    );
                                    ?>
                                <?php endif; ?>
                            </span>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    <?php
    }

endif;

add_action( 'cargo_and_shipping_company_footer_content_action','cargo_and_shipping_company_footer_content_info',20 );



if( !function_exists( 'cargo_and_shipping_company_main_slider' ) ) :

function cargo_and_shipping_company_main_slider(){

    $defaults = cargo_and_shipping_company_get_default_theme_options();

    // Get number of sliders (user defined)
    $cargo_and_shipping_company_slider_count = get_theme_mod('cargo_and_shipping_company_slider_count', isset($cargo_and_shipping_company_defaults['cargo_and_shipping_company_slider_count']) ? $cargo_and_shipping_company_defaults['cargo_and_shipping_company_slider_count'] : 1);

    // Exit if slider not enabled
    $cargo_and_shipping_company_enable_slider = get_theme_mod('cargo_and_shipping_company_header_banner', isset($cargo_and_shipping_company_defaults['cargo_and_shipping_company_header_banner']) ? $cargo_and_shipping_company_defaults['cargo_and_shipping_company_header_banner'] : true);
    if( !$cargo_and_shipping_company_enable_slider ){
        return;
    }

    $cargo_and_shipping_company_rtl_attr = is_rtl() ? 'dir="rtl"' : '';

    if( $cargo_and_shipping_company_slider_count > 0 ) : ?>
        <div class="theme-custom-block theme-banner-block">
            <div class="slider-box">
                <div class="swiper-container theme-main-carousel" <?php echo $cargo_and_shipping_company_rtl_attr; ?>>
                    <div class="swiper-wrapper">

                        <?php for( $cargo_and_shipping_company_i = 1; $cargo_and_shipping_company_i <= $cargo_and_shipping_company_slider_count; $cargo_and_shipping_company_i++ ) :
                            $cargo_and_shipping_company_image       = get_theme_mod("cargo_and_shipping_company_slider_image_$cargo_and_shipping_company_i");
                            $cargo_and_shipping_company_short_title = esc_html( get_theme_mod("cargo_and_shipping_company_slider_short_title_$cargo_and_shipping_company_i"));
                            $cargo_and_shipping_company_slider_title       = esc_html( get_theme_mod("cargo_and_shipping_company_slider_title_$cargo_and_shipping_company_i"));
                            $cargo_and_shipping_company_slider_content     = esc_html( get_theme_mod("cargo_and_shipping_company_slider_content_$cargo_and_shipping_company_i"));
                            $cargo_and_shipping_company_slider_btn_text    = esc_html( get_theme_mod("cargo_and_shipping_company_slider_btn_text_$cargo_and_shipping_company_i"));
                            $cargo_and_shipping_company_btn_url     = esc_url( get_theme_mod("cargo_and_shipping_company_slider_btn_url_$cargo_and_shipping_company_i") );

                            if( empty($cargo_and_shipping_company_image) ) {
                                $cargo_and_shipping_company_image = get_template_directory_uri() . '/assets/images/slide-bg.png';
                            }
                        ?>

                        <div class="swiper-slide main-carousel-item">
                            <div class="slider-main">
                                <div class="data-bg banner-img" data-background="<?php echo esc_url( $cargo_and_shipping_company_image ); ?>">
                                    <?php if ( !empty($cargo_and_shipping_company_btn_url) ) : ?>
                                        <a href="<?php echo $cargo_and_shipping_company_btn_url; ?>" class="theme-image-responsive"></a>
                                    <?php else : ?>
                                        <a href="#" class="theme-image-responsive"></a>
                                    <?php endif; ?>
                                </div>

                                <div class="main-carousel-caption">
                                    <div class="post-content">
                                        <header class="entry-header">
                                            <?php if( $cargo_and_shipping_company_short_title ){ ?>
                                                <h3><?php echo $cargo_and_shipping_company_short_title; ?></h3>
                                            <?php } ?>

                                            <?php if( $cargo_and_shipping_company_slider_title ){ ?>
                                                <h2 class="entry-title entry-title-big">
                                                    <span><?php echo $cargo_and_shipping_company_slider_title; ?></span>
                                                </h2>
                                            <?php } ?>
                                        </header>

                                        <?php if( $cargo_and_shipping_company_slider_content ){ ?>
                                            <div class="entry-content">
                                                <?php echo wp_kses_post( wp_trim_words( $cargo_and_shipping_company_slider_content, 25, '...' ) ); ?>
                                            </div>
                                        <?php } ?>

                                        <?php if( $cargo_and_shipping_company_slider_btn_text ){ ?>
                                            <a href="<?php echo $cargo_and_shipping_company_btn_url ? $cargo_and_shipping_company_btn_url : '#'; ?>" class="btn-fancy btn-fancy-primary" tabindex="0">
                                                <?php echo $cargo_and_shipping_company_slider_btn_text; ?>
                                            </a>
                                        <?php } ?>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <?php endfor; ?>

                    </div>
                    <div class="custom-navigation">
                        <div class="swiper-button-prev custom-prev">
                            <span class="arrow"></span>
                        </div>
                        <div class="swiper-button-next custom-next">
                            <span class="arrow"></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    <?php
    endif;
}

endif;

    if( !function_exists( 'cargo_and_shipping_company_product_section' ) ) :

    function cargo_and_shipping_company_product_section(){ 

        $cargo_and_shipping_company_footer_column_layout = cargo_and_shipping_company_get_default_theme_options();

        $cargo_and_shipping_company_header_about_us = get_theme_mod( 'cargo_and_shipping_company_header_about_us', 
        $cargo_and_shipping_company_footer_column_layout['cargo_and_shipping_company_header_about_us'] );

        $cargo_and_shipping_company_about_us_section_title = esc_html( get_theme_mod( 'cargo_and_shipping_company_about_us_section_title',
        $cargo_and_shipping_company_footer_column_layout['cargo_and_shipping_company_about_us_section_title'] ) );

        $cargo_and_shipping_company_about_us_section_sub_title = esc_html( get_theme_mod( 'cargo_and_shipping_company_about_us_section_sub_title',
        $cargo_and_shipping_company_footer_column_layout['cargo_and_shipping_company_about_us_section_sub_title'] ) );

        $cargo_and_shipping_company_video_section_left_post_cat = get_theme_mod( 'cargo_and_shipping_company_video_section_left_post_cat' );
        
        if( $cargo_and_shipping_company_header_about_us ){ ?>
            <div class="most-read">
                <div class="wrapper">
                    <div class="list-heading-main">
                        <p class="list-title">
                            <?php if( $cargo_and_shipping_company_about_us_section_title ){ ?>
                                <?php echo esc_html($cargo_and_shipping_company_about_us_section_title) ?>
                            <?php } ?>
                        </p>
                        <h3 class="list-sub-title">
                            <?php if( $cargo_and_shipping_company_about_us_section_sub_title ){ ?>
                                <?php echo esc_html($cargo_and_shipping_company_about_us_section_sub_title) ?>
                            <?php } ?>
                        </h3>
                    </div>
                    <div class="most-read-div">
                        <div class="owl-carousel" role="listbox">
                            <?php  $cargo_and_shipping_company_locations_query = new WP_Query( array('post_type' => 'post', 'posts_per_page' => 6,'post__not_in' => get_option("sticky_posts"), 'category_name' => esc_html( $cargo_and_shipping_company_video_section_left_post_cat ) ) );
                            if( $cargo_and_shipping_company_locations_query->have_posts() ): ?>
                                <?php
                                    $s=1;
                                    while( $cargo_and_shipping_company_locations_query->have_posts() ):
                                    $cargo_and_shipping_company_locations_query->the_post();
                                    $cargo_and_shipping_company_featured_packs_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
                                    $cargo_and_shipping_company_featured_packs_image = isset( $cargo_and_shipping_company_featured_packs_image[0] ) ? $cargo_and_shipping_company_featured_packs_image[0] : '';

                                    ?>                                
                                    <div class="theme-article-post video-left-post-content">
                                        <div class="entry-thumbnail">
                                            <div class="data-bg featured-img" data-background="<?php echo esc_url($cargo_and_shipping_company_featured_packs_image ? $cargo_and_shipping_company_featured_packs_image : get_template_directory_uri() . '/assets/images/packs.png'); ?>">
                                            </div>
                                            <p class="postbtn"><a href="<?php esc_url( get_permalink() ); ?>"> <?php echo esc_html('More Details','cargo-and-shipping-company'); ?> </a></p>
                                            <?php cargo_and_shipping_company_post_format_icon(); ?>
                                        </div>
                                        <div class="main-video-caption">
                                            <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(), 35, '...'));

                                                } ?>
                                            </div>
                                        </div>
                                    </div>
                                <?php $s++; endwhile; ?>
                            <?php wp_reset_postdata(); endif; ?>
                        </div>
                    </div>
                </div>
            </div>
        <?php } ?>
    <?php }

endif;

if (!function_exists('cargo_and_shipping_company_post_format_icon')):

    // Post Format Icon.
    function cargo_and_shipping_company_post_format_icon() {

        $cargo_and_shipping_company_format = get_post_format(get_the_ID()) ?: 'standard';
        $cargo_and_shipping_company_icon = '';
        $cargo_and_shipping_company_title = '';
        if( $cargo_and_shipping_company_format == 'video' ){
            $cargo_and_shipping_company_icon = cargo_and_shipping_company_get_theme_svg( 'video' );
            $cargo_and_shipping_company_title = esc_html__('Video','cargo-and-shipping-company');
        }elseif( $cargo_and_shipping_company_format == 'audio' ){
            $cargo_and_shipping_company_icon = cargo_and_shipping_company_get_theme_svg( 'audio' );
            $cargo_and_shipping_company_title = esc_html__('Audio','cargo-and-shipping-company');
        }elseif( $cargo_and_shipping_company_format == 'gallery' ){
            $cargo_and_shipping_company_icon = cargo_and_shipping_company_get_theme_svg( 'gallery' );
            $cargo_and_shipping_company_title = esc_html__('Gallery','cargo-and-shipping-company');
        }elseif( $cargo_and_shipping_company_format == 'quote' ){
            $cargo_and_shipping_company_icon = cargo_and_shipping_company_get_theme_svg( 'quote' );
            $cargo_and_shipping_company_title = esc_html__('Quote','cargo-and-shipping-company');
        }elseif( $cargo_and_shipping_company_format == 'image' ){
            $cargo_and_shipping_company_icon = cargo_and_shipping_company_get_theme_svg( 'image' );
            $cargo_and_shipping_company_title = esc_html__('Image','cargo-and-shipping-company');
        } elseif( $cargo_and_shipping_company_format == 'link' ){
            $cargo_and_shipping_company_icon = cargo_and_shipping_company_get_theme_svg( 'link' );
            $cargo_and_shipping_company_title = esc_html__('Link','cargo-and-shipping-company');
        } elseif( $cargo_and_shipping_company_format == 'status' ){
            $cargo_and_shipping_company_icon = cargo_and_shipping_company_get_theme_svg( 'status' );
            $cargo_and_shipping_company_title = esc_html__('Status','cargo-and-shipping-company');
        } elseif( $cargo_and_shipping_company_format == 'aside' ){
            $cargo_and_shipping_company_icon = cargo_and_shipping_company_get_theme_svg( 'aside' );
            $cargo_and_shipping_company_title = esc_html__('Aside','cargo-and-shipping-company');
        } elseif( $cargo_and_shipping_company_format == 'chat' ){
            $cargo_and_shipping_company_icon = cargo_and_shipping_company_get_theme_svg( 'chat' );
            $cargo_and_shipping_company_title = esc_html__('Chat','cargo-and-shipping-company');
        }
        
        if (!empty($cargo_and_shipping_company_icon)) { ?>
            <div class="theme-post-format">
                <span class="post-format-icom"><?php echo cargo_and_shipping_company_svg_escape($cargo_and_shipping_company_icon); ?></span>
                <?php if( $cargo_and_shipping_company_title ){ echo '<span class="post-format-label">'.esc_html( $cargo_and_shipping_company_title ).'</span>'; } ?>
            </div>
        <?php }
    }

endif;

if ( ! function_exists( 'cargo_and_shipping_company_svg_escape' ) ):

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

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

        return $cargo_and_shipping_company_svg;

    }

endif;

if( !function_exists( 'cargo_and_shipping_company_sanitize_sidebar_option_meta' ) ) :

    // Sidebar Option Sanitize.
    function cargo_and_shipping_company_sanitize_sidebar_option_meta( $cargo_and_shipping_company_input ){

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

            return $cargo_and_shipping_company_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'cargo_and_shipping_company_sanitize_pagination_meta' ) ) :

    // Sidebar Option Sanitize.
    function cargo_and_shipping_company_sanitize_pagination_meta( $cargo_and_shipping_company_input ){

        $cargo_and_shipping_company_metabox_options = array( 'Center','Right','Left');
        if( in_array( $cargo_and_shipping_company_input,$cargo_and_shipping_company_metabox_options ) ){

            return $cargo_and_shipping_company_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'cargo_and_shipping_company_sanitize_menu_transform' ) ) :

    // Sidebar Option Sanitize.
    function cargo_and_shipping_company_sanitize_menu_transform( $cargo_and_shipping_company_input ){

        $cargo_and_shipping_company_metabox_options = array( 'capitalize','uppercase','lowercase');
        if( in_array( $cargo_and_shipping_company_input,$cargo_and_shipping_company_metabox_options ) ){

            return $cargo_and_shipping_company_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'cargo_and_shipping_company_sanitize_page_content_alignment' ) ) :

    // Sidebar Option Sanitize.
    function cargo_and_shipping_company_sanitize_page_content_alignment( $cargo_and_shipping_company_input ){

        $cargo_and_shipping_company_metabox_options = array( 'left','center','right');
        if( in_array( $cargo_and_shipping_company_input,$cargo_and_shipping_company_metabox_options ) ){

            return $cargo_and_shipping_company_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'cargo_and_shipping_company_sanitize_footer_widget_title_alignment' ) ) :

    // Footer Option Sanitize.
    function cargo_and_shipping_company_sanitize_footer_widget_title_alignment( $cargo_and_shipping_company_input ){

        $cargo_and_shipping_company_metabox_options = array( 'left','center','right');
        if( in_array( $cargo_and_shipping_company_input,$cargo_and_shipping_company_metabox_options ) ){

            return $cargo_and_shipping_company_input;

        }else{

            return '';

        }
    }

endif;

if( !function_exists( 'cargo_and_shipping_company_sanitize_pagination_type' ) ) :

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

if( !function_exists( 'cargo_and_shipping_company_sanitize_copyright_alignment_meta' ) ) :

    // Sidebar Option Sanitize.
    function cargo_and_shipping_company_sanitize_copyright_alignment_meta( $cargo_and_shipping_company_input ){

        $cargo_and_shipping_company_metabox_options = array( 'Default','Reverse','Center');
        if( in_array( $cargo_and_shipping_company_input,$cargo_and_shipping_company_metabox_options ) ){

            return $cargo_and_shipping_company_input;

        }else{

            return '';

        }
    }

endif;

/**
 * Sidebar Layout Function
 */
function cargo_and_shipping_company_get_final_sidebar_layout() {
    $cargo_and_shipping_company_defaults       = cargo_and_shipping_company_get_default_theme_options();
    $cargo_and_shipping_company_global_layout  = get_theme_mod('cargo_and_shipping_company_global_sidebar_layout', $cargo_and_shipping_company_defaults['cargo_and_shipping_company_global_sidebar_layout']);
    $cargo_and_shipping_company_page_layout    = get_theme_mod('cargo_and_shipping_company_page_sidebar_layout', $cargo_and_shipping_company_global_layout);
    $cargo_and_shipping_company_post_layout    = get_theme_mod('cargo_and_shipping_company_post_sidebar_layout', $cargo_and_shipping_company_global_layout);
    $cargo_and_shipping_company_meta_layout    = get_post_meta(get_the_ID(), 'cargo_and_shipping_company_post_sidebar_option', true);

    if (!empty($cargo_and_shipping_company_meta_layout) && $cargo_and_shipping_company_meta_layout !== 'default') {
        return $cargo_and_shipping_company_meta_layout;
    }
    if (is_page() || (function_exists('is_shop') && is_shop())) {
        return $cargo_and_shipping_company_page_layout;
    }
    if (is_single()) {
        return $cargo_and_shipping_company_post_layout;
    }
    return $cargo_and_shipping_company_global_layout;
}