Advertisement
Guest User

Avatar Tooltip plugin: only profile bio, social links

a guest
Jan 9th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.72 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Add the new contact methods and remove not used
  4.  */
  5. function my_new_profile_contact_fields( $contactmethods ) {
  6.     // Add
  7.     $contactmethods['twitter'] = 'Twitter <span class="description">(username)</span>';
  8.     $contactmethods['facebook'] = 'Facebook <span class="description">(username)</span>';
  9.     $contactmethods['lnkin'] = 'LinkedIn <span class="description">(profile URL)</span>';
  10.     $contactmethods['gplus'] = 'Google+ <span class="description">(profile URL)</span>';
  11.  
  12.     // Remove
  13.     unset($contactmethods['yim']);
  14.     unset($contactmethods['aim']);
  15.    
  16.     return $contactmethods;
  17. }
  18. add_filter('user_contactmethods','my_new_profile_contact_fields', 20, 1);
  19.  
  20.  
  21. /**
  22.  * Displaying custom user fields inside tooltip
  23.  */
  24. function my_avatar_tooltip_content_user( $content_user, $user ) {
  25.    
  26.     $content_user = ''; // reset content
  27.  
  28.     $content_user .= '<div class="container-section container-user-description">';
  29.     if ( $bio = get_the_author_meta( 'description', $user->ID ) )
  30.     {
  31.         $content_user .= wp_kses_post( $bio ). '<br />';
  32.     }
  33.  
  34.     $content_user .= '<ul class="userinfo gravatar-info-services">';
  35.    
  36.     $content_user .= '<li><a href="'. esc_url( get_author_posts_url( $user->ID ) ) .'" style="float: left;margin-right: 10px">'. esc_html( __('Recent Posts') ) .'</a></li>';
  37.    
  38.     if ( $twitter = get_the_author_meta( 'twitter', $user->ID ) )
  39.     {
  40.         $content_user .= '<li><a href="http://www.twitter.com/'. esc_attr( $twitter ).'" class="img accounts_twitter" title="twitter" target="_blank">&nbsp;</a></li>';
  41.     }
  42.    
  43.     if ( $facebook = get_the_author_meta( 'facebook', $user->ID ) )
  44.     {
  45.         $content_user .= '<li><a href="http://www.facebook.com/'. esc_attr( $facebook ).'" class="img accounts_facebook" title="facebook" target="_blank">&nbsp;</a></li>';
  46.     }  
  47.  
  48.     if ( $linkedin = get_the_author_meta( 'lnkin', $user->ID ) )
  49.     {
  50.         $content_user .= '<li><a href="'. esc_url( $linkedin ) .'" class="img accounts_linkedin" title="'. 'linkedin' .'" target="_blank" rel="nofollow">&nbsp;</a>';
  51.     }
  52.  
  53.     if ( $google = get_the_author_meta( 'gplus', $user->ID ) )
  54.     {
  55.         $content_user .= '<li><a href="'. esc_url( $google ) .'" class="img accounts_google" title="'. 'google+' .'" target="_blank" rel="nofollow">&nbsp;</a>';
  56.     }
  57.        
  58.     $content_user .= '</ul>';
  59.  
  60.     $content_user .= '</div>';
  61.     return $content_user;
  62. }
  63. add_filter('axe_avatar_tooltip_content_user', 'my_avatar_tooltip_content_user', 10, 2);
  64.  
  65.  
  66.  
  67. // Then, empty text from Gravatar
  68. function my_avatar_tooltip_content_gravatar( $content_grav, $posted_md5email, $grav_profile ) {
  69.     $content_grav = ''; // comment this line to show also Gravatar content
  70.     return $content_grav;
  71. }
  72. add_filter('axe_avatar_tooltip_content_gravatar', 'my_avatar_tooltip_content_gravatar', 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement