Open “Visit Site” in a new tab [WordPress admin]

June 21st, 2016 by
Paste the following code in your functions.php file
add_action( 'admin_bar_menu', 'vsnt_node', 999 );
function vsnt_node( $wp_admin_bar ) {
	$all_toolbar_nodes = $wp_admin_bar->get_nodes();
	foreach ( $all_toolbar_nodes as $node ) {

		if($node->id == 'site-name' || $node->id == 'view-site')
		{
			$args = $node;
			$args->meta = array('target' => '_blank');
			$wp_admin_bar->add_node( $args );
		}
	}
}

Post a Comment

You must be logged in to post a comment.