Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have been customising the admin bar in version 3.3 to only have certain custom links with the following added to functions.php:

function mytheme_admin_bar_render() {
global $wp_admin_bar;

$wp_admin_bar->remove_menu('site-name');
$wp_admin_bar->remove_menu('new-content');
$wp_admin_bar->remove_menu('updates');
$wp_admin_bar->remove_menu('comments');
$wp_admin_bar->remove_menu('edit-profile');


$wp_admin_bar->add_menu( array(
    'id' => 'reports',  'title' => __( 'Reports'),  'href' => __('xyz.html'),
));
}
add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );

I'd now like to have the far right link that says Howdy, ..., function as a Logout button.

Does anyone have any suggestions on how achieve this?

share|improve this question
add comment

3 Answers

up vote -7 down vote accepted

EDIT: This is obviously not a good idea if you want to be able to update - see comments below

As this site explains, you need to replace <?php printf(__(‘Howdy, %2$s!’), ‘profile.php’, $user_identity) ?> in the wordpress admin with in your case the word 'logout.' Then make the url be echo wp_logout_url();

share|improve this answer
1  
And how do you run an update now? –  toscho Jun 17 '12 at 22:48
5  
Changes in core files will be lost in updates. I don't recommend editing core files at all. –  Jared Jun 18 '12 at 2:21
    
this is a dreadful idea, begging for constant maintenance... oh, I get it! (grr!) –  webaware Dec 16 '12 at 2:46
add comment

This should hit the spot:

function remove_old_logout() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_node('my-account');
}
add_action( 'wp_before_admin_bar_render', 'remove_old_logout' );

function newlogout() {
?>

<style type="text/css">
table#one-click01 tr td a:link,
table#one-click01 tr td a:visited {
    color:#CCCCCC;
    text-decoration: none;
}
table#one-click01 tr td a:hover,
table#one-click01 tr td a:active,
table#one-click01 tr td a:focus {
    color:#FAFAFA;
    text-decoration: none;
    }
table#one-click01 {
float:right;z-index:100000;position:fixed;right:0px;top:0px;background:#464646;padding-right:30px;padding-left:100px;border:0px;
}
body table#one-click01 tr td {
    height:25px;
    padding:3px 0 0 0;
    font-size:13px;
    font-family:sans-serif;
    line-height:1.5;
    color:#CCCCCC;
}
body.wp-admin table#one-click01 tr td {
    height:28px;
    padding-top:0px;
}
body.logged-in table#one-click01 tr td {
    padding-right:30px;
    border: 0px;
}
body.logged-in table#one-click01 {
    margin:0;border-collapse:collapse;border-spacing:0;
}
body.logged-in table#one-click01 tr td {
    vertical-align:middle;
    border:0;
}
</style>
<table id="one-click01" style="" border="0" cellspacing="0" cellpadding="0"><tr><td align=center valign=center>
<?php
    wp_get_current_user();
    $current_user = wp_get_current_user();
    if ( !($current_user instanceof WP_User) )
    return;
    $name = $current_user->display_name;
 ?>

<?php echo '
<a href="' . wp_logout_url() . '" title="' . esc_attr__('Log Out') . '">Howdy, ' . __($name) . '</a>'
; ?>

</td></tr></table>

<?php 
}
add_action( 'admin_bar_menu', 'newlogout' );
?>

Modified version of: http://wordpress.org/extend/plugins/one-click-logout/

share|improve this answer
add comment

Here is a simple solution I figured out by reverse engineering this plugin: http://wordpress.org/extend/plugins/dashboard-tweaks/

function custom_logout_link() {
    global $wp_admin_bar;
    $wp_admin_bar->add_menu( array(
        'id'    => 'wp-custom-logout',
        'title' => 'Logout',
        'parent'=> 'top-secondary',
        'href'  => wp_logout_url()
    ) );
    $wp_admin_bar->remove_menu('my-account');
}
add_action( 'wp_before_admin_bar_render', 'custom_logout_link' );
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.