<?php
/**
 * Template Part: Banner
 *
 * @package    Wira
 * @since      1.0.0
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$wira_banner_img_url = get_the_post_thumbnail_url( get_the_ID(), 'full' );
if ( ! $wira_banner_img_url ) {
	$wira_banner_img_url = get_template_directory_uri() . '/assets/img/laptop-desk-computer-macbook-writing-typing-1067984-pxhere.webp';
}

$wira_header_overlay_class = get_theme_mod( 'wira_enable_navbar_overlay', false ) ? ' theme-header-overlay' : '';
?>

<!-- Title Banner Main Wrapper -->
<div class="container-fluid theme-banner-section theme-bg-dark p-0" data-background="<?php echo esc_url( $wira_banner_img_url ); ?>">

	<!-- Title Banner Main Wrapper Overlay -->
	<div class="container-fluid theme-space-wider theme-banner-wrapper-overlay<?php echo esc_attr( $wira_header_overlay_class ); ?>">

		<!-- Title Banner Main Section -->
		<div class="container theme-title-center-wrap theme-color-white">

			<!-- Breadcrumb -->
			<?php if ( is_singular() ) : ?>
				<div class="mb-3">
					<div class="theme-breadcrumb p-0 d-flex justify-content-center align-items-center">
						<a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="theme-breadcrumb-link"><?php echo esc_html__( 'Home', 'wira' ); ?></a>
						<i class="fas fa-angle-right mx-2"></i>
						<span class="breadcrumb-title theme-accent-text theme-color-white-overlay breadcrumb-title--full">
							<?php echo esc_html( get_the_title() ); ?>
						</span>
						<span class="breadcrumb-title theme-accent-text theme-color-white-overlay breadcrumb-title--short">
							<?php echo esc_html( wp_trim_words( get_the_title(), 3, '…' ) ); ?>
						</span>
					</div>
				</div>
			<?php endif; ?>
			
			<!-- Title Wrapper Without Breadcrumb -->
			<div class="theme-wrapper">

				<!-- Singular -->
				<?php if ( is_singular() ) : ?>
					<h1 class="theme-very-big-title text-center theme-color-white">
						<?php echo esc_html( get_the_title() ); ?>
					</h1>
				
				<!-- Category -->
				<?php elseif ( is_category() ) : ?>
					<h1 class="theme-very-big-title text-center theme-color-white">
						<?php
						echo esc_html__( 'Category: ', 'wira' );
						echo esc_html( single_cat_title( '', false ) );
						?>
					</h1>
				
				<!-- Tag -->
				<?php elseif ( is_tag() ) : ?>
					<h1 class="theme-very-big-title text-center theme-color-white">
						<?php
						echo esc_html__( 'Tag: ', 'wira' );
						echo esc_html( single_tag_title( '', false ) );
						?>
					</h1>

				<!-- Author -->
				<?php elseif ( is_author() ) : ?>
					<h1 class="theme-very-big-title text-center theme-color-white">
						<?php
						echo esc_html__( 'Author: ', 'wira' );
						echo esc_html( get_the_author() );
						?>
					</h1>
				
				<!-- Day -->
				<?php elseif ( is_day() ) : ?>
					<h1 class="theme-very-big-title text-center theme-color-white">
						<?php
						echo esc_html__( 'Archive: ', 'wira' );
						echo esc_html( get_the_date() );
						?>
					</h1>
				
				<!-- Month -->
				<?php elseif ( is_month() ) : ?>
					<h1 class="theme-very-big-title text-center theme-color-white">
						<?php
						echo esc_html__( 'Archive: ', 'wira' );
						echo esc_html( get_the_date( 'F Y' ) );
						?>
					</h1>
				
				<!-- Year -->
				<?php elseif ( is_year() ) : ?>
					<h1 class="theme-very-big-title text-center theme-color-white">
						<?php
						echo esc_html__( 'Archive: ', 'wira' );
						echo esc_html( get_the_date( 'Y' ) );
						?>
					</h1>
				
				<!-- Archive -->
				<?php elseif ( is_post_type_archive() ) : ?>
					<h1 class="theme-very-big-title text-center theme-color-white"><?php echo esc_html( post_type_archive_title( '', false ) ); ?></h1>
				
				<!-- Search -->
				<?php elseif ( is_search() ) : ?>
					<h1 class="theme-very-big-title text-center theme-color-white">
						<?php
						echo esc_html__( 'Search results for: ', 'wira' );
						echo esc_html( get_search_query() );
						?>
					</h1>
				
				<!-- 404 Not Found -->
				<?php elseif ( is_404() ) : ?>
					<div class="theme-space-wide">
						<h1 class="theme-not-found-text text-center theme-color-primary">
							<?php echo esc_html( get_theme_mod( 'wira_notfound_code_text', '404' ) ); ?>
						</h1>
						<h2 class="theme-color-white text-center">
							<?php echo esc_html( get_theme_mod( 'wira_notfound_heading_text', 'Page Not Found' ) ); ?>
						</h2>
						<p class="theme-color-white-overlay text-center">
							<?php echo wp_kses_post( get_theme_mod( 'wira_notfound_wrong_text', 'Oops... Something went wrong, please go back.' ) ); ?>
						</p>
						<div class="d-flex justify-content-center mt-3">
							<a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="theme-btn theme-btn-one">
								<div class="text-btn-wrapper"><span><?php echo esc_html( get_theme_mod( 'wira_goback_text', 'Back to Home' ) ); ?></span><span><?php echo esc_html( get_theme_mod( 'wira_goback_text', 'Back to Home' ) ); ?></span></div>
							</a>
						</div>
					</div>
				
				<!-- Blog Home -->
				<?php elseif ( is_home() ) : ?>
					<h1 class="theme-blog-home theme-very-big-title text-center theme-color-white">
						<?php echo esc_html( get_theme_mod( 'wira_blog_home_heading', 'Blog Home' ) ); ?>
					</h1>
				
				<!-- Else -->
				<?php else : ?>
					<h1 class="theme-very-big-title text-center theme-color-white"><?php echo esc_html__( 'Archives', 'wira' ); ?></h1>
				<?php endif; ?>
			</div>
		</div> <!-- Title Banner Main Section /End -->
	</div> <!-- Title Banner Main Wrapper Overlay /End -->
</div> <!-- Title Banner Main Wrapper /End -->
