css
4 years ago
images
12 years ago
img
13 years ago
js
4 years ago
archiveorg-book.php
4 years ago
archiveorg.php
4 years ago
archives.php
5 years ago
bandcamp.php
5 years ago
brightcove.php
5 years ago
cartodb.php
5 years ago
class.filter-embedded-html-objects.php
5 years ago
codepen.php
5 years ago
crowdsignal.php
5 years ago
dailymotion.php
4 years ago
descript.php
4 years ago
facebook.php
5 years ago
flatio.php
5 years ago
flickr.php
5 years ago
getty.php
5 years ago
gist.php
5 years ago
googleapps.php
5 years ago
googlemaps.php
5 years ago
googleplus.php
5 years ago
gravatar.php
5 years ago
houzz.php
5 years ago
inline-pdfs.php
4 years ago
instagram.php
4 years ago
kickstarter.php
5 years ago
mailchimp.php
5 years ago
medium.php
5 years ago
mixcloud.php
5 years ago
others.php
5 years ago
pinterest.php
5 years ago
presentations.php
5 years ago
quiz.php
4 years ago
recipe.php
5 years ago
scribd.php
5 years ago
sitemap.php
5 years ago
slideshare.php
5 years ago
slideshow.php
4 years ago
smartframe.php
4 years ago
soundcloud.php
4 years ago
spotify.php
4 years ago
ted.php
5 years ago
tweet.php
5 years ago
twitchtv.php
5 years ago
twitter-timeline.php
5 years ago
unavailable.php
4 years ago
untappd-menu.php
5 years ago
upcoming-events.php
5 years ago
ustream.php
5 years ago
videopress.php
5 years ago
vimeo.php
4 years ago
vine.php
5 years ago
vr.php
4 years ago
wordads.php
5 years ago
wufoo.php
4 years ago
youtube.php
4 years ago
ustream.php
136 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Ustream.tv shortcode |
| 4 | * |
| 5 | * Example: |
| 6 | * [ustream id=1524 live=1] |
| 7 | * [ustreamsocial id=12980237 width="500"] |
| 8 | * |
| 9 | * Embed code example, from http://www.ustream.tv/leolaporte |
| 10 | * <iframe src="http://www.ustream.tv/embed/recorded/1524?v=3&wmode=direct" width="480" height="296" scrolling="no" frameborder="0" style="border: 0 none transparent;"></iframe> |
| 11 | * |
| 12 | * @package automattic/jetpack |
| 13 | */ |
| 14 | |
| 15 | add_shortcode( 'ustream', 'ustream_shortcode' ); |
| 16 | add_shortcode( 'ustreamsocial', 'ustreamsocial_shortcode' ); |
| 17 | |
| 18 | /** |
| 19 | * Parse shortcode arguments and render output for ustream single video. |
| 20 | * |
| 21 | * @since 4.5.0 |
| 22 | * |
| 23 | * @param array $atts array of user-supplied arguments. |
| 24 | * |
| 25 | * @return string HTML output. |
| 26 | */ |
| 27 | function ustream_shortcode( $atts ) { |
| 28 | if ( isset( $atts[0] ) ) { |
| 29 | return '<!-- ustream error: bad parameters -->'; |
| 30 | } |
| 31 | |
| 32 | $defaults = array( |
| 33 | 'width' => 480, |
| 34 | 'height' => 296, |
| 35 | 'id' => 0, |
| 36 | 'live' => 0, |
| 37 | 'highlight' => 0, |
| 38 | 'version' => 3, |
| 39 | 'hwaccel' => 1, |
| 40 | ); |
| 41 | $atts = array_map( 'intval', shortcode_atts( $defaults, $atts ) ); |
| 42 | |
| 43 | if ( 0 >= $atts['id'] ) { |
| 44 | return '<!-- ustream error: bad video ID -->'; |
| 45 | } |
| 46 | |
| 47 | if ( 0 >= $atts['height'] ) { |
| 48 | return '<!-- ustream error: height invalid -->'; |
| 49 | } |
| 50 | |
| 51 | if ( 0 >= $atts['width'] ) { |
| 52 | return '<!-- ustream error: width invalid -->'; |
| 53 | } |
| 54 | |
| 55 | if ( $atts['live'] ) { |
| 56 | $recorded = ''; |
| 57 | } else { |
| 58 | $recorded = 'recorded/'; |
| 59 | } |
| 60 | |
| 61 | if ( ! $atts['live'] && ( 0 < $atts['highlight'] ) ) { |
| 62 | $highlight = sprintf( '/highlight/%d', esc_attr( $atts['highlight'] ) ); |
| 63 | } else { |
| 64 | $highlight = ''; |
| 65 | } |
| 66 | |
| 67 | $url_base = sprintf( |
| 68 | 'https://www.ustream.tv/embed/%s%d%s', |
| 69 | $recorded, |
| 70 | esc_attr( $atts['id'] ), |
| 71 | $highlight |
| 72 | ); |
| 73 | |
| 74 | $video_options = array( |
| 75 | 'html5ui' => 1, |
| 76 | 'v' => absint( $atts['version'] ), |
| 77 | ); |
| 78 | |
| 79 | if ( 0 < $atts['hwaccel'] ) { |
| 80 | $video_options['wmode'] = 'direct'; |
| 81 | } |
| 82 | |
| 83 | $url = add_query_arg( |
| 84 | $video_options, |
| 85 | $url_base |
| 86 | ); |
| 87 | |
| 88 | $output = sprintf( |
| 89 | '<iframe src="%1$s" width="%2$d" height="%3$d" scrolling="no" style="border: 0 none transparent;"></iframe>', |
| 90 | esc_url( $url ), |
| 91 | absint( $atts['width'] ), |
| 92 | absint( $atts['height'] ) |
| 93 | ); |
| 94 | |
| 95 | return $output; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Parse shortcode arguments and render output for ustream's Social Stream. |
| 100 | * |
| 101 | * @since 4.5.0 |
| 102 | * |
| 103 | * @param array $atts array of user-supplied arguments. |
| 104 | * |
| 105 | * @return string HTML output. |
| 106 | */ |
| 107 | function ustreamsocial_shortcode( $atts ) { |
| 108 | $defaults = array( |
| 109 | 'id' => 0, |
| 110 | 'height' => 420, |
| 111 | 'width' => 320, |
| 112 | ); |
| 113 | $atts = array_map( 'intval', shortcode_atts( $defaults, $atts ) ); |
| 114 | |
| 115 | if ( 0 >= $atts['id'] ) { |
| 116 | return '<!-- ustreamsocial error: bad social stream ID -->'; |
| 117 | } |
| 118 | |
| 119 | if ( 0 >= $atts['height'] ) { |
| 120 | return '<!-- ustreamsocial error: height invalid -->'; |
| 121 | } |
| 122 | |
| 123 | if ( 0 >= $atts['width'] ) { |
| 124 | return '<!-- ustreamsocial error: width invalid -->'; |
| 125 | } |
| 126 | |
| 127 | $url = 'https://www.ustream.tv/socialstream/' . esc_attr( $atts['id'] ); |
| 128 | |
| 129 | return sprintf( |
| 130 | '<iframe id="SocialStream" src="%1$s" class="" name="SocialStream" width="%2$d" height="%3$d" scrolling="no" allowtransparency="true" style="visibility: visible; margin-top: 0; margin-bottom: 0; border: 0;"></iframe>', |
| 131 | esc_url( $url ), |
| 132 | absint( $atts['width'] ), |
| 133 | absint( $atts['height'] ) |
| 134 | ); |
| 135 | } |
| 136 |