Created
February 2, 2012 12:24
-
-
Save bueltge/1723225 to your computer and use it in GitHub Desktop.
Remove Gravatar on Admin Bar (Hintergründe: http://talkpress.de/artikel/wordpress-admin-bar-datenkrake-missbrauch)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Remove Gravatar on Admin Bar | |
* Plugin URI: http://talkpress.de/artikel/wordpress-admin-bar-datenkrake-missbrauch | |
* Description: Remove Gravatar on Admin Bar | |
* Version: 1.0.0 | |
* Author: Frank Bültge | |
* Author URI: http://bueltge.de | |
* License: GPLv3 | |
*/ | |
// This file is not called from WordPress. We don't like that. | |
! defined( 'ABSPATH' ) and exit; | |
// If the function exists this file is called as comments template. | |
// We don't do anything then. | |
if ( ! function_exists( 'fb_admin_bar_init' ) ) { | |
add_action( 'init', 'fb_admin_bar_init' ); | |
function fb_admin_bar_init() { | |
remove_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 ); | |
remove_action( 'admin_bar_menu', 'wp_admin_bar_my_account_item', 7 ); | |
add_action( 'admin_bar_menu', 'fb_admin_bar_my_account_menu', 0 ); | |
add_action( 'admin_bar_menu', 'fb_admin_bar_my_account_item', 7 ); | |
} | |
function fb_admin_bar_my_account_menu( $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; | |
$wp_admin_bar->add_group( array( | |
'parent' => 'my-account', | |
'id' => 'user-actions', | |
) ); | |
$user_info = "<span class='display-name'>{$current_user->display_name}</span>"; | |
if ( $current_user->display_name !== $current_user->user_nicename ) | |
$user_info .= "<span class='username'>{$current_user->user_nicename}</span>"; | |
$wp_admin_bar->add_menu( array( | |
'parent' => 'user-actions', | |
'id' => 'user-info', | |
'title' => $user_info, | |
'href' => $profile_url, | |
'meta' => array( | |
'tabindex' => -1, | |
), | |
) ); | |
$wp_admin_bar->add_menu( array( | |
'parent' => 'user-actions', | |
'id' => 'edit-profile', | |
'title' => __( 'Edit My Profile' ), | |
'href' => $profile_url, | |
) ); | |
$wp_admin_bar->add_menu( array( | |
'parent' => 'user-actions', | |
'id' => 'logout', | |
'title' => __( 'Log Out' ), | |
'href' => wp_logout_url(), | |
) ); | |
} | |
function fb_admin_bar_my_account_item( $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; | |
$howdy = sprintf( __('Howdy, %1$s'), $current_user->display_name ); | |
$wp_admin_bar->add_menu( array( | |
'id' => 'my-account', | |
'parent' => 'top-secondary', | |
'title' => $howdy, | |
'href' => $profile_url, | |
'meta' => array( | |
'title' => __('My Account'), | |
), | |
) ); | |
} | |
} // end if |
What's the
fb_
means?
That's only a prefix for clear namespace to remove problems with other functions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like not working in version 5.3.2.