Repository navigation
Expand file tree
/
Copy pathcustom-toolbar.php
More file actions
126 lines (103 loc) · 4.09 KB
/
Copy pathcustom-toolbar.php
File metadata and controls
126 lines (103 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
/*
Plugin Name: Custom Toolbar
Plugin URI: http://www.my-dev.com/
Description: Modifies the WordPress 3.3+ toolbar.
Version: 1.1
Author: Ben Jones
Author URI: http://www.my-dev.com/
License: GPL2
*/
/*
* Remove the WordPress Logo from the WordPress Admin Bar
*/
function remove_wp_logo() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
}
add_action( 'wp_before_admin_bar_render', 'remove_wp_logo' );
/**
* Removes the "Howdy" item.
*
* @since 3.3.0
*/
function remove_howdy( $wp_admin_bar ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$profile_url = get_edit_profile_url( $user_id );
if ( ! $user_id )
return;
$avatar = get_avatar( $user_id, 16 );
$name = sprintf( __('%1$s'), $current_user->display_name ) . '\'s Profile';
$class = empty( $avatar ) ? '' : 'with-avatar';
$wp_admin_bar->add_menu( array(
'id' => 'my-account',
'parent' => 'top-secondary',
'title' => $name . $avatar,
'href' => $profile_url,
'meta' => array(
'class' => $class,
'title' => __('My Account'),
),
) );
}
add_action('admin_bar_menu', 'remove_howdy', 999);
/* Remove Unwanted Toolbar Items */
/* remove site name */
function custom_toolbar($wp_toolbar) {
global $wp_admin_bar;
/* ... code to go here ... */
if ( !current_user_can( 'manage_options' ) ) {
$wp_toolbar->remove_node('site-name');
}
$wp_toolbar->remove_node('comments');
$wp_toolbar->remove_node('new-content');
$wp_toolbar->remove_node('search');
$wp_toolbar->remove_node('bp-login');
$wp_toolbar->remove_node('bp-register');
$wp_toolbar->remove_node('edit');
$wp_toolbar->remove_node('bp-notifications');
if ( is_user_logged_in() ) {
$wp_toolbar->add_node(array(
'id' => 'bp-notifications',
'title' => __('<img src="' . plugins_url( '_inc/images/notifications.png' , __FILE__ ) . '" style="margin-top: 5px;"> '),
'href' => bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/',
/*'meta' => array('class' => 'notifications')*/
));
/*$wp_toolbar->add_node(array(
'parent' => 'bp-notifications',
'id' => ' Notices',
'title' => $notifications,
'href' => bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/',
'meta' => 'echo count($notifications);'
));*/
$wp_toolbar->add_node(array(
'id' => 'user-friends',
'title' => __('<img src="' . plugins_url( '_inc/images/friends.png' , __FILE__ ) . '" style="margin-top: 5px;"> '),
'href' => bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/',
/*'meta' => array('class' => 'menupop')*/
) );
$wp_toolbar->add_node(array(
'parent' => 'user-friends',
'id' => 'friend-requests',
'title' => 'Friend Requests',
'href' => bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/',
'meta' => array('html' => '<span style="margin-left:50px; background: none repeat scroll 0 0 #21759B; border-radius: 10px 10px 10px 10px; color: #FFFFFF; display: inline; font-size: 10px; font-weight: bold; padding: 2px 5px; text-shadow: none;">' . bp_friend_get_total_requests_count( bp_loggedin_user_id() ) . '</span>' )
));
$wp_toolbar->add_node(array(
'id' => 'user-messages',
'title' => __('<img src="' . plugins_url( '_inc/images/messages.png' , __FILE__ ) . '" style="margin-top: 5px;"> '),
'href' => bp_loggedin_user_domain() . bp_get_messages_slug() . '/view/',
/*'meta' => array('class' => 'menupop')*/
) );
$wp_toolbar->add_node(array(
'parent' => 'user-messages',
'id' => 'messages',
'title' => ' Messages ',
'href' => bp_loggedin_user_domain() . bp_get_messages_slug() . '/view/',
'meta' => array('html' =>'<span style="margin-left:35px; background: none repeat scroll 0 0 #21759B; border-radius: 10px 10px 10px 10px; color: #FFFFFF; display: inline; font-size: 10px; font-weight: bold; padding: 2px 5px; text-shadow: none;color: #FFFFFF; display: inline; background: none repeat scroll 0 0 #21759B; border-radius: 10px 10px 10px 10px; font-weight: bold; padding: 2px 5px; text-shadow: none;">' . bp_get_total_unread_messages_count( bp_loggedin_user_id() . '</span>' ) )
));
}
}
add_action('admin_bar_menu', 'custom_toolbar', 999);
?>