Skip to content

Instantly share code, notes, and snippets.

@manchumahara
Created October 30, 2020 18:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save manchumahara/0e1710721ab5741b68f3e8aad84fd8fd to your computer and use it in GitHub Desktop.
Save manchumahara/0e1710721ab5741b68f3e8aad84fd8fd to your computer and use it in GitHub Desktop.
Single Click "Visit Site" Menu in WordPress Admin Bar(Admin Top Menu) https://manchumahara.com/?p=1266&preview=true
add_action( 'admin_bar_menu', 'admin_bar_menu_visitsite', 999 );
function admin_bar_menu_visitsite( $wp_admin_bar ) {
if ( current_user_can( 'manage_options' ) ) {
$wp_admin_bar->add_node(
array(
'id' => 'visitsite',
'title' => 'Visit Site',
'href' => site_url(),
'meta' => array( 'class' => 'visitsite_adminbar', 'target' => '_blank' ),
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment