Google_Maps_Builder_Core_Front_End_Scripts

Class Google_Maps_Builder_Core_Front_End_Scripts.

Defined (1)

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

/vendor/wordimpress/maps-builder-core/includes/class-gmc-frontend-scripts.php  
  1. class Google_Maps_Builder_Core_Front_End_Scripts extends Google_Maps_Builder_Core_Scripts { 
  2.  
  3. /** 
  4. * Hooks 
  5. */ 
  6. protected function hooks() { 
  7. add_action( 'wp_enqueue_scripts', array( $this, 'load_frontend_scripts' ), 11 ); 
  8. add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_styles' ) ); 
  9.  
  10. /** 
  11. * Load Frontend Scripts. 
  12. * Enqueues the required scripts to display maps on the frontend only. 
  13. */ 
  14. function load_frontend_scripts() { 
  15.  
  16. $libraries = 'places'; 
  17. $signed_in_option = false; 
  18. if ( ! empty( $this->plugin_settings['gmb_signed_in'] ) && $this->plugin_settings['gmb_signed_in'] == 'enabled' ) { 
  19. $signed_in_option = true; 
  20.  
  21. $google_maps_api_url = $this->google_maps_url( $signed_in_option, $libraries ); 
  22.  
  23. wp_register_script( 'google-maps-builder-gmaps', $google_maps_api_url, array( 'jquery' ) ); 
  24. wp_enqueue_script( 'google-maps-builder-gmaps' ); 
  25.  
  26. $js_dir = $this->paths->front_end_js_dir(); 
  27. $js_plugins = $this->paths->front_end_js_url(); 
  28.  
  29. // Use minified libraries if SCRIPT_DEBUG is turned off. 
  30. $suffix = $this->paths->suffix(); 
  31.  
  32. wp_register_script( 'google-maps-builder-infowindows', $js_plugins . '/gmb-infobubble' . $suffix . '.js', array( 'jquery' ), GMB_VERSION, true ); 
  33. wp_enqueue_script( 'google-maps-builder-infowindows' ); 
  34.  
  35. wp_register_script( 'google-maps-builder-plugin-script', $js_dir . 'google-maps-builder' . $suffix . '.js', array( 
  36. 'jquery',  
  37. 'google-maps-builder-infowindows' 
  38. ), GMB_VERSION, true ); 
  39. wp_enqueue_script( 'google-maps-builder-plugin-script' ); 
  40.  
  41. wp_register_script( 'google-maps-builder-maps-icons', GMB_CORE_URL . 'includes/libraries/map-icons/js/map-icons.js', array( 'jquery' ), GMB_VERSION, true ); 
  42. wp_enqueue_script( 'google-maps-builder-maps-icons' ); 
  43.  
  44. // Initial data to pass to the `gmb_data` front-end JS object. 
  45. $maps_data = apply_filters( 'gmb_frontend_data_array', array( 
  46. 'i18n' => array( 
  47. 'get_directions' => __( 'Get Directions', 'google-maps-builder' ),  
  48. 'visit_website' => __( 'Visit Website', 'google-maps-builder' ),  
  49. ),  
  50. 'infobubble_args' => array( 
  51. 'shadowStyle' => 0,  
  52. 'padding' => 12,  
  53. 'backgroundColor' => 'rgb(255, 255, 255)',  
  54. 'borderRadius' => 3,  
  55. 'arrowSize' => 15,  
  56. 'minHeight' => 20,  
  57. 'maxHeight' => 450,  
  58. 'minWidth' => 200,  
  59. 'maxWidth' => 350,  
  60. 'borderWidth' => 0,  
  61. 'disableAutoPan' => true,  
  62. 'disableAnimation' => true,  
  63. 'backgroundClassName' => 'gmb-infobubble',  
  64. 'closeSrc' => 'https://www.google.com/intl/en_us/mapfiles/close.gif' 
  65. ); 
  66.  
  67. wp_localize_script( 'google-maps-builder-plugin-script', 'gmb_data', $maps_data ); 
  68.  
  69.  
  70.  
  71. /** 
  72. * Register and enqueue public-facing style sheet. 
  73. * @since 2.0 
  74. */ 
  75. function enqueue_frontend_styles() { 
  76.  
  77. $suffix = $this->paths->suffix(); 
  78.  
  79. wp_register_style( 'google-maps-builder-plugin-styles', GMB_CORE_URL . 'assets/css/google-maps-builder' . $suffix . '.css', array(), GMB_VERSION ); 
  80. wp_enqueue_style( 'google-maps-builder-plugin-styles' ); 
  81.  
  82. wp_register_style( 'google-maps-builder-map-icons', GMB_CORE_URL . 'includes/libraries/map-icons/css/map-icons.css', array(), GMB_VERSION ); 
  83. wp_enqueue_style( 'google-maps-builder-map-icons' ); 
  84.  
  85.