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

get_header();


    $vintuna_default = vintuna_get_default_theme_options();
    $vintuna_default = vintuna_get_default_theme_options();
    $sidebar = esc_attr( get_theme_mod( 'global_sidebar_layout', $vintuna_default['global_sidebar_layout'] ) );
    

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

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

            $sidebar = $sidebar;
        }else{
            $sidebar = $vintuna_post_sidebar;
        }

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

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

    $wpi_vintuna_home_sections_2 = json_decode( $wpi_vintuna_home_sections_2 );

    if( $wpi_vintuna_home_sections_2 ){ ?>

        <?php
        foreach ( $wpi_vintuna_home_sections_2 as $vintuna_home_section ) {

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

            switch ($home_section_type) {

                case 'default-banner-area':

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

                break;

                case 'video-slider':

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

                break;


                case 'must-read':

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

                break;


                case 'latest-posts-blocks':

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

                break;

                case 'tiles-blocks':

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

                break;

                case 'banner-blocks-1':

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

                break;

                case 'advertise-blocks':

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

                case 'home-widget-area':

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

                case 'you-may-like-blocks':

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

                default:

                break;

            }

        $repeat_times++;
        } 
        ?>

    <?php
    }

get_footer();
