--- ../tags/2.0.3/get-recent-comments.php 2009-03-27 00:06:56.000000000 +0100 +++ get-recent-comments.php 2009-03-27 13:48:31.000000000 +0100 @@ -1,8 +1,8 @@ Options/Recent Comments after activation of the plugin. @@ -1050,7 +1050,9 @@ { // kjgrc_log("kjgrc_get_comments2 $caller"); // echo "kjgrc_get_comments2 $requested_comment_type $caller
"; - mb_regex_encoding(mb_internal_encoding()); + if (function_exists("mb_regex_encoding")) { + mb_regex_encoding(mb_internal_encoding()); + } global $wpdb; $batch_number = 0; $number_of_comments = 0; @@ -1269,8 +1271,13 @@ $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); + if (function_exists("mb_ereg_replace")) { + $trackback_title = mb_ereg_replace('([^\s]{'.$chars_per_word.'})','\\1 ', $trackback_title); // split long words + $trackback_title = preg_replace("/\s{2,}/"," ",$trackback_title); + } else { + $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; @@ -1284,8 +1291,13 @@ $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 + if (function_exists("mb_ereg_replace")) { + $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 + } else { + $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; @@ -1497,22 +1509,40 @@ function kjgrc_excerpt ($text,$chars_per_comment,$chars_per_word,$tag,$output) { - $length = mb_strlen(str_replace($tag,"",strip_tags($output))); + if (function_exists('mb_strlen')) { + $length = mb_strlen(str_replace($tag,"",strip_tags($output))); + } else { + $length = 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 (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,' ')); + if (function_exists('mb_strlen') && function_exists('mb_substr') && function_exists('mb_strrpos')) + { + 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 . "..."; } - // 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); - } + } else + { + 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); + } + $text = $text . "..."; + } - $text = $text . "..."; } #$text = "[EXCERPT]: '$text'"; return "$text";