| @@ 349-362 (lines=14) @@ | ||
| 346 | (?: <a(?:[^&]|&(?!gt;))+?href=" (?:https?:)?//(?:www\.)?dailymotion\.com/[^"\']++ "(?:[^&]|&(?!gt;))*+>.+?</a>\s*+ )? |
|
| 347 | (?: <i>.*?<a(?:[^&]|&(?!gt;))+?href=" (?:https?:)?//(?:www\.)?dailymotion\.com/[^"\']++ "(?:[^&]|&(?!gt;))*+>.+?</a>\s*+</i> )?#ix'; |
|
| 348 | ||
| 349 | foreach ( $regexes as $regex ) { |
|
| 350 | if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) { |
|
| 351 | continue; |
|
| 352 | } |
|
| 353 | ||
| 354 | foreach ( $matches as $match ) { |
|
| 355 | $url = esc_url( sprintf( 'https://dailymotion.com/video/%s', $match[1] ) ); |
|
| 356 | $replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $match[0], '#' ) ); |
|
| 357 | $content = preg_replace( $replace_regex, sprintf( "\n\n%s\n\n", $url ), $content ); |
|
| 358 | ||
| 359 | /** This action is documented in modules/shortcodes/youtube.php */ |
|
| 360 | do_action( 'jetpack_embed_to_shortcode', 'dailymotion', $url ); |
|
| 361 | } |
|
| 362 | } |
|
| 363 | ||
| 364 | return $content; |
|
| 365 | } |
|
| @@ 112-128 (lines=17) @@ | ||
| 109 | // Let's play nice with the visual editor too. |
|
| 110 | $regexes[] = '#<iframe(?:[^&]|&(?!gt;))+?src="((?:https?:)?//(?:www\.)instagram\.com/p/([^"\'/]++)[^"\']*?)"(?:[^&]|&(?!gt;))*+>\s*?</iframe>#i'; |
|
| 111 | ||
| 112 | foreach ( $regexes as $regex ) { |
|
| 113 | if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) { |
|
| 114 | continue; |
|
| 115 | } |
|
| 116 | ||
| 117 | foreach ( $matches as $match ) { |
|
| 118 | if ( ! preg_match( '#(https?:)?//(?:www\.)?instagr(\.am|am\.com)/p/([^/]*)#i', $match[1], $url_matches ) ) { |
|
| 119 | continue; |
|
| 120 | } |
|
| 121 | ||
| 122 | // Since we support Instagram via oEmbed, we simply leave a link on a line by itself. |
|
| 123 | $replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $match[0], '#' ) ); |
|
| 124 | $url = esc_url( $url_matches[0] ); |
|
| 125 | ||
| 126 | $content = preg_replace( $replace_regex, sprintf( "\n\n%s\n\n", $url ), $content ); |
|
| 127 | /** This action is documented in modules/shortcodes/youtube.php */ |
|
| 128 | do_action( 'jetpack_embed_to_shortcode', 'instagram', $url ); |
|
| 129 | } |
|
| 130 | } |
|
| 131 | ||