<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) exit;

if ( ! function_exists( 'sekhlo_execute_hooks' ) ) {
	function sekhlo_execute_hooks( $id ) {
		$hooks = get_option( 'sekhlo_hooks' );

		$content = isset( $hooks[$id] ) ? $hooks[$id] : null;

		$disable = isset( $hooks[$id . '_disable'] ) ? $hooks[$id . '_disable'] : null;

		if ( ! $content || 'true' == $disable ) {
			return;
		}

		$php = isset( $hooks[$id . '_php'] ) ? $hooks[$id . '_php'] : null;

		$value = do_shortcode( $content );

		if ( 'true' == $php && ! defined( 'sekhlo_HOOKS_DISALLOW_PHP' ) ) {
			eval( "?>$value<?php " );
		} else {
			echo $value;
		}
	}
}

if ( ! function_exists( 'sekhlo_hooks_wp_head' ) ) {
	add_action( 'wp_head', 'sekhlo_hooks_wp_head' );

	function sekhlo_hooks_wp_head() {
		sekhlo_execute_hooks( 'sekhlo_wp_head' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_before_header' ) ) {
	add_action( 'sekhlo_before_header', 'sekhlo_hooks_before_header', 4 );

	function sekhlo_hooks_before_header() {
		sekhlo_execute_hooks( 'sekhlo_before_header' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_before_header_content' ) ) {
	add_action( 'sekhlo_before_header_content', 'sekhlo_hooks_before_header_content' );

	function sekhlo_hooks_before_header_content() {
		sekhlo_execute_hooks( 'sekhlo_before_header_content' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_after_header_content' ) ) {
	add_action( 'sekhlo_after_header_content', 'sekhlo_hooks_after_header_content' );

	function sekhlo_hooks_after_header_content() {
		sekhlo_execute_hooks( 'sekhlo_after_header_content' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_after_header' ) ) {
	add_action( 'sekhlo_after_header', 'sekhlo_hooks_after_header' );

	function sekhlo_hooks_after_header() {
		sekhlo_execute_hooks( 'sekhlo_after_header' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_inside_main_content' ) ) {
	add_action( 'sekhlo_before_main_content', 'sekhlo_hooks_inside_main_content', 9 );

	function sekhlo_hooks_inside_main_content() {
		sekhlo_execute_hooks( 'sekhlo_before_main_content' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_before_content' ) ) {
	add_action( 'sekhlo_before_content', 'sekhlo_hooks_before_content' );

	function sekhlo_hooks_before_content() {
		sekhlo_execute_hooks( 'sekhlo_before_content' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_after_entry_header' ) ) {
	add_action( 'sekhlo_after_entry_header', 'sekhlo_hooks_after_entry_header' );

	function sekhlo_hooks_after_entry_header() {
		sekhlo_execute_hooks( 'sekhlo_after_entry_header' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_after_content' ) ) {
	add_action( 'sekhlo_after_content', 'sekhlo_hooks_after_content' );

	function sekhlo_hooks_after_content() {
		sekhlo_execute_hooks( 'sekhlo_after_content' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_before_right_sidebar_content' ) ) {
	add_action( 'sekhlo_before_right_sidebar_content', 'sekhlo_hooks_before_right_sidebar_content', 5 );

	function sekhlo_hooks_before_right_sidebar_content() {
		sekhlo_execute_hooks( 'sekhlo_before_right_sidebar_content' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_after_right_sidebar_content' ) ) {
	add_action( 'sekhlo_after_right_sidebar_content', 'sekhlo_hooks_after_right_sidebar_content' );

	function sekhlo_hooks_after_right_sidebar_content() {
		sekhlo_execute_hooks( 'sekhlo_after_right_sidebar_content' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_before_left_sidebar_content' ) ) {
	add_action( 'sekhlo_before_left_sidebar_content', 'sekhlo_hooks_before_left_sidebar_content', 5 );

	function sekhlo_hooks_before_left_sidebar_content() {
		sekhlo_execute_hooks( 'sekhlo_before_left_sidebar_content' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_after_left_sidebar_content' ) ) {
	add_action( 'sekhlo_after_left_sidebar_content', 'sekhlo_hooks_after_left_sidebar_content' );

	function sekhlo_hooks_after_left_sidebar_content() {
		sekhlo_execute_hooks( 'sekhlo_after_left_sidebar_content' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_before_footer' ) ) {
	add_action( 'sekhlo_before_footer', 'sekhlo_hooks_before_footer' );

	function sekhlo_hooks_before_footer() {
		sekhlo_execute_hooks( 'sekhlo_before_footer' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_after_footer_widgets' ) ) {
	add_action( 'sekhlo_after_footer_widgets', 'sekhlo_hooks_after_footer_widgets' );

	function sekhlo_hooks_after_footer_widgets() {
		sekhlo_execute_hooks( 'sekhlo_after_footer_widgets' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_before_footer_content' ) ) {
	add_action( 'sekhlo_before_footer_content', 'sekhlo_hooks_before_footer_content' );

	function sekhlo_hooks_before_footer_content() {
		sekhlo_execute_hooks( 'sekhlo_before_footer_content' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_after_footer_content' ) ) {
	add_action( 'sekhlo_after_footer_content', 'sekhlo_hooks_after_footer_content' );

	function sekhlo_hooks_after_footer_content() {
		sekhlo_execute_hooks( 'sekhlo_after_footer_content' );
	}
}

if ( ! function_exists( 'sekhlo_hooks_wp_footer' ) ) {
	add_action( 'wp_footer', 'sekhlo_hooks_wp_footer' );

	function sekhlo_hooks_wp_footer() {
		sekhlo_execute_hooks( 'sekhlo_wp_footer' );
	}
}
