<?php
/**
 * Template part for displaying Hero Content
 *
 * @package Stygian
 */
if ( ! stygian_gtm( 'stygian_hero_content_page' ) ) {
	return;
}

$stygian_args = array(
	'page_id'        => absint( stygian_gtm( 'stygian_hero_content_page' ) ),
	'posts_per_page' => 1,
	'post_type'      => 'page',
);

$stygian_loop = new WP_Query( $stygian_args );

while ( $stygian_loop->have_posts() ) :
	$stygian_loop->the_post();

	$stygian_content_align = stygian_gtm( 'stygian_hero_content_position' );
	$stygian_text_align    = stygian_gtm( 'stygian_hero_content_text_align' );
	$stygian_subtitle      = stygian_gtm( 'stygian_hero_content_custom_subtitle' );

	$classes[] = 'hero-content-section section';
	$classes[] = stygian_gtm( 'stygian_hero_content_position' );
	$classes[] = stygian_gtm( 'stygian_hero_content_text_align' );

	if ( ! has_post_thumbnail() ) {
		$classes[] = 'thumbnail-disable';
	}
	?>

	<div id="hero-content-section" class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>">
		<div class="section-featured-page">
			<div class="container">
				<div class="row">
					<div class="hero-content-wrapper">
						<?php if ( has_post_thumbnail() ) : ?>
						<div class="ff-grid-6 featured-page-thumb">
							<div class=" featured-page-thumb-wrapper"><?php the_post_thumbnail( 'stygian-hero', array( 'class' => 'alignnone' ) );?>
						</div>
						</div>
						<?php endif; ?>

						<!-- .ff-grid-6 -->
						<div class="ff-grid-6 featured-page-content">
							<div class="featured-page-section">
								<div class="section-title-wrap text-alignleft">
									<?php if ( $stygian_subtitle ) : ?>
									<p class="section-top-subtitle"><?php echo esc_html( $stygian_subtitle ); ?></p>
									<?php endif; ?>

									<?php the_title( '<h2 class="section-title">', '</h2>' ); ?>

									<span class="divider"></span>
								</div>

								<?php stygian_display_content( 'hero_content' ); ?>
							</div><!-- .featured-page-section -->
						</div><!-- .ff-grid-6 -->
					</div><!-- .hero-content-wrapper -->

				</div><!-- .row -->
			</div><!-- .container -->
		</div><!-- .section-featured-page -->
	</div><!-- .section -->
<?php
endwhile;

wp_reset_postdata();
