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

if ( ! function_exists( 'power_news_is_loader_enable' ) ) :
	/**
	 * Check if loader is enabled.
	 *
	 * @since Power News 1.0.0
	 * @param WP_Customize_Control $control WP_Customize_Control instance.
	 * @return bool Whether the control is active to the current preview.
	 */
	function power_news_is_loader_enable( $control ) {
		return $control->manager->get_setting( 'power_news_theme_options[loader_enable]' )->value();
	}
endif;

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

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

/**
 * Front Page Active Callbacks
 */

/**
 * Check if topbar section is enabled.
 *
 * @since Power News 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function power_news_is_topbar_section_enable( $control ) {
	return ( $control->manager->get_setting( 'power_news_theme_options[topbar_section_enable]' )->value() );
}

/****************************Breaking News****************************************** */

/**
 * Check if Breaking News section is enabled.
 *
 * @since Power News 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function power_news_is_breaking_news_section_enable( $control ) {
	return ( $control->manager->get_setting( 'power_news_theme_options[breaking_news_section_enable]' )->value() );
}

/*==================Featured Posts===============*/

/**
 * Check if featured_post section is enabled.
 *
 * @since Power News 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function power_news_is_featured_posts_section_enable( $control ) {
	return ( $control->manager->get_setting( 'power_news_theme_options[featured_posts_section_enable]' )->value() );
}

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

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

/*==================Popular Posts===============*/

/**
 * Check if latest_post section is enabled.
 *
 * @since Power News 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function power_news_is_popular_post_section_enable( $control ) {
	return ( $control->manager->get_setting( 'power_news_theme_options[popular_post_section_enable]' )->value() );
}

/*==================Multi Posts Section===============*/

/**
 * Check if multi_post section is enabled.
 *
 * @since Power News 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function power_news_is_multi_post_section_enable( $control ) {
	return ( $control->manager->get_setting( 'power_news_theme_options[multi_post_section_enable]' )->value() );
}

/*==================Media Posts Section===============*/

/**
 * Check if featured section is enabled.
 *
 * @since Power News 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function power_news_is_media_post_section_enable( $control ) {
	return ( $control->manager->get_setting( 'power_news_theme_options[media_post_section_enable]' )->value() );
}

/*==================Related Posts===============*/

/**
 * Check if latest_post section is enabled.
 *
 * @since Power News 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function power_news_is_related_posts_section_enable( $control ) {
	return ( $control->manager->get_setting( 'power_news_theme_options[related_posts_section_enable]' )->value() );
}

/**
 * Check if related_posts section content type is post.
 *
 * @since Power News 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function power_news_is_related_posts_section_content_post_enable( $control ) {
	$content_type = $control->manager->get_setting( 'power_news_theme_options[related_posts_content_type]' )->value();
	return power_news_is_related_posts_section_enable( $control ) && ( 'post' == $content_type );
}

/**
 * Check if related_posts section content type is category.
 *
 * @since Power News 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function power_news_is_related_posts_section_content_category_enable( $control ) {
	$content_type = $control->manager->get_setting( 'power_news_theme_options[related_posts_content_type]' )->value();
	return power_news_is_related_posts_section_enable( $control ) && ( 'category' == $content_type );
}

/****************************Advertisement****************************************** */

/**
 * Check if Advertisement section is enabled.
 *
 * @since Power News 1.0.0
 * @param WP_Customize_Control $control WP_Customize_Control instance.
 * @return bool Whether the control is active to the current preview.
 */
function power_news_is_advertisement_section_enable( $control ) {
	return ( $control->manager->get_setting( 'power_news_theme_options[advertisement_section_enable]' )->value() );
}