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-link.php

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

108 lines 3.0 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 Link 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_Link_Widget extends \Bricks\Element {
11
12 // Element properties
13 public $category = 'propertyhive';
14 public $name = 'bricks-builder-property-map-link';
15 public $icon = 'fas fa-map';
16
17 public function get_label()
18 {
19 return esc_html__( 'Map Link', 'propertyhive' );
20 }
21
22 // Enqueue element styles and scripts
23 public function enqueue_scripts()
24 {
25 $suffix = '';
26 $assets_path = str_replace( array( 'http:', 'https:' ), '', PH()->plugin_url() ) . '/assets/';
27
28
29 }
30
31 public function set_control_groups()
32 {
33 /*$this->control_groups['form'] = [
34 'title' => esc_html__( 'Form', 'propertyhive' ),
35 'tab' => 'content', // content / style
36 ];*/
37 }
38
39 public function set_controls()
40 {
41 $this->controls['map_link_type'] = [
42 'tab' => 'content',
43 //'group' => 'settings',
44 'label' => esc_html__( 'Link Type', 'propertyhive' ),
45 'type' => 'select',
46 'options' => array(
47 '_blank' => 'Open map in new window',
48 'embedded' => 'Open embedded map in lightbox',
49 'iframe' => 'Open iframe map in lightbox',
50 ),
51 'default' => '_blank',
52 ];
53 }
54
55 public function render()
56 {
57 global $property;
58
59 if ( !isset($property->id) )
60 {
61 return;
62 }
63
64 if ( $property->latitude == '' || $property->longitude == '' || $property->latitude == '0' || $property->longitude == '0' )
65 {
66 return;
67 }
68
69 $root_classes[] = $this->name;
70
71 // Add 'class' attribute to element root tag
72 $this->set_attribute( '_root', 'class', $root_classes );
73
74 echo "<div {$this->render_attributes( '_root' )}>";
75
76 $link_type = ( isset($this->settings['map_link_type']) && !empty($this->settings['map_link_type']) ) ? $this->settings['map_link_type'] : '_blank';
77
78 switch ($link_type)
79 {
80 case "_blank":
81 {
82 echo '<a href="https://www.google.com/maps/?q=' . (float)$property->latitude . ',' . (float)$property->longitude . '&ll=' . (float)$property->latitude . ',' . (float)$property->longitude . '" target="_blank">' . esc_html(__( 'View Map', 'propertyhive' )) . '</a>';
83 break;
84 }
85 case "embedded":
86 {
87 echo '<a href="#map_lightbox" data-fancybox>' . esc_html(__( 'View Map', 'propertyhive' )) . '</a>';
88
89 echo '<div id="map_lightbox" style="display:none; width:90%; max-width:800px;">';
90 echo do_shortcode('[property_map]');
91 echo '</div>';
92 break;
93 }
94 case "iframe":
95 {
96 echo '<a
97 href="#"
98 data-fancybox
99 data-type="iframe"
100 data-src="https://maps.google.com/?output=embed&amp;f=q&amp;q=' . (float)$property->latitude . ',' . (float)$property->longitude . '&amp;ll=' . (float)$property->latitude . ',' . (float)$property->longitude . '&amp;layer=t&amp;hq=&amp;t=m&amp;z=15"
101 >' . esc_html(__( 'View Map', 'propertyhive' )) . '</a>';
102 break;
103 }
104 }
105
106 echo '</div>';
107 }
108 }