get_search_query

The timeline below displays how wordpress function get_search_query has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.5

/**
 * Retrieves the contents of the search WordPress query variable.
 *
 * The search query string is passed through esc_attr() to ensure that it is safe
 * for placing in an HTML attribute.
 *
 * @since 2.3.0
 *
 * @param bool $escaped Whether the result is escaped. Default true.
 *                      Only use when you are later escaping it. Do not use unescaped.
 * @return string
 */
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;
}

WordPress Version: 5.1

/**
 * Retrieves the contents of the search WordPress query variable.
 *
 * The search query string is passed through esc_attr() to ensure that it is safe
 * for placing in an html attribute.
 *
 * @since 2.3.0
 *
 * @param bool $escaped Whether the result is escaped. Default true.
 *                      Only use when you are later escaping it. Do not use unescaped.
 * @return string
 */
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;
}

WordPress Version: 4.6

/**
 * Retrieves the contents of the search WordPress query variable.
 *
 * The search query string is passed through esc_attr() to ensure that it is safe
 * for placing in an html attribute.
 *
 * @since 2.3.0
 *
 * @param bool $escaped Whether the result is escaped. Default true.
 * 	                    Only use when you are later escaping it. Do not use unescaped.
 * @return string
 */
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;
}

WordPress Version: 4.3

/**
 * Retrieve the contents of the search WordPress query variable.
 *
 * The search query string is passed through {@link esc_attr()}
 * to ensure that it is safe for placing in an html attribute.
 *
 * @since 2.3.0
 *
 * @param bool $escaped Whether the result is escaped. Default true.
 * 	                    Only use when you are later escaping it. Do not use unescaped.
 * @return string
 */
function get_search_query($escaped = true)
{
    /**
     * Filter 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;
}

WordPress Version: 4.1

/**
 * Retrieve the contents of the search WordPress query variable.
 *
 * The search query string is passed through {@link esc_attr()}
 * to ensure that it is safe for placing in an html attribute.
 *
 * @since 2.3.0
 *
 * @param bool $escaped Whether the result is escaped. Default true.
 * 	Only use when you are later escaping it. Do not use unescaped.
 * @return string
 */
function get_search_query($escaped = true)
{
    /**
     * Filter 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;
}

WordPress Version: 3.9

/**
 * Retrieve the contents of the search WordPress query variable.
 *
 * The search query string is passed through {@link esc_attr()}
 * to ensure that it is safe for placing in an html attribute.
 *
 * @since 2.3.0
 * @uses esc_attr()
 *
 * @param bool $escaped Whether the result is escaped. Default true.
 * 	Only use when you are later escaping it. Do not use unescaped.
 * @return string
 */
function get_search_query($escaped = true)
{
    /**
     * Filter 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;
}

WordPress Version: 3.7

/**
 * Retrieve the contents of the search WordPress query variable.
 *
 * The search query string is passed through {@link esc_attr()}
 * to ensure that it is safe for placing in an html attribute.
 *
 * @since 2.3.0
 * @uses esc_attr()
 *
 * @param bool $escaped Whether the result is escaped. Default true.
 * 	Only use when you are later escaping it. Do not use unescaped.
 * @return string
 */
function get_search_query($escaped = true)
{
    $query = apply_filters('get_search_query', get_query_var('s'));
    if ($escaped) {
        $query = esc_attr($query);
    }
    return $query;
}