我一直在定制admin bar
在版本3.3中,仅具有某些自定义链接,其中添加了以下内容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\' );
我现在想要一个最右边的链接,上面写着Howdy。。。,用作注销按钮。
有人对如何实现这一目标有什么建议吗?
SO网友:INT
这应该很到位:
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\' );
?>
修改版本:
http://wordpress.org/extend/plugins/one-click-logout/