<?php
/**
 * The main template file
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package newshit
 */

get_header();
?>
    <?php
        /**
        * Hook - newshit_action_before_front_page.
        *
        * @hooked newshit_front_page_start
        */
        do_action( 'newshit_action_before_front_page' );  
    
        /**
        * Hook - newshit_action_braking_news.
        */
        if( true === get_theme_mod( 'enable_news_sticker', true )){
            do_action( 'newshit_action_braking_news' ); 
        }


        /**
        * Hook - front_banner_section_action.
        */
        if( true === get_theme_mod( 'enable_news_main_section', true ) ){
            do_action( 'front_banner_section_action' ); 
        }
        
        /**
        * Hook - front_featured_section_action.
        */
        if( true === get_theme_mod( 'enable_news_featured', false ) ){
            do_action( 'front_featured_section_action');
        }

        if( true === get_theme_mod( 'news_featured_ads_enable', false ) ) : ?>
            <div class="container">
                <div class="newshit-featured-section-ads-wrapper <?php echo esc_attr( true === get_theme_mod( 'enable_news_featured', true ) ? 'mt-1' : 'mt-4' ); ?> text-center">
                    <div class="newshit-global-ads-wrapper">
                        <?php if( get_theme_mod( 'featured_section_ads_type', 'link' ) === 'link' && !empty( get_theme_mod( 'featured_section_ads_image') ) ) : 
                            $ads = get_theme_mod( 'featured_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( 'featured_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 else : ?>
                            <img src="<?php echo esc_url( get_template_directory_uri() ); ?>/assets/image/ads/header-ads.png" alt="<?php esc_attr_e( 'NewsHit ads', 'newshit' ); ?>">
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        <?php endif;

        /**
        * Hook - front_featured_section_action.
        */
        do_action( 'front_content_with_sidebar_action');

        if( true === get_theme_mod( 'enable_three_box_section', false ) ){
            /**
            * Hook - front_three_box_section_action.
            */
            do_action( 'front_three_box_section_action');
        }
        
        /**
        * Hook - front_video_section_action.
        */
        do_action( 'front_video_section_action');
        
        if( true === get_theme_mod( 'enable_news_most_liked', true ) ){
        /**
        * Hook - front_video_section_action.
        */
            do_action( 'front_most_liked_section_action');
        }
        
        if( true === get_theme_mod( 'enable_newsletter_section', false ) ){
        /**
        * Hook - front_newsletter_section_action.
        */
            do_action( 'front_newsletter_section_action');
        }


        /**
        * Hook - newshit_action_after_front_page.
        *
        * @hooked newshit_front_page_end
        */
        do_action( 'newshit_action_after_front_page' );
    ?>
<?php
get_footer();