<?php
/**
 * Theme Name: 		Noisa
 * Theme Author: 	Mariusz Rek - Rascals Themes
 * Theme URI: 		http://rascalsthemes.com/noisa
 * Author URI: 		http://rascalsthemes.com
 * File:			sidebar.php
 * =========================================================================================================================================
 *
 * @package noisa
 * @since 1.0.0
 */
?>

<?php
	// Get panel options
   	$noisa_opts = noisa_opts();

   	if ( class_exists( 'WooCommerce' ) && is_shop() ) {
		$page_id = get_option( 'woocommerce_shop_page_id' );
	} else {
		$page_id = $wp_query->post->ID;
	}

   // Get custom sidebar
   $custom_sidebar = get_post_meta( $page_id, '_custom_sidebar', true );

   // Get layout
   $noisa_layout = get_post_meta( $page_id, '_layout', true );
   $noisa_layout = isset( $noisa_layout ) && $noisa_layout != '' ? $noisa_layout = $noisa_layout : $noisa_layout = 'wide';
?>
	
<aside class="sidebar content-sidebar <?php echo esc_attr( $noisa_layout ) ?>">
	<?php if ( $custom_sidebar === '' || $custom_sidebar === '_default' ) : ?>
		<?php dynamic_sidebar( 'primary-sidebar' ); ?>
	<?php else : ?>
		<?php dynamic_sidebar( sanitize_title_with_dashes( $custom_sidebar ) ); ?> 
	<?php endif; ?>
</aside>