<?php
/**
 * The sidebar containing the main widget area
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package nbcore
 */

$blog_class     = '';
$shop_class     = '';
$product_class  = '';
$page_class     = '';
$store_class    = '';
$widget_title_class    = '';

//$page_sidebar = aidoo_get_options('page_sidebar');
if(aidoo_get_options('nbcore_widget_title')){
    $widget_title_class = 'widget_style';
}

if(aidoo_get_options('nbcore_blog_sticky_sidebar')) {
    $blog_class = ' sticky-wrapper sticky-sidebar';
}
if(aidoo_get_options('shop_sticky_sidebar')) {
    $shop_class = ' sticky-wrapper sticky-sidebar';
}
if(aidoo_get_options('product_sticky_sidebar')) {
    $product_class = ' sticky-wrapper sticky-sidebar';
}

if( function_exists('is_woocommerce') && is_woocommerce() ) {
    if (is_product()) {
        if ('no-sidebar' !== aidoo_get_options('nbcore_pd_details_sidebar') && is_active_sidebar('product-sidebar')) {
            echo '<aside id="secondary" class="widget-area shop-sidebar '.$widget_title_class.'" role="complementary"><div class="sidebar-wrapper' . esc_attr($product_class) . '">';
            dynamic_sidebar('product-sidebar');
            echo '</div></aside>';
        }
    } 
    else {
        if ('no-sidebar' !== aidoo_get_options('nbcore_shop_sidebar') && is_active_sidebar('shop-sidebar')) {
            echo '<aside id="secondary" class="widget-area shop-sidebar '.$widget_title_class.'" role="complementary"><div class="sidebar-wrapper' . esc_attr($shop_class) . '">';
            dynamic_sidebar('shop-sidebar');
            echo '</div></aside>';
        }
    }
} elseif(is_page() && 'no-sidebar' !== aidoo_get_options('nbcore_pages_sidebar') && is_active_sidebar('page-sidebar') ) {
    echo '<aside id="secondary" class="widget-area '.$widget_title_class.'" role="complementary"><div class="sidebar-wrapper' . esc_attr($blog_class) . '">';
    dynamic_sidebar( 'page-sidebar' );
    echo '</div></aside>';
}
 else {
	if( 'no-sidebar' !== aidoo_get_options('nbcore_blog_sidebar') && is_active_sidebar('default-sidebar') ) {
        echo '<aside id="secondary" class="widget-area '.$widget_title_class.'" role="complementary"><div class="sidebar-wrapper' . esc_attr($blog_class) . '">';
        dynamic_sidebar( 'default-sidebar' );
        echo '</div></aside>';
	}
}

