Ready to get started?Download WordPress


Make "Visit Site" Link open in new tab

  1. marshapearson


    It would be really great if the "visit site" link in the upper left would open in a new tab. I usually want to keep the "back end" open and go look at the site changes. As it is now, I have to either "right click" and select "open in a new tab", or click, then use the back arrow to go back.

    Keep up the wonderful work, and hope this suggestion is helpful to others as well!

    Posted: 1 year ago #
  2. saverdaj

    Hi marshapearson. I was looking through the idea section today and came across yours. I have been trying to be more involved in the WordPress community and decided to try solving your problem. Here is the solution I cam up with. Let me know what you think or if I am doing any of this wrong.

     * Function used for when clicking on the site title or "Visit Site" in the toolbar a new tab will open instead of the default way of staying in the same tap.
     * For more information look at wp-includes/class-wp-admin-bar.php.  As of version 3.8 you can find additional information starting on Line 80
    add_action( 'admin_bar_menu', 'vsnt_node', 999 );
    function vsnt_node( $wp_admin_bar ) {
        //Grab all of the nodes
        $all_toolbar_nodes = $wp_admin_bar->get_nodes();
        //Loop through the nodes and find the ones to add the _blank target to
    	foreach ( $all_toolbar_nodes as $node ) {
            if($node->id == 'site-name' || $node->id == 'view-site')
                // use the same node's properties
                $args = $node;
                // put a span before the title
                $args->meta = array('target' => '_blank');
    		// update the Toolbar node
    		$wp_admin_bar->add_node( $args );
    Posted: 1 year ago #

RSS feed for this topic


You must log in to post.

  • Rating

    4 Votes
  • Status

    Sorry, not right now