Skip to content

Instantly share code, notes, and snippets.

@cogdog
Created February 28, 2017 19:36
Show Gist options
  • Save cogdog/6727cdec1346338318b5e9562fb8a81e to your computer and use it in GitHub Desktop.
Save cogdog/6727cdec1346338318b5e9562fb8a81e to your computer and use it in GitHub Desktop.
Timebuddy Shortcode for Wordpress multisite
/* ----- shortcode to time buddy widget -------- */
add_shortcode("timebuddy", "do_timebuddy");
function do_timebuddy ( $atts ) {
// generate a Timebuddy widget because WP strips script tags
extract( shortcode_atts( array( "params" => ""), $atts ) );
if ( empty( $params ) ) {
return "Missing parameter! set <code>params=\"xxxxx\" from the Timebuddy generated embed code for <code>src=\"</code> e.g. <code>params=\"h=2643743&md=2/24/2017&mt=19.50&ml=1.00&sts=0&sln=0&wt=ew-ltc\"</code> after the \"?\"";
} else {
return '<p><span class="wtb-ew-v1" style="width: 560px; display:inline-block"><script src="http://www.worldtimebuddy.com/event_widget.js?' . $params . '"></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></p>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment