<?php

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

$section_content                    = array();
$section_content['adver_image']     = get_theme_mod( 'majestic_blog_advertisement_image', '' );
$section_content['adver_image_url'] = get_theme_mod( 'majestic_blog_advertisement_image_url', '' );
$section_content                    = apply_filters( 'majestic_blog_advertisement_section_content', $section_content );

majestic_blog_render_advertisement_section( $section_content );

/**
 * Render Advertisement Section
 */
function majestic_blog_render_advertisement_section( $section_content ) {
	?>
	<section id="majestic_blog_advertisement_section" class="advertisement-section section-splitter">
		<?php
		if ( is_customize_preview() ) :
			majestic_blog_section_link( 'majestic_blog_advertisement_section' );
		endif;
		?>
		<div class="section-wrapper">
			<div class="adver-slider">
				<?php if ( ! empty( $section_content['adver_image'] ) ) { ?>
					<a href="<?php echo esc_url( $section_content['adver_image_url'] ); ?>"><img src="<?php echo esc_url( $section_content['adver_image'] ); ?>" alt="<?php echo esc_attr( 'Advertisment Image', 'majestic-blog' ); ?>"></a>
				<?php } ?>
			</div>
		</div>
	</section>
	<?php
}
