p2_get_discussion_links

The BP Groupblog p2 get discussion links function.

Description

p2_get_discussion_links(); 

Usage

  1. if ( !function_exists( 'p2_get_discussion_links' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bp-groupblog/themes/p2/inc/template-tags.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = p2_get_discussion_links(); 
  7.  

Defined (1)

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

/themes/p2/inc/template-tags.php  
  1. function p2_get_discussion_links() { 
  2. global $post; 
  3. $content = ''; 
  4.  
  5. $comments = get_comments( array( 'post_id' => $post->ID ) ); 
  6.  
  7. foreach ( $comments as $comment ) 
  8. $unique_commentors[$comment->comment_author_email] = $comment; 
  9.  
  10. $total_unique_commentors = count( $unique_commentors ); 
  11.  
  12. $counter = 1; 
  13. foreach ($unique_commentors as $comment) { 
  14. if ( $counter > 3 ) 
  15. break; 
  16.  
  17. if ( 1 != $counter && $total_unique_commentors == $counter ) 
  18. $content .= __( ', and ', p2 ); 
  19. else if ( 1 != $counter ) 
  20. $content .= ', '; 
  21.  
  22. $content .= get_avatar( $comment, 16 ) . ' '; 
  23.  
  24. if ( $comment->user_id ) 
  25. $content .= '<a href="' . site_url( 'author/' . esc_attr( $comment->comment_author ) ) . '">' . esc_attr( $comment->comment_author ) . '</a>'; 
  26. else { 
  27. if ( $comment->comment_author_url ) 
  28. $content .= '<a href="' . esc_attr( $comment->comment_author_url ) . '">' . esc_attr( $comment->comment_author ) . '</a>'; 
  29. else 
  30. $content .= esc_attr( $comment->comment_author ); 
  31.  
  32. $counter++; 
  33.  
  34. if ( $total_unique_commentors > 3 ) 
  35. if ( ( $total_unique_commentors - 3 ) != 1 ) 
  36. $content .= sprintf( __( ' and %s others are discussing.', p2 ), ( $total_unique_commentors - 3 ) ); 
  37. else 
  38. $content .= __( ' and one other person are discussing.', p2 ); 
  39. else { 
  40. if ( $total_unique_commentors == 1 ) 
  41. $content .= __( ' is discussing.', p2 ); 
  42. else 
  43. $content .= __( ' are discussing.', p2 ); 
  44.  
  45. return $content;