<?php

if ( ! get_theme_mod( 'charity_elite_enable_video_section', false ) ) {
	return;
}

$charity_elite_section_content              = array();
$charity_elite_section_content['subtitle']  = get_theme_mod( 'charity_elite_video_subtitle', '' );
$charity_elite_section_content['title']     = get_theme_mod( 'charity_elite_video_title', __( 'Watch the Video', 'charity-elite' ) );
$charity_elite_section_content['bg_image']  = get_theme_mod( 'charity_elite_video_section_bg_image', '' );
$charity_elite_section_content['video_url'] = get_theme_mod( 'charity_elite_video_video_link', '' );

$charity_elite_section_content = apply_filters( 'charity_elite_video_section_content', $charity_elite_section_content );
charity_elite_render_video_section( $charity_elite_section_content );

/**
 * Render Video Section.
 */
function charity_elite_render_video_section( $charity_elite_section_content ) {
	if ( empty( $charity_elite_section_content ) ) {
		return;
	}
	?>

	<section id="charity_elite_video_section" class="ascendoor-frontpage-section video-section section-has-background video-style-1" style="background-color: #202020;">
		<?php
		if ( is_customize_preview() ) :
			charity_elite_section_link( 'charity_elite_video_section' );
		endif;
		?>
		<?php if ( ! empty( $charity_elite_section_content['bg_image'] ) ) : ?>
			<div class="video-background-img">
				<img src="<?php echo esc_url( $charity_elite_section_content['bg_image'] ); ?>">
			</div>
		<?php endif; ?>
		<div class="ascendoor-wrapper">
			<div class="video-details-wrapper">
				<div class="section-header-subtitle video-details">
					<p class="section-subtitle video-detail-subtitle"><?php echo esc_html( $charity_elite_section_content['subtitle'] ); ?></p>
					<h3 class="section-title video-detail-title"><?php echo esc_html( $charity_elite_section_content['title'] ); ?></h3>
				</div>
				<?php if ( ! empty( $charity_elite_section_content['video_url'] ) ) : ?>
					<div class="video-icon">
						<a href="<?php echo esc_url( $charity_elite_section_content['video_url'] ); ?>" class="ascendoor-video-popup corporaze-video-play-btn"><i class="fas fa-play"></i></a>
					</div>
				<?php endif; ?>
			</div>
		</div>
	</section>

	<?php
}
