getRecentComments

The ColorWay Theme getRecentComments function.

Description

getRecentComments( (int) $src_count = 4, (int) $src_length = 75 ); 

Parameters (2)

0. $src_count — Optional. (int) => 4
The src count.
1. $src_length — Optional. (int) => 75
The src length.

Usage

  1. if ( !function_exists( 'getRecentComments' ) ) { 
  2. require_once '/functions/tabs.php'; 
  3.  
  4. // The src count. 
  5. $src_count = 4; 
  6.  
  7. // The src length. 
  8. $src_length = 75; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = getRecentComments($src_count, $src_length); 
  12.  

Defined (1)

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

/functions/tabs.php  
  1. function getRecentComments($src_count=4, $src_length=75) 
  2. global $wpdb; 
  3. $sql = "SELECT DISTINCT ID, post_title, comment_ID, comment_post_ID, comment_author, comment_date_gmt,  
  4. comment_content AS com_excerpt 
  5. FROM $wpdb->comments 
  6. LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) 
  7. WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' 
  8. ORDER BY comment_date_gmt DESC 
  9. LIMIT $src_count"; 
  10. $comments = $wpdb->get_results($sql); 
  11. $output = ""; 
  12. foreach ($comments as $comment) { 
  13. if (strlen($comment->comment_author) > 11) { 
  14. $author_min = substr($comment->comment_author, 0, 35) . '...'; 
  15. } else { 
  16. $author_min = $comment->comment_author; 
  17. $output .= "<li><span class='element'><a class='authorcom' href='" . get_permalink($comment->comment_post_ID) . "#comment-" . $comment->comment_ID . "'>" . $author_min . "</a>: <span class='textcom'>" . substr(strip_tags($comment->com_excerpt), 0, $src_length) . "... <a href='" . get_permalink($comment->comment_post_ID) . "' class='link'> »</a></span></span></li>"; 
  18. echo $output;