Last active
December 10, 2015 22:29
-
-
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
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 | |
/** | |
* 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"> </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"> </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"> </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"> </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