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