the_google_map_embedder

The Embed Google Map the google map embedder function.

Description

the_google_map_embedder( $content ); 

Parameters (1)

0. $content
The content.

Usage

  1. if ( !function_exists( 'the_google_map_embedder' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'embed-google-map/embed_google_map.php'; 
  3.  
  4. // The content. 
  5. $content = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = the_google_map_embedder($content); 
  9.  

Defined (1)

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

/embed_google_map.php  
  1. function the_google_map_embedder($content) { 
  2.  
  3. // Regex for finding all the google_map tags 
  4. $regex = "#{google_map}(.*?) {/google_map}#s"; 
  5. // Read all the tags in an array 
  6. $found = preg_match_all($regex, $content, $matches); 
  7. // Get default options 
  8. $options = get_option('embed_google_map_options'); 
  9. // Initialize options 
  10.  
  11. // Check if any matches were found 
  12. if ( $found ) { 
  13. // Loop through all the matches 
  14. foreach ( $matches[0] as $value ) { 
  15. // Plugin params 
  16. $plgParams = new EmbedGoogleMapParameters;  
  17. // Set default parameters 
  18. $plgParams->setVersion($options['version']); 
  19. $plgParams->setEmbedAPIKey($options['embed_api_key']);  
  20. $plgParams->setMapType($options['map_type']); 
  21. $plgParams->setZoomLevel($options['zoom_level']); 
  22. $plgParams->setLanguage($options['language']); 
  23. $plgParams->setAddLink($options['add_link']); 
  24. $plgParams->setLinkLabel($options['link_label']); 
  25. $plgParams->setLinkFull($options['link_full']); 
  26. $plgParams->setShowInfo($options['show_info']); 
  27. $plgParams->setHeight($options['height']); 
  28. $plgParams->setWidth($options['width']); 
  29. $plgParams->setBorder($options['border']); 
  30. $plgParams->setBorderStyle($options['border_style']); 
  31. $plgParams->setBorderColor($options['border_color']); 
  32. $plgParams->setHttps($options['https']); 
  33. $plgParams->setInfoLabel($options['info_label']);  
  34.  
  35. $map = $value; 
  36. $map = str_replace('{google_map}', '', $map); 
  37. $map = str_replace('{/google_map}', '', $map); 
  38. $find = '|'; 
  39.  
  40. // Check parameters 
  41. if( strstr($map, $find) ) { 
  42. // New Parser object 
  43. $parser = new EmbedGoogleMapParser; 
  44. // Parse parameters 
  45. $parser->parse($map, $plgParams); 
  46. } else { 
  47. $plgParams->setAddress($map); 
  48.  
  49. // Create new HTML builder 
  50. $builder = EmbedGoogleMapBuilderFactory::createBuilder($plgParams->getVersion()); 
  51. // Generate HTML code 
  52. $replacement = $builder->buildHtml($plgParams); 
  53. // Replace the tag with the html code that embeds the map 
  54. $content = str_replace($value, $replacement, $content); 
  55. return $content;