<?php
	/**
	 * The header for our theme.
	 *
	 * This is the template that displays all of the <head> section and everything up until <div id="content">
	 *
	 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
	 *
	 * @package Theme Palace
	 * @subpackage FavBlog
	 * @since FavBlog 1.0.0
	 */

	/**
	 * favblog_doctype hook
	 *
	 * @hooked favblog_doctype -  10
	 *
	 */
	do_action( 'favblog_doctype' );

?>
<head>
<?php
	/**
	 * favblog_before_wp_head hook
	 *
	 * @hooked favblog_head -  10
	 *
	 */
	do_action( 'favblog_before_wp_head' );

	wp_head(); 
?>
</head>

<body <?php body_class(); ?>>

<?php do_action( 'wp_body_open' ); ?>
<?php
	/**
	 * favblog_page_start_action hook
	 *
	 * @hooked favblog_page_start -  10
	 *
	 */
	do_action( 'favblog_page_start_action' ); 

	/**
	 * favblog_header_action hook
	 *
	 * @hooked favblog_site_branding -  10
	 * @hooked favblog_header_start -  20
	 * @hooked favblog_site_navigation -  30
	 * @hooked favblog_header_end -  50
	 *
	 */
	do_action( 'favblog_header_action' );

	/**
	 * favblog_content_start_action hook
	 *
	 * @hooked favblog_content_start -  10
	 *
	 */
	do_action( 'favblog_content_start_action' );

    /**
     * favblog_header_image_action hook
     *
     * @hooked favblog_header_image -  10
     *
     */
    do_action( 'favblog_header_image_action' );

		// Call home if Homepage setting is set to latest posts.
		if ( favblog_is_latest_posts() ) {

			get_template_part( 'template-parts/content', 'home' );

		} elseif ( favblog_is_frontpage() ) {
			
			$options = favblog_get_theme_options();
			$sorted = array();

			if ( ! empty( $options['sortable'] ) ) {
				$sorted = explode( ',' , $options['sortable'] );
			}
			else{
				$sorted = explode( ',' ,'hero,popular_post,recent_post,most_read' );
			}
			foreach ( $sorted as $section ) {
				add_action( 'favblog_primary_content', 'favblog_add_'. $section .'_section' );
			}
			do_action( 'favblog_primary_content' );
		}