WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #26935


Ignore:
Timestamp:
03/21/2014 12:35:20 PM (7 years ago)
Author:
SergeyBiryukov
Comment:

Related: #19085

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26935

    • Property Version changed from trunk to 3.8
  • Ticket #26935 – Description

    initial v1  
    22   
    33If we have "Main" as our main page, and "Sub" as our sub page...
    4 
    5     add_menu_page('Main', 'Main', 'manage_options', 'main_options', array($this, 'main_do_page'));
    6     add_submenu_page('main_options', 'Sub', 'Sub', 'manage_options', 'sub_options', null);
    7 
     4{{{
     5add_menu_page('Main', 'Main', 'manage_options', 'main_options', array($this, 'main_do_page'));
     6add_submenu_page('main_options', 'Sub', 'Sub', 'manage_options', 'sub_options', null);
     7}}}
    88This will create a menu structure such as:
    99* Main
     
    1414
    1515Now, we can hide that duplication with a slight adjustment to the code:
    16 
    17     add_menu_page('Main', 'Main', 'manage_options', 'main_options', array($this, 'main_do_page'));
    18     add_submenu_page('main_options', 'Sub', 'Sub', 'manage_options', 'main_options', null);
    19 
     16{{{
     17add_menu_page('Main', 'Main', 'manage_options', 'main_options', array($this, 'main_do_page'));
     18add_submenu_page('main_options', 'Sub', 'Sub', 'manage_options', 'main_options', null);
     19}}}
    2020By changing the fifth argument to match the "Main" page slug.. it will successfully hide the submenu; resulting in:
    2121
     
    2626
    2727It appears in the submenu html output as such (with the second snippet above):
    28 
    29     <li class="wp-first-item current">
     28{{{
     29<li class="wp-first-item current">
    3030    <a class="wp-first-item current" href="admin.php?page=main_options"></a>
    31     </li>
    32     <li>
     31</li>
     32<li>
    3333    <a href="admin.php?page=sub_options">Options</a>
    34     </li>
    35 
     34</li>
     35}}}
    3636See how the top item has the html for a list item.. but has no inner html?
    3737