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

<?php
$quantity = get_theme_mod( 'signify_featured_content_number', 3 );

for ( $i = 1; $i <= $quantity; $i++ ) {
	$target = get_theme_mod( 'signify_featured_content_target_' . $i ) ? '_blank' : '_self';

	$signify_link = get_theme_mod( 'signify_featured_content_link_' . $i ) ? get_theme_mod( 'signify_featured_content_link_' . $i ) : '#';

	if ( function_exists( 'qtrans_convertURL' ) ) {
		$signify_link = qtrans_convertURL( $signify_link );
	}

	echo '
	<article id="featured-post-' . esc_attr( $i ) . '" class="hentry featured-image-content">
		<div class="hentry-inner">';

			$signify_title   = get_theme_mod( 'signify_featured_content_title_' . $i );
			$content = get_theme_mod( 'signify_featured_content_content_' . $i );

			$image = get_theme_mod( 'signify_featured_content_image_' . $i ) ? get_theme_mod( 'signify_featured_content_image_' . $i ) :  trailingslashit( esc_url( get_template_directory_uri() ) );
			if ( $image ) {
				echo '
				<a href="' . esc_url( $signify_link ) . '" class="post-thumbnail" target="' . esc_attr( $target ) . '">
					<img src="' . esc_url( $image ) . '" class="wp-post-image" alt="' . esc_attr( $signify_title ) . '" title="' . esc_attr( $signify_title ) . '">
				</a>';
			}
			
			if ( $signify_title || $content ) {
				echo '
				<div class="entry-container">';

				if ( $signify_title ) {
					echo '
					<header class="featured-content entry-header">
						<h2 class="entry-title">
							<a href="' . esc_url( $signify_link ) . '" rel="bookmark" target="' . esc_attr( $target ) . '">' . wp_kses_post( $signify_title ) . '</a>
						</h2>
					</header>';
				}

				if ( '' !== $content ) {
					echo '
					<div class="entry-summary">' . wp_kses_post( $content ) . '</div><!-- .entry-summary -->';
				}

				echo '
				</div><!-- .entry-container -->';
			}

		echo '
		</div><!-- .hentry-inner -->
	</article><!-- .featured-post-' . esc_attr( $i ) . ' -->';
} // End for().
