slideshare_shortcode

The Jetpack by WordPress.com slideshare shortcode function.

Description

slideshare_shortcode( $atts ); 

Parameters (1)

0. $atts
The atts.

Usage

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

Defined (1)

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

/modules/shortcodes/slideshare.php  
  1. function slideshare_shortcode( $atts ) { 
  2. global $content_width; 
  3.  
  4. $params = shortcode_new_to_old_params( $atts ); 
  5. parse_str( $params, $arguments ); 
  6.  
  7. if ( empty( $arguments ) ) 
  8. return '<!-- SlideShareerror no arguments -->'; 
  9.  
  10. extract( $arguments ); 
  11.  
  12. // check that the Slideshare ID contains letters, numbers and query strings 
  13. $pattern = '/[^-_a-zA-Z0-9?=&]/'; 
  14. if ( empty( $id ) || preg_match( $pattern, $id ) ) 
  15. return '<!-- SlideShareerror id is missing or has illegal characters -->'; 
  16.  
  17. // check the width/height 
  18. if ( empty( $w ) && ! empty( $content_width ) ) 
  19. $w = intval( $content_width ); 
  20. elseif ( ! ( $w = intval( $w ) ) || $w < 300 || $w > 1600 ) 
  21. $w = 425; 
  22. else 
  23. $w = intval( $w ); 
  24.  
  25. $h = ceil( $w * 348 / 425 ); 
  26.  
  27. if ( isset( $pro ) ) { 
  28. $source = "https://www.slideshare.net/slidesharepro/$id"; 
  29. } else { 
  30. $source = "https://www.slideshare.net/slideshow/embed_code/$id"; 
  31.  
  32. if ( isset( $rel ) ) 
  33. $source = add_query_arg( 'rel', intval( $rel ), $source ); 
  34.  
  35. if ( isset( $startSlide ) ) 
  36. $source = add_query_arg( 'startSlide', intval( $startSlide ), $source ); 
  37.  
  38. $player = sprintf( "<iframe src='%s' width='%d' height='%d'", esc_url( $source ), $w, $h ); 
  39.  
  40. // check the frameborder 
  41. if ( isset( $fb ) ) 
  42. $player .= " frameborder='" . intval( $fb ) . "'"; 
  43.  
  44. // check the margin width; if not empty, cast as int 
  45. if ( isset( $mw ) ) 
  46. $player .= " marginwidth='" . intval( $mw ) . "'"; 
  47.  
  48. // check the margin height, if not empty, cast as int 
  49. if ( isset( $mh ) ) 
  50. $player .= " marginheight='" . intval( $mh ) . "'"; 
  51.  
  52. if ( ! empty( $style ) ) 
  53. $player .= " style='" . $style . "'"; 
  54.  
  55. // check the scrollbar; cast as a lowercase string for comparison 
  56. $sc = isset( $sc ) ? strtolower( $sc ) : ''; 
  57.  
  58. if ( in_array( $sc, array( 'yes', 'no' ) ) ) 
  59. $player .= " scrolling='" . $sc . "'"; 
  60.  
  61. $player .= ' allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>'; 
  62.  
  63. return $player;