PluginProbe
Property Hive / 2.2.6
Property Hive v2.2.6
2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 1.4.62 All 260 releases
propertyhive / includes / bricks-builder-widgets / property-map.php

property-map.php in Property Hive 2.2.6, at includes/bricks-builder-widgets/property-map.php

127 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Bricks Builder Property Map Widget.
4 *
5 * @since 1.0.0
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
9
10 class Bricks_Builder_Property_Map_Widget extends \Bricks\Element {
11
12 // Element properties
13 public $category = 'propertyhive';
14 public $name = 'bricks-builder-property-map';
15 public $icon = 'fas fa-map';
16 public $scripts = ['initialize_property_map'];
17
18 public function get_label()
19 {
20 return esc_html__( 'Map', 'propertyhive' );
21 }
22
23 // Enqueue element styles and scripts
24 public function enqueue_scripts()
25 {
26 $suffix = '';
27 $assets_path = str_replace( array( 'http:', 'https:' ), '', PH()->plugin_url() ) . '/assets/';
28
29 if ( get_option('propertyhive_maps_provider') == 'osm' )
30 {
31 $assets_path = str_replace( array( 'http:', 'https:' ), '', PH()->plugin_url() ) . '/assets/js/leaflet/';
32
33 wp_register_style('leaflet', $assets_path . 'leaflet.css', array(), '1.9.4');
34 wp_enqueue_style('leaflet');
35
36 wp_register_script('leaflet', $assets_path . 'leaflet.js', array(), '1.9.4', false);
37 wp_enqueue_script('leaflet');
38 }
39 else
40 {
41 $api_key = get_option('propertyhive_google_maps_api_key');
42 wp_register_script('googlemaps', '//maps.googleapis.com/maps/api/js?' . ( ( $api_key != '' && $api_key !== FALSE ) ? 'key=' . $api_key : '' ), false, '3');
43 wp_enqueue_script('googlemaps');
44 }
45 }
46
47 public function set_control_groups()
48 {
49 /*$this->control_groups['form'] = [
50 'title' => esc_html__( 'Form', 'propertyhive' ),
51 'tab' => 'content', // content / style
52 ];*/
53 }
54
55 public function set_controls()
56 {
57 $this->controls['height'] = [
58 'tab' => 'content',
59 //'group' => 'settings',
60 'label' => esc_html__( 'Height', 'propertyhive' ),
61 'type' => 'number',
62 'default' => 400
63 ];
64
65 $this->controls['zoom'] = [
66 'tab' => 'content',
67 //'group' => 'settings',
68 'label' => esc_html__( 'Zoom', 'propertyhive' ),
69 'type' => 'number',
70 'min' => 1,
71 'max' => 20,
72 'default' => 14,
73 ];
74
75 $this->controls['scrollwheel'] = [
76 'tab' => 'content',
77 //'group' => 'settings',
78 'label' => esc_html__( 'Scrollwheel Zoom', 'propertyhive' ),
79 'type' => 'select',
80 'options' => array(
81 'true' => __( 'True', 'propertyhive' ),
82 'false' => __( 'False', 'propertyhive' ),
83 ),
84 'default' => 'true',
85 ];
86 }
87
88 public function render()
89 {
90 global $property;
91
92 if ( !isset($property->id) )
93 {
94 return;
95 }
96
97 if ( $property->latitude == '' || $property->longitude == '' || $property->latitude == '0' || $property->longitude == '0' )
98 {
99 return;
100 }
101
102 $root_classes[] = $this->name;
103
104 // Add 'class' attribute to element root tag
105 $this->set_attribute( '_root', 'class', $root_classes );
106
107 echo "<div {$this->render_attributes( '_root' )}>";
108
109 $attributes = array();
110 if ( isset($this->settings['height']) && $this->settings['height'] != '' )
111 {
112 $attributes['height'] = $this->settings['height'];
113 }
114 if ( isset($this->settings['zoom']) && isset($this->settings['zoom']) && $this->settings['zoom'] != '' )
115 {
116 $attributes['zoom'] = $this->settings['zoom'];
117 }
118 if ( isset($this->settings['scrollwheel']) && $this->settings['scrollwheel'] != '' )
119 {
120 $attributes['scrollwheel'] = $this->settings['scrollwheel'];
121 }
122
123 get_property_map($attributes);
124
125 echo '</div>';
126 }
127 }