<?php require(ghostpool_inc . 'options.php'); ?>

<?php 
// Homepage
if (is_home() OR is_front_page()) { ?>
    <div id="sidebar">	
            <?php dynamic_sidebar('homepage-2'); ?>		
    </div>	
<?php } else { ?>

<?php if(

// Homepage
($theme_homepage_layout == "fullwidth" && (is_home() OR is_front_page()))

// Blog Pages
OR (is_page_template('blog.php') && get_post_meta($post->ID, 'ghostpool_layout', true) == "Fullwidth")
OR ($theme_blog_layout == "fullwidth" && (is_page_template('blog.php') && get_post_meta($post->ID, 'ghostpool_layout', true) == "Default"))

// Review Posts
OR ((is_single() && $gp_settings['post_type'] == "Review") && get_post_meta($post->ID, 'ghostpool_layout', true) == "fullwidth")
OR ($theme_review_layout == "fullwidth" && ((is_single() && $gp_settings['post_type'] == "Review") && get_post_meta($post->ID, 'ghostpool_layout', true) == "Default")) 

// Posts
OR ((is_single() && $gp_settings['post_type'] != "Review") && get_post_meta($post->ID, 'ghostpool_layout', true) == "fullwidth")
OR ($theme_post_layout == "fullwidth" && ((is_single() && $gp_settings['post_type'] != "Review") && get_post_meta($post->ID, 'ghostpool_layout', true) == "Default")) 

// Pages
OR (is_page() && !is_page_template('blog.php') && get_post_meta($post->ID, 'ghostpool_layout', true) == "Fullwidth")
OR ($theme_page_layout == "fullwidth" && (is_page() && !is_page_template('blog.php') && get_post_meta($post->ID, 'ghostpool_layout', true) == "Default"))

// Categories
OR (!is_singular() && !is_home && !is_front_page && $theme_cat_layout == "fullwidth")

// BuddyPress/bbPress
OR (function_exists('bp_is_active') && !bp_is_blog_page()) 
OR (function_exists('is_bbpress') && is_bbpress())

) {} else { ?>

	<div id="sidebar">
	
		<?php if(function_exists('bp_message_get_notices')) { ?>
			<?php bp_message_get_notices(); ?>
		<?php } ?>
		
		<?php if(is_singular() && get_post_meta($post->ID, 'ghostpool_sidebar', true)) { dynamic_sidebar(get_post_meta($post->ID, 'ghostpool_sidebar', true)); } else { dynamic_sidebar('default'); } ?>
		
	</div>	

    <?php } ?>
<?php } ?>
