page.php 1.85 KB
<?php

get_header();

$meta = get_post_meta( $post->ID, 'offshore_options', true );
$page_template = get_theme_mod( 'page_template', 'right-sidebar' );

if( !isset( $meta['template'] ) ){
    $meta['template'] = 'global';
}

$column = 'col-md-9';

if( 'full-width' == $page_template && $meta['template'] == 'global' ){
    $column = 'col-md-12';
} elseif( $meta['template'] == 'full-width' ) {
    $column = 'col-md-12';
}

?>
    <div class="row">

        <?php 
            if( 'left-sidebar' == $page_template && $meta['template'] == 'global' ){
                get_sidebar();
            } elseif( $meta['template'] == 'left-sidebar' ) {
                get_sidebar();
            }

            if( 'no-sidebar' == $page_template && $meta['template'] == 'global' ) {
                $column = 'col-md-12';
            } elseif( $meta['template'] == 'no-sidebar' ) {
                $column = 'col-md-12';
            }
        ?>

        <div class="<?php echo $column; ?>">
            <?php 
                
                // Remove the section tag if a page is set as the front page
                if( !is_home() && !is_front_page() ){
                    echo '<section>';
                }

                offshore_content_top();

                get_template_part( 'parts/content', 'page' );

                offshore_content_bottom();

                // Remove the section tag if a page is set as the front page
                if( !is_home() && !is_front_page() ){
                    echo '</section>';
                }

            ?>
        </div>

        <?php 
            if( 'right-sidebar' == $page_template && $meta['template'] == 'global' ) {
                get_sidebar();
            } elseif( $meta['template'] == 'right-sidebar' ) {
                get_sidebar();
            }
        ?>

    </div>

<?php

offshore_content_after();

get_footer(); 

?>