Skip to content

Instantly share code, notes, and snippets.

@groucho75
Last active December 10, 2015 22:29
Show Gist options
  • Save groucho75/4503028 to your computer and use it in GitHub Desktop.
Save groucho75/4503028 to your computer and use it in GitHub Desktop.
Avatar Tooltip plugin customization: How to show only user bio and social links. Put this file in /wp-content/mu-plugins folder
<?php
/**
* Customization for Avatar Tooltip plugin, for WordPress
* How to show only user bio and social links. Put this file in /wp-content/mu-plugins folder
*
* More info and screenshot:
* http://www.eventualo.net/blog/2013/01/avatar-tooltip-plugin-how-to-show-only-user-bio-and-social-links/
*
* Avatar Tooltip plugin:
* http://wordpress.org/extend/plugins/avatar-tooltip/
*/
/**
* Add the new contact methods and remove not used
*/
function my_new_profile_contact_fields( $contactmethods ) {
// Add new
$contactmethods['twitter'] = 'Twitter <span class="description">(username)</span>';
$contactmethods['facebook'] = 'Facebook <span class="description">(username)</span>';
$contactmethods['lnkin'] = 'LinkedIn <span class="description">(profile URL)</span>';
$contactmethods['gplus'] = 'Google+ <span class="description">(profile URL)</span>';
// Remove not used
unset($contactmethods['yim']);
unset($contactmethods['aim']);
return $contactmethods;
}
add_filter('user_contactmethods','my_new_profile_contact_fields', 20, 1);
/**
* Displaying custom user fields inside tooltip
*/
function my_avatar_tooltip_content_user( $content_user, $user ) {
$content_user = ''; // reset content
$content_user .= '<div class="container-section container-user-description">';
if ( $bio = get_the_author_meta( 'description', $user->ID ) )
{
$content_user .= wp_kses_post( $bio ). '<br />';
}
$content_user .= '<ul class="userinfo gravatar-info-services">';
$content_user .= '<li><a href="'. esc_url( get_author_posts_url( $user->ID ) ) .'" style="float: left;margin-right: 10px" title="'. esc_html( __('Recent Posts') ) .'">'. esc_html( __('Recent Posts') ) .'</a></li>';
if ( $url = get_the_author_meta( 'url', $user->ID ) )
{
$content_user .= '<li><a href="'. esc_url( $url ).'" class="url" title="'. esc_attr( __('Website') ) .'" style="float: left;margin-right: 10px" rel="nofollow" target="_blank">'. esc_html( __('Website') ) .'</a></li>';
}
if ( $twitter = get_the_author_meta( 'twitter', $user->ID ) )
{
$content_user .= '<li><a href="http://www.twitter.com/'. esc_attr( $twitter ).'" class="img accounts_twitter" title="twitter" target="_blank">&nbsp;</a></li>';
}
if ( $facebook = get_the_author_meta( 'facebook', $user->ID ) )
{
$content_user .= '<li><a href="http://www.facebook.com/'. esc_attr( $facebook ).'" class="img accounts_facebook" title="facebook" target="_blank">&nbsp;</a></li>';
}
if ( $linkedin = get_the_author_meta( 'lnkin', $user->ID ) )
{
$content_user .= '<li><a href="'. esc_url( $linkedin ) .'" class="img accounts_linkedin" title="'. 'linkedin' .'" target="_blank" rel="nofollow">&nbsp;</a>';
}
if ( $google = get_the_author_meta( 'gplus', $user->ID ) )
{
$content_user .= '<li><a href="'. esc_url( $google ) .'" class="img accounts_google" title="'. 'google+' .'" target="_blank" rel="nofollow">&nbsp;</a>';
}
$content_user .= '</ul>';
$content_user .= '</div>';
return $content_user;
}
add_filter('axe_avatar_tooltip_content_user', 'my_avatar_tooltip_content_user', 10, 2);
// Then, empty text from Gravatar
function my_avatar_tooltip_content_gravatar( $content_grav, $posted_md5email, $grav_profile ) {
$content_grav = ''; // comment this line to show also Gravatar content
return $content_grav;
}
add_filter('axe_avatar_tooltip_content_gravatar', 'my_avatar_tooltip_content_gravatar', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment