How to enable additional page in WordPress custom plugin?

Solution:1

You can create a sub menu page and pass null as its parent:

$parent_slug
Use NULL or set to ‘options.php’ if you want to create a page that doesn’t appear in any menu.

A demo:

add_action('admin_menu', function() 
{
    # Main page
    add_menu_page( 
        'Vsa', 
        'Vsa', 
        'add_users', // Capability, not role
        'listaj-narocila', 
        function(){ 
            printf(
                '<h2>%s</h2><a href="%s">%s</a>',
                __( 'Main page' ),
                admin_url( 'admin.php?page=single-norcilo&id='.rand(1,25) ),
                __( 'Hidden sub page' )
            );
        },
        'http://sstatic.net/stackexchange/img/favicon.ico'
    );  

    # Child page    
    $hook = add_submenu_page(
        null,
        'Norcilo',
        'Norcilo',
        'add_users',
        'single-norcilo',
        function(){ 
            printf(
                '<h2>%s</h2><a href="%s">%s</a>',
                __( 'Hidden sub page' ),
                admin_url( 'admin.php?page=listaj-narocila' ),
                __( 'back' )
            );
        }
    );

    # Enqueue script in submenu page to fix the current menu indicator
    add_action( "admin_footer-$hook", function()
    {
        echo <<<HTML
<script type="text/javascript">
jQuery(document).ready( function($) {
    $('#toplevel_page_listaj-narocila')
        .removeClass('wp-not-current-submenu')
        .addClass('current');
});     
</script>
HTML;

    });
});

Solution:2

You’d have to manipulate the global $submenu and modify the link in it. Or use jQuery.

The following example adds a submenu in the Dashboard menu and changes the destination link just after. The submenu page will dump the contents of the global var.

add_action( 'admin_menu', function()
{
    add_submenu_page(  
        'index.php',                  
        'Sandbox Options',          
        'Options',                  
        'administrator',            
        'sandbox_options',    
        function() { global $submenu; var_dump($submenu); }
    );
    global $submenu; 
    $submenu['index.php'][11][2] = 'index.php?page=sandbox_options&tab=3';
});

[Update]

The example given, Redux Framework, uses the following technique:

  • Add a menu page with a slug example_slug.
  • Add the submenu pages and use the same slug example_slug + &tab=N.
  • All the menu and submenu pages are rendered with the menu callback. The submenu have null callbacks.

Example:

add_submenu_page(  
    'sandbox',                  
    'Sandbox Options',          
    'Options',                  
    'add_users',            
    'sandbox&tab=4',    
    '__return_null'
);