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.9 11.9.1 11.9.2 11.9.3 12.0 12.0.1 12.0.2 12.1 12.1.1 12.1.2 12.2 12.2.1 12.2.2 12.3 12.3.1 12.4 12.4.1 12.5 12.5.1 12.6 12.6.1 12.6.2 12.6.3 12.7 12.7.1 12.7.2 12.8 12.8.1 12.8.2 12.9 12.9.1 12.9.2 12.9.3 12.9.4 13.0 13.0.1 13.1 13.1.1 13.1.2 13.1.3 13.1.4 13.2 13.2.1 13.2.2 13.2.3 13.3 13.3.1 13.3.2 13.4 13.4.1 13.4.2 13.4.3 13.4.4 13.5 13.5.1 13.6 13.6.1 13.7 13.7.1 13.8 13.8.1 13.8.2 13.9 13.9.1 14.0 14.1 14.2 14.2.1 14.3 14.4 14.4.1 14.5 14.6 14.7 14.8 14.9 14.9.1 15.0 15.0.1 15.0.2 15.1 15.1.1 15.2 15.3 15.3.1 15.4 15.5 15.6 15.7 15.7-a.1 15.7-a.3 15.7-a.5 15.7-a.7 15.7-beta
jetpack / modules / shortcodes / dailymotion.php
jetpack / modules / shortcodes Last commit date
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
dailymotion.php
386 lines
1 <?php
2 /**
3 * Dailymotion code
4 *
5 * @package automattic/jetpack
6 */
7
8 /**
9 * Original codes:
10 *
11 * <embed height="270" type="application/x-shockwave-flash" width="480" src="http&#58;//www.dailymotion.com/swf/video/xekmrq?additionalInfos=0" wmode="opaque" pluginspage="http&#58;//www.macromedia.com/go/getflashplayer" allowscriptaccess="never" allownetworking="internal" />
12 *
13 * <object width="480" height="240"><param name="movie" value="http://www.dailymotion.com/swf/video/xen4ms_ghinzu-cold-love-mirror-mirror_music?additionalInfos=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param>
14 * <embed type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/video/xen4ms_ghinzu-cold-love-mirror-mirror_music?additionalInfos=0" width="480" height="240" allowfullscreen="true" allowscriptaccess="always"></embed>
15 * </object><br /><b><a href="http://www.dailymotion.com/video/xen4ms_ghinzu-cold-love-mirror-mirror_music">Ghinzu - Cold Love (Mirror Mirror)</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/GhinzuTV">GhinzuTV</a>. - <a href="http://www.dailymotion.com/us/channel/music">Watch more music videos, in HD!</a></i>
16 *
17 * Code as of 01.01.11:
18 * <object width="560" height="421"><param name="movie" value="http://www.dailymotion.com/swf/video/xaose5?width=560&theme=denim&foreground=%2392ADE0&highlight=%23A2ACBF&background=%23202226&start=&animatedTitle=&iframe=0&additionalInfos=0&autoPlay=0&hideInfos=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/video/xaose5?width=560&theme=denim&foreground=%2392ADE0&highlight=%23A2ACBF&background=%23202226&start=&animatedTitle=&iframe=0&additionalInfos=0&autoPlay=0&hideInfos=0" width="560" height="421" allowfullscreen="true" allowscriptaccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x29zm17_funny-videos-of-cats-and-babies-compilation-2015_fun">Funny cats and babies!</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/GilLavie">GilLavie</a>. - <a target="_self" href="http://www.dailymotion.com/channel/funny/featured/1">Find more funny videos.</a></i>
19 * movie param enforces anti-xss protection
20 *
21 * Scroll down for the new <iframe> embed code handler.
22 *
23 * @param string $content Post content.
24 */
25 function dailymotion_embed_to_shortcode( $content ) {
26 if ( ! is_string( $content ) || false === stripos( $content, 'www.dailymotion.com/swf/' ) ) {
27 return $content;
28 }
29
30 $regexp = '!<object.*>\s*(<param.*></param>\s*)*<embed((?:\s+\w+="[^"]*")*)\s+src="http(?:\:|&#0*58;)//(www\.dailymotion\.com/swf/[^"]*)"((?:\s+\w+="[^"]*")*)\s*(?:/>|>\s*</embed>)\s*</object><br /><b><a .*>.*</a></b><br /><i>.*</i>!';
31 $regexp_ent = str_replace( '&amp;#0*58;', '&amp;#0*58;|&#0*58;', htmlspecialchars( $regexp, ENT_NOQUOTES ) );
32
33 foreach ( compact( 'regexp', 'regexp_ent' ) as $reg => $regexp ) {
34 if ( ! preg_match_all( $regexp, $content, $matches, PREG_SET_ORDER ) ) {
35 continue;
36 }
37
38 foreach ( $matches as $match ) {
39 $src = html_entity_decode( $match[3] );
40 $params = $match[2] . $match[4];
41
42 if ( 'regexp_ent' === $reg ) {
43 $src = html_entity_decode( $src );
44 $params = html_entity_decode( $params );
45 }
46
47 $params = wp_kses_hair( $params, array( 'http' ) );
48
49 if ( ! isset( $params['type'] ) || 'application/x-shockwave-flash' !== $params['type']['value'] ) {
50 continue;
51 }
52
53 $id = basename( substr( $src, strlen( 'www.dailymotion.com/swf' ) ) );
54 $id = preg_replace( '/[^a-z0-9].*$/is', '', $id );
55
56 $content = str_replace( $match[0], "[dailymotion id=$id]", $content );
57 /** This action is documented in modules/shortcodes/youtube.php */
58 do_action( 'jetpack_embed_to_shortcode', 'dailymotion', $id );
59 }
60 }
61 return $content;
62 }
63 add_filter( 'pre_kses', 'dailymotion_embed_to_shortcode' );
64
65 /**
66 * DailyMotion shortcode
67 *
68 * The documented shortcode is:
69 * [dailymotion id=x8oma9]
70 *
71 * Possibilities, according to the old parsing regexp:
72 * [dailymotion x8oma9]
73 * [dailymotion=x8oma9]
74 *
75 * Hypothetical option, according to the old shortcode function is
76 * [dailymotion id=1&title=2&user=3&video=4]
77 *
78 * The new style is now:
79 * [dailymotion id=x8oma9 title=2 user=3 video=4]
80 *
81 * Supported parameters for player customization: width, height,
82 * autoplay, endscreen-enable, mute, sharing-enabled, start, subtitles-default,
83 * ui-highlight, ui-logo, ui-start-screen-info, ui-theme
84 * see https://developer.dailymotion.com/player#player-parameters
85 *
86 * @todo: Update code to sniff for iframe embeds and convert those to shortcodes.
87 *
88 * @param array $atts Shortcode attributes.
89 *
90 * @return string html
91 */
92 function dailymotion_shortcode( $atts ) {
93 global $content_width;
94
95 if ( isset( $atts[0] ) ) {
96 $id = ltrim( $atts[0], '=' );
97 $atts['id'] = $id;
98
99 } else {
100 $params = shortcode_new_to_old_params( $atts );
101 parse_str( $params, $atts_new );
102
103 foreach ( $atts_new as $k => $v ) {
104 $atts[ $k ] = $v;
105 }
106 }
107
108 $atts = shortcode_atts(
109 array(
110 'id' => '', // string.
111 'width' => '', // int.
112 'height' => '', // int.
113 'title' => '', // string.
114 'user' => '', // string.
115 'video' => '', // string.
116 'autoplay' => 0, // int.
117 'endscreen-enable' => 1, // int.
118 'mute' => 0, // int.
119 'sharing-enable' => 1, // int.
120 'start' => '', // int.
121 'subtitles-default' => '', // string.
122 'ui-highlight' => '', // string.
123 'ui-logo' => 1, // int.
124 'ui-start-screen-info' => 0, // int.
125 'ui-theme' => '', // string.
126 ),
127 $atts,
128 'dailymotion'
129 );
130
131 if ( isset( $atts['id'] ) && ! empty( $atts['id'] ) ) {
132 $id = rawurlencode( $atts['id'] );
133 } else {
134 return '<!--Dailymotion error: bad or missing ID-->';
135 }
136
137 /*set width and height using provided parameters if any */
138 $width = isset( $atts['width'] ) ? (int) $atts['width'] : 0;
139 $height = isset( $atts['height'] ) ? (int) $atts['height'] : 0;
140
141 if ( ! $width && ! $height ) {
142 if ( ! empty( $content_width ) ) {
143 $width = absint( $content_width );
144 } else {
145 $width = 425;
146 }
147 $height = $width / 425 * 334;
148 } elseif ( ! $height ) {
149 $height = $width / 425 * 334;
150 } elseif ( ! $width ) {
151 $width = $height / 334 * 425;
152 }
153
154 if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
155 return sprintf(
156 '<amp-dailymotion data-videoid="%1$s" layout="responsive" width="%2$d" height="%3$d"></amp-dailymotion>',
157 esc_attr( $id ),
158 absint( $width ),
159 absint( $height )
160 );
161 }
162
163 /**
164 * Let's add parameters if needed.
165 *
166 * @see https://developer.dailymotion.com/player
167 */
168 $player_params = array();
169
170 if ( isset( $atts['autoplay'] ) && '1' === $atts['autoplay'] ) {
171 $player_params['autoplay'] = '1';
172 }
173 if ( isset( $atts['endscreen-enable'] ) && '0' === $atts['endscreen-enable'] ) {
174 $player_params['endscreen-enable'] = '0';
175 }
176 if ( isset( $atts['mute'] ) && '1' === $atts['mute'] ) {
177 $player_params['mute'] = '1';
178 }
179 if ( isset( $atts['sharing-enable'] ) && '0' === $atts['sharing-enable'] ) {
180 $player_params['sharing-enable'] = '0';
181 }
182 if ( isset( $atts['start'] ) && ! empty( $atts['start'] ) ) {
183 $player_params['start'] = abs( (int) $atts['start'] );
184 }
185 if ( isset( $atts['subtitles-default'] ) && ! empty( $atts['subtitles-default'] ) ) {
186 $player_params['subtitles-default'] = esc_attr( $atts['subtitles-default'] );
187 }
188 if ( isset( $atts['ui-highlight'] ) && ! empty( $atts['ui-highlight'] ) ) {
189 $player_params['ui-highlight'] = esc_attr( $atts['ui-highlight'] );
190 }
191 if ( isset( $atts['ui-logo'] ) && '0' === $atts['ui-logo'] ) {
192 $player_params['ui-logo'] = '0';
193 }
194 if ( isset( $atts['ui-start-screen-info'] ) && '0' === $atts['ui-start-screen-info'] ) {
195 $player_params['ui-start-screen-info'] = '0';
196 }
197 if ( isset( $atts['ui-theme'] ) && in_array( strtolower( $atts['ui-theme'] ), array( 'dark', 'light' ), true ) ) {
198 $player_params['ui-theme'] = esc_attr( $atts['ui-theme'] );
199 }
200
201 // Add those parameters to the Video URL.
202 $video_url = add_query_arg(
203 $player_params,
204 'https://www.dailymotion.com/embed/video/' . $id
205 );
206
207 $output = '';
208
209 if ( preg_match( '/^[A-Za-z0-9]+$/', $id ) ) {
210 $output .= '<iframe width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" src="' . esc_url( $video_url ) . '" style="border:0;" allowfullscreen></iframe>';
211
212 $video = preg_replace( '/[^-a-z0-9_]/i', '', $atts['video'] );
213 $title = wp_kses( $atts['title'], array() );
214 if (
215 array_key_exists( 'video', $atts )
216 && $video
217 && array_key_exists( 'title', $atts )
218 && $title
219 ) {
220 $output .= '<br /><strong><a href="' . esc_url( 'https://www.dailymotion.com/video/' . $video ) . '" target="_blank">' . esc_html( $title ) . '</a></strong>';
221 }
222
223 $user = preg_replace( '/[^-a-z0-9_]/i', '', $atts['user'] );
224 if ( array_key_exists( 'user', $atts ) && $user ) {
225 /* translators: %s is a Dailymotion user name */
226 $output .= '<br /><em>' . wp_kses(
227 sprintf(
228 /* Translators: placeholder is a Dailymotion username, linking to a Dailymotion profile page. */
229 __( 'Uploaded by %s', 'jetpack' ),
230 '<a href="' . esc_url( 'https://www.dailymotion.com/' . $user ) . '" target="_blank">' . esc_html( $user ) . '</a>'
231 ),
232 array(
233 'a' => array(
234 'href' => true,
235 'target' => true,
236 ),
237 )
238 ) . '</em>';
239 }
240 }
241
242 /**
243 * Calypso Helper
244 *
245 * Makes shortcode output responsive to the location it is loaded:
246 * Notifications, Reader, Email
247 */
248 if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
249 require_once WP_CONTENT_DIR . '/lib/display-context.php';
250 $context = A8C\Display_Context\get_current_context();
251
252 // Notifications.
253 if ( A8C\Display_Context\NOTIFICATIONS === $context ) {
254 return sprintf(
255 '<a href="%1$s" target="_blank" rel="noopener noreferrer">%1$s</a>',
256 esc_url( 'https://www.dailymotion.com/video/' . $id )
257 );
258 }
259 }
260
261 return $output;
262 }
263 add_shortcode( 'dailymotion', 'dailymotion_shortcode' );
264
265 /**
266 * DailyMotion Channel Shortcode
267 *
268 * Examples:
269 * [dailymotion-channel user=MatthewDominick]
270 * [dailymotion-channel user=MatthewDominick type=grid] (supports grid, carousel, badge/default)
271 *
272 * @param array $atts Shortcode attributes.
273 */
274 function dailymotion_channel_shortcode( $atts ) {
275 $username = $atts['user'];
276
277 switch ( $atts['type'] ) {
278 case 'grid':
279 $channel_iframe = '<iframe sandbox="allow-popups allow-scripts allow-same-origin allow-presentation" width="300px" height="264px" scrolling="no" style="border:0;" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username . '?type=grid' ) . '"></iframe>';
280 break;
281 case 'carousel':
282 $channel_iframe = '<iframe sandbox="allow-popups allow-scripts allow-same-origin allow-presentation" width="300px" height="360px" scrolling="no" style="border:0;" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username . '?type=carousel' ) . '"></iframe>';
283 break;
284 default:
285 $channel_iframe = '<iframe sandbox="allow-popups allow-scripts allow-same-origin allow-presentation" width="300px" height="78px" scrolling="no" style="border:0;" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username ) . '"></iframe>';
286 }
287
288 return $channel_iframe;
289 }
290 add_shortcode( 'dailymotion-channel', 'dailymotion_channel_shortcode' );
291
292 /**
293 * Embed Reversal for Badge/Channel
294 *
295 * @param string $content Post content.
296 */
297 function dailymotion_channel_reversal( $content ) {
298 if ( ! is_string( $content ) || false === stripos( $content, 'dailymotion.com/badge/' ) ) {
299 return $content;
300 }
301
302 /*
303 * Sample embed code:
304 * <iframe width="300px" height="360px" scrolling="no" frameborder="0" src="http://www.dailymotion.com/badge/user/Dailymotion?type=carousel"></iframe>
305 */
306
307 $regexes = array();
308
309 $regexes[] = '#<iframe[^>]+?src=" (?:https?:)?//(?:www\.)?dailymotion\.com/badge/user/([^"\'/]++) "[^>]*+></iframe>#ix';
310
311 // Let's play nice with the visual editor too.
312 $regexes[] = '#&lt;iframe(?:[^&]|&(?!gt;))+?src=" (?:https?:)?//(?:www\.)?dailymotion\.com/badge/user/([^"\'/]++) "(?:[^&]|&(?!gt;))*+&gt;&lt;/iframe&gt;#ix';
313
314 foreach ( $regexes as $regex ) {
315 if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) {
316 continue;
317 }
318
319 foreach ( $matches as $match ) {
320 $url_pieces = wp_parse_url( $match[1] );
321
322 if ( 'type=carousel' === $url_pieces['query'] ) {
323 $type = 'carousel';
324 } elseif ( 'type=grid' === $url_pieces['query'] ) {
325 $type = 'grid';
326 } else {
327 $type = 'badge';
328 }
329
330 $shortcode = '[dailymotion-channel user=' . esc_attr( $url_pieces['path'] ) . ' type=' . esc_attr( $type ) . ']';
331 $replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $match[0], '#' ) );
332 $content = preg_replace( $replace_regex, sprintf( "\n\n%s\n\n", $shortcode ), $content );
333 }
334 }
335
336 return $content;
337 }
338 add_filter( 'pre_kses', 'dailymotion_channel_reversal' );
339
340 /**
341 * Dailymotion Embed Reversal (with new iframe code as of 17.09.2014)
342 *
343 * Converts a generic HTML embed code from Dailymotion into an
344 * oEmbeddable URL.
345 *
346 * @param string $content Post content.
347 */
348 function jetpack_dailymotion_embed_reversal( $content ) {
349 if ( ! is_string( $content ) || false === stripos( $content, 'dailymotion.com/embed' ) ) {
350 return $content;
351 }
352
353 /*
354 * Sample embed code as of Sep 17th 2014:
355 * <iframe frameborder="0" width="480" height="270" src="//www.dailymotion.com/embed/video/x25x71x" allowfullscreen></iframe><br /><a href="http://www.dailymotion.com/video/x25x71x_dog-with-legs-in-casts-learns-how-to-enter-the-front-door_animals" target="_blank">Dog with legs in casts learns how to enter the...</a> <i>by <a href="http://www.dailymotion.com/videobash" target="_blank">videobash</a></i>
356 */
357 $regexes = array();
358
359 // I'm Konstantin and I love regex.
360 $regexes[] = '#<iframe[^>]+?src=" (?:https?:)?//(?:www\.)?dailymotion\.com/embed/video/([^"\'/]++) "[^>]*+>\s*+</iframe>\s*+(?:<br\s*+/>)?\s*+
361 (?: <a[^>]+?href=" (?:https?:)?//(?:www\.)?dailymotion\.com/[^"\']++ "[^>]*+>.+?</a>\s*+ )?
362 (?: <i>.*?<a[^>]+?href=" (?:https?:)?//(?:www\.)?dailymotion\.com/[^"\']++ "[^>]*+>.+?</a>\s*+</i> )?#ix';
363
364 $regexes[] = '#&lt;iframe(?:[^&]|&(?!gt;))+?src=" (?:https?:)?//(?:www\.)?dailymotion\.com/embed/video/([^"\'/]++) "(?:[^&]|&(?!gt;))*+&gt;\s*+&lt;/iframe&gt;\s*+(?:&lt;br\s*+/&gt;)?\s*+
365 (?: &lt;a(?:[^&]|&(?!gt;))+?href=" (?:https?:)?//(?:www\.)?dailymotion\.com/[^"\']++ "(?:[^&]|&(?!gt;))*+&gt;.+?&lt;/a&gt;\s*+ )?
366 (?: &lt;i&gt;.*?&lt;a(?:[^&]|&(?!gt;))+?href=" (?:https?:)?//(?:www\.)?dailymotion\.com/[^"\']++ "(?:[^&]|&(?!gt;))*+&gt;.+?&lt;/a&gt;\s*+&lt;/i&gt; )?#ix';
367
368 foreach ( $regexes as $regex ) {
369 if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) {
370 continue;
371 }
372
373 foreach ( $matches as $match ) {
374 $url = esc_url( sprintf( 'https://dailymotion.com/video/%s', $match[1] ) );
375 $replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $match[0], '#' ) );
376 $content = preg_replace( $replace_regex, sprintf( "\n\n%s\n\n", $url ), $content );
377
378 /** This action is documented in modules/shortcodes/youtube.php */
379 do_action( 'jetpack_embed_to_shortcode', 'dailymotion', $url );
380 }
381 }
382
383 return $content;
384 }
385 add_filter( 'pre_kses', 'jetpack_dailymotion_embed_reversal' );
386