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

Built from https://develop.svn.wordpress.org/trunk@27304


git-svn-id: http://core.svn.wordpress.org/trunk@27157 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2014-02-26 23:58:14 +00:00
parent edb9364df1
commit 1d06679518
1 changed files with 10 additions and 7 deletions

View File

@ -19,12 +19,13 @@
* @uses $wp_query * @uses $wp_query
* *
* @param string $var The variable key to retrieve. * @param string $var The variable key to retrieve.
* @param mixed $default Value to return if the query variable is not set. Default ''.
* @return mixed * @return mixed
*/ */
function get_query_var($var) { function get_query_var( $var, $default = '' ) {
global $wp_query; global $wp_query;
return $wp_query->get($var); return $wp_query->get( $var, $default );
} }
/** /**
@ -2130,13 +2131,15 @@ class WP_Query {
* @access public * @access public
* *
* @param string $query_var Query variable key. * @param string $query_var Query variable key.
* @param mixed $default Value to return if the query variable is not set. Default ''.
* @return mixed * @return mixed
*/ */
function get($query_var) { function get( $query_var, $default = '' ) {
if ( isset($this->query_vars[$query_var]) ) if ( isset( $this->query_vars[ $query_var ] ) ) {
return $this->query_vars[ $query_var ]; return $this->query_vars[ $query_var ];
}
return ''; return $default;
} }
/** /**