Blog

  • WordPress latest twitter sidebar widget

    wordpress-twitter-widgetDiscontinued! This plugin is dead, details here.

    I made a WordPress widget to display latest Twitter updates for any Twitter user in a WordPress website’s sidebar. A widget is activated just like a plugin on any “widget ready” theme and can be positioned within the sidebar using the drag and drop Widgets page in the Administration Dashboard.

    • Links @usernames, #hashtags and URLs
    • Displays up to 20 twitter updates
    • Works for any username with public tweets
    • Does not require twitter password
    • CSS friendly element IDs

    Requirements to run

    • WordPress version 3.0.0 minimum (MySQL 5 + PHP5)
    • json extension for PHP

    This project is based on some code written by Ryan Barr. I added some sauce and already have a nice idea of where the next version will progress. Thanks for introducing me to the twitter API, Ryan.

    PHP5 required

    This will be the last version of this plugin that runs uses PHP4’s DOMXML object. All future versions published to this plugin’s page on the WordPress Plugin Directory will be PHP5 only. Click here to download the last PHP4 compatible build from my server, version 0.100210 of this plugin.

  • PHP4 Friendly htmlspecialchars_decode

    I needed to use the PHP function htmlspecialchars_decode( ) for a WordPress widget I am making. This function is built into PHP versions 5.1.0 and greater and is used to convert special HTML entities to characters. As defined, htmlspecialchars_decode( ) is the opposite of htmlspecialchars( ). Someone named Thomas commented on the PHP man page to point out a flaw in the definition. He also provides some code, which I have only modified slightly below to check function_exists( ).

    
    if ( !function_exists('htmlspecialchars_decode') ){
        function htmlspecialchars_decode($string,$style=ENT_COMPAT)
        {
            $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS,$style));
            if($style === ENT_QUOTES){ $translation['''] = '\''; }
            return strtr($string,$translation);
        }
    }