Latest Updates: function RSS

  • maryann 12:45 pm on July 3, 2009 | 0 Permalink | Reply
    Tags: function,

    Get post slug – http://wordpress.org/support/topic/128046?replies=6

     
  • maryann 9:16 pm on June 30, 2009 | 0 Permalink | Reply
    Tags: function,

    Relative dates – http://blog.ninedays.org/2008/06/23/relative-dates-in-wordpress-templates/

     
  • Get Twitter avatars in comments

    maryann 8:57 pm on June 30, 2009 | 0 Permalink | Reply
    Tags: function, ,

    Get function – http://is.gd/CYUB

    <?php twittar('45', 'default.png', '#e9e9e9', 'twitavatars', 1, 'G'); ?>

     
  • Get Twitter followers count

    maryann 8:55 pm on June 30, 2009 | 0 Permalink | Reply
    Tags: function, ,

    function string_getInsertedString($long_string,$short_string,$is_html=false){  
      if($short_string>=strlen($long_string))return false;  
      $insertion_length=strlen($long_string)-strlen($short_string);  
      for($i=0;$i<strlen ($short_string);++$i){  
        if($long_string[$i]!=$short_string[$i])break;  
      }  
      $inserted_string=substr($long_string,$i,$insertion_length);  
      if($is_html && $inserted_string[$insertion_length-1]=='<'){  
        $inserted_string='<'.substr($inserted_string,0,$insertion_length-1);  
      }  
      return $inserted_string;  
    }  
      
    function DOMElement_getOuterHTML($document,$element){  
      $html=$document->saveHTML();  
      $element->parentNode->removeChild($element);  
      $html2=$document->saveHTML();  
      return string_getInsertedString($html,$html2,true);  
    }  
      
    function getFollowers($username){  
      $x = file_get_contents("http://twitter.com/".$username);  
      $doc = new DomDocument;  
      @$doc->loadHTML($x);  
      $ele = $doc->getElementById('follower_count');  
      $innerHTML=preg_replace('/^< [^>]*>(.*)< [^>]*>$/',"1",DOMElement_getOuterHTML($doc,$ele));  
      return $innerHTML;  
    }  

    <?php echo getFollowers("instantshift")." followers"; ?>  

     
  • Add TinyURL to post

    maryann 8:43 pm on June 30, 2009 | 0 Permalink | Reply
    Tags: function, tinyurl, ,

    function getTinyUrl($url) {  
      $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);  
      return $tinyurl;  
    }  

    Add this to theme:

    <?php  
      $turl = getTinyUrl(get_permalink($post->ID));  
      echo 'Tiny Url for this post: <a href="'.$turl.'">'.$turl.'</a>'  
    ?> 

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
esc
cancel