bbp_get_reply_author_link

Return the author link of the reply.

Description

(string) bbp_get_reply_author_link( (string) $args = '' ); 

Returns (string)

Author link of reply

Parameters (1)

0. $args — Optional. (string) => ''
If an integer, it is used as reply id.

Usage

  1. if ( !function_exists( 'bbp_get_reply_author_link' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/replies/template.php'; 
  3.  
  4. // Optional. If an integer, it is used as reply id. 
  5. $args = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_reply_author_link($args); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/replies/template.php  
  1. function bbp_get_reply_author_link( $args = '' ) { 
  2.  
  3. // Parse arguments against default values 
  4. $r = bbp_parse_args( $args, array( 
  5. 'post_id' => 0,  
  6. 'link_title' => '',  
  7. 'type' => 'both',  
  8. 'size' => 80,  
  9. 'sep' => ' ',  
  10. 'show_role' => false 
  11. ), 'get_reply_author_link' ); 
  12.  
  13. // Used as reply_id 
  14. if ( is_numeric( $args ) ) { 
  15. $reply_id = bbp_get_reply_id( $args ); 
  16. } else { 
  17. $reply_id = bbp_get_reply_id( $r['post_id'] ); 
  18.  
  19. // Reply ID is good 
  20. if ( !empty( $reply_id ) ) { 
  21.  
  22. // Get some useful reply information 
  23. $author_url = bbp_get_reply_author_url( $reply_id ); 
  24. $anonymous = bbp_is_reply_anonymous( $reply_id ); 
  25.  
  26. // Tweak link title if empty 
  27. if ( empty( $r['link_title'] ) ) { 
  28. $link_title = sprintf( empty( $anonymous ) ? __( 'View %s\'s profile', bbpress ) : __( 'Visit %s\'s website', bbpress ), bbp_get_reply_author_display_name( $reply_id ) ); 
  29.  
  30. // Use what was passed if not 
  31. } else { 
  32. $link_title = $r['link_title']; 
  33.  
  34. // Setup title and author_links array 
  35. $link_title = !empty( $link_title ) ? ' title="' . esc_attr( $link_title ) . '"' : ''; 
  36. $author_links = array(); 
  37.  
  38. // Get avatar 
  39. if ( 'avatar' === $r['type'] || 'both' === $r['type'] ) { 
  40. $author_links['avatar'] = bbp_get_reply_author_avatar( $reply_id, $r['size'] ); 
  41.  
  42. // Get display name 
  43. if ( 'name' === $r['type'] || 'both' === $r['type'] ) { 
  44. $author_links['name'] = bbp_get_reply_author_display_name( $reply_id ); 
  45.  
  46. // Link class 
  47. $link_class = ' class="bbp-author-' . esc_attr( $r['type'] ) . '"'; 
  48.  
  49. // Add links if not anonymous and existing user 
  50. if ( empty( $anonymous ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) { 
  51.  
  52. // Assemble the links 
  53. foreach ( $author_links as $link => $link_text ) { 
  54. $link_class = ' class="bbp-author-' . $link . '"'; 
  55. $author_link[] = sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url( $author_url ), $link_title, $link_class, $link_text ); 
  56.  
  57. if ( true === $r['show_role'] ) { 
  58. $author_link[] = bbp_get_reply_author_role( array( 'reply_id' => $reply_id ) ); 
  59.  
  60. $author_link = implode( $r['sep'], $author_link ); 
  61.  
  62. // No links if anonymous 
  63. } else { 
  64. $author_link = implode( $r['sep'], $author_links ); 
  65.  
  66. // No replies so link is empty 
  67. } else { 
  68. $author_link = ''; 
  69.  
  70. return apply_filters( 'bbp_get_reply_author_link', $author_link, $r );