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

WordPress Trac wp-trac at lists.automattic.com
Tue Nov 15 14:48:54 UTC 2011


#19248: menu_page_url() should return unencoded URL, and echo encoded URL
--------------------------+-----------------------------
 Reporter:  nathanrice    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Plugins       |    Version:  3.2
 Severity:  normal        |   Keywords:  has-patch
--------------------------+-----------------------------
 See #18274

 `menu_page_url()` should use `esc_url_raw()` when returning, and use
 `esc_url` when echoing.

 Use case:
 Let's say you created a custom post type (with its own menu) called
 `restaurant`, and you want to put a settings submenu under the top level
 `restaurant` menu.

 {{{
 $menu = menu_page_url( 'restaurant-settings', 0 );
 // Unencoded http://example.com/wp-
 admin/edit.php?post_type=restaurant&page=restaurant-settings
 // Encoded http://example.com/wp-
 admin/edit.php?post_type=restaurant&page=restaurant-settings

 add_query_arg( 'reset', 'true', $menu );
 }}}

 If `$menu` is encoded, it can't be passed to `add_query_arg()`, see
 #18274.

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


More information about the wp-trac mailing list