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

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

	/**
	 * newscope Head Hook
	 */
	if ( ! function_exists( 'newscope_head' ) ) :
		/**
		* Header Codes.
		*
		* @since 1.0.0
		*/
		function newscope_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">
				<link rel="preconnect" href="https://fonts.googleapis.com">
				<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
				<?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( 'newscope_action_head', 'newscope_head', 10 );

	/**
	 * newscope Page Start Hook
	 */
	if ( ! function_exists( 'newscope_page_start' ) ) :
		/**
		 * Add Skip to content.
		 *
		 * @since 1.0.0
		 */
		function newscope_page_start() {
			?>
				<body <?php body_class(); ?>>
				<?php wp_body_open(); ?>
					<div id="page" class="site">
					<a class="skip-link screen-reader-text" href="#primary"><?php esc_html_e( 'Skip to content', 'newscope' ); ?></a>
					<?php if( get_theme_mod( 'preloader_options', true ) ) : ?>
					<div class="preloader-area">
						<div class="preloader-inner">
							<div class="theme-loader"></div>
						</div>
					</div>
				<?php endif; ?>
			<?php
		}
	endif;
	add_action( 'newscope_action_before_page', 'newscope_page_start', 10 );


	/**
	 * newscope Stat Header Hook
	 */
	if ( ! function_exists( 'newscope_header_start' ) ) :
		/**
		 * Header Start.
		 *
		 * @since 1.0.0
		 */
		function newscope_header_start() {
			?>
				<header id="masthead" class="site-header">
					<div class="header-inner">
						
			<?php 
		}

	endif;
	add_action( 'newscope_action_before_header', 'newscope_header_start' );

	/**
	 * newscope Header End Hook
	 */
	if ( ! function_exists( 'newscope_header_end' ) ) :
		/**
		 * Header End.
		 *
		 * @since 1.0.0
		 */
		function newscope_header_end() {
			?>
					</div>
				</header><!-- #masthead -->
			<?php
		}
	endif;
	add_action( 'newscope_action_header', 'newscope_header_end', 15 );

	/**
	 * newscope Footer Start Hook
	 */
	if ( ! function_exists( 'newscope_footer_start' ) ) :
		/**
		 * Footer Start.
		 *
		 * @since 1.0.0
		 */
		function newscope_footer_start() { ?>
			<footer id="colophon" class="site-footer footer-style-<?php echo esc_attr(get_theme_mod('select_footer', 'one')); ?>">
				<div class="footer-wrapper">
		<?php }
	endif;
	add_action( 'newscope_action_before_footer', 'newscope_footer_start', 10 );
	
	/**
	 * newscope Footer End Hook
	 */
	if ( ! function_exists( 'newscope_footer_end' ) ) :
		/**
		 * Footer End.
		 *
		 * @since 1.0.0
		 */
		function newscope_footer_end() {?>
				</div>
			</footer><!-- #colophon -->
		<?php }
	endif;
	add_action( 'newscope_action_footer', 'newscope_footer_end', 10 );


	/**
	 * newscope Page End Hook
	 */
	if ( ! function_exists( 'newscope_page_end' ) ) :
		/**
		 * End Page Content.
		 *
		 * @since 1.0.0
		 */
		function newscope_page_end() {
			?>	
					<?php if(get_theme_mod( 'bottom_to_top', true )) : ?>
						<div class="bottom-to-top">
						<a href="#" class="to-top active"><span class="fas fa-angle-double-up to-top-icon"></span></a>
						</div>
					<?php endif; ?>
					</div><!-- #page -->
				<?php wp_footer(); ?>
				</body>
			</html>
			<?php 
		}
	endif;
	add_action( 'newscope_action_after_page', 'newscope_page_end', 10 );



	/**
	 * newscope Single Page Hook
	 */
	if ( ! function_exists( 'newscope_single_page_start' ) ) :
		/**
		 * Start Single Page.
		 *
		 * @since 1.0.0
		 */
		function newscope_single_page_start() {
			?>	
				<main id="primary" class="<?php echo esc_attr( is_page() ? 'site-main content-area page-content-area' : 'site-main' ); ?>">
					<?php 
					if( true === get_theme_mod( 'single_breadcrumb_enable', true ) ){
						/**
						* Hook - newscope_action_breadcrumb.
						*
						* @hooked newscope_breadcrumb
						*/
						do_action( 'newscope_action_breadcrumb' );
					}
					?>
					<div class="post-details-wrapper">
						<div class="container">
							<div class="row">
			<?php 
		}
	endif;
	add_action( 'newscope_action_before_single_page', 'newscope_single_page_start' );

	/**
	 * newscope Single Page End Hook
	 */
	if ( ! function_exists( 'newscope_single_page_end' ) ) :
		/**
		 * End Single Page.
		 *
		 * @since 1.0.0
		 */
		function newscope_single_page_end() {
			?>	
						</div>
					</div>
				</div>
			</main><!-- #main -->
			<?php 
		}
	endif;
	add_action( 'newscope_action_after_single_page', 'newscope_single_page_end' );


	/**
		 * newscope Single Page Hook
		 */
		if ( ! function_exists( 'newscope_global_page_start' ) ) :
			/**
			 * Start Single Page.
			 *
			 * @since 1.0.0
			 */
			function newscope_global_page_start() {
				?>	
					<main id="primary" class="<?php echo esc_attr( is_page() ? 'site-main content-area page-content-area' : 'site-main' ); ?>">
						<?php 
						if(true === get_theme_mod( 'page_breadcrumb_enable', true )){
							/**
							* Hook - newscope_action_breadcrumb.
							*
							* @hooked newscope_breadcrumb
							*/
							do_action( 'newscope_action_breadcrumb' );
						}
						?>
						<div class="post-details-wrapper">
							<div class="container">
								<div class="row">
				<?php 
			}
		endif;
		add_action( 'newscope_action_before_global_page', 'newscope_global_page_start' );

		/**
		 * newscope Single Page End Hook
		 */
		if ( ! function_exists( 'newscope_global_page_end' ) ) :
			/**
			 * End Single Page.
			 *
			 * @since 1.0.0
			 */
			function newscope_global_page_end() {
				?>	
							</div>
						</div>
					</div>
				</main><!-- #main -->
				<?php 
			}
		endif;
		add_action( 'newscope_action_after_global_page', 'newscope_global_page_end' );



	/**
	 * newscope Search Page Hook
	 */
	if ( ! function_exists( 'newscope_search_page_start' ) ) :
		/**
		 * Start Search Page.
		 *
		 * @since 1.0.0
		 */
		function newscope_search_page_start() {
			?>	
				<main id="primary" class="site-main layout-<?php echo esc_attr(get_theme_mod( 'search_layout' )); ?>">
					<?php 
						if( true === get_theme_mod( 'enable_search_title', true ) ) :
						/**
						* Hook - newscope_action_breadcrumb.
						*
						* @hooked newscope_breadcrumb
						*/
						do_action( 'newscope_action_breadcrumb' );
						endif;
					?>
					<div class="page-wrapper page-search">
						<div class="container">
			<?php 
		}
	endif;
	add_action( 'newscope_action_before_search_page', 'newscope_search_page_start' );

	/**
	 * newscope Search Page End Hook
	 */
	if ( ! function_exists( 'newscope_search_page_end' ) ) :
		/**
		 * End Search Page.
		 *
		 * @since 1.0.0
		 */
		function newscope_search_page_end() {
			?>	
					</div>
				</div>
			</main><!-- #main -->
			<?php 
		}
	endif;
	add_action( 'newscope_action_after_search_page', 'newscope_search_page_end' );
	
	
	
	
	/**
	 * newscope Archive Page Hook
	 */
	if ( ! function_exists( 'newscope_archive_page_start' ) ) :
		/**
		 * Start Archive Page.
		 *
		 * @since 1.0.0
		 */
		function newscope_archive_page_start() {
			?>	
			<main id="primary" class="site-main layout-<?php echo esc_attr(get_theme_mod( 'archive_layout' )); ?>">
				<?php 
					if( true === get_theme_mod( 'enable_archive_title', true ) ) :
					/**
					* Hook - newscope_action_breadcrumb.
					*
					* @hooked newscope_breadcrumb
					*/
					do_action( 'newscope_action_breadcrumb' );
					endif;
				?>
				<div class="page-wrapper page-archive">
					<div class="container">
			<?php 
		}
	endif;
	add_action( 'newscope_action_before_archive_page', 'newscope_archive_page_start' );

	/**
	 * newscope Archive Page End Hook
	 */
	if ( ! function_exists( 'newscope_archive_page_end' ) ) :
		/**
		 * End Archive Page.
		 *
		 * @since 1.0.0
		 */
		function newscope_archive_page_end() {
			?>	
					</div>
				</div>
			</main><!-- #main -->
			<?php 
		}
	endif;
	add_action( 'newscope_action_after_archive_page', 'newscope_archive_page_end' );


	/**
	 * newscope Index Page Start Hook
	 */
	if ( ! function_exists( 'newscope_index_page_start' ) ) :
		/**
		 * Start Index Page.
		 *
		 * @since 1.0.0
		 */
		function newscope_index_page_start() {
			?>	
				<main id="primary" class="site-main layout-<?php echo esc_attr(get_theme_mod( 'blog_layout' )); ?>">
					
					<div class="page-wrapper page-index">
						<div class="container">
			<?php 
		}
	endif;
	add_action( 'newscope_action_before_index_page', 'newscope_index_page_start' );


	/**
	 * newscope Index Page End Hook
	 */
	if ( ! function_exists( 'newscope_index_page_end' ) ) :
		/**
		 * End Index Page.
		 *
		 * @since 1.0.0
		 */
		function newscope_index_page_end() {
			?>	
						</div>
					</div>
				</main><!-- #main -->
			<?php 
		}
	endif;
	add_action( 'newscope_action_after_index_page', 'newscope_index_page_end' );


	/**
	 * newscope Grid List Hook
	 */
	if ( ! function_exists( 'newscope_grid_list_start' ) ) :
		/**
		 * End Index Page.
		 *
		 * @since 1.0.0
		 */
		function newscope_grid_list_loop() {

			if( 'grid' === get_theme_mod( 'blog_layout', 'right-sidebar' ) ){
				get_template_part( 'template-parts/post/post-grid');
			}else{
				get_template_part( 'template-parts/post/post-sidebar');
			} 
		}
	endif;
	add_action( 'newscope_action_grid_list', 'newscope_grid_list_loop' );

	/** 
	 *  Fallback for primary navigation.
	 */
	if( ! function_exists( 'newscope_primary_navigation_fallback' ) ) :

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


	/** 
	 *  Fallback for primary navigation.
	 */
	if( ! function_exists( 'newscope_top_menu_navigation_fallback' ) ) :

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


	/**
	 * newscope Front Page Start Hook
	 */
	if ( ! function_exists( 'newscope_front_page_start' ) ) :
		/**
		 * Start Index Page.
		 *
		 * @since 1.0.0
		 */
		function newscope_front_page_start() {
			?>	
				<main id="primary" class="site-main">
					
					<div class="page-wrapper newscope-front-page-wrapper">
			<?php 
		}
	endif;
	add_action( 'newscope_action_before_front_page', 'newscope_front_page_start' );


	/**
	 * newscope Index Page End Hook
	 */
	if ( ! function_exists( 'newscope_front_page_end' ) ) :
		/**
		 * End Index Page.
		 *
		 * @since 1.0.0
		 */
		function newscope_front_page_end() {
			?>	
					</div>
				</main><!-- #main -->
			<?php 
		}
	endif;
	add_action( 'newscope_action_after_front_page', 'newscope_front_page_end' );
