WP_Plugins_List_Table::search_box() WordPress Method
The WP_Plugins_List_Table::search_box() method is used to display a search box for plugins. It takes two arguments: the text to display in the search box and the URL to which the search form will be submitted. This method is used to display a search box for plugins. You can specify the text to display in the search box and the URL to which the search form will be submitted. This is a useful way to allow users to search for plugins.
WP_Plugins_List_Table::search_box( string $text, string $input_id ) #
Displays the search box.
Parameters
- $text
(string)(Required)The 'submit' button label.
- $input_id
(string)(Required)ID attribute value for the search input field.
Source
File: wp-admin/includes/class-wp-plugins-list-table.php
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 class="screen-reader-text" 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(); ?>" placeholder="<?php esc_attr_e( 'Search installed plugins...' ); ?>" />
<?php submit_button( $text, 'hide-if-js', '', false, array( 'id' => 'search-submit' ) ); ?>
</p>
<?php
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 4.6.0 | Introduced. |