<?php
/**
 * The template part for displaying the features section on homepage
 *
 * @package Meridian One
 * @since 1.0
 */
?>
<?php

	$title = false;
	$subtitle = false;
	$description = false;
	$image_url = false;
	$image_title = false;
	$image_description = false;

	if ( meridian_one_get_theme_option( 'home_features_section_title' ) ) {
		$title = meridian_one_get_theme_option( 'home_features_section_title' );
	}

	if ( meridian_one_get_theme_option( 'home_features_section_subtitle' ) ) {
		$subtitle = meridian_one_get_theme_option( 'home_features_section_subtitle' );
	}

	if ( meridian_one_get_theme_option( 'home_features_section_description' ) ) {
		$description = meridian_one_get_theme_option( 'home_features_section_description' );
	}

	if ( meridian_one_get_theme_option( 'home_features_section_image' ) ) {
		$image_url = meridian_one_get_theme_option( 'home_features_section_image' );
	}

	if ( meridian_one_get_theme_option( 'home_features_section_image_title' ) ) {
		$image_title = meridian_one_get_theme_option( 'home_features_section_image_title' );
	}

	if ( meridian_one_get_theme_option( 'home_features_section_image_description' ) ) {
		$image_description = meridian_one_get_theme_option( 'home_features_section_image_description' );
	}

?>
<div id="features" class="section section-features">

	<div class="wrapper">

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

		<div class="section-features-main-wrap">

			<div class="section-features-main clearfix">

				<div class="section-features-main-inner clearfix">

					<?php if ( is_active_sidebar( 'sidebar-home-features' ) ) : ?>
						<div class="section-features-items clearfix <?php if ( $image_url ) echo 'col col-6'; ?>">
							<?php dynamic_sidebar( 'sidebar-home-features' ); ?>
						</div><!-- .section-features-items -->	
					<?php endif; ?>

					<?php if ( $image_url ) : ?>
						<div class="col col-1">&nbsp;</div>
						<div class="section-features-image col col-5 col-last">
							<img src="<?php echo esc_url( $image_url ); ?>" alt="<?php echo esc_attr( $image_title ); ?>" />
							<?php if ( $image_title || $image_description ) : ?>
								<div class="section-features-image-caption">
									<?php if ( $image_title ) : ?>
										<h4 class="section-features-image-caption-title"><?php echo esc_html( $image_title ); ?></h4>
									<?php endif; ?>
									<?php if ( $image_description ) : ?>
										<div class="section-features-image-caption-description"><?php echo esc_html( $image_description ); ?></div>
									<?php endif; ?>
								</div><!-- .section-features-image-caption -->
							<?php endif; ?>
						</div><!-- .section-features-image -->
					<?php endif; ?>

				</div><!-- .section-features-main-inner -->

			</div><!-- .section-features-main -->

		</div><!-- .section-features-main-wrap -->

	</div><!-- .wrapper -->

</div><!-- .section-features -->