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

if ( ! is_active_sidebar( 'sidebar-1' ) || code_manas_is_woo_active() && ( is_cart() || is_checkout() || is_account_page() ) ){
	return;
}

// Return if the sidebar position in customizer for archive/blog/search is set to No Sidebar
if ( code_manas_is_archive() ) {
	$archive_layout = get_theme_mod( 'archive_layout', 'rs' );
	if ( 'ns' === $archive_layout ) {
		return;
	}
}

// Return if the sidebar position in customizer for single posts is set to No Sidebar
if ( is_single() ) {
	$archive_layout = get_theme_mod( 'posts_layout', 'rs' );
	if ( 'ns' === $archive_layout ) {
		return;
	}
}

// Return if the sidebar position in customizer for single pages is set to No Sidebar
if ( is_page() ) {
	$archive_layout = get_theme_mod( 'pages_layout', 'rs' );
	if ( 'ns' === $archive_layout ) {
		return;
	}
}
?>

<div id="secondary" class="widget-area sidebar">
	<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div><!-- #secondary -->
