PluginProbe
Property Hive / 2.2.5
Property Hive v2.2.5
2.3.1 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 All 261 releases
propertyhive / includes / elementor-widgets / property-epcs-link.php

property-epcs-link.php in Property Hive 2.2.5, at includes/elementor-widgets/property-epcs-link.php

187 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Elementor Property EPCs Link Widget.
4 *
5 * @since 1.0.0
6 */
7 class Elementor_Property_EPCs_Link_Widget extends \Elementor\Widget_Base {
8
9 public function get_name() {
10 return 'property-epcs-link';
11 }
12
13 public function get_title() {
14 return __( 'EPCs Link', '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', 'epc', 'epcs' ];
27 }
28
29 protected function register_controls() {
30
31 $this->start_controls_section(
32 'style_section',
33 [
34 'label' => __( 'EPCs', 'propertyhive' ),
35 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
36 ]
37 );
38
39 $this->add_group_control(
40 \Elementor\Group_Control_Typography::get_type(),
41 [
42 'name' => 'typography',
43 'label' => __( 'Typography', 'propertyhive' ),
44 'global' => [
45 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Typography::TYPOGRAPHY_PRIMARY,
46 ],
47 'selector' => '{{WRAPPER}} a',
48 ]
49 );
50
51 $this->add_control(
52 'color',
53 [
54 'label' => __( 'Colour', 'propertyhive' ),
55 'type' => \Elementor\Controls_Manager::COLOR,
56 'global' => [
57 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_PRIMARY,
58 ],
59 'selectors' => [
60 '{{WRAPPER}} a' => 'color: {{VALUE}}',
61 ],
62 ]
63 );
64
65 $this->add_control(
66 'text_align',
67 [
68 'label' => __( 'Alignment', 'propertyhive' ),
69 'type' => \Elementor\Controls_Manager::CHOOSE,
70 'options' => [
71 'left' => [
72 'title' => __( 'Left', 'propertyhive' ),
73 'icon' => 'eicon-text-align-left',
74 ],
75 'center' => [
76 'title' => __( 'Center', 'propertyhive' ),
77 'icon' => 'eicon-text-align-center',
78 ],
79 'right' => [
80 'title' => __( 'Right', 'propertyhive' ),
81 'icon' => 'eicon-text-align-right',
82 ],
83 ],
84 'default' => 'center',
85 'toggle' => true,
86 'selectors' => [
87 '{{WRAPPER}}' => 'text-align: {{VALUE}}',
88 ],
89 ]
90 );
91
92 $this->add_control(
93 'background_color',
94 [
95 'label' => __( 'Background Colour', 'propertyhive' ),
96 'type' => \Elementor\Controls_Manager::COLOR,
97 'global' => [
98 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_SECONDARY,
99 ],
100 'selectors' => [
101 '{{WRAPPER}} a' => 'background: {{VALUE}}',
102 ],
103 ]
104 );
105
106 $this->add_control(
107 'padding',
108 [
109 'label' => __( 'Link Padding', 'propertyhive' ),
110 'type' => \Elementor\Controls_Manager::DIMENSIONS,
111 'size_units' => [ 'px' ],
112 'selectors' => [
113 '{{WRAPPER}} a' => 'display:inline-block; padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
114 ],
115 'default' => [
116 'top' => 5,
117 'right' => 5,
118 'bottom' => 5,
119 'left' => 5,
120 'isLinked' => true,
121 ],
122 ]
123 );
124
125 $this->end_controls_section();
126
127 }
128
129 protected function render() {
130
131 global $property;
132
133 $settings = $this->get_settings_for_display();
134
135 if ( !isset($property->id) ) {
136 return;
137 }
138
139 if ( get_option('propertyhive_epcs_stored_as', '') == 'urls' )
140 {
141 $epc_urls = $property->epc_urls;
142 if ( !is_array($epc_urls) ) { $epc_urls = array(); }
143
144 if ( !empty($epc_urls) )
145 {
146 $i = 0;
147 foreach ( $epc_urls as $epc )
148 {
149 $image_extensions = array( 'jpg', 'jpeg', 'png', 'gif', 'bmp' );
150 $image = false;
151 foreach ( $image_extensions as $image_extension )
152 {
153 if ( strpos(strtolower($epc['url']), '.' . $image_extension) )
154 {
155 $image = true;
156 }
157 }
158 if ( $image )
159 {
160 echo '<a' . ( $i > 0 ? ' style="display:none"' : '' ) . ' href="' . esc_url($epc['url']) . '" data-fancybox="epcs" rel="nofollow">' . esc_html( ( count($epc_urls) > 1 ? __( 'EPCs', 'propertyhive' ) : __( 'EPC', 'propertyhive' ) ) ) . '</a>';
161 ++$i;
162 }
163 else
164 {
165 echo '<a href="' . esc_url($epc['url']) . '" rel="nofollow" target="_blank">' . esc_html( ( count($epc_urls) > 1 ? __( 'EPCs', 'propertyhive' ) : __( 'EPC', 'propertyhive' ) ) ) . '</a>';
166 }
167 }
168 }
169 }
170 else
171 {
172 $epc_attachment_ids = $property->get_epc_attachment_ids();
173
174 if ( !empty($epc_attachment_ids) )
175 {
176 $i = 0;
177 foreach ( $epc_attachment_ids as $attachment_id )
178 {
179 echo '<a' . ( $i > 0 ? ' style="display:none"' : '' ) . ' href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" data-fancybox="epc" rel="nofollow">' . esc_html( ( count($epc_attachment_ids) > 1 ? __( 'EPCs', 'propertyhive' ) : __( 'EPC', 'propertyhive' ) ) ) . '</a>';
180 ++$i;
181 }
182 }
183 }
184
185 }
186
187 }