<?php 

/**
* Front Stories Section Hook 
*/
if ( ! function_exists( 'front_stories_section_hook' ) ) :
    function front_stories_section_hook() {  ?>

    <section class="trending-stories my-100 py-100">
        <div class="container">
            <div class="section-title">
                <div class="section-title-wrapper">
                    <div class="section-title-wrap">
                        <<?php echo esc_attr( get_theme_mod( 'storis_news_section_title_tag', 'h2' ) ); ?> class="big-title tranding-stories-title" data-aos="fade-right" data-aos-duration="800" data-aos-delay="100"><?php echo esc_html( get_theme_mod( 'storis_news_section_title', __('Trending Stories','newscope') ) ); ?></<?php echo esc_attr( get_theme_mod( 'storis_news_section_title_tag', 'h2' ) ); ?>>
                    </div>
                </div>
            </div>
        </div>
        <div class="swiper trending-stories-swiper">
            <div class="swiper-wrapper">
                <?php do_action( 'newscope_stories_post_loop_action' ); ?>
            </div>
            <div class="trending-pagination-wrapper">
                <div class="pagination-icon-right">
                    <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/image/trending-stories/pagination-arrow-right.svg" alt="pagnination-icon">
                </div>
                <div class="pagination-wrap">
                    <div class="swiper-pagination"></div>
                </div>
                <div class="pagination-icon-left">
                    <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/image/trending-stories/pagination-arrow-left.svg" alt="pagnination-icon">
                </div>
            </div>
        </div>
    </section>

    <?php if( true === get_theme_mod( 'stories_ads_banner_section', false ) ) : ?>
    <section class="fashion-sale my-100">
        <div class="container">
            <div class="fashion-sale-wrapper" data-aos="fade-up" data-aos-duration="800" data-aos-delay="100">
                <?php if( get_theme_mod( 'stories_section_ads_type', 'link' ) === 'link' && !empty( get_theme_mod( 'stories_section_ads_image') ) ) : 
                    $ads = get_theme_mod( 'stories_section_ads_image');
                    $ads_alt = get_post_meta( $ads['id'], '_wp_attachment_image_alt', true );
                    $ads_title = get_the_title( $ads['id']);
                ?>
                    <a href="<?php echo esc_url_raw(get_theme_mod( 'stories_section_ads_url')) ?>">
                        <img src="<?php echo esc_url($ads['url']); ?>" alt="<?php echo esc_attr($ads_alt); ?>" title="<?php echo esc_attr($ads_title); ?>">
                    </a>
                <?php endif; ?>
            </div>
        </div>
    </section>
    <?php endif; ?>

    <?php  }
endif;
add_action( 'front_stories_section_action', 'front_stories_section_hook' );