PluginProbe
Themify Builder / 7.6.2
Themify Builder v7.6.2
7.8.1 7.8.0 7.7.9 7.7.8 7.7.7 7.7.6 7.7.5 7.7.4 7.7.3 7.7.2 trunk 7.6.0 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.8 7.6.9 7.7.0 7.7.1
themify-builder / modules / module-map.php

module-map.php in Themify Builder 7.6.2, at modules/module-map.php

69 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined( 'ABSPATH' ) || exit;
4
5 /**
6 * Module Name: Map
7 * Description: Display Map
8 */
9
10 class TB_Map_Module extends Themify_Builder_Component_Module {
11
12
13 public static function get_module_name():string{
14 add_filter( 'themify_builder_active_vars', array(__CLASS__, 'check_map_api'));
15 return __('Map', 'themify');
16 }
17
18 public static function get_module_icon():string{
19 return 'map-alt';
20 }
21
22 /**
23 * Handles Ajax request to check map api
24 *
25 * @since 4.5.0
26 */
27 public static function check_map_api($values) {
28 $googleAPI = themify_builder_get( 'setting-google_map_key', 'builder_settings_google_map_key' );
29 $values['google_api'] = !empty($googleAPI);
30 $url = themify_is_themify_theme() ? admin_url( 'admin.php?page=themify#setting-integration-api' ) : admin_url( 'admin.php?page=themify-builder&tab=builder_settings' );
31 if(!$values['google_api']) {
32 $values['google_api_err'] = sprintf( __('Please enter the required <a href="%s" target="_blank">Google Maps API key</a>.','themify'), $url );
33 }
34 $bingAPI = themify_builder_get( 'setting-bing_map_key', 'builder_settings_bing_map_key' );
35 $values['bing_api'] = !empty($bingAPI);
36 if(!$values['bing_api']) {
37 $values['bing_api_err'] = sprintf( __('Please enter the required <a href="%s" target="_blank">Bing Maps API key</a>.','themify'), $url );
38 }
39 return $values;
40 }
41
42
43 /**
44 * Render plain content
45 */
46 public static function get_static_content(array $module):string {
47 $mod_settings = $module['mod_settings']+array(
48 'mod_title_map' => '',
49 'address_map' => 'Toronto',
50 'zoom_map' => 15
51 );
52 if (!empty($mod_settings['address_map'])) {
53 $mod_settings['address_map'] = preg_replace('/\s+/', ' ', trim($mod_settings['address_map']));
54 }
55 $text = sprintf('<h3>%s</h3>', $mod_settings['mod_title_map']);
56 $text .= sprintf(
57 '<iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?q=%s&amp;t=m&amp;z=%d&amp;output=embed&amp;iwloc=near"></iframe>', urlencode($mod_settings['address_map']), absint($mod_settings['zoom_map'])
58 );
59 return $text;
60 }
61
62 public static function get_translatable_text_fields( $module ) : array {
63 return [ 'mod_title_map', 'latlong_map' ];
64 }
65
66 public static function get_translatable_textarea_fields( $module ) : array {
67 return [ 'address_map', 'info_window_map' ];
68 }
69 }