PluginProbe
Property Hive / 2.2.4
Property Hive v2.2.4
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 / elementor-widgets / property-floorplans.php

property-floorplans.php in Property Hive 2.2.4, at includes/elementor-widgets/property-floorplans.php

151 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Elementor Property Floorplans Widget.
4 *
5 * @since 1.0.0
6 */
7 class Elementor_Property_Floorplans_Widget extends \Elementor\Widget_Base {
8
9 public function get_name() {
10 return 'property-floorplans';
11 }
12
13 public function get_title() {
14 return __( 'Floorplans', 'propertyhive' );
15 }
16
17 public function get_icon() {
18 return 'eicon-document-file';
19 }
20
21 public function get_categories() {
22 return [ 'property-hive' ];
23 }
24
25 public function get_keywords() {
26 return [ 'property hive', 'propertyhive', 'property', 'floorplan', 'floorplans', 'floor plan', 'floor plans' ];
27 }
28
29 protected function register_controls() {
30
31 $this->start_controls_section(
32 'style_section',
33 [
34 'label' => __( 'Floorplans', 'propertyhive' ),
35 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
36 ]
37 );
38
39 $this->add_control(
40 'show_title',
41 [
42 'label' => __( 'Show Title', 'propertyhive' ),
43 'type' => \Elementor\Controls_Manager::SWITCHER,
44 'label_on' => __( 'Show', 'propertyhive' ),
45 'label_off' => __( 'Hide', 'propertyhive' ),
46 'return_value' => 'yes',
47 'default' => 'yes',
48 ]
49 );
50
51 $this->add_group_control(
52 \Elementor\Group_Control_Typography::get_type(),
53 [
54 'name' => 'title_typography',
55 'label' => __( 'Title Typography', 'propertyhive' ),
56 'global' => [
57 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Typography::TYPOGRAPHY_PRIMARY,
58 ],
59 'selector' => '{{WRAPPER}} .floorplans h4',
60 'condition' => [
61 'show_title' => 'yes'
62 ],
63 ]
64 );
65
66 $this->add_control(
67 'title_color',
68 [
69 'label' => __( 'Title Colour', 'propertyhive' ),
70 'type' => \Elementor\Controls_Manager::COLOR,
71 'global' => [
72 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_PRIMARY,
73 ],
74 'selectors' => [
75 '{{WRAPPER}} .floorplans h4' => 'color: {{VALUE}}',
76 ],
77 'condition' => [
78 'show_title' => 'yes'
79 ],
80 ]
81 );
82
83 $this->end_controls_section();
84
85 }
86
87 protected function render() {
88
89 global $property;
90
91 $settings = $this->get_settings_for_display();
92
93 if ( !isset($property->id) ) {
94 return;
95 }
96
97 if ( isset($settings['show_title']) && $settings['show_title'] != 'yes' )
98 {
99 ?>
100 <style type="text/css">
101 .floorplans h4 { display:none; }
102 </style>
103 <?php
104 }
105
106 if ( get_option('propertyhive_floorplans_stored_as', '') == 'urls' )
107 {
108 $floorplan_urls = $property->_floorplan_urls;
109 if ( is_array($floorplan_urls) && !empty( $floorplan_urls ) )
110 {
111 echo '<div class="floorplans">';
112
113 echo '<h4>' . esc_html(__( 'Floorplans', 'propertyhive' )) . '</h4>';
114
115 foreach ($floorplan_urls as $floorplan)
116 {
117 echo '<a href="' . esc_url($floorplan['url']) . '" data-fancybox="floorplans" rel="nofollow"><img src="' . esc_url($floorplan['url']) . '" alt=""></a>';
118 }
119
120 echo '</div>';
121 }
122 }
123 else
124 {
125 $floorplan_attachment_ids = $property->get_floorplan_attachment_ids();
126
127 if ( !empty($floorplan_attachment_ids) )
128 {
129 echo '<div class="floorplans">';
130
131 echo '<h4>' . esc_html(__( 'Floorplans', 'propertyhive' )) . '</h4>';
132
133 foreach ( $floorplan_attachment_ids as $attachment_id )
134 {
135 if ( wp_attachment_is_image($attachment_id) )
136 {
137 echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" data-fancybox="floorplans" rel="nofollow"><img src="' . esc_url(wp_get_attachment_url($attachment_id)) . '" alt=""></a>';
138 }
139 else
140 {
141 echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" target="_blank" rel="nofollow">' . esc_html(__( 'View Floorplan', 'propertyhive' )) . '</a>';
142 }
143 }
144
145 echo '</div>';
146 }
147 }
148
149 }
150
151 }