jetpack_googlemaps_shortcode

[googlemaps] shortcode.

Description

jetpack_googlemaps_shortcode( $atts ); 

Example usage: [googlemaps http://maps.google.com/maps?f=q&hl=en&geocode=&q=San+Francisco,+CA&sll=43.469466,-83.998504&sspn=0.01115,0.025942&g=San+Francisco,+CA&ie=UTF8&z=12&iwloc=addr&ll=37.808156,-122.402458&output=embed&s=AARTsJp56EajYksz3JXgNCwT3LJnGsqqAQ&w=425&h=350] [googlemaps https://mapsengine.google.com/map/embed?mid=zbBhkou4wwtE.kUmp8K6QJ7SA&w=640&h=480]

Parameters (1)

0. $atts
The atts.

Usage

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

Defined (1)

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

/modules/shortcodes/googlemaps.php  
  1. function jetpack_googlemaps_shortcode( $atts ) { 
  2. if ( !isset($atts[0]) ) 
  3. return ''; 
  4.  
  5. $params = ltrim( $atts[0], '=' ); 
  6.  
  7. $width = 425; 
  8. $height = 350; 
  9.  
  10. if ( preg_match( '!^https?://(www|maps|mapsengine)\.google(\.co|\.com)?(\.[a-z]+)?/.*?(\?.+)!i', $params, $match ) ) { 
  11. $params = str_replace( '&', '&', $params ); 
  12. $params = str_replace( '&', '&', $params ); 
  13. parse_str( $params, $arg ); 
  14.  
  15. if ( isset( $arg['hq'] ) ) 
  16. unset( $arg['hq'] ); 
  17.  
  18. $url = ''; 
  19. foreach ( (array) $arg as $key => $value ) { 
  20. if ( 'w' == $key ) { 
  21. $percent = ( '%' == substr( $value, -1 ) ) ? '%' : ''; 
  22. $width = (int) $value . $percent; 
  23. } elseif ( 'h' == $key ) { 
  24. $height = (int) $value; 
  25. } else { 
  26. $key = str_replace( '_', '.', $key ); 
  27. $url .= esc_attr( "$key=$value&" ); 
  28. $url = substr( $url, 0, -5 ); 
  29.  
  30. if( is_ssl() ) 
  31. $url = str_replace( 'http://', 'https://', $url ); 
  32.  
  33. $css_class = 'googlemaps'; 
  34.  
  35. if ( ! empty( $atts['align'] ) && in_array( strtolower( $atts['align'] ), array( 'left', 'center', 'right' ), true ) ) { 
  36. $atts['align'] = strtolower( $atts['align'] ); 
  37.  
  38. if ( $atts['align'] === 'left' ) { 
  39. $css_class .= ' alignleft'; 
  40. } elseif ( $atts['align'] === 'center' ) { 
  41. $css_class .= ' aligncenter'; 
  42. } elseif ( $atts['align'] === 'right' ) { 
  43. $css_class .= ' alignright'; 
  44.  
  45. return '<div class="' . esc_attr( $css_class ) . '"><iframe width="' . $width . '" height="' . $height . '" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' . $url . '"></iframe></div>';