<?php
/**
 * The template for the search form.
 *
 * @package Sunset
 */

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

// Build a string containing an aria-label to use for the search form.
if ( $args['aria_label'] ) {
	$sunset_aria_label = 'aria-label="' . esc_attr( $args['aria_label'] ) . '" ';
} else {
	/*
	* If there's no custom aria-label, we can set a default here. At the
	* moment it's empty as there's uncertainty about what the default should be.
	*/
	$sunset_aria_label = '';
}
?>

<form role="search" <?php echo $sunset_aria_label; ?> method="get" class="search-form" action="<?php echo esc_url(home_url( '/' )); ?>">
	<label>
		<span class="screen-reader-text"><?php echo _x( 'Search for:', 'label', 'my-sunset' ) ?></span>
		<input type="search" <?php echo $args['aria_label'] === 'header-search' ? 'tabindex="-1"' : ''; ?> required class="search-field" placeholder="<?php echo esc_attr_x( 'Search', 'placeholder', 'my-sunset' ) ?>" value="<?php echo get_search_query() ?>" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label', 'my-sunset' ) ?>" />
	</label>
	<button type="submit" <?php echo $args['aria_label'] === 'header-search' ? 'tabindex="-1"' : ''; ?> class="search-submit">
		<?php echo esc_attr_x( 'Search', 'button', 'my-sunset' ) ?>
		<?php echo sunset_get_svg_icon('search'); ?>
	</button>
</form>