PluginProbe
Property Hive / 2.3.1
Property Hive v2.3.1
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-brochures-link.php

property-brochures-link.php in Property Hive 2.3.1, at includes/elementor-widgets/property-brochures-link.php

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