<?php 
/**
 * Theme functions related to structure.
 *
 * This file contains structural hook functions.
 *
 * @package anews
 */

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

add_action( 'anews_action_doctype', 'anews_doctype', 10 );

if ( ! function_exists( 'anews_head' ) ) :
	/**
	 * Header Codes.
	 *
	 * @since 1.0.0
	 */
function anews_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;
}
endif;
add_action( 'anews_action_head', 'anews_head', 10 );

if ( ! function_exists( 'anews_page_start' ) ) :
	/**
	 * Add Skip to content.
	 *
	 * @since 1.0.0
	 */
	function anews_page_start() {
	?><div id="page" class="site">
		<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'anews' ); ?></a><?php
	}
endif;

add_action( 'anews_action_before', 'anews_page_start', 10 );

if( ! function_exists( 'anews_primary_navigation_fallback' ) ) :

	/**
	 * Fallback for primary navigation.
	 *
	 * @since 1.0.0
	 */
	function anews_primary_navigation_fallback() {
		
		echo '<ul class="sf-menu" id="primary-menu">';
			echo '<li><a href="' . esc_url( home_url( '/' ) ) . '">' .esc_html__( 'Home', 'anews' ). '</a></li>';
			wp_list_pages( array(
			'title_li' => '',
			'depth'    => 1,
			'number'   => 5,
			) );
		echo '</ul>';

	}

endif;

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

		?>
    <header id="masthead" class="site-header">
        <?php 
		$anews_header_top = get_theme_mod( 'anews_header_top_show' );
		$anews_header_top_menu = get_theme_mod( 'anews_header_top_menu', true );
		if($anews_header_top == true ) : ?>
        <div class="header-top-section">
            <div class="container">
                <div class="row">
                    <div class="col-12 col-sm-12 col-md-5 col-lg-5 col-xl-6">
                        <?php if($anews_header_top_menu == true ) : ?>
                        <div class="header-left">
                            <?php 
							wp_nav_menu(
								array(
									'container' 		=> false,
									'theme_location' 	=> 'header_top_menu',
									'menu_id'        	=> false,
									'fallback_cb'     => false,
								)
							);
							?>
                        </div>
                        <?php endif; ?>
                    </div>
                    <div class="col-12 col-sm-12 col-md-7 col-lg-7 col-xl-6">
                        <div class="header-right">
                            <div class="header-lang header-right-item">
                                <a href="#"><i
                                        class="fa fa-envelope"></i><span><?php echo esc_html(get_theme_mod('anews_header_top_email')); ?></span></a>
                            </div>
                            <div class="header-subscribe header-right-item">
                                <a href="#"><i
                                        class="fa fa-phone-alt"></i><span><?php echo esc_html(get_theme_mod('anews_header_top_phone')); ?></span></a>
                            </div>
                            <div class="header-socials header-right-item">
                                <label><?php echo esc_html(get_theme_mod('anews_header_top_socil_text')); ?></label>
                                <ul>
                                    <?php if(get_theme_mod('anews_header_top_fb')) {
										echo ' <li><a href="'.esc_url(get_theme_mod('anews_header_top_fb')).'"><i class="fab fa-facebook-f"></i></a></li>';
									} ?>
                                    <?php if(get_theme_mod('anews_header_top_tw')) {
										echo ' <li><a href="'.esc_url(get_theme_mod('anews_header_top_tw')).'"><i class="fab fa-twitter"></i></a></li>';
									} ?>
                                    <?php if(get_theme_mod('anews_header_top_linkedin')) {
										echo '<li><a href="'.esc_url(get_theme_mod('anews_header_top_linkedin')).'"><i class="fab fa-linkedin-in"></i></a></li>';
									} ?>
                                    <?php if(get_theme_mod('anews_header_top_ins')) {
										echo '<li><a href="'.esc_url(get_theme_mod('anews_header_top_ins')).'"><i class="fab fa-instagram"></i></a></li>';
									} ?>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php endif;?>
        <?php 
	}
endif;
add_action( 'anews_action_before_header', 'anews_header_start' );

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

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


if ( ! function_exists( 'anews_footer_start' ) ) :
	/**
	 * Footer Start.
	 *
	 * @since 1.0.0
	 */
	function anews_footer_start() {
	?>
    <footer id="colophon" class="site-footer" role="contentinfo">
        <div class="container">
            <?php 
	}
endif;
add_action( 'anews_action_before_footer', 'anews_footer_start' );


if ( ! function_exists( 'anews_footer_end' ) ) :
	/**
	 * Footer End.
	 *
	 * @since 1.0.0
	 */
	function anews_footer_end() {?>
        </div>
    </footer><!-- #colophon -->
</div><!-- #page -->
<?php
	}
endif;
add_action( 'anews_action_after_footer', 'anews_footer_end' );