[wp-trac] [WordPress Trac] #21454: Admin menu top label linked to sub pages screen id?

WordPress Trac wp-trac at lists.automattic.com
Thu Aug 2 23:06:29 UTC 2012


#21454: Admin menu top label linked to sub pages screen id?
-------------------------------+------------------------------
 Reporter:  CoenJacobs         |       Owner:
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Administration     |     Version:
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |
-------------------------------+------------------------------

Comment (by CoenJacobs):

 Replying to [comment:1 scribu]:
 > Notice the $menu_slug parameter. You're probably generating it
 automatically from $page_title.

 No, I'm not referring to the `$menu_slug` parameter, but the id of the
 sublevel page. This id seems to be generated from the top level menu title
 and thus will it change when you translate that.  Example:

 {{{
 add_action( 'admin_menu', 'example_menu' );

 function example_menu() {
         add_menu_page( 'Toplevel title', 'Toplevel nav', 'manage_options',
 'toplevel_slug', 'example_toplevel_page' );
         add_submenu_page( 'toplevel_slug', 'Sublevel title', 'Sublevel
 nav', 'manage_options', 'sublevel_slug', 'example_sublevel_page' );
 }

 function example_toplevel_page() {
         $screen = get_current_screen();
         echo $screen->id; // toplevel_page_toplevel_slug
 }

 function example_sublevel_page() {
         $screen = get_current_screen();
         echo $screen->id; // toplevel-nav_page_sublevel_slug
 }
 }}}

 When make the menu_title argument in the add_menu_page function call
 translatable, I enable the translator to change the `$screen->id` variable
 on all submenu pages, as the `$menu title` argument of the toplevel menu
 item gets prefixed to that id.

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


More information about the wp-trac mailing list