WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/26/2014 11:57:10 PM (6 years ago)
Author:
nacin
Message:

Add a $default argument to get_query_var() and WP_Query::get(). fixes #16471.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/query.php

    r27211 r27304  
    1919 * @uses $wp_query
    2020 *
    21  * @param string $var The variable key to retrieve.
     21 * @param string $var       The variable key to retrieve.
     22 * @param mixed  $default   Value to return if the query variable is not set. Default ''.
    2223 * @return mixed
    2324 */
    24 function get_query_var($var) {
     25function get_query_var( $var, $default = '' ) {
    2526    global $wp_query;
    2627
    27     return $wp_query->get($var);
     28    return $wp_query->get( $var, $default );
    2829}
    2930
     
    21312132     *
    21322133     * @param string $query_var Query variable key.
     2134     * @param mixed  $default   Value to return if the query variable is not set. Default ''.
    21332135     * @return mixed
    21342136     */
    2135     function get($query_var) {
    2136         if ( isset($this->query_vars[$query_var]) )
    2137             return $this->query_vars[$query_var];
    2138 
    2139         return '';
     2137    function get( $query_var, $default = '' ) {
     2138        if ( isset( $this->query_vars[ $query_var ] ) ) {
     2139            return $this->query_vars[ $query_var ];
     2140        }
     2141
     2142        return $default;
    21402143    }
    21412144
Note: See TracChangeset for help on using the changeset viewer.