/modules/shortcodes.php

  1. <?php 
  2.  
  3. /** 
  4. * Module Name: Shortcode Embeds 
  5. * Module Description: Embed content from YouTube, Vimeo, SlideShare, and more, no coding necessary. 
  6. * Sort Order: 3 
  7. * First Introduced: 1.1 
  8. * Major Changes In: 1.2 
  9. * Requires Connection: No 
  10. * Auto Activate: Yes 
  11. * Module Tags: Photos and Videos, Social, Writing, Appearance 
  12. * Additional Search Queries: shortcodes, shortcode, embeds, media, bandcamp, blip.tv, dailymotion, digg, facebook, flickr, google calendars, google maps, google+, polldaddy, recipe, recipes, scribd, slideshare, slideshow, slideshows, soundcloud, ted, twitter, vimeo, vine, youtube 
  13. */ 
  14.  
  15. /** 
  16. * Transforms the $atts array into a string that the old functions expected 
  17. * 
  18. * The old way was: 
  19. * [shortcode a=1&b=2&c=3] or [shortcode=1] 
  20. * This is parsed as array( a => '1&b=2&c=3' ) and array( 0 => '=1' ), which is useless 
  21. * 
  22. * @param Array $params 
  23. * @param Bool $old_format_support true if [shortcode=foo] format is possible. 
  24. * @return String $params 
  25. */ 
  26. function shortcode_new_to_old_params( $params, $old_format_support = false ) { 
  27. $str = ''; 
  28.  
  29. if ( $old_format_support && isset( $params[0] ) ) { 
  30. $str = ltrim( $params[0], '=' ); 
  31. } elseif ( is_array( $params ) ) { 
  32. foreach ( array_keys( $params ) as $key ) { 
  33. if ( ! is_numeric( $key ) ) 
  34. $str = $key . '=' . $params[$key]; 
  35.  
  36. return str_replace( array( '&', '&' ), '&', $str ); 
  37.  
  38. function jetpack_load_shortcodes() { 
  39. global $wp_version; 
  40.  
  41. $shortcode_includes = array(); 
  42.  
  43. foreach ( Jetpack::glob_php( dirname( __FILE__ ) . '/shortcodes' ) as $file ) { 
  44. $shortcode_includes[] = $file; 
  45.  
  46. /** 
  47. * This filter allows other plugins to override which shortcodes Jetpack loads. 
  48. * 
  49. * @module shortcodes 
  50. * 
  51. * @since 2.2.1 
  52. * 
  53. * @param array $shortcode_includes An array of which shortcodes to include. 
  54. */ 
  55. $shortcode_includes = apply_filters( 'jetpack_shortcodes_to_include', $shortcode_includes ); 
  56.  
  57. foreach ( $shortcode_includes as $include ) { 
  58. if ( version_compare( $wp_version, '3.6-z', '>=' ) && stristr( $include, 'audio.php' ) ) { 
  59. continue; 
  60.  
  61. include $include; 
  62.  
  63. global $wp_version; 
  64.  
  65. if ( version_compare( $wp_version, '3.6-z', '>=' ) ) { 
  66. add_filter( 'shortcode_atts_audio', 'jetpack_audio_atts_handler', 10, 3 ); 
  67.  
  68. function jetpack_audio_atts_handler( $out, $pairs, $atts ) { 
  69. if( isset( $atts[0] ) ) 
  70. $out['src'] = $atts[0]; 
  71.  
  72. return $out; 
  73.  
  74. function jetpack_shortcode_get_audio_id( $atts ) { 
  75. if ( isset( $atts[ 0 ] ) ) 
  76. return $atts[ 0 ]; 
  77. else 
  78. return 0; 
  79.  
  80. if ( ! function_exists( 'jetpack_shortcode_get_wpvideo_id' ) ) { 
  81. function jetpack_shortcode_get_wpvideo_id( $atts ) { 
  82. if ( isset( $atts[ 0 ] ) ) 
  83. return $atts[ 0 ]; 
  84. else 
  85. return 0; 
  86.  
  87. jetpack_load_shortcodes(); 
.