<?php
/**
 * @package WordPress
 * @subpackage Campoal
 */

global $campoal_options;
global $post;

get_header();

$sidebar_position = get_post_meta($post->ID, 'meta_box_sidebar', true);
$sidebar_position = $sidebar_position != '' ? $sidebar_position : 'default';
$show_bc = isset($campoal_options['conikal_breadcrumbs_field']) ? $campoal_options['conikal_breadcrumbs_field'] : 0;

if (!is_active_sidebar('main-widget-area') && $sidebar_position != 'center') {
    $sidebar_content_classes = 'sixteen';
} elseif ($sidebar_position == 'none') {
    $sidebar_content_classes = 'sixteen';
} else {
    $sidebar_content_classes = 'eleven';
}
?>
<div id="wrapper">
    <div class="ui container">
        <?php if($show_bc == 1 && $sidebar_position != 'center') {
            conikal_petition_breadcrumbs();
        } elseif($sidebar_position != 'center') {
            print '<div class="none-breadcrumb"></div>';
        } ?>
        <div class="page content">
            <div class="ui <?php echo esc_attr($sidebar_position == 'center' ? 'centered ' : '') ?>grid">
                <?php if(is_active_sidebar('main-widget-area') && $sidebar_position == 'left') { ?>
                    <div class="sixteen wide mobile sixteen wide tablet five wide computer column computer only post-left-widget-sidebar" id="post-left-widget-sidebar">
                        <?php get_sidebar(); ?>
                    </div>
                <?php } ?>
                <div class="sixteen wide mobile <?php echo esc_html($sidebar_content_classes) ?> wide computer left aligned column" id="content">
                    <?php if($show_bc == 1 && $sidebar_position == 'center') {
                        conikal_petition_breadcrumbs();
                    } elseif($sidebar_position == 'center') {
                        print '<div class="none-breadcrumb"></div>';
                    } ?>

                    <?php while(have_posts()) : the_post(); ?>
                    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                        <div class="entry-content">
                            <?php the_content(); ?>
                            <div class="clearfix"></div>
                            <?php wp_link_pages( array(
                                'before'      => '<div class="page-links">',
                                'after'       => '</div>',
                                'link_before' => '<span>',
                                'link_after'  => '</span>',
                                'pagelink'    => '%',
                                'separator'   => '',
                            ) ); ?>
                        </div>
                    </div>

                    <?php if(comments_open() || get_comments_number()) { ?>
                        <div class="post-comment-section">
                            <?php comments_template(); ?>
                        </div>
                    <?php } ?>

                    <?php endwhile; ?>
                </div>
                <?php if(is_active_sidebar('main-widget-area') && ($sidebar_position == 'right' || $sidebar_position == 'default')) { ?>
                    <div class="sixteen wide mobile sixteen wide tablet five wide computer column post-right-widget-sidebar" id="post-right-widget-sidebar">
                        <?php get_sidebar(); ?>
                    </div>
                <?php } ?>
            </div>
        </div>
    </div>
</div>

<?php get_footer(); ?>