PluginProbe
WP Directory Kit / 1.3.8
WP Directory Kit v1.3.8
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / elementor-elements / classes / wdk-field-icon.php

wdk-field-icon.php in WP Directory Kit 1.3.8, at elementor-elements/classes/wdk-field-icon.php

322 lines 10.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Wdk\Elementor\Widgets;
4
5 use Wdk\Elementor\Widgets\WdkElementorBase;
6 use Elementor\Widget_Base;
7 use Elementor\Controls_Manager;
8 use Elementor\Utils;
9 use Elementor\Typography;
10 use Elementor\Editor;
11 use Elementor\Plugin;
12 use Elementor\Repeater;
13 use Elementor\Core\Schemes;
14 use Elementor\Icons_Manager;
15 use Elementor\Group_Control_Typography;
16 use Elementor\Group_Control_Border;
17 use Elementor\Group_Control_Box_Shadow;
18
19 if (!defined('ABSPATH'))
20 exit; // Exit if accessed directly
21
22 /**
23 * @since 1.1.0
24 */
25 class WdkFieldIcon extends WdkElementorBase {
26
27 public $field_id = NULL;
28 public $fields_list = array();
29
30 public function __construct($data = array(), $args = null) {
31
32 \Elementor\Controls_Manager::add_tab(
33 'tab_conf',
34 esc_html__('Settings', 'wpdirectorykit')
35 );
36
37 \Elementor\Controls_Manager::add_tab(
38 'tab_layout',
39 esc_html__('Layout', 'wpdirectorykit')
40 );
41
42 \Elementor\Controls_Manager::add_tab(
43 'tab_content',
44 esc_html__('Main', 'wpdirectorykit')
45 );
46
47 add_action( 'elementor/editor/after_enqueue_styles', function()
48 {
49 wp_add_inline_style( 'elementor-editor', '.elementor-control-content select option[value*="section"]{color:#fff;background:#000}');
50 } );
51
52 if ($this->is_edit_mode_load()) {
53 $this->enqueue_styles_scripts();
54 }
55
56 parent::__construct($data, $args);
57
58 }
59
60 /**
61 * Retrieve the list of categories the widget belongs to.
62 *
63 * Used to determine where to display the widget in the editor.
64 *
65 * Note that currently Elementor supports only one category.
66 * When multiple categories passed, Elementor uses the first one.
67 *
68 * @since 1.1.0
69 *
70 * @access public
71 *
72 * @return array Widget categories.
73 */
74 public function get_categories() {
75 return [ 'wdk-elementor-listing-preview' ];
76 }
77
78 /**
79 * Retrieve the widget name.
80 *
81 * @since 1.1.0
82 *
83 * @access public
84 *
85 * @return string Widget name.
86 */
87 public function get_name() {
88 return 'wdk-field-icon';
89 }
90
91 /**
92 * Retrieve the widget title.
93 *
94 * @since 1.1.0
95 *
96 * @access public
97 *
98 * @return string Widget title.
99 */
100 public function get_title() {
101 return esc_html__('Wdk Field Icon', 'wpdirectorykit');
102 }
103
104 /**
105 * Retrieve the widget icon.
106 *
107 * @since 1.1.0
108 *
109 * @access public
110 *
111 * @return string Widget icon.
112 */
113 public function get_icon() {
114 return 'eicon-image-bold';
115 }
116
117 /**
118 * Register the widget controls.
119 *
120 * Adds different input fields to allow the user to change and customize the widget settings.
121 *
122 * @since 1.1.0
123 *
124 * @access protected
125 */
126 protected function register_controls() {
127 $this->generate_controls_conf();
128 $this->generate_controls_layout();
129 $this->generate_controls_styles();
130 $this->generate_controls_content();
131
132 $this->insert_pro_message('1');
133 parent::register_controls();
134 }
135
136 /**
137 * Render the widget output on the frontend.
138 *
139 * Written in PHP and used to generate the final HTML.
140 *
141 * @since 1.1.0
142 *
143 * @access protected
144 */
145 protected function render() {
146 parent::render();
147 global $wdk_listing_id;
148
149 $this->data['id_element'] = $this->get_id();
150 $this->data['settings'] = $this->get_settings();
151
152 $this->data['field_icon'] = '';
153 if(!empty($this->data['settings']['field_id'])) {
154 if(strpos($this->data['settings']['field_id'],'__') !== FALSE){
155 $this->data['settings']['field_id'] = substr($this->data['settings']['field_id'], strpos($this->data['settings']['field_id'],'__')+2);
156 }
157 if(wdk_field_option ($this->data['settings']['field_id'], 'icon_id'))
158 $this->data['field_icon'] = wdk_field_option ($this->data['settings']['field_id'], 'icon_id');
159 }
160
161
162 $this->data['is_edit_mode']= false;
163 if(Plugin::$instance->editor->is_edit_mode()){
164 $this->data['is_edit_mode']= true;
165 } else {
166
167 /* return false if no content */
168 if($this->data['settings']['hide_onempty'] == 'yes' && wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id) == '')
169 return false;
170
171 /* return false if no content */
172 if(wdk_field_option ($this->data['settings']['field_id'], 'icon_id') == ''|| wdk_field_option ($this->data['settings']['field_id'], 'icon_id') == 0)
173 return false;
174 }
175
176 echo $this->view('wdk-field-icon', $this->data);
177 }
178
179
180 private function generate_controls_conf() {
181 $this->start_controls_section(
182 'tab_conf_main_section',
183 [
184 'label' => esc_html__('Main', 'wpdirectorykit'),
185 'tab' => '1',
186 ]
187 );
188
189 $fields_data = wdk_cached_field_get();
190 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
191 $order_i = 0;
192
193 $fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
194 $fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit');
195 $fields_list [(++$order_i).'__post_content'] = esc_html__('WP Content', 'wpdirectorykit');
196 $fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit');
197 $fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit');
198 $fields_list [(++$order_i).'__location_id'] = esc_html__('Location', 'wpdirectorykit');
199
200 foreach($fields_data as $field)
201 {
202 if(wmvc_show_data('field_type', $field) == 'SECTION') {
203 $fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
204 } else {
205 $fields_list[(++$order_i).'__'.wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field).'['.wmvc_show_data('field_type', $field).']';
206 }
207 }
208 $this->add_control(
209 'field_id',
210 [
211 'label' => __( 'Field id', 'wpdirectorykit' ),
212 'type' => \Elementor\Controls_Manager::SELECT2,
213 'default' => '',
214 'options' => $fields_list,
215 'separator' => 'after',
216 ]
217 );
218
219 $this->add_control(
220 'hide_onempty',
221 [
222 'label' => __( 'Hide if empty', 'wpdirectorykit' ),
223 'type' => \Elementor\Controls_Manager::SWITCHER,
224 'label_on' => __( 'True', 'wpdirectorykit' ),
225 'label_off' => __( 'False', 'wpdirectorykit' ),
226 'return_value' => 'yes',
227 'default' => '',
228 ]
229 );
230
231 $this->end_controls_section();
232
233 }
234
235 private function generate_controls_layout() {
236 }
237
238
239 private function generate_controls_styles() {
240 $this->start_controls_section(
241 'field_group',
242 [
243 'label' => esc_html__('Field icon', 'wpdirectorykit'),
244 'tab' => Controls_Manager::TAB_STYLE,
245 ]
246 );
247
248 $this->add_responsive_control (
249 'field_group_icon_max_heigth',
250 [
251 'label' => esc_html__('Max Height', 'wpdirectorykit'),
252 'type' => Controls_Manager::SLIDER,
253 'range' => [
254 'px' => [
255 'min' => 10,
256 'max' => 1500,
257 ],
258 'vw' => [
259 'min' => 0,
260 'max' => 100,
261 ],
262 '%' => [
263 'min' => 0,
264 'max' => 100,
265 ],
266 ],
267 'size_units' => [ 'px', 'vw','%' ],
268 'default' => [
269 'unit' => 'px',
270 'size' => 18,
271 ],
272 'selectors' => [
273 '{{WRAPPER}} .wdk-field-icon' => 'max-width: {{SIZE}}{{UNIT}}',
274 ],
275 ]
276 );
277
278
279 $this->add_responsive_control (
280 'field_group_icon_max_width',
281 [
282 'label' => esc_html__('Max Width', 'wpdirectorykit'),
283 'type' => Controls_Manager::SLIDER,
284 'range' => [
285 'px' => [
286 'min' => 10,
287 'max' => 1500,
288 ],
289 'vw' => [
290 'min' => 0,
291 'max' => 100,
292 ],
293 '%' => [
294 'min' => 0,
295 'max' => 100,
296 ],
297 ],
298 'size_units' => [ 'px', 'vw','%' ],
299 'default' => [
300 'unit' => 'px',
301 'size' => 18,
302 ],
303 'selectors' => [
304 '{{WRAPPER}} .wdk-field-icon' => 'max-width: {{SIZE}}{{UNIT}}',
305 ],
306 ]
307 );
308
309 $this->end_controls_section();
310 /* END special for some elements */
311 }
312
313
314 private function generate_controls_content() {
315
316 }
317
318 public function enqueue_styles_scripts() {
319
320 }
321 }
322