Last active
December 15, 2018 20:58
-
-
Save RyanBayne/abcc5a0a369a4352080990527974c4a5 to your computer and use it in GitHub Desktop.
TwitchPress Shortcode Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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