[wp-trac] [WordPress Trac] #16471: Support default values for non-existant query vars in get_query_var() et al
WordPress Trac
wp-trac at lists.automattic.com
Sun Feb 6 15:54:19 UTC 2011
#16471: Support default values for non-existant query vars in get_query_var() et al
-------------------------+------------------------------
Reporter: hakre | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.0
Severity: normal | Resolution:
Keywords: has-patch |
-------------------------+------------------------------
Comment (by hakre):
The attached patch now allows easier checking if certain values have been
set (not being null in PHP):
{{{
$var_test = get_query_var('test', null);
if (!isset($var_test)) {
throw new BadMethodCallException ('Invalid request. Test parameter not
set.');
}
}}}
or making use of a predefined, default value more easily:
{{{
$days = get_query_var('days', 7);
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16471#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list