Skip to content

Instantly share code, notes, and snippets.

@carlodaniele
Created February 18, 2016 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlodaniele/f51debe98eaec6cd6fc9 to your computer and use it in GitHub Desktop.
Save carlodaniele/f51debe98eaec6cd6fc9 to your computer and use it in GitHub Desktop.
<?php
/**
* Customize WordPress Toolbar
*
* @param obj $wp_admin_bar An instance of the global object WP_Admin_Bar
*/
function myplugin_customize_toolbar( $wp_admin_bar ){
$user = wp_get_current_user();
if ( ! ( $user instanceof WP_User ) ){
return;
}
$my_account = $wp_admin_bar->get_node( 'my-account' );
if( ! empty( $user->user_url ) && $my_account ){
$wp_admin_bar->add_node( array(
'parent' => 'user-actions',
'id' => 'user-url',
'title' => '<span class="user-url">' . __( 'My Website' ) . '</span>',
'href' => esc_url( $user->user_url )
) );
}
}
add_action( 'admin_bar_menu', 'myplugin_customize_toolbar', 999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment