<?php
/**
 * Theme functions related to structure.
 *
 * This file contains structural hook functions.
 *
 * @package Party Planner Bell Pro
 */

if ( ! function_exists( 'party_planner_bell_doctype' ) ) :
	/**
	 * Doctype Declaration.
	 *
	 * @since 1.0.0
	 */
function party_planner_bell_doctype() {
	?><!DOCTYPE html> <html <?php language_attributes(); ?>><?php
}
endif;

add_action( 'party_planner_bell_action_doctype', 'party_planner_bell_doctype', 10 );


if ( ! function_exists( 'party_planner_bell_head' ) ) :
	/**
	 * Header Codes.
	 *
	 * @since 1.0.0
	 */
function party_planner_bell_head() {
	?>
	<meta charset="<?php bloginfo( 'charset' ); ?>">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="profile" href="http://gmpg.org/xfn/11">
	<?php if ( is_singular() && pings_open( get_queried_object() ) ) : ?>
		<link rel="pingback" href="<?php echo esc_url( get_bloginfo( 'pingback_url' ) ); ?>">
	<?php endif; ?>
	<?php
}
endif;
add_action( 'party_planner_bell_action_head', 'party_planner_bell_head', 10 );

if ( ! function_exists( 'party_planner_bell_page_start' ) ) :
	/**
	 * Add Skip to content.
	 *
	 * @since 1.0.0
	 */
	function party_planner_bell_page_start() { 
		$loader_enable = party_planner_bell_get_option( 'preloader_loader_enable' );
	?><div id="page" class="site">
		<a class="skip-link screen-reader-text" href="#content">
			<?php esc_html_e( 'Skip to content', 'party-planner-bell' ); ?>
		</a>
		<?php if ($loader_enable==true): ?>
			<div id="loader">
				<div class="loader-container">
					<div id="preloader">
						<?php party_planner_bell_preloader(); ?>
					</div>
				</div>
			</div>
		<?php endif ?>
	<?php
	}
endif;

add_action( 'party_planner_bell_action_before', 'party_planner_bell_page_start', 10 );

if ( ! function_exists( 'party_planner_bell_header_start' ) ) :
	/**
	 * Header Start.
	 *
	 * @since 1.0.0
	 */
	function party_planner_bell_header_start() {

        $show_topbar = party_planner_bell_get_option( 'show_topbar' );
        $show_contact = party_planner_bell_get_option( 'show_header_contact_info' );
        $location     = party_planner_bell_get_option( 'header_location' );
        $email        = party_planner_bell_get_option( 'header_email' );
        $phone        = party_planner_bell_get_option( 'header_phone' ); 
        $class = 'col-1';
        $show_social =party_planner_bell_get_option('show_header_social_links');
        $header_social_link =party_planner_bell_get_option('header_social_link');
        $topbar_color =party_planner_bell_get_option('topbar_color');
        $topbar_background_color =party_planner_bell_get_option('topbar_background_color');
        $show_header_search =party_planner_bell_get_option('show_header_search'); 
        $homelayout     = party_planner_bell_get_option( 'homepage_design_layout_options' ); 
        $show_current_date     = party_planner_bell_get_option( 'show_current_date' ); 
        $topbar_date_contact     = party_planner_bell_get_option( 'topbar_layout_option' );  
        $search_login     = party_planner_bell_get_option( 'search_login_layout' ); 

        if( ( (( ! empty( $email ) || ! empty( $phone ) || ! empty( $location ) ) && $topbar_date_contact != 'topbar-none')|| $show_current_date==true ) && ( $show_social==true ) && ($search_login != 'search-login-none')  ) {
            $class = 'col-3';
        } elseif(($topbar_date_contact != 'topbar-none' && $show_social==true ) ||($topbar_date_contact != 'topbar-none' && $search_login != 'search-login-none' ) || ($search_login != 'search-login-none' && $show_social==true)){
        	$class ='col-2';
        } else{
        	$class = 'col-1';
        }

        if (($show_topbar==true) && ($topbar_date_contact != 'topbar-none' )) {
	        if(( $show_social==true ) || ($show_header_search==true) || ($topbar_date_contact != 'topbar-none' ) ){ ?>
	        	<style>
	        		#top-bar .widget_address_block ul li,
	        		#top-bar .widget_address_block ul li a,
	        		#top-bar .social-icons li a,
	        		#top-bar .current-date,
	        		#top-bar .top-login a,
	        		#top-bar .top-register a{
	        			color: <?php echo esc_attr($topbar_color); ?>;
	        		}
	        		#top-bar .top-register a{
	        			border-color: <?php echo esc_attr($topbar_color); ?>;
	        		}
	        	</style>
	    		<?php $topbar_background_color =party_planner_bell_get_option('topbar_background_color'); ?>
	            <div id="top-bar" class="top-bar-widgets <?php echo esc_attr( $class ); ?>"style="background-color: <?php echo esc_attr($topbar_background_color); ?> ">
	            	<button><span><i class="fa fa-angle-down"></i></span></button>
	                <div class="wrapper">
	                    <?php if( $topbar_date_contact != 'topbar-none' ) : ?>
	                        
	                        <div class="widget widget_address_block">
	                            <ul>
	                            	<?php if ($show_current_date==true && $topbar_date_contact=='current-date-option' ) {
					                     $current_date = date('l jS F Y'); ?>
					                    <div class="current-date" > 
					                        <?php echo $current_date ?> 
					                    </div>
					                <?php } ?>
					                <?php if ($topbar_date_contact=='contact-info-option' ) { ?>
		                                <?php 

		                                    if( ! empty( $location ) ){
		                                        echo '<li><i class="fa fa-map-marker"></i>'. esc_html( $location ) .'</li>';
		                                    }
		                                    if( ! empty( $phone ) ){
		                                        echo '<li><a href="tel: '. esc_attr( $phone ) .'"><i class="fa fa-phone"></i>'. esc_html( $phone ) .'</a></li>';
		                                    }
		                                    if( ! empty( $email ) ){
		                                        echo '<li><a href="' . esc_url('mailto:' . sanitize_email($email)) . '"><i class="fa fa-envelope"></i>'. esc_html( $email ) .'</a></li>';
		                                    }
		                                ?>
		                            <?php } ?>
	                                
	                            </ul>
	                        </div><!-- .widget_address_block -->
	                    <?php endif; 

	                    if ( $show_social==true){ ?>
	                       <div class="widget widget_social_icons">
	                           <ul class="social-icons">
	                                <?php 
	                                $header_social_links = ! empty( $header_social_link ) ? explode( '|', ( $header_social_link ) ) : array();
	                                foreach ($header_social_links as $social_links ) { 
	                                    if ( isset( $social_links ) ) { 
	                                    ?>
	                                        <li><a href=" <?php echo esc_url($social_links); ?>"></a></li>
	                                    <?php }  
	                                } ?>
	                            </ul> 
	                        </div><!-- .widget_social_icons -->
	                    <?php } ?>
	                    <?php if ( $search_login != 'search-login-none' ){ ?>
				            <div class="widget top-search">
				            	<?php if ( $search_login == 'search-form-option' ){ ?>
					                <?php get_search_form( $echo = true ); ?>
					            <?php } else{ ?>
					            	<?php 
					            		$top_login_text     = party_planner_bell_get_option( 'top_login_text' );
					            		$top_login_url     = party_planner_bell_get_option( 'top_login_text' );
					            		$top_register_text     = party_planner_bell_get_option( 'top_register_text' );
					            		$top_register_url     = party_planner_bell_get_option( 'top_register_url' );
					            	?>
					            	<ul class="top-login-register">
					            		<?php if (!empty($top_login_text) && !empty($top_login_url) ): ?>
					            			<li class="top-login"><a href="<?php echo esc_url($top_login_url); ?>"><?php echo esc_html($top_login_text); ?></a></li>
					            		<?php endif ?>
					            		<?php if (!empty($top_register_text) && !empty($top_register_url) ): ?>
					            			<li class="top-register"><a href="<?php echo esc_url($top_register_url); ?>"><?php echo esc_html($top_register_text); ?></a></li>
					            		<?php endif ?>
					            	</ul>
					            <?php } ?>
				            </div><!-- .widget_social_icons -->
				        <?php } ?>
	                </div><!-- .wrapper -->
	            </div><!-- #top-bar -->
	        <?php
	        } 
	    }?>
		<header id="masthead" class="site-header nav-shrink" role="banner">
			<?php
	}
endif;
add_action( 'party_planner_bell_action_before_header', 'party_planner_bell_header_start' );

if ( ! function_exists( 'party_planner_bell_header_end' ) ) :
	/**
	 * Header Start.
	 *
	 * @since 1.0.0
	 */
	function party_planner_bell_header_end() {

		?></header> <!-- header ends here --><?php
	}
endif;
add_action( 'party_planner_bell_action_header', 'party_planner_bell_header_end', 15 );

if ( ! function_exists( 'party_planner_bell_content_start' ) ) :
	/**
	 * Header End.
	 *
	 * @since 1.0.0
	 */
	function party_planner_bell_content_start() { 
	?>
	<div id="content" class="site-content">
	<?php 

	}
endif;

add_action( 'party_planner_bell_action_before_content', 'party_planner_bell_content_start', 10 );

if ( ! function_exists( 'party_planner_bell_footer_start' ) ) :
	/**
	 * Footer Start.
	 *
	 * @since 1.0.0 
	 */
	function party_planner_bell_footer_start() {
		if( !(is_home() || is_front_page()) ){  
			echo '</div>';
		} ?>
		</div>
		<footer id="colophon" class="site-footer" role="contentinfo">
			
		<?php if ( true === party_planner_bell_get_option('scroll_top_visible') ) : ?>
			<div class="backtotop"><i class="fa fa-chevron-up"></i></div>
		<?php endif;
	} 
endif;
add_action( 'party_planner_bell_action_before_footer', 'party_planner_bell_footer_start' );


if ( ! function_exists( 'party_planner_bell_footer_end' ) ) :
	/**
	 * Footer End.
	 *
	 * @since 1.0.0
	 */
	function party_planner_bell_footer_end() { ?>

		</footer><?php
	}
endif;
add_action( 'party_planner_bell_action_after_footer', 'party_planner_bell_footer_end', 100 );

