Skip to content

Commit

Permalink
Shorten plugin now strips any tags out of the shortened string to ens…
Browse files Browse the repository at this point in the history
…ure that it doesn't leave open tags.
  • Loading branch information
Lonnie authored and Lonnie committed Oct 31, 2012
1 parent 47f9583 commit cdf0e24
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/helpers/shorten_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* @author Electric Function, Inc.
*/
function shorten ($string, $length, $retain_whole_words = FALSE) {
$string = trim($string);
$string = trim(strip_tags($string));

if (strlen(strip_tags($string)) > $length) {
if ($retain_whole_words == FALSE) {
$string = substr($string, 0, ($length - 3));
Expand All @@ -25,7 +25,7 @@ function shorten ($string, $length, $retain_whole_words = FALSE) {
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, ($length - 3)));
$string .= '…';
}

return $string;
}
else {
Expand Down

0 comments on commit cdf0e24

Please sign in to comment.