render_block_core_search( array $attributes ): string
- Since
- 6.3.0
- Source
wp-includes/blocks/search.php:17
core/search block.Compatibility
- WordPress
- since 6.3.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$attributesarray- The block attributes.
Return value
string- The search block markup.
Performance profile
How much work a call to render_block_core_search() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 148–269
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 388.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()one call below render_block_core_search()
Further down the call graph this can also reach option, cache, serialize, query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 28 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost render_block_core_search() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$value && !->next_tag() && empty($typography_classes) && $button_position !== "button-only" | 148–156 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), esc_attr(), class(), home_url(), esc_url(), sprintf() |
$value && !->next_tag() && empty($typography_classes) && $button_position !== "button-only" && $tag_name !== "search" && $tag_name === "" | 155–161 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), esc_attr(), class(), current_theme_supports(), home_url(), esc_url(), sprintf() |
$value && !->next_tag() && empty($typography_classes) && $button_position === "button-only" | 167–175 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), esc_attr(), class(), __(), __(), isSearchInputVisible(), home_url(), esc_url(), sprintf() |
$value && !->next_tag() && empty($typography_classes) && $button_position === "button-only" && $tag_name !== "search" && $tag_name === "" | 174–180 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), esc_attr(), class(), __(), __(), isSearchInputVisible(), current_theme_supports(), home_url(), esc_url(), sprintf() |
$value && !->next_tag() && empty($typography_classes) && $button_position !== "button-only" | 176–191 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_theme_get_element_class_name(), ->next_tag(), esc_attr(), class(), home_url(), esc_url(), sprintf() |
$value && !->next_tag() && empty($typography_classes) && $button_position !== "button-only" && $tag_name !== "search" && $tag_name === "" | 183–196 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_theme_get_element_class_name(), ->next_tag(), esc_attr(), class(), current_theme_supports(), home_url(), esc_url(), sprintf() |
$value && !->next_tag() && empty($typography_classes) && empty($color_classes) && $button_position !== "button-only" | 183–197 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_kses_post(), wp_theme_get_element_class_name(), ->next_tag(), esc_attr(), class(), home_url(), esc_url(), sprintf() |
$value && !->next_tag() && empty($typography_classes) && empty($color_classes) && $button_position !== "button-only" && $tag_name !== "search" && $tag_name === "" | 190–202 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_kses_post(), wp_theme_get_element_class_name(), ->next_tag(), esc_attr(), class(), current_theme_supports(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position !== "button-only" | 192–207 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), wp_strip_all_tags(), ->set_attribute(), esc_attr(), class(), home_url(), esc_url(), sprintf() |
$value && !->next_tag() && empty($typography_classes) && $button_position === "button-only" | 195–210 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_theme_get_element_class_name(), ->next_tag(), esc_attr(), class(), __(), __(), isSearchInputVisible(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position !== "button-only" && $tag_name !== "search" && $tag_name === "" | 199–212 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), wp_strip_all_tags(), ->set_attribute(), esc_attr(), class(), current_theme_supports(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position !== "button-only" | 199–213 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_kses_post(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), wp_strip_all_tags(), ->set_attribute(), esc_attr(), class(), home_url(), esc_url(), sprintf() |
16 further outcomes, up to 269 instructions
$value && !->next_tag() && empty($typography_classes) && $button_position === "button-only" && $tag_name !== "search" && $tag_name === "" | 202–215 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_theme_get_element_class_name(), ->next_tag(), esc_attr(), class(), __(), __(), isSearchInputVisible(), current_theme_supports(), home_url(), esc_url(), sprintf() |
$value && !->next_tag() && empty($typography_classes) && empty($color_classes) && $button_position === "button-only" | 202–216 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_kses_post(), wp_theme_get_element_class_name(), ->next_tag(), esc_attr(), class(), __(), __(), isSearchInputVisible(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position !== "button-only" && $tag_name !== "search" && $tag_name === "" | 206–218 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_kses_post(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), wp_strip_all_tags(), ->set_attribute(), esc_attr(), class(), current_theme_supports(), home_url(), esc_url(), sprintf() |
$value && !->next_tag() && empty($typography_classes) && empty($color_classes) && $button_position === "button-only" && $tag_name !== "search" && $tag_name === "" | 209–221 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_kses_post(), wp_theme_get_element_class_name(), ->next_tag(), esc_attr(), class(), __(), __(), isSearchInputVisible(), current_theme_supports(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position === "button-only" | 211–226 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), wp_strip_all_tags(), ->set_attribute(), esc_attr(), class(), __(), __(), isSearchInputVisible(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position === "button-only" && $tag_name !== "search" && $tag_name === "" | 218–231 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), wp_strip_all_tags(), ->set_attribute(), esc_attr(), class(), __(), __(), isSearchInputVisible(), current_theme_supports(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position === "button-only" | 218–232 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_kses_post(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), wp_strip_all_tags(), ->set_attribute(), esc_attr(), class(), __(), __(), isSearchInputVisible(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position !== "button-only" | 224–239 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), __(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), esc_attr(), class(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position === "button-only" && $tag_name !== "search" && $tag_name === "" | 225–237 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_kses_post(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), wp_strip_all_tags(), ->set_attribute(), esc_attr(), class(), __(), __(), isSearchInputVisible(), current_theme_supports(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position !== "button-only" && $tag_name !== "search" && $tag_name === "" | 231–244 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), __(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), esc_attr(), class(), current_theme_supports(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position !== "button-only" | 231–245 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_kses_post(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), __(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), esc_attr(), class(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position !== "button-only" && $tag_name !== "search" && $tag_name === "" | 238–250 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_kses_post(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), __(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), esc_attr(), class(), current_theme_supports(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position === "button-only" | 243–258 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), __(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), esc_attr(), class(), __(), __(), isSearchInputVisible(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position === "button-only" && $tag_name !== "search" && $tag_name === "" | 250–263 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), __(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), esc_attr(), class(), __(), __(), isSearchInputVisible(), current_theme_supports(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position === "button-only" | 250–264 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_kses_post(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), __(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), esc_attr(), class(), __(), __(), isSearchInputVisible(), home_url(), esc_url(), sprintf() |
$value && empty($typography_classes) && empty($color_classes) && $button_position === "button-only" && $tag_name !== "search" && $tag_name === "" | 257–269 | __(), __(), label(), wp_unique_id(), classnames_for_block_core_search(), styles_for_block_core_search(), get_color_classes_for_block_core_search(), get_typography_classes_for_block_core_search(), get_border_color_classes_for_block_core_search(), wp_kses_post(), sprintf(), wp_parse_args(), ->next_tag(), ->next_tag(), wp_kses_post(), wp_theme_get_element_class_name(), ->next_tag(), ->add_class(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), __(), ->set_attribute(), ->set_attribute(), ->set_attribute(), ->set_attribute(), esc_attr(), class(), __(), __(), isSearchInputVisible(), current_theme_supports(), home_url(), esc_url(), sprintf() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 386 | 147–268 | 36 | 2 fewer instructions than PHP 8.5 |
| 8.5 | 388 | 148–269 | 36 | |
| 8.4 | 388 | 148–269 | 36 | 10 fewer instructions than PHP 8.3 |
| 8.3 | 398 | 152–276 | 36 | |
| 8.2 | 398 | 152–276 | 36 | |
| 8.1 | 398 | 152–276 | 36 | 2 fewer instructions than PHP 7.4 |
| 7.4 | 400 | 152–276 | 36 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 20
- wp_parse_args()Merges user defined arguments into defaults array.
- __()Retrieves the translation of $text.
- wp_unique_id()Gets unique ID.
- classnames_for_block_core_search()Builds the correct top level classnames for the 'core/search' block.
- styles_for_block_core_search()Builds an array of inline styles for the search block.
- get_color_classes_for_block_core_search()Returns color classnames depending on whether there are named or custom text and background colors.
- get_typography_classes_for_block_core_search()Returns typography classnames depending on whether there are named font sizes/families.
- get_border_color_classes_for_block_core_search()Returns border color classnames depending on whether there are named or custom border colors.
- wp_kses_post()Sanitizes content for allowed HTML tags for post content.
- get_search_query()Retrieves the contents of the search WordPress query variable.
- wp_enqueue_script_module()Marks the script module to be enqueued in the page.
- esc_attr()Escaping for HTML attributes.
Show all 20
- wp_theme_get_element_class_name()Given an element name, returns a class name.
- wp_strip_all_tags()Properly strips all HTML tags including 'script' and 'style'.
- get_block_wrapper_attributes()Generates a string of attributes by applying to the current block being rendered all of the features that the block supports.
- wp_interactivity_data_wp_context()Generates a `data-wp-context` directive attribute by encoding a context array.
- current_theme_supports()Checks a theme's support for a given feature.
- esc_url()Checks and cleans a URL.
- home_url()Retrieves the URL for the current site where the front end is accessible.
- WP_HTML_Tag_Processor::__construct()Constructor.
Source code
function render_block_core_search( $attributes ) { // Older versions of the Search block defaulted the label and buttonText // attributes to `__( 'Search' )` meaning that many posts contain `<!-- // wp:search /-->`. Support these by defaulting an undefined label and // buttonText to `__( 'Search' )`. $attributes = wp_parse_args( $attributes, array( 'label' => __( 'Search' ), 'buttonText' => __( 'Search' ), ) ); $input_id = wp_unique_id( 'wp-block-search__input-' ); $classnames = classnames_for_block_core_search( $attributes ); $show_label = ! empty( $attributes['showLabel'] ); $use_icon_button = ! empty( $attributes['buttonUseIcon'] ); $show_button = ( ! empty( $attributes['buttonPosition'] ) && 'no-button' === $attributes['buttonPosition'] ) ? false : true; $button_position = $show_button ? $attributes['buttonPosition'] : null; $query_params = ( ! empty( $attributes['query'] ) ) ? $attributes['query'] : array(); $button = ''; $query_params_markup = ''; $inline_styles = styles_for_block_core_search( $attributes ); $color_classes = get_color_classes_for_block_core_search( $attributes ); $typography_classes = get_typography_classes_for_block_core_search( $attributes ); $is_button_inside = ! empty( $attributes['buttonPosition'] ) && 'button-inside' === $attributes['buttonPosition']; // Border color classes need to be applied to the elements that have a border color. $border_color_classes = get_border_color_classes_for_block_core_search( $attributes ); // This variable is a constant and its value is always false at this moment. // It is defined this way because some values depend on it, in case it changes in the future. $open_by_default = false; $label_inner_html = empty( $attributes['label'] ) ? __( 'Search' ) : wp_kses_post( $attributes['label'] ); $label = new WP_HTML_Tag_Processor( sprintf( '<label %1$s>%2$s</label>', $inline_styles['label'], $label_inner_html ) ); if ( $label->next_tag() ) { $label->set_attribute( 'for', $input_id ); $label->add_class( 'wp-block-search__label' ); if ( $show_label && ! empty( $attributes['label'] ) ) { if ( ! empty( $typography_classes ) ) { $label->add_class( $typography_classes ); } } else { $label->add_class( 'screen-reader-text' ); } } $input = new WP_HTML_Tag_Processor( sprintf( '<input type="search" name="s" required %s/>', $inline_styles['input'] ) ); $input_classes = array( 'wp-block-search__input' ); if ( ! $is_button_inside && ! empty( $border_color_classes ) ) { $input_classes[] = $border_color_classes; } if ( ! empty( $typography_classes ) ) { $input_classes[] = $typography_classes; } if ( ! $show_button && ! empty( $color_classes ) ) { $input_classes[] = $color_classes; } if ( $input->next_tag() ) { $input->add_class( implode( ' ', $input_classes ) ); $input->set_attribute( 'id', $input_id ); $input->set_attribute( 'value', get_search_query( false ) ); $input->set_attribute( 'placeholder', $attributes['placeholder'] ); // If it's interactive, enqueue the script module and add the directives. $is_expandable_searchfield = 'button-only' === $button_position; if ( $is_expandable_searchfield ) { wp_enqueue_script_module( '@wordpress/block-library/search/view' ); $input->set_attribute( 'data-wp-bind--aria-hidden', '!context.isSearchInputVisible' ); $input->set_attribute( 'data-wp-bind--tabindex', 'state.tabindex' ); // Adding these attributes manually is needed until the Interactivity API // SSR logic is added to core. $input->set_attribute( 'aria-hidden', 'true' ); $input->set_attribute( 'tabindex', '-1' ); } } if ( count( $query_params ) > 0 ) {Changelog
Introduced in 6.3.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/blocks/search.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.