-
Notifications
You must be signed in to change notification settings - Fork 60
/
admin-bar.php
executable file
·85 lines (67 loc) · 2.75 KB
/
admin-bar.php
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
<?php
/**
* Hide the admin bar on the front-end
*
* @link https://developer.wordpress.org/reference/hooks/show_admin_bar
*/
add_filter( 'show_admin_bar', '__return_false' );
/**
* Hide or create new menus and items in the admin bar.
* Indentation shows sub-items.
*
* @link https://developer.wordpress.org/reference/hooks/wp_before_admin_bar_render/
*/
add_action(
'wp_before_admin_bar_render',
function () {
global $wp_admin_bar;
/* WP logo menu */
$wp_admin_bar->remove_menu( 'wp-logo' ); // Remove the WordPress logo
$wp_admin_bar->remove_menu( 'about' ); // Remove the about WordPress link
$wp_admin_bar->remove_menu( 'wporg' ); // Remove the about WordPress link
$wp_admin_bar->remove_menu( 'documentation' ); // Remove the WordPress documentation link
$wp_admin_bar->remove_menu( 'support-forums' ); // Remove the support forums link
$wp_admin_bar->remove_menu( 'feedback' ); // Remove the feedback link
/* Site name menu */
$wp_admin_bar->remove_menu( 'site-name' ); // Remove the site name menu
$wp_admin_bar->remove_menu( 'view-site' ); // Remove the view site link
$wp_admin_bar->remove_menu( 'dashboard' ); // Remove the dashboard link
$wp_admin_bar->remove_menu( 'themes' ); // Remove the themes link
$wp_admin_bar->remove_menu( 'widgets' ); // Remove the widgets link
$wp_admin_bar->remove_menu( 'menus' ); // Remove the menus link
/* Customize menu */
$wp_admin_bar->remove_menu( 'customize' ); // Remove the site name menu
/* Updates menu */
$wp_admin_bar->remove_menu( 'updates' ); // Remove the updates link
$wp_admin_bar->remove_menu( 'comments' ); // Remove the comments link
/* New content menu */
$wp_admin_bar->remove_menu( 'new-content' ); // Remove the content link
$wp_admin_bar->remove_menu( 'new-post' ); // Remove the new post link
$wp_admin_bar->remove_menu( 'new-media' ); // Remove the new media link
$wp_admin_bar->remove_menu( 'new-page' ); // Remove the new page link
$wp_admin_bar->remove_menu( 'new-user' ); // Remove the new user link
/* Edit menu */
$wp_admin_bar->remove_menu( 'edit' ); // Remove the edit link
/* Account menu */
$wp_admin_bar->remove_menu( 'my-account' ); // Remove the user details tab
/* Search bar */
$wp_admin_bar->remove_menu( 'search' ); // Remove the search tab
},
999
);
/**
* Replace "Howdy, "-title and avatar with only users display_name
*
* @link https://developer.wordpress.org/reference/hooks/admin_bar_menu/
*/
add_filter(
'admin_bar_menu',
function ( $admin_bar ) {
$title = wp_get_current_user()->display_name;
$admin_bar->add_node( array(
'id' => 'my-account',
'title' => $title,
));
},
25
);