[wp-trac] [WordPress Trac] #34699: New function: `get_query_arg()`

WordPress Trac noreply at wordpress.org
Sun Feb 5 12:38:47 UTC 2017


#34699: New function: `get_query_arg()`
-------------------------------------------------+-------------------------
 Reporter:  sebastian.pisula                     |       Owner:
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
Component:  General                              |  Review
 Severity:  normal                               |     Version:
 Keywords:  reporter-feedback has-patch needs-   |  Resolution:
  unit-tests 2nd-opinion                         |     Focuses:
-------------------------------------------------+-------------------------
Changes (by flixos90):

 * keywords:  close reporter-feedback needs-patch => reporter-feedback has-
     patch needs-unit-tests 2nd-opinion


Comment:

 IMO it makes sense to introduce this function. While it is not that
 complex to do it manually at this point, a function like that would still
 allow for cleaner code and it also makes sense to introduce this function
 for parity. We have `add_query_arg()` and `remove_query_arg()`, so one
 could easily assume there is also `get_query_arg()`.

 I provided a new patch, where `$key` is also supported to be an array, so
 it works in the same way like the other two functions. Open question: If
 `$key` is an array and one of its keys is not available as query argument,
 should the result array include the key with value `NULL` or should it
 just be left out? For `isset()` it wouldn't matter, but for
 `array_key_exists()` it would. Leaving it out would make the function code
 a bit simpler, but it would also mean there could be notices if a user
 simply tries to access a key that is not set.

 This function would still need to unit tests, in case the decision is to
 introduce it. I'll gladly provide those after we have it figured out.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34699#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list