get_search_query( bool $escaped = true )
Retrieves the contents of the search WordPress query variable.
Description Description
The search query string is passed through esc_attr() to ensure that it is safe for placing in an html attribute.
Parameters Parameters
- $escaped
-
(bool) (Optional) Whether the result is escaped. Only use when you are later escaping it. Do not use unescaped.
Default value: true
Return Return
(string)
Source Source
File: wp-includes/general-template.php
function get_search_query( $escaped = true ) {
/**
* Filters the contents of the search query variable.
*
* @since 2.3.0
*
* @param mixed $search Contents of the search query variable.
*/
$query = apply_filters( 'get_search_query', get_query_var( 's' ) );
if ( $escaped ) {
$query = esc_attr( $query );
}
return $query;
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 2.3.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Different usage methods