Skip to content

Instantly share code, notes, and snippets.

@RyanBayne
Last active December 15, 2018 20:58
Show Gist options
  • Save RyanBayne/abcc5a0a369a4352080990527974c4a5 to your computer and use it in GitHub Desktop.
Save RyanBayne/abcc5a0a369a4352080990527974c4a5 to your computer and use it in GitHub Desktop.
TwitchPress Shortcode Template
function twitchpress_SHORTCODE_NAME_shortcode( $atts ) {
$html_output = '';
$atts = shortcode_atts( array(
'PARAM' => VALUE,
), $atts, 'twitchpress_SHORTCODE_NAME' );
$transient_code = $atts['PARAM'];
if( $cache = get_transient( 'twitchpress_SHORTCODE_NAME' . $transient_code ) ) {
return $cache;
}
// Get the stream.
$helix = new TWITCHPRESS_Twitch_API();
$result = $helix->CALLMETHOD
if( $result )
{
$html_output .= '<ol>';
foreach( $result->data as $key => $item )
{
$html_output .= '<li>';
$html_output .= $item->id;
$html_output .= '</li>';
}
$html_output .= '</ol>';
}
set_transient( 'twitchpress_SHORTCODE_NAME' . $transient_code, $html_output, 86400 );
return $html_output;
}
add_shortcode( 'twitchpress_SHORTCODE_NAME', 'twitchpress_SHORTCODE_NAME_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment