mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-09 20:30:43 +01:00
77cf4ea88d
In the bundled Twenty Twenty theme, a `label` argument was passed to `get_search_form` but used as the `aria_label` on the form. This change updates the argument name to `aria_label` and maintains backwards compatibility for usage of the original `label` argument. Props poena, sabernhardt, ipulc2, kishanjasani, mukesh27. Fixes #51877. Built from https://develop.svn.wordpress.org/trunk@50933 git-svn-id: http://core.svn.wordpress.org/trunk@50542 1a063a9b-81f0-0310-95a4-ce76da25c4cd
33 lines
1.7 KiB
PHP
33 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* The searchform.php template.
|
|
*
|
|
* Used any time that get_search_form() is called.
|
|
*
|
|
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
|
|
*
|
|
* @package WordPress
|
|
* @subpackage Twenty_Twenty
|
|
* @since Twenty Twenty 1.0
|
|
*/
|
|
|
|
/*
|
|
* Generate a unique ID for each form and a string containing an aria-label
|
|
* if one was passed to get_search_form() in the args array.
|
|
*/
|
|
$twentytwenty_unique_id = twentytwenty_unique_id( 'search-form-' );
|
|
|
|
$twentytwenty_aria_label = ! empty( $args['aria_label'] ) ? 'aria-label="' . esc_attr( $args['aria_label'] ) . '"' : '';
|
|
// Backward compatibility, in case a child theme template uses a `label` argument.
|
|
if ( empty( $twentytwenty_aria_label ) && ! empty( $args['label'] ) ) {
|
|
$twentytwenty_aria_label = 'aria-label="' . esc_attr( $args['label'] ) . '"';
|
|
}
|
|
?>
|
|
<form role="search" <?php echo $twentytwenty_aria_label; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped above. ?> method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
|
|
<label for="<?php echo esc_attr( $twentytwenty_unique_id ); ?>">
|
|
<span class="screen-reader-text"><?php _e( 'Search for:', 'twentytwenty' ); // phpcs:ignore: WordPress.Security.EscapeOutput.UnsafePrintingFunction -- core trusts translations ?></span>
|
|
<input type="search" id="<?php echo esc_attr( $twentytwenty_unique_id ); ?>" class="search-field" placeholder="<?php echo esc_attr_x( 'Search …', 'placeholder', 'twentytwenty' ); ?>" value="<?php echo get_search_query(); ?>" name="s" />
|
|
</label>
|
|
<input type="submit" class="search-submit" value="<?php echo esc_attr_x( 'Search', 'submit button', 'twentytwenty' ); ?>" />
|
|
</form>
|