WordPress: Open “Visit site” in a new window

add_action( 'admin_bar_menu', 'customize_my_wp_admin_bar', 80 );
function customize_my_wp_admin_bar( $wp_admin_bar ) {

    //Get a reference to the view-site node to modify.
    $node = $wp_admin_bar->get_node('view-site');

    //Change target
    $node->meta['target'] = '_blank';

    //Update Node.
    $wp_admin_bar->add_node($node);

}

To change any other item in the menu bar you just need to find the id of the item to change and adapt get_node. Look in /wp-includes/admin-bar.php for the id or have a look at the css classes of the output.

source: kraftner

Artikel terkait:   Using Dashicons for WordPress Theme and Plugin

Isi Komentar

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

This site uses Akismet to reduce spam. Learn how your comment data is processed.