<?php
/**
 * @author Deepen.
 * @created_on 12/3/19
 *
 * @since 1.0.0
 * @copyright 2019. CodeManas
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * AFter head tag hook
 */
function octane_after_head() {
	do_action( 'octane_after_head' );
}

/**
 * Main body top
 */
function octane_body_top() {
	do_action( 'octane_body_top' );
}

/**
 * Before main header hook
 */
function octane_before_header() {
	do_action( 'octane_before_header' );
}

/**
 * Main header hook
 */
function octane_header() {
	do_action( 'octane_header' );
}

/**
 * After main header hook
 */
function octane_after_header() {
	do_action( 'octane_after_header' );
}

/**
 * Main Header Content
 */
function octane_masthead_content() {
	do_action( 'octane_masthead_content' );
}

/**
 * Before Main Header Content
 */
function octane_before_masthead_content() {
	do_action( 'octane_before_masthead_content' );
}

/**
 * After Main Header Content
 */
function octane_after_masthead_content() {
	do_action( 'octane_after_masthead_content' );
}

/**
 * Before top banner image content
 */
function octane_before_top_banner_image() {
	do_action( 'octane_before_top_banner_image' );
}

/**
 * Top banner image content
 */
function octane_top_banner_image() {
	do_action( 'octane_top_banner_image' );
}

/**
 * After Top banner image content
 */
function octane_after_top_banner_image() {
	do_action( 'octane_after_top_banner_image' );
}

/**
 * Before main navigation
 */
function octane_before_main_nav() {
	do_action( 'octane_before_main_nav' );
}


/**
 * Before main navigation
 */
function octane_after_main_nav() {
	do_action( 'octane_after_main_nav' );
}

/**
 * Before main footer render
 */
function octane_before_footer() {
	do_action( 'octane_before_footer' );
}

/**
 * After main container
 */
function octane_after_main_container() {
	do_action( 'octane_after_main_container' );
}

/**
 * Main Footer Hook
 */
function octane_footer() {
	do_action( 'octane_footer' );
}

/**
 * After main footer render
 */
function octane_after_footer() {
	do_action( 'octane_after_footer' );
}

/**
 * Top Header
 */
function octane_top_header_main() {
	do_action( 'octane_top_header_main' );
}

/**
 * Bottom footer
 */
function octane_body_bottom() {
	do_action( 'octane_body_bottom' );
}

/**
 * Output before footer widgets
 */
function octane_before_footer_widgets() {
	do_action( 'octane_before_footer_widgets' );
}

/**
 * Output after footer widgets
 */
function octane_after_footer_widgets() {
	do_action( 'octane_after_footer_widgets' );
}

/**
 * Output before social menus
 */
function octane_before_social_menus() {
	do_action( 'octane_before_social_menus' );
}

/**
 * Output after social menus
 */
function octane_after_social_menus() {
	do_action( 'octane_after_social_menus' );
}

/**
 * Post Hooks Start
 */
function octane_before_main_content() {
	do_action( 'octane_before_main_content' );
}

function octane_after_main_content() {
	do_action( 'octane_after_main_content' );
}

function octane_before_post_content() {
	do_action( 'octane_before_post_content' );
}

function octane_after_post_content() {
	do_action( 'octane_after_post_content' );
}

function octane_before_sidebar() {
	do_action( 'octane_before_sidebar' );
}

function octane_after_sidebar() {
	do_action( 'octane_after_sidebar' );
}

function octane_main_content() {
	do_action( 'octane_main_content' );
}

function octane_main_comments() {
	do_action( 'octane_main_comments' );
}

function octane_contact_before_main_content() {
	do_action( 'octane_contact_before_main_content' );
}

function octane_contact_main_content() {
	do_action( 'octane_contact_main_content' );
}

function octane_contact_after_main_content() {
	do_action( 'octane_contact_after_main_content' );
}


/**
 * Include a skip to content link at the top of the page so that users can bypass the menu.
 */
function octane_skip_link() {
	echo '<a class="skip-link screen-reader-text" href="#content">' . __( 'Skip to the content', 'octane' ) . '</a>';
}

add_action( 'wp_body_open', 'octane_skip_link', 5 );

/**
 * Post Hooks End
 */


/* Homepage hooks */
function octane_homepage_main_content() {
	do_action( 'octane_homepage_main_content' );
}

function octane_homepage_before_main_content() {
	do_action( 'octane_homepage_before_main_content' );
}

function octane_homepage_after_main_content() {
	do_action( 'octane_homepage_after_main_content' );
}


/* About hooks */
function octane_about_main_content() {
	do_action( 'octane_about_main_content' );
}

function octane_about_before_main_content() {
	do_action( 'octane_about_before_main_content' );
}

function octane_about_after_main_content() {
	do_action( 'octane_about_after_main_content' );
}


/**
 * Headers
 *
 * @see  Octane_Template_Functions::master_header()
 * @see  Octane_Template_Functions::after_header_contents()
 * @see  octane_masthead_logo()
 * @see  octane_masthead_nav()
 * @see  Octane_Template_Functions::top_header()
 * @see  Octane_Template_Functions::breadcrumbs_inside_header()
 */

add_action( 'octane_header', array( 'Octane_Template_Functions', 'master_header' ) );
add_action( 'octane_after_header', array( 'Octane_Template_Functions', 'after_header_contents' ), 10 );

add_action( 'wp', 'octane_header_design_layout_cb' ); // Hooked to wp since the template functions does not work until wp is loaded.
function octane_header_design_layout_cb() {
	add_action( 'octane_masthead_content', 'octane_masthead_logo', 10 );
	add_action( 'octane_masthead_content', 'octane_header_right_wrapper_start', 15 );
	add_action( 'octane_masthead_content', 'octane_masthead_nav', 20 );
	add_action( 'octane_masthead_content', 'octane_header_right_head_start', 25 );
	add_action( 'octane_masthead_content', 'octane_header_search_trigger', 30 );
	add_action( 'octane_masthead_content', 'octane_masthead_search', 40 );
	add_action( 'octane_masthead_content', 'octane_masthead_mini_cart', 50 );
	add_action( 'octane_masthead_content', 'octane_header_right_head_end', 55 );
	add_action( 'octane_masthead_content', 'octane_header_right_wrapper_end', 60 );
}

// Top header
// add_action( 'octane_before_masthead_content', array( 'Octane_Template_Functions', 'mobile_menu' ), 10 );



/**
 * Top banner image
 *
 * @see  octane_pageshow_title_in_banner()
 */

add_action( 'octane_top_banner_image', 'octane_pageshow_title_in_banner' );

/**
 * Homepage sections
 *
 * @see  octane_pageshow_title_in_banner()
 */
add_action( 'wp', 'octane_homepage_sorting_cb' ); // Hooked to wp since the template functions does not work until wp is loaded.
function octane_homepage_sorting_cb() {
	$homepage_sort_sections = Octane_Theme_Options::get_option( 'field-homepage-sort' );

	$section_priority = 10;
	foreach ( $homepage_sort_sections as $section ) {
		add_action( 'octane_homepage_main_content', array( 'Octane_' . esc_html( $section ) . '_Section', 'render_content' ), $section_priority );
	}
}


/**
 * Footer
 *
 * @see Octane_Template_Functions::master_footer()
 * @see Octane_Template_Functions::main_footer()
 * @see Octane_Template_Functions::super_footer()
 */

add_action( 'octane_footer', array( 'Octane_Template_Functions', 'footer_widgets' ) );
add_action( 'octane_footer', array( 'Octane_Template_Functions', 'footer_site_info' ), 30 );
add_action( 'octane_body_bottom', array( 'Octane_Template_Functions', 'octane_scrollToTop' ), 10 );


/**
 * Singular hooks
 *
 * @see octane_before_main_content_wrapper_start()
 * @see Octane_Template_Functions::main_footer()
 */

add_action( 'octane_main_content', 'octane_content_post_sortable', 10 );
add_action( 'octane_main_comments', 'octane_show_comments' );


// Post/body classes
add_filter( 'post_class', 'octane_blog_archive_column', 10, 1 );
add_filter( 'body_class', 'octane_body_class', 10, 1 );