From 410b5c0093eb4a4f744ab8a1f254a11f487cd855 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Thu, 19 May 2022 09:56:22 +0400 Subject: [PATCH] Search: Avoid double escaping (#41147) * Search: Avoid double escaping * Use wp_unique_id --- packages/block-library/src/search/index.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/search/index.php b/packages/block-library/src/search/index.php index 7b33ebc9c78cd..d0f3a54feca35 100644 --- a/packages/block-library/src/search/index.php +++ b/packages/block-library/src/search/index.php @@ -13,8 +13,6 @@ * @return string The search block markup. */ function render_block_core_search( $attributes ) { - static $instance_id = 0; - // Older versions of the Search block defaulted the label and buttonText // attributes to `__( 'Search' )` meaning that many posts contain ``. Support these by defaulting an undefined label and @@ -27,7 +25,7 @@ function render_block_core_search( $attributes ) { ) ); - $input_id = 'wp-block-search__input-' . ++$instance_id; + $input_id = wp_unique_id( 'wp-block-search__input-' ); $classnames = classnames_for_block_core_search( $attributes ); $show_label = ( ! empty( $attributes['showLabel'] ) ) ? true : false; $use_icon_button = ( ! empty( $attributes['buttonUseIcon'] ) ) ? true : false; @@ -65,7 +63,7 @@ function render_block_core_search( $attributes ) { '', $input_id, esc_attr( $input_classes ), - esc_attr( get_search_query() ), + get_search_query(), esc_attr( $attributes['placeholder'] ), $inline_styles['input'] );