dailymotion_channel_reversal

Embed Reversal for Badge/Channel.

Description

dailymotion_channel_reversal( $content ); 

Parameters (1)

0. $content
The content.

Usage

  1. if ( !function_exists( 'dailymotion_channel_reversal' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/shortcodes/dailymotion.php'; 
  3.  
  4. // The content. 
  5. $content = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = dailymotion_channel_reversal($content); 
  9.  

Defined (1)

The function is defined in the following location(s).

/modules/shortcodes/dailymotion.php  
  1. function dailymotion_channel_reversal( $content ) { 
  2. if ( false === stripos( $content, 'dailymotion.com/badge/' ) ) { 
  3. return $content; 
  4.  
  5. /** Sample embed code: 
  6. <iframe width="300px" height="360px" scrolling="no" frameborder="0" src="http://www.dailymotion.com/badge/user/Dailymotion?type=carousel"></iframe> 
  7. */ 
  8.  
  9. $regexes = array(); 
  10.  
  11. $regexes[] = '#<iframe[^>]+?src=" (?:https?:)?//(?:www\.)?dailymotion\.com/badge/user/([^"\'/]++) "[^>]*+></iframe>#ix'; 
  12.  
  13. // Let's play nice with the visual editor too. 
  14. $regexes[] = '#<iframe(?:[^&]|&(?!gt;))+?src=" (?:https?:)?//(?:www\.)?dailymotion\.com/badge/user/([^"\'/]++) "(?:[^&]|&(?!gt;))*+></iframe>#ix'; 
  15.  
  16. foreach ( $regexes as $regex ) { 
  17. if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) { 
  18. continue; 
  19.  
  20. foreach ( $matches as $match ) { 
  21. $url_pieces = parse_url( $match[1] ); 
  22.  
  23. if ( 'type=carousel' === $url_pieces['query'] ) { 
  24. $type = 'carousel'; 
  25. } else if ( 'type=grid' === $url_pieces['query'] ) { 
  26. $type = 'grid'; 
  27. } else { 
  28. $type = 'badge'; 
  29.  
  30. $shortcode = '[dailymotion-channel user=' . esc_attr( $url_pieces['path'] ) . ' type=' . esc_attr( $type ) . ']'; 
  31. $replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $match[0], '#' ) ); 
  32. $content = preg_replace( $replace_regex, sprintf( "\n\n%s\n\n", $shortcode ), $content ); 
  33.  
  34. return $content;