<?php
/* Template Name: Search shortcode */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<?php if ( $search_type === 'normal' ) : ?>
	<form class="prodigy-search prodigy-custom-template" role="search">
		<label for="search-input" class="prodigy-visually-hidden"><?php esc_attr_e( 'Search', 'prodigy-commerce' ); ?></label>
		<input id="search-input" class="prodigy-main-input prodigy-search__input prodigy-search__input-js"
				placeholder="<?php echo esc_attr( $placeholder ); ?>" type="text">
		<button aria-label="<?php esc_attr_e( 'Search', 'prodigy-commerce' ); ?>" class="prodigy-search__icon prodigy-search__icon-widget-js" 
				type="submit">
			<?php if ( $icon_type === 'icon' ) : ?>
				<?php if ( $icon_class !== '' ) : ?>
					<i class="<?php echo esc_attr( $icon_class ); ?>" aria-hidden="true" role="presentation"></i>
				<?php endif; ?>
			<?php elseif ( $icon_type === 'svg' ) : ?>
				<img class="icon-img" src="<?php echo esc_url( $settings['prg_style_search_icon']['value']['url'] ); ?>"
					alt="<?php esc_attr_e( 'Search icon', 'prodigy-commerce' ); ?>">
			<?php endif; ?>
		</button>
		<button aria-label="<?php echo esc_attr( 'Clear search', 'prodigy-commerce' ); ?>" class="prodigy-search__close-icon d-none" type="button"></button>
	</form>
<?php elseif ( $search_type === 'button' ) : ?>
	<!-- Search widget shortcode for search widget as icon -->
	<?php if ( $is_elementor_header ) : ?>
		<div class="prodigy-navbar__custom-search">
	<?php else : ?>
		<li class="prodigy-navbar__custom-search">
	<?php endif; ?>
		<button type="button" aria-label="<?php esc_attr_e( 'Open search dropdown', 'prodigy-commerce' ); ?>" class="prodigy-custom-template prodigy-search__custom-dropdown prodigy-search"
				aria-expanded="false"
				aria-controls="prodigy-search-form" >
			<div class="prodigy-search__custom-dropdown-wrap prodigy-search__custom-search">
				<?php if ( $icon_type === 'icon' ) : ?>
					<?php if ( $icon_class !== '' ) : ?>
						<i class="<?php echo esc_attr( $icon_class ); ?>" aria-hidden="true" role="presentation"></i>
					<?php endif; ?>
				<?php elseif ( $icon_type === 'svg' ) : ?>
					<img class="icon-img" src="<?php echo esc_url( $settings['prg_style_search_icon']['value']['url'] ); ?>" 
						alt="<?php esc_attr_e( 'Search icon', 'prodigy-commerce' ); ?>">
				<?php endif; ?>
				<span class="prodigy-search__custom-title"><?php echo esc_html( $placeholder ); ?></span>
			</div>
		</button>
		<form class="prodigy-search prodigy-custom-template"
				id="prodigy-search-form"
				role="search"
				aria-hidden="true">
			<div class="prodigy-search__custom-dropdown-block-search">
				<div class="position-relative prodigy-search__custom-dropdown-block-search-wrap">
					<label for="navbar-search-input" class="prodigy-visually-hidden"><?php esc_attr_e( 'Search', 'prodigy-commerce' ); ?></label>
					<input id="navbar-search-input" class="prodigy-main-input prodigy-search__input prodigy-search__input-js"
						placeholder="<?php echo esc_attr( $placeholder ); ?>" type="text">
					<button aria-label="<?php esc_attr_e( 'Search', 'prodigy-commerce' ); ?>" class="prodigy-search__icon prodigy-search__icon-widget-js" type="submit">
						<?php if ( $icon_type === 'icon' ) : ?>
							<?php if ( $icon_class !== '' ) : ?>
								<i class="<?php echo esc_attr( $icon_class ); ?>" aria-hidden="true" role="presentation"></i>
							<?php endif; ?>
						<?php elseif ( $icon_type === 'svg' ) : ?>
							<img class="icon-img" src="<?php echo esc_url( $settings['prg_style_search_icon']['value']['url'] ); ?>"
								alt="<?php esc_attr_e( 'Search icon', 'prodigy-commerce' ); ?>">
						<?php endif; ?>
					</button>
					<button aria-label="Clear Search" class="prodigy-search__close-icon d-none" type="button" aria-label="<?php echo esc_attr( 'Clear search and close', 'prodigy-commerce' ); ?>"></button>
				</div>
			</div>
		</form>
		<?php if ( $is_elementor_header ) : ?>
			</div>
		<?php else : ?>
			</li>
		<?php endif; ?>
<?php endif; ?>
