header.php 7.65 KB
<!DOCTYPE html>
<?php offshore_html_before(); ?>
<html <?php language_attributes(); ?>>
<head>
<?php 
    offshore_head_top();
    offshore_head_bottom();
    wp_head(); 
?>
</head>
<body <?php body_class(); ?>>
    <?php offshore_body_top(); ?>
    <!-- Page Wrapper -->
    <div class="wrapper">

        <?php offshore_header_before(); ?>

        <!-- Header Section -->
        <header>
            <div class="header-area">

                <?php 

                    offshore_header_top(); 

                    if( isset( $post->ID ) ){
                        $meta = get_post_meta( $post->ID, 'offshore_options', true );
                    } else {
                        $meta = array();
                    }

                ?>

                <!-- Top Contact Info -->
                <div class="row logo-top-info">
                    <div class="container">
                        <div class="col-md-3 logo">
                            <!-- Main Logo -->
                            <?php

                                if( get_theme_mod( 'custom_logo' ) ) {
	                                echo '<div itemscope>';
	                                offshore_the_custom_logo();
	                                echo '</div>';
                                }
                                
                                $title = get_bloginfo( 'title', 'display' );
                                $description = get_bloginfo( 'description', 'display' );

                                if( get_theme_mod( 'header_textcolor' ) != 'blank' ){
                                    $display = '';
                                } else {
                                    $display = ' hidden';
                                }

                                if( display_header_text() ) {
	                                if ( is_front_page() ) {
		                                echo '<h1 class="site-title' . esc_attr( $display ) . '"><a href="' . esc_url( home_url( '/' ) ) . '" rel="home">' . esc_html( get_bloginfo( 'name' ) ) . '</a></h1>';
	                                } else {
		                                echo '<p class="site-title' . esc_attr( $display ) . '"><a href="' . esc_url( home_url( '/' ) ) . '" rel="home">' . esc_html( get_bloginfo( 'name' ) ) . '</a></p>';
	                                }
	                                if ( $description ) {
		                                echo '<p class="site-description' . esc_attr( $display ) . '">' .
		                                     wp_kses( $description, array(
				                                     'a'      => array(
					                                     'href'  => array(),
					                                     'title' => array()
				                                     ),
				                                     'br'     => array(),
				                                     'em'     => array(),
				                                     'strong' => array(),
			                                     )
		                                     ) .
		                                     '</p>';
	                                }
                                }

                            ?>
                            
                            <!-- Responsive Toggle Menu -->
                            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
                                <span class="sr-only"><?php esc_html_e( 'Main Menu', 'offshore' ); ?></span>
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                            </button>
                        </div>
                        <div class="col-md-9 top-info-social">
                            <div class="pull-right">
                                <div class="top-widgets">
                                    <?php 

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

                                        // Hide / Display header widgets
                                        if( '0' == get_theme_mod( 'hide_header_widgets', '0' ) && $meta['hide_header_widgets'] == 'global' ){
                                            if ( is_active_sidebar( 'offshore_top_widgets' ) ){
                                                dynamic_sidebar( 'offshore_top_widgets' );
                                            }
                                        } elseif( $meta['hide_header_widgets'] == 'no' )  {
                                            if ( is_active_sidebar( 'offshore_top_widgets' ) ){
                                                dynamic_sidebar( 'offshore_top_widgets' );
                                            }
                                        }

                                    ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Main Navigation Section -->
                <?php 

                    $navbar_default = array( 
                        'menu_class' => 'main-menu',
                        'container' => 'nav', 
                        'container_class' => 'collapse navbar-collapse main-menu', 
                        'container_id' => 'navbar',
                        'theme_location' => 'primary',
                        'walker' => new offshore_bootstrap_navwalker(),
                        'items_wrap' => '<div class="container"><ul id="%1$s" class="%2$s">%3$s</ul></div>'
                    );

                    // Override menu based on page options
                    // if( isset( $meta['main_menu'] ) && is_numeric( $meta['main_menu'] ) ) {
                    //     $navbar_default[ 'menu' ] = $meta['main_menu'];
                    // }
                    // Hide / Display main menu
                    // if( isset( $meta['hide_menu'] ) && $meta['hide_menu'] != 'yes' || !isset( $meta['hide_menu'] ) ) {
                    //     wp_nav_menu( $navbar_default );
                    // }
                    // 
                    wp_nav_menu( $navbar_default );

                    offshore_header_bottom();
                ?>

            </div>
        </header>
        <!-- Header Section -->

        <?php offshore_header_after(); ?>

        <!-- Main Content Section -->
        <main class="main">
            <?php 

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

                // Hide / Display title area
                if( '0' == get_theme_mod( 'hide_title_area', '0' ) && $meta['hide_title_area'] == 'global' || $meta['hide_title_area'] == 'no' ){
                    get_template_part( 'parts/part', 'title' );
                }

                // get_template_part( 'parts/header', 'image' );

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

                $container = 'container';

                // Set page template to full width
                if( 'full-width' == get_theme_mod( 'page_template', 'right-sidebar' ) && $meta['template'] == 'global' ){
                    $container = 'full-width';
                } elseif( $meta['template'] == 'full-width' ) {
                    $container = 'full-width';
                }

                offshore_content_before();

            ?>
            <!-- Main Container -->
            <div class="<?php echo $container; ?>">