flickr_shortcode_handler

The Jetpack by WordPress.com flickr shortcode handler function.

Description

flickr_shortcode_handler( $atts ); 

Parameters (1)

0. $atts
The atts.

Usage

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

Defined (1)

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

/modules/shortcodes/flickr.php  
  1. function flickr_shortcode_handler( $atts ) { 
  2. $atts = shortcode_atts( array( 
  3. 'video' => 0,  
  4. 'photo' => 0,  
  5. 'show_info' => 0,  
  6. 'w' => 400,  
  7. 'h' => 300,  
  8. 'secret' => 0,  
  9. 'size' => 0,  
  10. ), $atts, 'flickr' ); 
  11.  
  12. if ( ! empty( $atts['video'] ) ) { 
  13. $showing = 'video'; 
  14. $src = $atts['video']; 
  15. } elseif ( ! empty( $atts['photo'] ) ) { 
  16. $showing = 'photo'; 
  17. $src = $atts['photo']; 
  18. } else { 
  19. return ''; 
  20.  
  21. if ( is_ssl() ) { 
  22. $src = str_replace( 'http://', 'https://', $src ); 
  23.  
  24. if ( $showing == 'video' ) { 
  25.  
  26. if ( ! is_numeric( $src ) && ! preg_match( '~^(https?:)?//([\da-z\-]+\.)*?((static)?flickr\.com|flic\.kr)/.*~i', $src ) ) { 
  27. return ''; 
  28.  
  29. if ( preg_match( "!photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/([0-9]+)/?$!", $src, $m ) ) { 
  30. $atts['photo_id'] = $m[4]; 
  31. } else { 
  32. $atts['photo_id'] = $atts['video']; 
  33.  
  34. if ( ! isset( $atts['show_info'] ) || in_array( $atts['show_info'], array('yes', 'true') ) ) { 
  35. $atts['show_info'] = 'true'; 
  36. } elseif ( in_array( $atts['show_info'], array( 'false', 'no' ) ) ) { 
  37. $atts['show_info'] = 'false'; 
  38.  
  39. if ( isset( $atts['secret'] ) ) { 
  40. $atts['secret'] = preg_replace( '![^\w]+!i', '', $atts['secret'] ); 
  41.  
  42. return flickr_shortcode_video_markup( $atts ); 
  43. } elseif ( 'photo' == $showing ) { 
  44.  
  45. if ( ! preg_match( '~^(https?:)?//([\da-z\-]+\.)*?((static)?flickr\.com|flic\.kr)/.*~i', $src ) ) { 
  46. return ''; 
  47.  
  48. $src = sprintf( '%s/player/', untrailingslashit( $src ) ); 
  49.  
  50. return sprintf( '<iframe src="%s" height="%s" width="%s" frameborder="0" allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>', esc_url( $src ), esc_attr( $atts['h'] ), esc_attr( $atts['w'] ) ); 
  51.