<?php
/**
 * Customizer active callbacks
 *
 * @package Theme Palace
 * @subpackage Photoistic
 * @since Photoistic 1.0.0
 */

if ( ! function_exists( 'photoistic_is_breadcrumb_enable' ) ) :
	/**
	 * Check if breadcrumb is enabled.
	 *
	 * @since Photoistic 1.0.0
	 * @param WP_Customize_Control $control WP_Customize_Control instance.
	 * @return bool Whether the control is active to the current preview.
	 */
	function photoistic_is_breadcrumb_enable( $control ) {
		return $control->manager->get_setting( 'photoistic_theme_options[breadcrumb_enable]' )->value();
	}
endif;

if ( ! function_exists( 'photoistic_is_pagination_enable' ) ) :
	/**
	 * Check if pagination is enabled.
	 *
	 * @since Photoistic 1.0.0
	 * @param WP_Customize_Control $control WP_Customize_Control instance.
	 * @return bool Whether the control is active to the current preview.
	 */
	function photoistic_is_pagination_enable( $control ) {
		return $control->manager->get_setting( 'photoistic_theme_options[pagination_enable]' )->value();
	}
endif;

if ( ! function_exists( 'photoistic_is_static_homepage_enable' ) ) :
	/**
	 * Check if static homepage is enabled.
	 *
	 * @since Photoistic 1.0.0
	 * @param WP_Customize_Control $control WP_Customize_Control instance.
	 * @return bool Whether the control is active to the current preview.
	 */
	function photoistic_is_static_homepage_enable( $control ) {
		return ( 'page' == $control->manager->get_setting( 'show_on_front' )->value() );
	}
endif;

/**
 * Front Page Active Callbacks
 */

/*==================Slider===============*/

/**
 * Check if slider section is enabled.
 *
 * @since Photoistic 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function photoistic_is_slider_section_enable( $control ) {
	return ( $control->manager->get_setting( 'photoistic_theme_options[slider_section_enable]' )->value() );
}

/*==================Speciality===============*/

/**
 * Check if speciality section is enabled.
 *
 * @since Photoistic 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function photoistic_is_speciality_section_enable( $control ) {
	return ( $control->manager->get_setting( 'photoistic_theme_options[speciality_section_enable]' )->value() );
}

/*==================Stories===============*/

/**
 * Check if stories section is enabled.
 *
 * @since Photoistic 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function photoistic_is_stories_section_enable( $control ) {
	return ( $control->manager->get_setting( 'photoistic_theme_options[stories_section_enable]' )->value() );
}

/*==================Promotion=====================*/

/**
 * Check if promotion section is enabled.
 *
 * @since Photoistic 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function photoistic_is_promotion_section_enable( $control ) {
	return ( $control->manager->get_setting( 'photoistic_theme_options[promotion_section_enable]' )->value() );
}

/*=================Recent Products================*/

/**
 * Check if recent_products section is enabled.
 *
 * @since Photoistic 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function photoistic_is_recent_products_section_enable( $control ) {
	return ( $control->manager->get_setting( 'photoistic_theme_options[recent_products_section_enable]' )->value() );
}

/*=========================Latest Posts==================*/

/**
 * Check if latest_posts section is enabled.
 *
 * @since Photoistic 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function photoistic_is_latest_posts_section_enable( $control ) {
	return ( $control->manager->get_setting( 'photoistic_theme_options[latest_posts_section_enable]' )->value() );
}

/**
 * Check if latest_posts section content type is category.
 *
 * @since Photoistic 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function photoistic_is_latest_posts_section_content_category_enable( $control ) {
	$content_type = $control->manager->get_setting( 'photoistic_theme_options[latest_posts_content_type]' )->value();
	return photoistic_is_latest_posts_section_enable( $control ) && ( 'category' == $content_type );
}

/**
 * Check if latest_posts section content type is post.
 *
 * @since Photoistic 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function photoistic_is_latest_posts_section_content_post_enable( $control ) {
	$content_type = $control->manager->get_setting( 'photoistic_theme_options[latest_posts_content_type]' )->value();
	return photoistic_is_latest_posts_section_enable( $control ) && ( 'post' == $content_type );
}