PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 6.2
Jetpack – WP Security, Backup, Speed, & Growth v6.2
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / modules / shortcodes / ustream.php

ustream.php in Jetpack – WP Security, Backup, Speed, & Growth 6.2, at modules/shortcodes/ustream.php

128 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * ustream.tv shortcode
5 *
6 * Example:
7 * [ustream id=1524 live=1]
8 * [ustreamsocial id=12980237 width="500"]
9 *
10 * Embed code example, from http://www.ustream.tv/leolaporte
11 * <iframe src="http://www.ustream.tv/embed/recorded/1524?v=3&#038;wmode=direct" width="480" height="296" scrolling="no" frameborder="0" style="border: 0 none transparent;"></iframe>
12 */
13
14 add_shortcode( 'ustream', 'ustream_shortcode' );
15 add_shortcode( 'ustreamsocial', 'ustreamsocial_shortcode' );
16
17 /**
18 * Parse shortcode arguments and render output for ustream single video.
19 *
20 * @since 4.5.0
21 *
22 * @param $atts array of user-supplied arguments.
23 *
24 * @return string HTML output.
25 */
26 function ustream_shortcode( $atts ) {
27 if ( isset( $atts[0] ) ) {
28 return '<!-- ustream error: bad parameters -->';
29 }
30
31 $defaults = array(
32 'width' => 480,
33 'height' => 296,
34 'id' => 0,
35 'live' => 0,
36 'highlight' => 0,
37 'version' => 3,
38 'hwaccel' => 1,
39 );
40
41 $atts = array_map( 'intval', shortcode_atts( $defaults, $atts ) );
42
43 $ustream_id = $atts['id'];
44 $width = $atts['width'];
45 $height = $atts['height'];
46 $live = $atts['live'];
47 $highlight = $atts['highlight'];
48 $version = $atts['version'];
49 $hwaccel = $atts['hwaccel'];
50
51 $version = 'v=' . esc_attr( $version );
52
53 if ( 0 >= $ustream_id ) {
54 return '<!-- ustream error: bad video ID -->';
55 }
56
57 if ( 0 >= $height ) {
58 return '<!-- ustream error: height invalid -->';
59 }
60
61 if ( 0 >= $width ) {
62 return '<!-- ustream error: width invalid -->';
63 }
64
65 if ( $live ) {
66 $recorded = '';
67 } else {
68 $recorded = 'recorded/';
69 }
70
71 if ( ! $live && ( 0 < $highlight ) ) {
72 $highlight = "/highlight/$highlight";
73 } else {
74 $highlight = '';
75 }
76
77 if ( 0 < $hwaccel ) {
78 $wmode = '&amp;wmode=direct';
79 } else {
80 $wmode = '';
81 }
82
83 $url = 'http://www.ustream.tv/embed/' . $recorded . esc_attr( $ustream_id ) . $highlight . '?' . $version . $wmode;
84 $url = set_url_scheme( $url );
85 $output = '<iframe src="' . esc_url( $url ) . '" width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" scrolling="no" style="border: 0 none transparent;"></iframe>';
86
87 return $output;
88 }
89
90 /**
91 * Parse shortcode arguments and render output for ustream's Social Stream.
92 *
93 * @since 4.5.0
94 *
95 * @param $atts array of user-supplied arguments.
96 *
97 * @return string HTML output.
98 */
99 function ustreamsocial_shortcode( $atts ) {
100 $defaults = array(
101 'id' => 0,
102 'height' => 420,
103 'width' => 320,
104 );
105
106 $atts = array_map( 'intval', shortcode_atts( $defaults, $atts ) );
107
108 $ustream_id = $atts['id'];
109 $width = $atts['width'];
110 $height = $atts['height'];
111
112 if ( 0 >= $ustream_id ) {
113 return '<!-- ustreamsocial error: bad social stream ID -->';
114 }
115
116 if ( 0 >= $height ) {
117 return '<!-- ustreamsocial error: height invalid -->';
118 }
119
120 if ( 0 >= $width ) {
121 return '<!-- ustreamsocial error: width invalid -->';
122 }
123
124 $url = set_url_scheme( "http://www.ustream.tv/socialstream/$ustream_id" );
125
126 return '<iframe id="SocialStream" class="" name="SocialStream" width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" scrolling="no" allowtransparency="true" src="' . esc_url( $url ) . '" style="visibility: visible; margin-top: 0; margin-bottom: 0; border: 0;"></iframe>';
127 }
128