<?php
/**
 * The template for displaying featured content
 *
 * @package Signify
 */
?>

<?php
$enable_content = get_theme_mod( 'signify_featured_content_option', 'disabled' );

if ( ! signify_check_section( $enable_content ) ) {
	// Bail if featured content is disabled.
	return;
}

$signify_type = get_theme_mod( 'signify_featured_content_type', 'page' );

$layout = get_theme_mod( 'signify_featured_content_layout', 'layout-three' );

$classes[] = $layout;
$classes[] = $signify_type;
$classes[] = 'section';

$signify_sub_title   = get_theme_mod( 'signify_featured_content_sub_title' );
$signify_title       = get_theme_mod( 'signify_featured_content_title' );
$signify_description = get_theme_mod( 'signify_featured_content_description' );

if ( ! $signify_sub_title && ! $signify_title && ! $signify_description ) {
	$classes[] = 'no-section-heading';
}
?>

<div id="featured-content-section" class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>">
	<div class="wrapper">
		<?php signify_section_header( $signify_sub_title, $signify_title, $signify_description ); ?>

		<div class="section-content-wrapper featured-content-wrapper <?php echo esc_attr( $layout ); ?>">
			<?php
				if ( 'custom' === $signify_type ) {
					get_template_part( 'template-parts/featured-content/custom-featured' );
				} else {
					get_template_part( 'template-parts/featured-content/content-featured' );
				}
			?>
		</div><!-- .section-content-wrap -->

		<?php
			$target        = get_theme_mod( 'signify_featured_content_target' ) ? '_blank': '_self';
			$signify_link = get_theme_mod( 'signify_featured_content_link', '#' );
			$text          = get_theme_mod( 'signify_featured_content_text' );

			if ( $text ) :
			?>
			<p class="view-more">
				<a class="button" target="<?php echo $target; ?>" href="<?php echo esc_url( $signify_link ); ?>"><?php echo esc_html( $text ); ?></a>
			</p>
		<?php endif; ?>
	</div><!-- .wrapper -->
</div><!-- #featured-content-section -->
