PluginProbe
Property Hive / 2.2.3
Property Hive v2.2.3
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.php

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

145 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 * Elementor Property EPCs Widget.
4 *
5 * @since 1.0.0
6 */
7 class Elementor_Property_EPCs_Widget extends \Elementor\Widget_Base {
8
9 public function get_name() {
10 return 'property-epcs';
11 }
12
13 public function get_title() {
14 return __( 'EPCs', '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_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}} .epcs 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}} .epcs 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 .epcs h4 { display:none; }
102 </style>
103 <?php
104 }
105
106 if ( get_option('propertyhive_epcs_stored_as', '') == 'urls' )
107 {
108 $epc_urls = $property->_epc_urls;
109 if ( is_array($epc_urls) && !empty( $epc_urls ) )
110 {
111 foreach ($epc_urls as $epc)
112 {
113 echo '<a href="' . $epc['url'] . '" data-fancybox="epcs" rel="nofollow"><img src="' . esc_url($epc['url']) . '" alt=""></a>';
114 }
115 }
116 }
117 else
118 {
119 $epc_attachment_ids = $property->get_epc_attachment_ids();
120
121 if ( !empty($epc_attachment_ids) )
122 {
123 echo '<div class="epcs">';
124
125 echo '<h4>' . esc_html(__( 'EPCs', 'propertyhive' )) . '</h4>';
126
127 foreach ( $epc_attachment_ids as $attachment_id )
128 {
129 if ( wp_attachment_is_image($attachment_id) )
130 {
131 echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" data-fancybox="epc" rel="nofollow"><img src="' . esc_url(wp_get_attachment_url($attachment_id)) . '" alt=""></a>';
132 }
133 else
134 {
135 echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" target="_blank" rel="nofollow">' . esc_html(__( 'View EPC', 'propertyhive' )) . '</a>';
136 }
137 }
138
139 echo '</div>';
140 }
141 }
142
143 }
144
145 }