Twitter Digest

Twitter Digest

Andrea was looking for a Twitter digest plugin so that she could start making a permanent backup of her tweets because the twitter API only provides access to the last 3200 tweets. The plugin she asked me to look at was Twitter Digest by Tim Beck. The reason she asked me to look at it was that it the option page did not save the settings in WordPress MU.

To get the plugin options to save, I followed the process I outlined in Writing Plugins (for WP & WPMU). The other two minor changes that I made were:

  • A minor fix with post scheduling - if the digest runs after the publish time in the settings, the post status is publish. If it runs before the publish time, the status is future.
  • Text field options from the settings page are sanitized before saving.

To sanitize the options I added these lines of code to the plugin:


function ws_filter_options( $setting ) {
return wp_specialchars( $setting );
}
foreach( array( 'ws_td_username', 'ws_td_title', 'ws_td_post_tags', 'ws_td_pub_time' ) as $opt ) {
add_filter( 'pre_update_option_' . $opt, 'ws_filter_options' );
}

The thing to bear in mind with the options screens is the options are automatically saved to the options table. If you want to process the option in some way before saving it to the options table, use the pre_update_option_ + option_name filter. This filter hooks the process during the update_option process prior to the option being saved in the object cache or options table.

You can download my version here: [download#17]

4 Comments
  • James D Kirk
    Posted at 23:42h, 11 December Reply

    Hey Ron (and Andrea!) I’ve was easily able to get the plugin installed on a subdomain in my MU install (http://mytweets.boldlygoing.com) with the P2 theme running (thought that was a nice, sparse look and feel.)

    Was wondering however, is there anything other than the %date variable that can be used? I personally like to have my date in the permalink (%year%-%monthnum%-%day%/%postname%/). Since the post name without the date variable is sort of static (http://mytweets.boldlygoing.com/2009-12-11/james-d-kirk-tweeted/) I was hoping to maybe get the weekday name or something like that inserted into the permalink. Thoughts? And thanks!

    • James D Kirk
      Posted at 23:46h, 11 December Reply

      I guess I could just use one of the Structure tags (http://codex.wordpress.org/Using_Permalinks) and add it to my permalink structure to make each post title more unique, yeah? Perhaps the %post_id% might be a good choice…

      TIA!

    • Ron
      Posted at 00:29h, 14 December Reply

      I’ll have to look. I didn’t write the plugin, I just edited it and tweaked a few things.

      I’ve done this type of thing with a lot of plugins over the last 4-5 years, so I know what to look for in the plugin and in most instances, I don’t have to know specifically what all the plugin does.

  • mwaterous
    Posted at 21:44h, 14 December Reply

    Me and my wife were just discussing something akin to this the other day. There’s a few twitter plugins for WP that save the entirety of your history (from activation on) without any automatic or configurable way of running a cleanup.

    Easy enough to modify, but it seemed to me like a lot of needless database bloat, which brought up the question; why would you want to save so many? Just pure curiosity, I guess from a business/support perspective I could understand, but from a personal I’m at a loss.

Post A Comment