I had a need. A need for timezones. I happened to post about an event happening at 2pm ET, under the mistaken assumption that people knew how to convert timezones, or at least go to a website for it. Instead, after a weekend full of emails and me snapping at them for being under educated (don’t schools teach this stuff anymore?) I linked them to a page.
Then I thought “Well heck, they won’t click that. Why not embed it.” Alas, TimeAndDate.com didn’t let you embed, but worldtimebuddy.com does. With a hat tip to Rarst for the link, I pulled this shortcode out:
// World Time Buddy Event Time // Usage: [eventtime time="14:00" length="1" date="2/20/2013" tz="ET"] function eventtime_func( $atts ) { extract( shortcode_atts( array( 'time' => '14:00', 'length' => '1', 'date' => '2/20/2013', 'tz' => 'ET', ), $atts ) ); if ( $tz == 'ET') $timezone = '5128581'; if ( $tz == 'PT') $timezone = '5368361'; return '<span class="wtb-ew-v1" style="width: 560px; display:inline-block;padding-bottom:5px;"><script src="http://www.worldtimebuddy.com/event_widget.js?h='.$timezone.'&md='.$date.'&mt='.$time.'&ml='.$length.'&sts=0&sln=0&wt=ew-lt"></script><i><a target="_blank" href="http://www.worldtimebuddy.com/">Time converter</a> at worldtimebuddy.com</i><noscript><a href="http://www.worldtimebuddy.com/">Time converter</a> at worldtimebuddy.com</noscript><script>window[wtb_event_widgets.pop()].init()</script></span>'; } add_shortcode( 'eventtime', 'eventtime_func' );
I can’t make this a plugin because it has a powered-by link, and while I could remove it, I won’t. If the link was put in by the script itself and not my return, it’d be fine for the repo, but since I’m only going to use this a few times, I’m leaving it be.