managed wordpress hosting

Open New Window for Frontend of your Website in WordPress


On 03-18-2013 code, wordpress

Im not sure why WordPress hasn’t added the open in new window when you click on visit website when you are in the admin section. Of course I want to keep my admin window and not take that page to my front end. Personally I like to have both the admin and front end of my website in 2 different tabs. I was getting tired of having to right click and go to open in new tab.

So I wrote a quick fix code in the functions file to add 2 links.

*Note I am hiding the site description from the admin bar (cleaner and no need for dropdown simple front end text works great).

// Remove Admin Bar Elements
function remove_admin_bar_links() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_menu('new-link');
$wp_admin_bar->remove_menu('updates');
$wp_admin_bar->remove_menu('themes');
$wp_admin_bar->remove_menu('customize');
$wp_admin_bar->remove_menu('site-name');// Remove the site name menu
}
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );

 

//Add to Admin Bar
function add_to_admin_bar () {
global $wp_admin_bar;
$wp_admin_bar->add_menu(array(
   'title' => "Front End",
   'href' => site_url(),
   'meta' => array('target' => '_blank'),
));
$wp_admin_bar->add_menu(array(
   'title' => "Admin",
   'href' => admin_url(),
   'meta' => array('target' => '_blank'),
));
}
add_action('admin_bar_menu', 'add_to_admin_bar', 1);