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

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

if ( ! is_active_sidebar( 'right-sidebar' ) ) {
	return;
}
// when both sidebars turned on reduce col size to 3 from 4.
$sidebar_pos = get_theme_mod('wrockmetro_sidebar_position');
$layoutmeta = get_post_meta(get_the_ID(), '_singlepost_wrockmetro', true);
$layoutmetapage = get_post_meta(get_the_ID(), '_pagepost_wrockmetro', true);
$col_size = 'col-md-4'; // Default column size

if (('lr' === $layoutmeta && is_single()) || ('lr' === $layoutmetapage && is_page()) || 'both' === $sidebar_pos) {
    $col_size = 'col-md-3'; // Reduce column size to 3
}

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