[wp-trac] [WordPress Trac] #19248: menu_page_url() should return unencoded URL, and echo encoded URL

WordPress Trac wp-trac at lists.automattic.com
Wed Nov 16 08:39:43 UTC 2011


#19248: menu_page_url() should return unencoded URL, and echo encoded URL
--------------------------+----------------------
 Reporter:  nathanrice    |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Plugins       |     Version:  3.0
 Severity:  normal        |  Resolution:  invalid
 Keywords:  has-patch     |
--------------------------+----------------------
Changes (by westi):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 Replying to [comment:3 nathanrice]:
 > Replying to [comment:2 westi]:
 > > Can you not get the url for the settings menu by using the result of
 add_settings_page(...) as the slug you pass to menu_page_url to solve your
 usecase ?
 >
 > I could, but that doesn't solve the issue. `menu_page_url()` returns an
 escaped URL. `add_query_arg()` barfs when you pass it an escaped URL. So,
 either we're OK with these two functions NOT being able to work together,
 or we need to find a way to fix it. As it stands, you cannot take the
 result of `menu_page_url()` and pass it to `add_query_arg()`.

 I'm happy with these two functions not working together.

 {{{menu_page_url()}}} was just meant to be a simple helper to stop you
 having to build urls to registered admin menus manually and it serves this
 purpose extremely well.

 Whether or not returning an escaped url is the ''right'' thing it is what
 we have now, what plugins are using and works for the normal use case of
 the function which is getting back a url to echo yourself rather than
 having it printed straight away.

 Closing as invalid as I don't see this as a bug.

 If we were to change anything it would be simplest to have this function
 take an array of extra arguments to add to the query string for you - but
 I don't think that is required.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19248#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list