searchform.php 1.4 KB

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * The searchform.php template.
  4. *
  5. * Used any time that get_search_form() is called.
  6. *
  7. * @link https://developer.wordpress.org/reference/functions/wp_unique_id/
  8. * @link https://developer.wordpress.org/reference/functions/get_search_form/
  9. *
  10. * @package WordPress
  11. * @subpackage Twenty_Twenty_One
  12. * @since Twenty Twenty-One 1.0
  13. */
  14. /*
  15. * Generate a unique ID for each form and a string containing an aria-label
  16. * if one was passed to get_search_form() in the args array.
  17. */
  18. $twentytwentyone_unique_id = wp_unique_id( 'search-form-' );
  19. $twentytwentyone_aria_label = ! empty( $args['aria_label'] ) ? 'aria-label="' . esc_attr( $args['aria_label'] ) . '"' : '';
  20. ?>
  21. <form role="search" <?php echo $twentytwentyone_aria_label; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped above. ?> method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
  22. <label for="<?php echo esc_attr( $twentytwentyone_unique_id ); ?>"><?php _e( 'Search&hellip;', 'twentytwentyone' ); // phpcs:ignore: WordPress.Security.EscapeOutput.UnsafePrintingFunction -- core trusts translations ?></label>
  23. <input type="search" id="<?php echo esc_attr( $twentytwentyone_unique_id ); ?>" class="search-field" value="<?php echo get_search_query(); ?>" name="s" />
  24. <input type="submit" class="search-submit" value="<?php echo esc_attr_x( 'Search', 'submit button', 'twentytwentyone' ); ?>" />
  25. </form>