<?php
/**
 *
 * Front Page
 *
 * @package NewsNation
 */

get_header();


    $newsnation_default = newsnation_get_default_theme_options();
    $newsnation_default = newsnation_get_default_theme_options();
    $sidebar = esc_attr( get_theme_mod( 'global_sidebar_layout', $newsnation_default['global_sidebar_layout'] ) );
    

    if( is_single() || is_page() ){

        $newsnation_post_sidebar = esc_attr( get_post_meta( $post->ID, 'newsnation_post_sidebar_option', true ) );
        if( $newsnation_post_sidebar == 'global-sidebar' || empty( $newsnation_post_sidebar ) ){

            $sidebar = $sidebar;
        }else{
            $sidebar = $newsnation_post_sidebar;
        }

    }
    $wpi_newsnation_home_sections_2 = get_theme_mod( 'wpi_newsnation_home_sections_2', json_encode( $newsnation_default['wpi_newsnation_home_sections_2'] ) );
    $repeat_times = 1;
    $paged_active = false;

    if ( !is_paged() ) {
        $paged_active = true;
    }

    $wpi_newsnation_home_sections_2 = json_decode( $wpi_newsnation_home_sections_2 );

    if( $wpi_newsnation_home_sections_2 ){ ?>

        <?php
        foreach ( $wpi_newsnation_home_sections_2 as $newsnation_home_section ) {

            $home_section_type = isset( $newsnation_home_section->home_section_type ) ? $newsnation_home_section->home_section_type : '';

            switch ($home_section_type) {

                case 'default-banner-area':

                    $ed_horizontal_vertical_slider = isset( $newsnation_home_section->section_ed ) ? $newsnation_home_section->section_ed : '';
                    if ( $ed_horizontal_vertical_slider == 'yes' && $paged_active ) {
                        newsnation_horizontal_vertical_slider( $newsnation_home_section , $repeat_times);
                    }

                break;

                case 'video-slider':

                    $ed_slider_blocks = isset( $newsnation_home_section->section_ed ) ? $newsnation_home_section->section_ed : '';
                    if ( $ed_slider_blocks == 'yes' && $paged_active ) {
                        newsnation_main_banner( $newsnation_home_section , $repeat_times);
                    }

                break;


                case 'must-read':

                    $ed_must_read = isset( $newsnation_home_section->section_ed ) ? $newsnation_home_section->section_ed : '';
                    if ( $ed_must_read == 'yes' && $paged_active ) {
                        newsnation_must_read( $newsnation_home_section , $repeat_times);
                    }

                break;


                case 'latest-posts-blocks':

                    $ed_latest_posts_blocks = isset( $newsnation_home_section->section_ed ) ? $newsnation_home_section->section_ed : '';
                    if ( $ed_latest_posts_blocks == 'yes' ) {
                        newsnation_latest_blocks( $newsnation_home_section  , $repeat_times);
                    }

                break;

                case 'tiles-blocks':

                    $ed_tiles_block = isset( $newsnation_home_section->section_ed ) ? $newsnation_home_section->section_ed : '';
                    if ( $ed_tiles_block == 'yes' && $paged_active ) {
                        newsnation_tiles_block_section( $newsnation_home_section , $repeat_times);
                    }

                break;

                case 'banner-blocks-1':

                    $ed_banner_blocks_1 = isset( $newsnation_home_section->section_ed ) ? $newsnation_home_section->section_ed : '';
                    if ( $ed_banner_blocks_1 == 'yes' && $paged_active ) {
                        newsnation_banner_block_1_section( $newsnation_home_section , $repeat_times);
                    }

                break;

                case 'advertise-blocks':

                    $ed_advertise_blocks = isset( $newsnation_home_section->section_ed ) ? $newsnation_home_section->section_ed : '';
                    if ( $ed_advertise_blocks == 'yes' && $paged_active ) {
                        newsnation_advertise_block( $newsnation_home_section , $repeat_times);
                    }
                    
                break;

                case 'home-widget-area':

                    $ed_home_widget_area = isset( $newsnation_home_section->section_ed ) ? $newsnation_home_section->section_ed : '';
                    if ( $ed_home_widget_area == 'yes' && $paged_active ) {
                        newsnation_case_home_widget_area_block( $newsnation_home_section , $repeat_times);
                    }
                    
                break;

                case 'you-may-like-blocks':

                    $ed_you_may_like_area = isset( $newsnation_home_section->section_ed ) ? $newsnation_home_section->section_ed : '';
                    if ( $ed_you_may_like_area == 'yes' && $paged_active ) {
                        newsnation_you_may_like_block_section( $newsnation_home_section , $repeat_times);
                    }
                    
                break;

                default:

                break;

            }

        $repeat_times++;
        } 
        ?>

    <?php
    }

get_footer();
