<?php

/**
 * Template part for displaying front page introduction.
 *
 * @package Nice Blog
 */

// Banner Section.
$banner_section = get_theme_mod( 'nice_blog_banner_section_enable', false );

if ( false === $banner_section ) {
	return;
}

$banner_bg_image = get_theme_mod( 'nice_blog_banner_bg_image', '' );
$banner_title    = get_theme_mod( 'nice_blog_banner_title', __( 'Welcome to a world where curiosity is sparked with every line.', 'nice-blog' ) );
$meta_title      = get_theme_mod( 'nice_blog_banner_featured_meta_title', __( '#Categories:', 'nice-blog' ) );
?>

<div id="nice_blog_banner_section" class="frontpage banner-section banner-style-2 banner-search-section" style="background-image: url('<?php echo esc_url( $banner_bg_image ); ?>');">
	<div class="theme-wrapper">
		<div class="banner-search-wrapper">
			<div class="banner-search-inside">
				<?php if ( ! empty( $banner_title ) ) : ?>
					<h3 class="banner-title">
						<?php echo esc_html( $banner_title ); ?>
					</h3>
				<?php endif; ?>
				<div class="search-wrap">
					<?php get_search_form(); ?>
				</div>
				<div class="banner-tags-wrapper">
					<strong><?php echo esc_html( $meta_title ); ?></strong>
					<?php
					$featured_meta = get_categories(
						array( 'number' => absint( 15 ) )
					);

					if ( $featured_meta ) {
						foreach ( $featured_meta as $featured_tag ) {
							?>
							<a href="<?php echo esc_url( get_tag_link( $featured_tag->term_id ) ); ?>">
								<?php echo esc_html( $featured_tag->name ); ?>
								<span><?php echo absint( $featured_tag->count ); ?></span>
							</a>
							<?php
						}
					}
					?>
				</div>
			</div>
		</div>
	</div>
</div>
