WP_Plugins_List_Table::search_box( string $text, string $input_id )
- Since
- 4.6.0
- Source
wp-admin/includes/class-wp-plugins-list-table.php:441
Compatibility
- WordPress
- since 4.6.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
$textstring- The 'submit' button label.
$input_idstring- ID attribute value for the search input field.
Performance profile
How much work a call to WP_Plugins_List_Table::search_box() 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
- 9–59
- 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 60.
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 WP_Plugins_List_Table::search_box()
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 · 7 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Plugins_List_Table::search_box() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
empty($value) && !->has_items() | 9 | ->has_items() |
| always | 38 | esc_attr(), esc_attr(), _admin_search_query(), submit_button() |
empty($value) && ->has_items() | 41 | ->has_items(), esc_attr(), esc_attr(), _admin_search_query(), submit_button() |
| always | 47 | esc_attr(), esc_attr(), esc_attr(), _admin_search_query(), submit_button() |
->has_items() | 50 | ->has_items(), esc_attr(), esc_attr(), esc_attr(), _admin_search_query(), submit_button() |
!empty($value) | 56 | esc_attr(), esc_attr(), esc_attr(), esc_attr(), _admin_search_query(), submit_button() |
->has_items() | 59 | ->has_items(), esc_attr(), esc_attr(), esc_attr(), esc_attr(), _admin_search_query(), submit_button() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 60 | 9–59 | 4 | |
| 8.5 | 60 | 9–59 | 4 | |
| 8.4 | 60 | 9–59 | 4 | |
| 8.3 | 60 | 9–59 | 4 | |
| 8.2 | 60 | 9–59 | 4 | |
| 8.1 | 60 | 9–59 | 4 | 1 more instruction than PHP 7.4 |
| 7.4 | 59 | 9–58 | 4 |
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 · 4
- esc_attr()Escaping for HTML attributes.
- _admin_search_query()Displays the search query.
- submit_button()Echoes a submit button, with provided text and appropriate class(es).
- WP_Plugins_List_Table::has_items()
Source code
public function search_box( $text, $input_id ) { if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { return; } $input_id = $input_id . '-search-input'; if ( ! empty( $_REQUEST['orderby'] ) ) { echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; } if ( ! empty( $_REQUEST['order'] ) ) { echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; } ?> <p class="search-box"> <label for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?></label> <input type="search" id="<?php echo esc_attr( $input_id ); ?>" class="wp-filter-search" name="s" value="<?php _admin_search_query(); ?>" /> <?php submit_button( $text, 'hide-if-js', '', false, array( 'id' => 'search-submit' ) ); ?> </p> <?php }Changelog
Introduced in 4.6.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 6.9.7 tag, from
src/wp-admin/includes/class-wp-plugins-list-table.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.