<?php
/**
 * Active callbacks for Theme/Customzer Options
 *
 * @package Catch Themes
 * @subpackage Jomsom
 * @since Jomsom 1.0
 */


if( ! function_exists( 'jomsom_is_header_text_displayed' ) ) :
	/**
	* Return true if Display Header Text is Checked
	* This is generated by getting the value of header_textcolor
	* Value of header_textcolor is blank if the Display Header Text is Unchecked
	*
	* @since Jomsom 0.1
	*/
	function jomsom_is_header_text_displayed( $control ) {
		$value = $control->manager->get_setting( 'header_textcolor' )->value();
		if ( 'blank' == $value ) {
			return false;
		}

		return true;
	}
endif;


if( ! function_exists( 'jomsom_is_logo_available' ) ) :
	/**
	* Return true if logo is available
	*
	* @since Jomsom 0.1
	*/
	function jomsom_is_logo_available( $control ) {
		if ( function_exists('has_custom_logo') ) {
			if ( has_custom_logo() ) {
				return true;
			}

			return false;
		}
		else {
			$value = $control->manager->get_setting( 'jomsom_theme_options[logo_enable]' )->value();
			if( $value ){
				return true;
			}
			return false;
		}
	}
endif;


if( ! function_exists( 'jomsom_is_slider_active' ) ) :
	/**
	* Return true if slider is active
	*
	* @since Jomsom 0.1
	*/
	function jomsom_is_slider_active( $control ) {
		global $wp_query;

		$page_id = $wp_query->get_queried_object_id();

		// Front page display in Reading Settings
		$page_for_posts = get_option('page_for_posts');

		$enable = $control->manager->get_setting( 'jomsom_theme_options[featured_slider_option]' )->value();

		//return true only if previwed page on customizer matches the type of slider option selected
		return ( 'entire-site' == $enable  || ( ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) && 'homepage' == $enable  ) );
	}
endif;


if( ! function_exists( 'jomsom_is_demo_slider_inactive' ) ) :
	/**
	* Return true if demo slider is inactive
	*
	* @since Jomsom 0.1
	*/
	function jomsom_is_demo_slider_inactive( $control ) {
		global $wp_query;

		$page_id = $wp_query->get_queried_object_id();

		// Front page display in Reading Settings
		$page_for_posts = get_option('page_for_posts');

		$enable	= $control->manager->get_setting( 'jomsom_theme_options[featured_slider_option]' )->value();

		$type 	= $control->manager->get_setting( 'jomsom_theme_options[featured_slider_type]' )->value();

		//return true only if previwed page on customizer matches the type of slider option selected and is not demo slider
		return ( ( 'entire-site' == $enable  || ( ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) && 'homepage' == $enable  ) ) && !( 'demo-featured-slider' == $type ) );
	}
endif;


if( ! function_exists( 'jomsom_is_page_slider_active' ) ) :
	/**
	* Return true if page slider is active
	*
	* @since Jomsom 0.1
	*/
	function jomsom_is_page_slider_active( $control ) {
		global $wp_query;

		$page_id = $wp_query->get_queried_object_id();

		// Front page display in Reading Settings
		$page_for_posts = get_option('page_for_posts');

		$enable = $control->manager->get_setting( 'jomsom_theme_options[featured_slider_option]' )->value();

		$type 	= $control->manager->get_setting( 'jomsom_theme_options[featured_slider_type]' )->value();

		//return true only if previwed page on customizer matches the type of slider option selected and page slider
		return ( ( 'entire-site' == $enable  || ( ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) && 'homepage' == $enable  ) ) && ( 'featured-page-slider' == $type ) );
	}
endif;


if( ! function_exists( 'jomsom_is_featured_content_active' ) ) :
	/**
	* Return true if featured content is active
	*
	* @since Jomsom 0.1
	*/
	function jomsom_is_featured_content_active( $control ) {
		global $wp_query;

		$page_id = $wp_query->get_queried_object_id();

		// Front page display in Reading Settings
		$page_for_posts = get_option('page_for_posts');

		$enable = $control->manager->get_setting( 'jomsom_theme_options[featured_content_option]' )->value();

		//return true only if previwed page on customizer matches the type of content option selected
		return ( 'entire-site' == $enable  || ( ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) && 'homepage' == $enable  ) );
	}
endif;


if( ! function_exists( 'jomsom_is_demo_featured_content_inactive' ) ) :
	/**
	* Return true if demo featured content is inactive
	*
	* @since Jomsom 0.1
	*/
	function jomsom_is_demo_featured_content_inactive( $control ) {
		global $wp_query;

		$page_id = $wp_query->get_queried_object_id();

		// Front page display in Reading Settings
		$page_for_posts = get_option('page_for_posts');

		$enable 	= $control->manager->get_setting( 'jomsom_theme_options[featured_content_option]' )->value();

		$type 	= $control->manager->get_setting( 'jomsom_theme_options[featured_content_type]' )->value();

		//return true only if previwed page on customizer matches the type of content option selected and is not demo content
		return ( ( 'entire-site' == $enable  || ( ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) && 'homepage' == $enable  ) ) && !( 'demo-featured-content' == $type ) );
	}
endif;


if( ! function_exists( 'jomsom_is_featured_page_content_active' ) ) :
	/**
	* Return true if page content is active
	*
	* @since Jomsom 0.1
	*/
	function jomsom_is_featured_page_content_active( $control ) {
		global $wp_query;

		$page_id = $wp_query->get_queried_object_id();

		// Front page display in Reading Settings
		$page_for_posts = get_option('page_for_posts');

		$enable = $control->manager->get_setting( 'jomsom_theme_options[featured_content_option]' )->value();

		$type 	= $control->manager->get_setting( 'jomsom_theme_options[featured_content_type]' )->value();

		//return true only if previwed page on customizer matches the type of content option selected and page content
		return ( ( 'entire-site' == $enable  || ( ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) && 'homepage' == $enable  ) ) && ( 'featured-page-content' == $type ) );
	}
endif;