Twenty Twenty: Correct label attribute references to aria_label in get_search_form.

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.

git-svn-id: https://develop.svn.wordpress.org/trunk@50933 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
David Baumwald 2021-05-19 18:38:53 +00:00
parent 9d0cf7b4b1
commit d52fa9312c
4 changed files with 8 additions and 4 deletions

View File

@ -21,7 +21,7 @@ get_header();
<?php
get_search_form(
array(
'label' => __( '404 not found', 'twentytwenty' ),
'aria_label' => __( '404 not found', 'twentytwenty' ),
)
);
?>

View File

@ -98,7 +98,7 @@ get_header();
<?php
get_search_form(
array(
'label' => __( 'search again', 'twentytwenty' ),
'aria_label' => __( 'search again', 'twentytwenty' ),
)
);
?>

View File

@ -17,7 +17,11 @@
*/
$twentytwenty_unique_id = twentytwenty_unique_id( 'search-form-' );
$twentytwenty_aria_label = ! empty( $args['label'] ) ? 'aria-label="' . esc_attr( $args['label'] ) . '"' : '';
$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 ); ?>">

View File

@ -17,7 +17,7 @@
<?php
get_search_form(
array(
'label' => __( 'Search for:', 'twentytwenty' ),
'aria_label' => __( 'Search for:', 'twentytwenty' ),
)
);
?>