--- ../tags/2.0.2/get-recent-comments.php 2009-03-09 08:36:21.000000000 +0100 +++ get-recent-comments.php 2009-03-26 23:28:15.000000000 +0100 @@ -1,7 +1,7 @@ "; + mb_regex_encoding(mb_internal_encoding()); global $wpdb; $batch_number = 0; $number_of_comments = 0; @@ -1259,8 +1269,8 @@ $trackback_title = preg_replace("/^(.+?)<\/strong>.*/s","$1",$comment->comment_content); $trackback_title = strip_tags($trackback_title); $trackback_title = preg_replace("/[\n\t\r]/"," ",$trackback_title); + $trackback_title = mb_ereg_replace('([^\s]{'.$chars_per_word.'})','\\1 ', $trackback_title); // split long words $trackback_title = preg_replace("/\s{2,}/"," ",$trackback_title); - $trackback_title = wordwrap($trackback_title,$chars_per_word,' ',1); $comment_excerpt = preg_replace("/^.+?<\/strong>/","",$comment->comment_content,1); $comment_author = $comment->comment_author; @@ -1274,8 +1284,8 @@ $comment_excerpt = strip_tags(wptexturize($comment_excerpt)); $comment_excerpt = preg_replace("/[\n\t\r]/"," ",$comment_excerpt); // whitespace into 1 blank + $comment_excerpt = mb_ereg_replace('([^\s]{'.$chars_per_word.'})','\\1 ', $comment_excerpt); // split long words $comment_excerpt = preg_replace("/\s{2,}/"," ",$comment_excerpt); // whitespace into 1 blank - $comment_excerpt = wordwrap($comment_excerpt,$chars_per_word,' ',1); if ($trackback_title == '') $trackback_title = $comment_excerpt; @@ -1304,7 +1314,7 @@ if ($md5_cache && array_key_exists($comment->comment_author,$md5_cache)) { $gravatar_md5 = $md5_cache[$comment->comment_author]; } else { - $gravatar_md5 = md5($comment->comment_author_email); + $gravatar_md5 = md5(strtolower($comment->comment_author_email)); $md5_cache[$comment->comment_author_email] = $gravatar_md5; } $comment_gravatar_url = "http://www.gravatar.com/avatar.php?" . @@ -1334,6 +1344,7 @@ $post_counter = $post->comment_count; $author_url = $comment->comment_author_url; + $author_url_href = "a href=\"$comment->comment_author_url\""; if ($author_url == "http://") $author_url = ""; if (empty($author_url) || $author_url == "http://") @@ -1486,17 +1497,21 @@ function kjgrc_excerpt ($text,$chars_per_comment,$chars_per_word,$tag,$output) { - $length = strlen(str_replace($tag,"",strip_tags($output))); + $length = mb_strlen(str_replace($tag,"",strip_tags($output))); $length = $chars_per_comment - $length; $length = $length -2; // we will add three dots at the end if ($length < 0) $length = 0; - if (strlen($text) > $length) { - $text = substr($text,0,$length); - $text = substr($text,0,strrpos($text,' ')); - // last word exceeds max word length: - if ((strlen($text) - strrpos($text,' ')) > $chars_per_word) { - $text = substr($text,0,strlen($text)-3); - } + if (mb_strlen($text) > $length) { + $text = mb_substr($text,0,$length); + if ((mb_strlen($text) - mb_strrpos($text,' ')) < $chars_per_word-1) { + $text = mb_substr($text,0,mb_strrpos($text,' ')); + } + // last word has max word length: + if ((mb_strlen($text) - mb_strrpos($text,' ')) > $chars_per_word-2) + { + $text = mb_substr($text,0,mb_strlen($text)-3); + } + $text = $text . "..."; } #$text = "[EXCERPT]: '$text'";