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.6 11.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 2 weeks ago images 1 year ago img 4 weeks ago js 6 months ago archiveorg-book.php 6 months ago archiveorg.php 6 months ago archives.php 2 weeks ago bandcamp.php 6 months ago brightcove.php 5 months ago cartodb.php 6 months ago class.filter-embedded-html-objects.php 6 months ago codepen.php 6 months ago crowdsignal.php 5 months ago dailymotion.php 6 months ago descript.php 6 months ago facebook.php 6 months ago flatio.php 6 months ago flickr.php 5 months ago getty.php 6 months ago gist.php 6 months ago googleapps.php 6 months ago googlemaps.php 3 weeks ago googleplus.php 6 months ago gravatar.php 6 months ago houzz.php 6 months ago inline-pdfs.php 6 months ago instagram.php 6 months ago kickstarter.php 6 months ago mailchimp.php 5 months ago medium.php 6 months ago mixcloud.php 6 months ago others.php 6 months ago pinterest.php 6 months ago presentations.php 6 months ago quiz.php 6 months ago recipe.php 6 months ago scribd.php 6 months ago shortcode-utils.php 6 months ago sitemap.php 6 months ago slideshare.php 6 months ago slideshow.php 4 weeks ago smartframe.php 6 months ago soundcloud.php 6 months ago spotify.php 6 months ago ted.php 6 months ago tweet.php 6 months ago twitchtv.php 6 months ago twitter-timeline.php 6 months ago twitter.php 6 months ago unavailable.php 6 months ago untappd-menu.php 6 months ago upcoming-events.php 6 months ago ustream.php 6 months ago videopress.php 6 months ago vimeo.php 1 week ago vine.php 6 months ago vr.php 1 week ago wufoo.php 6 months ago youtube.php 3 months ago
dailymotion.php
393 lines
1 <?php
2 /**
3 * Dailymotion code
4 *
5 * @package automattic/jetpack
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit( 0 );
10 }
11
12 /**
13 * Original codes:
14 *
15 * <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" />
16 *
17 * <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>
18 * <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>
19 * </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>
20 *
21 * Code as of 01.01.11:
22 * <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>
23 * movie param enforces anti-xss protection
24 *
25 * Scroll down for the new <iframe> embed code handler.
26 *
27 * @param string $content Post content.
28 */
29 function dailymotion_embed_to_shortcode( $content ) {
30 if ( ! is_string( $content ) || false === stripos( $content, 'www.dailymotion.com/swf/' ) ) {
31 return $content;
32 }
33
34 $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>!';
35 $regexp_ent = str_replace( '&amp;#0*58;', '&amp;#0*58;|&#0*58;', htmlspecialchars( $regexp, ENT_NOQUOTES ) );
36
37 foreach ( compact( 'regexp', 'regexp_ent' ) as $reg => $regexp ) {
38 if ( ! preg_match_all( $regexp, $content, $matches, PREG_SET_ORDER ) ) {
39 continue;
40 }
41
42 foreach ( $matches as $match ) {
43 $src = html_entity_decode( $match[3], ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 );
44 $params = $match[2] . $match[4];
45
46 if ( 'regexp_ent' === $reg ) {
47 $src = html_entity_decode( $src, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 );
48 $params = html_entity_decode( $params, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 );
49 }
50
51 $params = wp_kses_hair( $params, array( 'http' ) );
52
53 if ( ! isset( $params['type'] ) || 'application/x-shockwave-flash' !== $params['type']['value'] ) {
54 continue;
55 }
56
57 $id = basename( substr( $src, strlen( 'www.dailymotion.com/swf' ) ) );
58 $id = preg_replace( '/[^a-z0-9].*$/is', '', $id );
59
60 $content = str_replace( $match[0], "[dailymotion id=$id]", $content );
61 /** This action is documented in modules/shortcodes/youtube.php */
62 do_action( 'jetpack_embed_to_shortcode', 'dailymotion', $id );
63 }
64 }
65 return $content;
66 }
67
68 /**
69 * DailyMotion shortcode
70 *
71 * The documented shortcode is:
72 * [dailymotion id=x8oma9]
73 *
74 * Possibilities, according to the old parsing regexp:
75 * [dailymotion x8oma9]
76 * [dailymotion=x8oma9]
77 *
78 * Hypothetical option, according to the old shortcode function is
79 * [dailymotion id=1&title=2&user=3&video=4]
80 *
81 * The new style is now:
82 * [dailymotion id=x8oma9 title=2 user=3 video=4]
83 *
84 * Supported parameters for player customization: width, height,
85 * autoplay, endscreen-enable, mute, sharing-enabled, start, subtitles-default,
86 * ui-highlight, ui-logo, ui-start-screen-info, ui-theme
87 * see https://developer.dailymotion.com/player#player-parameters
88 *
89 * @todo: Update code to sniff for iframe embeds and convert those to shortcodes.
90 *
91 * @param array $atts Shortcode attributes.
92 *
93 * @return string html
94 */
95 function dailymotion_shortcode( $atts ) {
96 global $content_width;
97
98 if ( isset( $atts[0] ) ) {
99 $id = ltrim( $atts[0], '=' );
100 $atts['id'] = $id;
101
102 } else {
103 $params = shortcode_new_to_old_params( $atts );
104 parse_str( $params, $atts_new );
105
106 foreach ( $atts_new as $k => $v ) {
107 $atts[ $k ] = $v;
108 }
109 }
110
111 $atts = shortcode_atts(
112 array(
113 'id' => '', // string.
114 'width' => '', // int.
115 'height' => '', // int.
116 'title' => '', // string.
117 'user' => '', // string.
118 'video' => '', // string.
119 'autoplay' => 0, // int.
120 'endscreen-enable' => 1, // int.
121 'mute' => 0, // int.
122 'sharing-enable' => 1, // int.
123 'start' => '', // int.
124 'subtitles-default' => '', // string.
125 'ui-highlight' => '', // string.
126 'ui-logo' => 1, // int.
127 'ui-start-screen-info' => 0, // int.
128 'ui-theme' => '', // string.
129 ),
130 $atts,
131 'dailymotion'
132 );
133
134 if ( isset( $atts['id'] ) && ! empty( $atts['id'] ) ) {
135 $id = rawurlencode( $atts['id'] );
136 } else {
137 return '<!--Dailymotion error: bad or missing ID-->';
138 }
139
140 /*set width and height using provided parameters if any */
141 $width = isset( $atts['width'] ) ? (int) $atts['width'] : 0;
142 $height = isset( $atts['height'] ) ? (int) $atts['height'] : 0;
143
144 if ( ! $width && ! $height ) {
145 if ( ! empty( $content_width ) ) {
146 $width = absint( $content_width );
147 } else {
148 $width = 425;
149 }
150 $height = $width / 425 * 334;
151 } elseif ( ! $height ) {
152 $height = $width / 425 * 334;
153 } elseif ( ! $width ) {
154 $width = $height / 334 * 425;
155 }
156
157 if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
158 return sprintf(
159 '<amp-dailymotion data-videoid="%1$s" layout="responsive" width="%2$d" height="%3$d"></amp-dailymotion>',
160 esc_attr( $id ),
161 absint( $width ),
162 absint( $height )
163 );
164 }
165
166 /**
167 * Let's add parameters if needed.
168 *
169 * @see https://developer.dailymotion.com/player
170 */
171 $player_params = array();
172
173 if ( isset( $atts['autoplay'] ) && '1' === $atts['autoplay'] ) {
174 $player_params['autoplay'] = '1';
175 }
176 if ( isset( $atts['endscreen-enable'] ) && '0' === $atts['endscreen-enable'] ) {
177 $player_params['endscreen-enable'] = '0';
178 }
179 if ( isset( $atts['mute'] ) && '1' === $atts['mute'] ) {
180 $player_params['mute'] = '1';
181 }
182 if ( isset( $atts['sharing-enable'] ) && '0' === $atts['sharing-enable'] ) {
183 $player_params['sharing-enable'] = '0';
184 }
185 if ( isset( $atts['start'] ) && ! empty( $atts['start'] ) ) {
186 $player_params['start'] = abs( (int) $atts['start'] );
187 }
188 if ( isset( $atts['subtitles-default'] ) && ! empty( $atts['subtitles-default'] ) ) {
189 $player_params['subtitles-default'] = esc_attr( $atts['subtitles-default'] );
190 }
191 if ( isset( $atts['ui-highlight'] ) && ! empty( $atts['ui-highlight'] ) ) {
192 $player_params['ui-highlight'] = esc_attr( $atts['ui-highlight'] );
193 }
194 if ( isset( $atts['ui-logo'] ) && '0' === $atts['ui-logo'] ) {
195 $player_params['ui-logo'] = '0';
196 }
197 if ( isset( $atts['ui-start-screen-info'] ) && '0' === $atts['ui-start-screen-info'] ) {
198 $player_params['ui-start-screen-info'] = '0';
199 }
200 if ( isset( $atts['ui-theme'] ) && in_array( strtolower( $atts['ui-theme'] ), array( 'dark', 'light' ), true ) ) {
201 $player_params['ui-theme'] = esc_attr( $atts['ui-theme'] );
202 }
203
204 // Add those parameters to the Video URL.
205 $video_url = add_query_arg(
206 $player_params,
207 'https://www.dailymotion.com/embed/video/' . $id
208 );
209
210 $output = '';
211
212 if ( preg_match( '/^[A-Za-z0-9]+$/', $id ) ) {
213 $output .= '<iframe width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" src="' . esc_url( $video_url ) . '" style="border:0;" allowfullscreen></iframe>';
214
215 $video = preg_replace( '/[^-a-z0-9_]/i', '', $atts['video'] );
216 $title = wp_kses( $atts['title'], array() );
217 if (
218 array_key_exists( 'video', $atts )
219 && $video
220 && array_key_exists( 'title', $atts )
221 && $title
222 ) {
223 $output .= '<br /><strong><a href="' . esc_url( 'https://www.dailymotion.com/video/' . $video ) . '" target="_blank">' . esc_html( $title ) . '</a></strong>';
224 }
225
226 $user = preg_replace( '/[^-a-z0-9_]/i', '', $atts['user'] );
227 if ( array_key_exists( 'user', $atts ) && $user ) {
228 /* translators: %s is a Dailymotion user name */
229 $output .= '<br /><em>' . wp_kses(
230 sprintf(
231 /* Translators: placeholder is a Dailymotion username, linking to a Dailymotion profile page. */
232 __( 'Uploaded by %s', 'jetpack' ),
233 '<a href="' . esc_url( 'https://www.dailymotion.com/' . $user ) . '" target="_blank">' . esc_html( $user ) . '</a>'
234 ),
235 array(
236 'a' => array(
237 'href' => true,
238 'target' => true,
239 ),
240 )
241 ) . '</em>';
242 }
243 }
244
245 /**
246 * Calypso Helper
247 *
248 * Makes shortcode output responsive to the location it is loaded:
249 * Notifications, Reader, Email
250 */
251 if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
252 require_once WP_CONTENT_DIR . '/lib/display-context.php';
253 $context = A8C\Display_Context\get_current_context();
254
255 // Notifications.
256 if ( A8C\Display_Context\NOTIFICATIONS === $context ) {
257 return sprintf(
258 '<a href="%1$s" target="_blank" rel="noopener noreferrer">%1$s</a>',
259 esc_url( 'https://www.dailymotion.com/video/' . $id )
260 );
261 }
262 }
263
264 return $output;
265 }
266 add_shortcode( 'dailymotion', 'dailymotion_shortcode' );
267
268 /**
269 * DailyMotion Channel Shortcode
270 *
271 * Examples:
272 * [dailymotion-channel user=MatthewDominick]
273 * [dailymotion-channel user=MatthewDominick type=grid] (supports grid, carousel, badge/default)
274 *
275 * @param array $atts Shortcode attributes.
276 */
277 function dailymotion_channel_shortcode( $atts ) {
278 $username = $atts['user'];
279
280 switch ( $atts['type'] ) {
281 case 'grid':
282 $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>';
283 break;
284 case 'carousel':
285 $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>';
286 break;
287 default:
288 $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>';
289 }
290
291 return $channel_iframe;
292 }
293 add_shortcode( 'dailymotion-channel', 'dailymotion_channel_shortcode' );
294
295 /**
296 * Embed Reversal for Badge/Channel
297 *
298 * @param string $content Post content.
299 */
300 function dailymotion_channel_reversal( $content ) {
301 if ( ! is_string( $content ) || false === stripos( $content, 'dailymotion.com/badge/' ) ) {
302 return $content;
303 }
304
305 /*
306 * Sample embed code:
307 * <iframe width="300px" height="360px" scrolling="no" frameborder="0" src="http://www.dailymotion.com/badge/user/Dailymotion?type=carousel"></iframe>
308 */
309
310 $regexes = array();
311
312 $regexes[] = '#<iframe[^>]+?src=" (?:https?:)?//(?:www\.)?dailymotion\.com/badge/user/([^"\'/]++) "[^>]*+></iframe>#ix';
313
314 // Let's play nice with the visual editor too.
315 $regexes[] = '#&lt;iframe(?:[^&]|&(?!gt;))+?src=" (?:https?:)?//(?:www\.)?dailymotion\.com/badge/user/([^"\'/]++) "(?:[^&]|&(?!gt;))*+&gt;&lt;/iframe&gt;#ix';
316
317 foreach ( $regexes as $regex ) {
318 if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) {
319 continue;
320 }
321
322 foreach ( $matches as $match ) {
323 $url_pieces = wp_parse_url( $match[1] );
324
325 if ( 'type=carousel' === $url_pieces['query'] ) {
326 $type = 'carousel';
327 } elseif ( 'type=grid' === $url_pieces['query'] ) {
328 $type = 'grid';
329 } else {
330 $type = 'badge';
331 }
332
333 $shortcode = '[dailymotion-channel user=' . esc_attr( $url_pieces['path'] ) . ' type=' . esc_attr( $type ) . ']';
334 $replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $match[0], '#' ) );
335 $content = preg_replace( $replace_regex, sprintf( "\n\n%s\n\n", $shortcode ), $content );
336 }
337 }
338
339 return $content;
340 }
341
342 /**
343 * Dailymotion Embed Reversal (with new iframe code as of 17.09.2014)
344 *
345 * Converts a generic HTML embed code from Dailymotion into an
346 * oEmbeddable URL.
347 *
348 * @param string $content Post content.
349 */
350 function jetpack_dailymotion_embed_reversal( $content ) {
351 if ( ! is_string( $content ) || false === stripos( $content, 'dailymotion.com/embed' ) ) {
352 return $content;
353 }
354
355 /*
356 * Sample embed code as of Sep 17th 2014:
357 * <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>
358 */
359 $regexes = array();
360
361 // I'm Konstantin and I love regex.
362 $regexes[] = '#<iframe[^>]+?src=" (?:https?:)?//(?:www\.)?dailymotion\.com/embed/video/([^"\'/]++) "[^>]*+>\s*+</iframe>\s*+(?:<br\s*+/>)?\s*+
363 (?: <a[^>]+?href=" (?:https?:)?//(?:www\.)?dailymotion\.com/[^"\']++ "[^>]*+>.+?</a>\s*+ )?
364 (?: <i>.*?<a[^>]+?href=" (?:https?:)?//(?:www\.)?dailymotion\.com/[^"\']++ "[^>]*+>.+?</a>\s*+</i> )?#ix';
365
366 $regexes[] = '#&lt;iframe(?:[^&]|&(?!gt;))+?src=" (?:https?:)?//(?:www\.)?dailymotion\.com/embed/video/([^"\'/]++) "(?:[^&]|&(?!gt;))*+&gt;\s*+&lt;/iframe&gt;\s*+(?:&lt;br\s*+/&gt;)?\s*+
367 (?: &lt;a(?:[^&]|&(?!gt;))+?href=" (?:https?:)?//(?:www\.)?dailymotion\.com/[^"\']++ "(?:[^&]|&(?!gt;))*+&gt;.+?&lt;/a&gt;\s*+ )?
368 (?: &lt;i&gt;.*?&lt;a(?:[^&]|&(?!gt;))+?href=" (?:https?:)?//(?:www\.)?dailymotion\.com/[^"\']++ "(?:[^&]|&(?!gt;))*+&gt;.+?&lt;/a&gt;\s*+&lt;/i&gt; )?#ix';
369
370 foreach ( $regexes as $regex ) {
371 if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) {
372 continue;
373 }
374
375 foreach ( $matches as $match ) {
376 $url = esc_url( sprintf( 'https://dailymotion.com/video/%s', $match[1] ) );
377 $replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $match[0], '#' ) );
378 $content = preg_replace( $replace_regex, sprintf( "\n\n%s\n\n", $url ), $content );
379
380 /** This action is documented in modules/shortcodes/youtube.php */
381 do_action( 'jetpack_embed_to_shortcode', 'dailymotion', $url );
382 }
383 }
384
385 return $content;
386 }
387
388 if ( jetpack_shortcodes_should_hook_pre_kses() ) {
389 add_filter( 'pre_kses', 'dailymotion_embed_to_shortcode' );
390 add_filter( 'pre_kses', 'dailymotion_channel_reversal' );
391 add_filter( 'pre_kses', 'jetpack_dailymotion_embed_reversal' );
392 }
393