flickr_embed_to_shortcode

Description

flickr_embed_to_shortcode( $content ); 

Parameters (1)

0. $content
The content.

Usage

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

Defined (1)

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

/modules/shortcodes/flickr.php  
  1. function flickr_embed_to_shortcode( $content ) { 
  2. if ( false === stripos( $content, '/www.flickr.com/apps/video/stewart.swf' ) ) 
  3. return $content; 
  4.  
  5. $regexp = '%(<object.*?(?:<(?!/?(?:object|embed)\s+).*?)*?)?<embed((?:\s+\w+="[^"]*")*)\s+src="http(?:\:|�*58;)//www.flickr.com/apps/video/stewart.swf[^"]*"((?:\s+\w+="[^"]*")*)\s*(?:/>|>\s*</embed>)(?(1)\s*</object>)%'; 
  6. $regexp_ent = str_replace( 
  7. array( 
  8. '&#0*58;',  
  9. '[^>]*',  
  10. '[^<]*',  
  11. ),  
  12. array( 
  13. '&#0*58;|�*58;',  
  14. '[^&]*(?:&(?!gt;)[^&]*)*',  
  15. '[^&]*(?:&(?!lt;)[^&]*)*',  
  16. ),  
  17. htmlspecialchars( $regexp, ENT_NOQUOTES ) 
  18. ); 
  19.  
  20. foreach ( array( 'regexp', 'regexp_ent' ) as $reg ) { 
  21. if ( !preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) 
  22. continue; 
  23. foreach ( $matches as $match ) { 
  24. $params = $match[2] . $match[3]; 
  25.  
  26. if ( 'regexp_ent' == $reg ) 
  27. $params = html_entity_decode( $params ); 
  28.  
  29. $params = wp_kses_hair( $params, array( 'http' ) ); 
  30. if ( ! isset( $params['type'] ) || 'application/x-shockwave-flash' != $params['type']['value'] || ! isset( $params['flashvars'] ) ) 
  31. continue; 
  32.  
  33. wp_parse_str( html_entity_decode( $params['flashvars']['value'] ), $flashvars ); 
  34.  
  35. if ( ! isset( $flashvars['photo_id'] ) ) 
  36. continue; 
  37.  
  38. $code_atts = array( 'video' => $flashvars['photo_id'], ); 
  39.  
  40. if ( isset( $flashvars['flickr_show_info_box'] ) && 'true' == $flashvars['flickr_show_info_box'] ) 
  41. $code_atts['show_info'] = 'true'; 
  42.  
  43. if ( ! empty( $flashvars['photo_secret'] ) ) 
  44. $code_atts['secret'] = $flashvars['photo_secret'] ; 
  45.  
  46. if ( ! empty( $params['width']['value'] ) ) 
  47. $code_atts['w'] = (int) $params['width']['value']; 
  48.  
  49. if ( ! empty( $params['height']['value'] ) ) 
  50. $code_atts['h'] = (int) $params['height']['value']; 
  51.  
  52. $code = '[flickr'; 
  53. foreach ( $code_atts as $k => $v ) 
  54. $code .= " $k=$v"; 
  55. $code .= ']'; 
  56.  
  57. $content = str_replace( $match[0], $code, $content ); 
  58. /** This action is documented in modules/shortcodes/youtube.php */ 
  59. do_action( 'jetpack_embed_to_shortcode', 'flickr_video', $flashvars['photo_id'] ); 
  60.  
  61. return $content;