<?php
if ( ! get_theme_mod( 'technology_software_firm_enable_banner_section', false ) ) {
	return;
}

/**
 * Render Banner Section.
 */
$technology_software_firm_banner_section_title     = get_theme_mod( 'technology_software_firm_banner_section_title', '' );
$technology_software_firm_banner_section_description = get_theme_mod( 'technology_software_firm_banner_section_description', '' );
$technology_software_firm_button_label             = get_theme_mod( 'technology_software_firm_banner_button_label_', '' );
$technology_software_firm_button_link              = get_theme_mod( 'technology_software_firm_banner_button_link_', '' );
$technology_software_firm_secondary_button_label   = get_theme_mod( 'technology_software_firm_banner_secondary_button_label', '' );
$technology_software_firm_secondary_button_link    = get_theme_mod( 'technology_software_firm_banner_secondary_button_link', '' );

$technology_software_firm_default_main_image_url = get_template_directory_uri() . '/resource/img/default1.png';
$technology_software_firm_banner_section_image   = get_theme_mod( 'technology_software_firm_banner_section_image', $technology_software_firm_default_main_image_url );

$technology_software_firm_banner_image_alt = '';
$technology_software_firm_banner_image_id  = attachment_url_to_postid( $technology_software_firm_banner_section_image );

if ( $technology_software_firm_banner_image_id ) {
	$technology_software_firm_banner_image_alt = get_post_meta( $technology_software_firm_banner_image_id, '_wp_attachment_image_alt', true );
}

if ( empty( $technology_software_firm_banner_image_alt ) ) {
	$technology_software_firm_banner_image_alt = $technology_software_firm_banner_section_title;
}

$technology_software_firm_primary_button_href   = ! empty( $technology_software_firm_button_link ) ? $technology_software_firm_button_link : '#';
$technology_software_firm_secondary_button_href = ! empty( $technology_software_firm_secondary_button_link ) ? $technology_software_firm_secondary_button_link : '#';
?>
<section id="technology_software_firm_banner_section" class="sale-banner sale-banner--modern">
	<div class="sale-banner__container">
		<div class="sale-banner__inner">
			<div class="sale-banner__content">
				<?php if ( ! empty( $technology_software_firm_banner_section_title ) ) : ?>
					<h1 class="sale-banner__title"><?php echo esc_html( $technology_software_firm_banner_section_title ); ?></h1>
				<?php endif; ?>

				<?php if ( ! empty( $technology_software_firm_banner_section_description ) ) : ?>
					<p class="sale-banner__description"><?php echo esc_html( $technology_software_firm_banner_section_description ); ?></p>
				<?php endif; ?>

				<?php if ( ! empty( $technology_software_firm_button_label ) || ! empty( $technology_software_firm_secondary_button_label ) ) : ?>
					<div class="sale-banner__actions">
						<?php if ( ! empty( $technology_software_firm_button_label ) ) : ?>
							<?php if ( empty( $technology_software_firm_button_link ) ) : ?>
								<a href="<?php echo esc_url( $technology_software_firm_primary_button_href ); ?>" class="sale-banner__button sale-banner__button--primary is-disabled" aria-disabled="true">
									<?php echo esc_html( $technology_software_firm_button_label ); ?>
								</a>
							<?php else : ?>
								<a href="<?php echo esc_url( $technology_software_firm_primary_button_href ); ?>" class="sale-banner__button sale-banner__button--primary">
									<?php echo esc_html( $technology_software_firm_button_label ); ?>
								</a>
							<?php endif; ?>
						<?php endif; ?>

						<?php if ( ! empty( $technology_software_firm_secondary_button_label ) ) : ?>
							<?php if ( empty( $technology_software_firm_secondary_button_link ) ) : ?>
								<a href="<?php echo esc_url( $technology_software_firm_secondary_button_href ); ?>" class="sale-banner__button sale-banner__button--secondary is-disabled" aria-disabled="true">
									<?php echo esc_html( $technology_software_firm_secondary_button_label ); ?>
								</a>
							<?php else : ?>
								<a href="<?php echo esc_url( $technology_software_firm_secondary_button_href ); ?>" class="sale-banner__button sale-banner__button--secondary">
									<?php echo esc_html( $technology_software_firm_secondary_button_label ); ?>
								</a>
							<?php endif; ?>
						<?php endif; ?>
					</div>
				<?php endif; ?>
			</div>

			<div class="sale-banner__media">
				<div class="sale-banner__media-frame">
					<div class="sale-banner__media-image">
						<?php if ( $technology_software_firm_banner_image_id ) : ?>
							<?php
							echo wp_get_attachment_image(
								$technology_software_firm_banner_image_id,
								'full',
								false,
								array(
									'class'         => 'sale-banner__model-image',
									'alt'           => esc_attr( $technology_software_firm_banner_image_alt ),
									'loading'       => 'eager',
									'decoding'      => 'async',
									'fetchpriority' => 'high',
								)
							);
							?>
						<?php else : ?>
							<img class="sale-banner__model-image" src="<?php echo esc_url( $technology_software_firm_banner_section_image ); ?>" alt="<?php echo esc_attr( $technology_software_firm_banner_image_alt ); ?>" loading="eager" decoding="async" fetchpriority="high">
						<?php endif; ?>
					</div>
					<span class="sale-banner__accent-block" aria-hidden="true"></span>
				</div>
			</div>
		</div>
	</div>
</section>
