<?php
/**
 * The template for Managing Theme Structure
 *
 * @package Catch Themes
 * @subpackage Gridalicious
 * @since Gridalicious 1.0
 */

if ( ! defined( 'GRIDALICIOUS_THEME_VERSION' ) ) {
	header( 'Status: 403 Forbidden' );
	header( 'HTTP/1.1 403 Forbidden' );
	exit();
}


if ( ! function_exists( 'gridalicious_doctype' ) ) :
	/**
	 * Doctype Declaration
	 *
	 * @since Gridalicious 1.0
	 *
	 */
	function gridalicious_doctype() {
		?>
		<!DOCTYPE html>
		<html <?php language_attributes(); ?>>
		<?php
	}
endif;
add_action( 'gridalicious_doctype', 'gridalicious_doctype', 10 );


if ( ! function_exists( 'gridalicious_head' ) ) :
	/**
	 * Header Codes
	 *
	 * @since Gridalicious 1.0
	 *
	 */
	function gridalicious_head() {
		?>
		<meta charset="<?php bloginfo( 'charset' ); ?>">
		<link rel="profile" href="http://gmpg.org/xfn/11">
		<?php
		if ( is_singular() && pings_open() ) {
			echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
		}
	}
endif;
add_action( 'gridalicious_before_wp_head', 'gridalicious_head', 10 );


if ( ! function_exists( 'gridalicious_doctype_start' ) ) :
	/**
	 * Start div id #page
	 *
	 * @since Gridalicious 1.0
	 *
	 */
	function gridalicious_page_start() {
		?>
		<div id="page" class="hfeed site">
		<?php
	}
endif;
add_action( 'gridalicious_header', 'gridalicious_page_start', 10 );


if ( ! function_exists( 'gridalicious_page_end' ) ) :
	/**
	 * End div id #page
	 *
	 * @since Gridalicious 1.0
	 *
	 */
	function gridalicious_page_end() {
		?>
		</div><!-- #page -->
		<?php
	}
endif;
add_action( 'gridalicious_footer', 'gridalicious_page_end', 200 );


if ( ! function_exists( 'gridalicious_header_start' ) ) :
	/**
	 * Start Header id #masthead and class .wrapper
	 *
	 * @since Gridalicious 1.0
	 *
	 */
	function gridalicious_header_start() {
		?>
		<header id="masthead" role="banner">
    		<div class="wrapper">
		<?php
	}
endif;
add_action( 'gridalicious_header', 'gridalicious_header_start', 30 );


if ( ! function_exists( 'gridalicious_header_end' ) ) :
	/**
	 * End Header id #masthead and class .wrapper
	 *
	 * @since Gridalicious 1.0
	 *
	 */
	function gridalicious_header_end() {
		?>
			</div><!-- .wrapper -->
		</header><!-- #masthead -->
		<?php
	}
endif;
add_action( 'gridalicious_header', 'gridalicious_header_end', 100 );


if ( ! function_exists( 'gridalicious_content_start' ) ) :
	/**
	 * Start div id #content and class .wrapper
	 *
	 * @since Gridalicious 1.0
	 *
	 */
	function gridalicious_content_start() {
		?>
		<div id="content" class="site-content">
			<div class="wrapper">
	<?php
	}
endif;
add_action('gridalicious_content', 'gridalicious_content_start', 10 );

if ( ! function_exists( 'gridalicious_content_end' ) ) :
	/**
	 * End div id #content and class .wrapper
	 *
	 * @since Gridalicious 1.0
	 */
	function gridalicious_content_end() {
		?>
			</div><!-- .wrapper -->
	    </div><!-- #content -->
		<?php
	}

endif;
add_action( 'gridalicious_after_content', 'gridalicious_content_end', 30 );


if ( ! function_exists( 'gridalicious_sidebar_secondary' ) ) :
	/**
	 * Secondary Sidebar
	 *
	 * @since Gridalicious 1.0
	 */
	function gridalicious_sidebar_secondary() {
		get_sidebar( 'secondary' );
	}
endif;


if ( ! function_exists( 'gridalicious_footer_content_start' ) ) :
/**
 * Start footer id #colophon
 *
 * @since Gridalicious 1.0
 */
function gridalicious_footer_content_start() {
	?>
	<footer id="colophon" class="site-footer" role="contentinfo">
    <?php
}
endif;
add_action('gridalicious_footer', 'gridalicious_footer_content_start', 10 );


if ( ! function_exists( 'gridalicious_footer_sidebar' ) ) :
/**
 * Footer Sidebar
 *
 * @since Gridalicious 1.0
 */
function gridalicious_footer_sidebar() {
	get_sidebar( 'footer' );
}
endif;
add_action( 'gridalicious_footer', 'gridalicious_footer_sidebar', 20 );


if ( ! function_exists( 'gridalicious_footer_content_end' ) ) :
/**
 * End footer id #colophon
 *
 * @since Gridalicious 1.0
 */
function gridalicious_footer_content_end() {
	?>
	</footer><!-- #colophon -->
	<?php
}
endif;
add_action( 'gridalicious_footer', 'gridalicious_footer_content_end', 110 );


if ( ! function_exists( 'gridalicious_header_right' ) ) :
/**
 * Header Right Sidebar
 *
 * @since Gridalicious 1.0
 */
function gridalicious_header_right() {
	$options = gridalicious_get_theme_options();

	//A sidebar in the Header Right
	if ( !$options['disable_header_right_sidebar'] ) {
		get_sidebar( 'header-right' );
	}
}
endif;
add_action( 'gridalicious_header', 'gridalicious_header_right', 50 );
