<?php
/**
 * The sidebar containing the main widget area
 *
 * @package Wrock Metro
 */

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

if ( ! is_active_sidebar( 'left-sidebar' ) ) {
	return;
}

// when both sidebars turned on reduce col size to 3 from 4.
$sidebar_pos = get_theme_mod('wrockmetro_sidebar_position');
$postID = get_queried_object_id();
$layoutmeta = get_post_meta($postID, '_singlepost_wrockmetro', true);
$layoutmetapage = get_post_meta($postID, '_pagepost_wrockmetro', true);

$col_size = 'col-md-4'; // Default column size

if (is_single() && '' !== $layoutmeta) {
    $col_size = ('lr' === $layoutmeta) ? 'col-md-3' : 'col-md-4';
} elseif (is_page() && '' !== $layoutmetapage) {
    $col_size = ('lr' === $layoutmetapage) ? 'col-md-3' : 'col-md-4';
} elseif ('both' === $sidebar_pos) {
    $col_size = 'col-md-3';
}

?>
<div class="<?php echo esc_attr($col_size); ?> widget-area" id="left-sidebar" <?php wrockmetro_do_schema( 'sidebar' ); ?>>
    <?php dynamic_sidebar('left-sidebar'); ?>
</div><!-- #left-sidebar -->

