WordPress.org

Plugin Directory

Changeset 501488


Ignore:
Timestamp:
02/07/12 04:59:38 (2 years ago)
Author:
jowilki
Message:

Version 1.1 - Fixes text trim for older versions of Wordpress.

Location:
pretty-pinterest-pins/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pretty-pinterest-pins/trunk/pretty-pinterest-pins.php

    r492514 r501488  
    151151                    $rss_pin_description = $item->get_description();             
    152152                    preg_match('/<img[^>]+>/i', $rss_pin_description, $pin_image);  
    153                     $pin_caption = wp_trim_words( strip_tags( $rss_pin_description ), 35 ); 
     153                    $pin_caption = $this->trim_text( strip_tags( $rss_pin_description ), 400 ); 
    154154                    ?> 
    155155                <li class="pretty-pinterest-pin"> 
     
    185185        return $rss_items; 
    186186    } 
     187     
     188    function trim_text( $text, $length ) { 
     189        //strip html 
     190        $text = strip_tags( $text );       
     191        //no need to trim if its shorter than length 
     192        if (strlen($text) <= $length) { 
     193            return $text; 
     194        }        
     195        $last_space = strrpos( substr( $text, 0, $length ), ' '); 
     196        $trimmed_text = substr( $text, 0, $last_space );         
     197        $trimmed_text .= '...';    
     198        return $trimmed_text; 
     199    } 
     200 
    187201 
    188202} 
  • pretty-pinterest-pins/trunk/readme.txt

    r492514 r501488  
    5656== Changelog == 
    5757 
     58= 1.1 = 
     59* Fixes text trim for older versions of Wordpress. 
     60 
    5861= 1.0 = 
    5962* Initial version 
     
    6164== Upgrade Notice == 
    6265 
    63 = 1.0 = 
    64 Enjoy! 
     66= 1.1 = 
Note: See TracChangeset for help on using the changeset viewer.