<?php
/**
 * The template for displaying home page.
 * @package Magazine Bell
 */

if ( 'posts' == get_option( 'show_on_front' )  || 'posts' != get_option( 'show_on_front' )){ 
    get_header(); ?>
    <?php 
    $enabled_sections = magazine_bell_get_sections();
    $homepage_design_layout     = magazine_bell_get_option( 'homepage_design_layout_options' );
    $decoration_image     = magazine_bell_get_option( 'decoration_side_enable' ); 
    ?>
    <div class="wrapper">

        <?php $disable_flash_section = magazine_bell_get_option( 'disable_flash_section' );
        $flash_lite_dark_bg = magazine_bell_get_option( 'flash_lite_dark_background' );
        if( true ==$disable_flash_section): ?>
            <section id="flash" class="relative page-section <?php echo esc_attr($flash_lite_dark_bg) ?>">
                <?php get_template_part( 'inc/sections/section-flash' ); ?>
            </section> 
        <?php endif; ?>
        <aside id="homepage-l-secondary" class="widget-area" role="complementary">
            <?php
            if ( is_active_sidebar( 'homepage-left-sidebar' ) ) {
                dynamic_sidebar('homepage-left-sidebar'); 
            } ?>
        </aside>
        <div id="home-primary" class="main-primary">
            <?php
            if( is_array( $enabled_sections ) &&  $homepage_design_layout== 'home-corporate') { 
                foreach( $enabled_sections as $section ) { ?>
                    <?php if( ( $section['id'] == 'featured-slider' ) ){ ?>
                        <?php $disable_featured_slider = magazine_bell_get_option( 'disable_featured-slider_section' );
                        if( true == $disable_featured_slider): ?>
                            <section id="<?php echo esc_attr( $section['id'] ); ?>">
                                
                                <?php $slider_layout = magazine_bell_get_option( 'slider_layout_option'); ?>
                                <?php if ($slider_layout=='default-slider'){ ?>
                                    <div class="wrapper">
                                        <?php get_template_part( 'inc/sections/section', esc_attr( $section['id'] ) ); ?>
                                    </div>
                                <?php } else {
                                    get_template_part( 'inc/sections/section', esc_attr( $section['id'] ) ); 
                                } ?>                       
                            </section>
                    <?php endif; ?>
                    <?php } elseif( $section['id'] == 'highlights' ) { ?>
                        <?php $disable_highlights_section = magazine_bell_get_option( 'disable_highlights_section' );
                        $highlights_lite_dark_bg = magazine_bell_get_option( 'highlights_lite_dark_background' );
                        if( true ==$disable_highlights_section): ?>
                            <section id="<?php echo esc_attr( $section['id'] ); ?>" class="relative page-section <?php echo esc_attr($highlights_lite_dark_bg) ?>">
                                    <?php get_template_part( 'inc/sections/section', esc_attr( $section['id'] ) ); ?>
                                
                            </section> 
                    <?php endif; ?>
                    <?php } elseif( $section['id'] == 'recent' ) { ?>
                        <?php $disable_recent_section = magazine_bell_get_option( 'disable_recent_section' ); 
                        $recent_lite_dark_background = magazine_bell_get_option( 'recent_lite_dark_background' );
                        if( true ==$disable_recent_section): ?>
                            <section id="<?php echo esc_attr( $section['id'] ); ?>" class="relative page-section <?php echo esc_attr($recent_lite_dark_background) ?>">
                                    <?php get_template_part( 'inc/sections/section', esc_attr( $section['id'] ) ); ?>
                            </section> 
                    <?php endif; ?>
                    <?php } elseif( $section['id'] == 'popular' ) { ?>
                        <?php $disable_popular_section = magazine_bell_get_option( 'disable_popular_section' );
                        if( true ==$disable_popular_section): ?>
                            <section id="<?php echo esc_attr( $section['id'] ); ?>" class="relative page-section">
                                
                                    <?php get_template_part( 'inc/sections/section', esc_attr( $section['id'] ) ); ?>
                                
                            </section> 
                    <?php endif; ?>
                    <?php } elseif( $section['id'] == 'categorynews' ) { ?>
                            <?php $disable_categorynews_section = magazine_bell_get_option( 'disable_categorynews_section' );
                             if( true ==$disable_categorynews_section): ?>
                                <?php   $number_of_categorynews_column = magazine_bell_get_option('number_of_categorynews_column'); ?>
                                <section id="<?php echo esc_attr( $section['id'] ); ?>" class="relative page-section col-<?php echo esc_attr($number_of_categorynews_column); ?>">
                                    <?php get_template_part( 'inc/sections/section', esc_attr( $section['id'] ) ); ?>
                                </section>
                        <?php endif; ?>
                    <?php } elseif( $section['id'] == 'trending' ) { ?>
                        <?php $disable_trending_section = magazine_bell_get_option( 'disable_trending_section' );
                        if( true ==$disable_trending_section): ?>
                            <section id="<?php echo esc_attr( $section['id'] ); ?>" class="relative page-section">
                                
                                    <?php get_template_part( 'inc/sections/section', esc_attr( $section['id'] ) ); ?>
                                
                            </section> 
                    <?php endif; ?>
                    <?php } elseif( $section['id'] == 'gallery' ) { ?>
                        <?php $disable_gallery_section = magazine_bell_get_option( 'disable_gallery_section' );
                        $gallery_lite_dark_background = magazine_bell_get_option( 'gallery_lite_dark_background' );
                        if( true ==$disable_gallery_section): ?>
                            <section id="<?php echo esc_attr( $section['id'] ); ?>" class="relative page-section <?php echo esc_attr($gallery_lite_dark_background) ?>">
                                
                                    <?php get_template_part( 'inc/sections/section', esc_attr( $section['id'] ) ); ?>
                                
                            </section> 
                    <?php endif; ?>
                    <?php } elseif( $section['id'] == 'featuredpost' ) { ?>
                        <?php $disable_featuredpost_section = magazine_bell_get_option( 'disable_featuredpost_section' );
                        $featuredpost_lite_dark_background = magazine_bell_get_option( 'featuredpost_lite_dark_background' );
                        if( true ==$disable_featuredpost_section): ?>
                            <section id="<?php echo esc_attr( $section['id'] ); ?>" class="relative page-section <?php echo esc_attr($featuredpost_lite_dark_background) ?>">
                                
                                    <?php get_template_part( 'inc/sections/section', esc_attr( $section['id'] ) ); ?>
                                
                            </section> 
                    <?php endif; ?> 
                    <?php } elseif( $section['id'] == 'shopproduct' ) { ?>
                        <?php $disable_shopproduct_section = magazine_bell_get_option( 'disable_shopproduct_section' );
                        if( true ==$disable_shopproduct_section): ?>
                            <section id="<?php echo esc_attr( $section['id'] );  ?>" class="relative page-section" >   
                                
                                    <?php get_template_part( 'inc/sections/section', esc_attr( $section['id'] ) ); ?>
                                
                            </section>
                    <?php endif; ?>  
                    <?php } elseif( $section['id'] == 'mustread' ) { ?>
                        <?php $disable_mustread_section = magazine_bell_get_option( 'disable_mustread_section' );
                        if( true ==$disable_mustread_section): 
                             $background_contact_section = magazine_bell_get_option( 'background_contact_section' );?>
                            <section id="<?php echo esc_attr( $section['id'] );  ?>" class="relative page-section">
                                
                                    <?php get_template_part( 'inc/sections/section', esc_attr( $section['id'] ) ); ?>
                                
                            </section>
                    <?php endif; ?> 
                    <?php } ?>
                <?php } ?>
            <?php } ?>
        </div>
        <aside id="homepage-r-secondary" class="widget-area" role="complementary">
            <?php
            if ( is_active_sidebar( 'homepage-right-sidebar' ) ) {
                dynamic_sidebar('homepage-right-sidebar'); 
            } ?>
        </aside>
    </div>
    <?php $disable_homepage_content_section = magazine_bell_get_option( 'disable_homepage_content_section' );
    if('posts' == get_option( 'show_on_front' )){ ?>
       <?php include( get_home_template() ); ?>
    <?php } elseif(($disable_homepage_content_section == true ) && ('posts' != get_option( 'show_on_front' ))) { ?>
        <div class="wrapper">
           <?php include( get_page_template() ); ?>
        </div>
     <?php  }
    get_footer();
} ?>