PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 12.2
Jetpack – WP Security, Backup, Speed, & Growth v12.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 12.2, at modules/shortcodes/ustream.php

136 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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&#038;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