Advertisement
vapvarun

Replace bbPress avatar with PeepSo avatar

Apr 2nd, 2018
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. // You can add the following function inside child theme functions.php or use Code Snippet plugin
  2.  
  3. add_filter( 'get_avatar', 'wb_peepso_bbpress_get_avatar', 10, 6 );
  4. function wb_peepso_bbpress_get_avatar( $avatar, $id_or_email, $args_size, $args_default, $args_alt, $args ) {
  5.     if( is_bbpress() ) {
  6.         $peepSoUser = PeepSoUser::get_instance();
  7.         $avatar_url = $peepSoUser->get_avatar();
  8.         $avatar = sprintf(
  9.             "<img alt='%s' src='%s' srcset='%s' class='%s' height='%d' width='%d' %s/>",
  10.             esc_attr( $args['alt'] ),
  11.             esc_url( $avatar_url ),
  12.             esc_url( $avatar_url ) . ' 2x',
  13.             esc_attr( join( ' ', $class = array( 'avatar avatar-14 photo' ) ) ),
  14.             (int) $args['height'],
  15.             (int) $args['width'],
  16.             $args['extra_attr']
  17.         );
  18.     }
  19.     return $avatar;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement