How To Open WordPress Admin Submenu in New Tab

In this wordpress tutorial i will let you know how to open submenu in wordpress link in new browser tab, The new link could be external link OR your wordpress internal link. The wodpress providing menu method to create menu and submenu method to create submenu but did not provide any argument which used to opened submenu in new tab, so you can achieve this with help of jquery. We will add new target='_blank' attribute on submenu to opened link in new tab.

How To Create menu and submenu in wordpress:

Step 1: We will create menu in wordpress admin.

add_action( 'admin_menu', 'register_my_custom_menu_page' );

function register_my_custom_menu_page(){
    add_menu_page( 'Test Admin', 'Test Admin', 'manage_options', 'testadminpage', test_options_pages, get_stylesheet_directory_uri().'/images/actionItem.gif', 6 );
}
function test_options_pages () {

echo $conent ='

Welcome admin menu

'; }

Step 2: Now We will create submenu in wordpress under above menu.

add_action('admin_menu', 'register_my_custom_submenu_page', 2);

function register_my_custom_submenu_page() {
    global $submenu;
	add_submenu_page( 'testadminpage', 'TestSubMenu', 'TestSubMenu', 'manage_options', 'http://google.com');	
}

Step 3: We will add jquery target attribute on link of submenu.

add_action( 'admin_head', 'devnet_options_page_redirect' );
function devnet_options_page_redirect() {
    
}

above steps will search last li and then find anchor a tag and finally add target attribute with _blank value.

I hope this help you.