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


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

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

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

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

/**
 * Check if slider section content type is page.
 *
 * @since  Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_slider_section_content_page_enable( $control ) {
	$content_type = $control->manager->get_setting( 'top_event_theme_options[slider_content_type]' )->value();
	return top_event_is_slider_section_enable( $control ) && ( 'page' == $content_type );
}

/**
 * Check if slider section content type is event.
 *
 * @since  Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_slider_section_content_event_enable( $control ) {
    $content_type = $control->manager->get_setting( 'top_event_theme_options[slider_content_type]' )->value();
    return top_event_is_slider_section_enable( $control ) && ( 'event' == $content_type );
}

/**
 * Check if about section is enabled.
 *
 * @since Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_about_section_enable( $control ) {
	return ( $control->manager->get_setting( 'top_event_theme_options[about_section_enable]' )->value() );
}


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

/**
 * Check if Promotion section is enabled.
 *
 * @since  Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_promotion_section_content_page_enable( $control ) {
	$content_type = $control->manager->get_setting( 'top_event_theme_options[promotion_content_type]' )->value();
	return ( $control->manager->get_setting( 'top_event_theme_options[promotion_section_enable]' )->value() && ('page' == $content_type) );
}

/**
 * Check if Promotion section is enabled.
 *
 * @since  Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_promotion_section_content_event_enable( $control ) {
	$content_type = $control->manager->get_setting( 'top_event_theme_options[promotion_content_type]' )->value();
	return ( $control->manager->get_setting( 'top_event_theme_options[promotion_section_enable]' )->value() && ('event' == $content_type) );
}

/**
 * Check if latest_post section is enabled.
 *
 * @since  Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_latest_post_section_enable( $control ) {
	return ( $control->manager->get_setting( 'top_event_theme_options[latest_post_section_enable]' )->value() );
}

/**
 * Check if latest_post section content type is post.
 *
 * @since  Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_latest_post_section_content_post_enable( $control ) {
	$content_type = $control->manager->get_setting( 'top_event_theme_options[latest_post_content_type]' )->value();
	return top_event_is_latest_post_section_enable( $control ) && ( 'post' == $content_type );
}

/**
 * Check if latest_post section content type is page.
 *
 * @since  Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_latest_post_section_content_page_enable( $control ) {
	$content_type = $control->manager->get_setting( 'top_event_theme_options[latest_post_content_type]' )->value();
	return top_event_is_latest_post_section_enable( $control ) && ( 'page' == $content_type );
}

/**
 * Check if latest_post section content type is category.
 *
 * @since  Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_latest_post_section_content_category_enable( $control ) {
	$content_type = $control->manager->get_setting( 'top_event_theme_options[latest_post_content_type]' )->value();
	return top_event_is_latest_post_section_enable( $control ) && ( 'category' == $content_type );
}

/**
 * Check if latest_post section content type is recent.
 *
 * @since  Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_latest_post_section_content_recent_enable( $control ) {
	$content_type = $control->manager->get_setting( 'top_event_theme_options[latest_post_content_type]' )->value();
	return top_event_is_latest_post_section_enable( $control ) && ( 'recent' == $content_type );
}
/**
 * Check if latest_post separator section is enabled.
 *
 * @since  Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_latest_post_section_separator_enable( $control ) {
    $content_type = $control->manager->get_setting( 'top_event_theme_options[latest_post_content_type]' )->value();
    return top_event_is_latest_post_section_enable( $control ) && !( 'recent' == $content_type || 'category' == $content_type ) ;
}


/**
 * Check if event section is enabled.
 *
 * @since  Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_event_section_enable( $control ) {
	return ( $control->manager->get_setting( 'top_event_theme_options[event_section_enable]' )->value() );
}

/**
 * Check if event section content type is page.
 *
 * @since  Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_event_section_content_page_enable( $control ) {
	$content_type = $control->manager->get_setting( 'top_event_theme_options[event_content_type]' )->value();
	return top_event_is_event_section_enable( $control ) && ( 'page' == $content_type );
}

/**
 * Check if event section content type is event_category.
 *
 * @since  Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_event_section_content_event_category_enable( $control ) {
	$content_type = $control->manager->get_setting( 'top_event_theme_options[event_content_type]' )->value();
	return top_event_is_event_section_enable( $control ) && ( 'event-category' == $content_type );
}

/**
 * Check if event separator section is enabled.
 *
 * @since  Top Event 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function top_event_is_event_section_separator_enable( $control ) {
    $content_type = $control->manager->get_setting( 'top_event_theme_options[event_content_type]' )->value();
    return top_event_is_event_section_enable( $control ) && !( 'event-category' == $content_type );
}
