<?php
/**
 * The template used for displaying promotion headline
 *
 * @package Signify
 */

$signify_classes[] = 'section';
$signify_classes[] = 'promotion-section';
$signify_classes[] = get_theme_mod( 'signify_promo_head_image_position', 'content-align-left' );
$signify_classes[] = get_theme_mod( 'signify_promo_head_text_alignment', 'text-align-center' );

if ( get_theme_mod( 'signify_promo_head_text_color', 0 ) ) {
   $signify_classes[] = 'content-color-white';
}

if( get_theme_mod( 'signify_promo_head_content_frame', 1 ) ) {
	$signify_classes[] = 'content-frame';
}

$signify_classes[] = 'promotion-headline-one';

$signify_link = get_theme_mod( 'signify_featured_video_link' );

if( $signify_link ) {
	$signify_classes[] = 'play-video';
}
?>
<div id="promotion-section" class="<?php echo esc_attr( implode( ' ', $signify_classes ) ); ?>">
	<div class="wrapper">
		<div class="section-content-wrapper">
			<article class="promotion-headline-image type-image hentry">
				<div class="hentry-inner">
					<?php
					$image = get_theme_mod( 'signify_promo_head_image' );
					if ( $image ) : ?>
						<div class="post-thumbnail-background" style="background-image: url( '<?php echo esc_url( $image ); ?>' )">
						</div><!-- .post-thumbnail-background -->
						<?php
							$signify_bg_image_link = get_theme_mod( 'signify_promo_head_link' );
							$signify_target = get_theme_mod( 'signify_promo_head_target' ) ? '_blank' : '_self';
							if ( $signify_bg_image_link ) :
							?>
								<a class="cover-link" href="<?php echo esc_url( $signify_bg_image_link ); ?>" target="<?php echo esc_attr( $signify_target ); ?>">
								</a>
							<?php
							endif;
					endif; ?>

					<div class="content-wrapper">
						<div class="entry-container">
							<div class="entry-container-frame">
								<?php
								$signify_sub_title   = get_theme_mod( 'signify_promotion_headline_sub_title' );
								$signify_title       = get_theme_mod( 'signify_promo_head_title' );
								$signify_description = get_theme_mod( 'signify_promotion_headline_description' );

								 if ( $signify_title || $signify_sub_title || $signify_link ) : ?>
									<header class="entry-header section-title-wrapper">
										<?php if ( $signify_sub_title ) : ?>
											<div class="section-description-wrapper section-subtitle">
											<?php
												echo esc_html( $signify_sub_title );
											?>
											</div><!-- .section-description-wrapper -->
										<?php endif; ?>
										<?php if ( $signify_title ) : ?>
											<h2 class="entry-title section-title">
												<?php echo esc_html( $signify_title ); ?>
											</h2>
										<?php endif; ?>

										<?php if ( $signify_description ) : ?>
											<div class="section-description">
												<p><?php echo wp_kses_post( $signify_description ); ?></p>
											</div><!-- .section-description-wrapper -->
										<?php endif; ?>

										<?php
										$image = get_theme_mod( 'signify_promo_head_logo_image' );
										if ( $image ) : ?>
											<div class="promo-logo">
												<img src="<?php echo esc_url( $image ); ?>">
											</div><!-- .post-thumbnail-->
										<?php endif; ?>

										<?php
											$embed_code = wp_oembed_get( esc_url( $signify_link ) );

											if ( $embed_code ) {
												echo '<div class="play-video"><a class="mixed button play-button" data-flashy-type="video" href="' . esc_url( $signify_link ) . '"> <span class="screen-reader-text">Play Video </span></a>
												</div>';
											}
										?>
									</header><!-- .entry-header -->
								<?php endif; ?>

								<?php if ( $content = get_theme_mod( 'signify_promo_head_content' ) ) : ?>
									<div class="entry-content">
										<?php echo wp_kses_post( $content ); ?>

										<?php
										$more_text   = get_theme_mod( 'signify_promo_head_more_text' );
										$more_link   = get_theme_mod( 'signify_promo_head_more_link', '#' );
										$more_target = get_theme_mod( 'signify_promo_head_more_target' ) ? '_blank' : '_self' ;


										if ( $more_text ) : ?>
											<p class="more-button">
												<a href="<?php echo esc_url( $more_link ); ?>" target="<?php echo esc_attr( $more_target ); ?>" class="more-link"><?php echo esc_html( $more_text ); ?></a>
											</p>
										<?php
										endif;
										?>
									</div><!-- .entry-content -->
								<?php endif; ?>
							</div><!-- .entry-container-frame -->
						</div><!-- .entry-container -->
					</div><!-- .content-wrapper -->
				</div><!-- .hentry-inner -->
			</article><!-- #post-## -->
		</div>
	</div><!-- .section-content-wrap -->
</div><!-- .section -->
