How can I add a sub menu link using add_submenu_page that will open a new window (target="_blank"
) instead of opening in the current one (default behavior)?

1 Answer
This has to be solved:
- with an unconventional submenu manipulation, provided by @t31os in this Answer
- and some jQuery
add_action( 'admin_menu', 'wpse_66020_admin_menu_new_item' );
add_action( 'admin_head', 'wpse_66020_add_jquery' );
function wpse_66020_admin_menu_new_item()
{
global $submenu;
$submenu['index.php'][500] = array(
'<div id="wpse-66020">Go to WPSE</div>'
, 'manage_options'
, 'https://wordpress.stackexchange.com/'
);
}
function wpse_66020_add_jquery()
{
?>
<script type="text/javascript">
jQuery(document).ready( function($) {
$('#wpse-66020').parent().attr('target','_blank');
});
</script>
<?php
}
Resulting in this:
click to enlarge