PluginProbe
WP Directory Kit / 1.2.3
WP Directory Kit v1.2.3
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 1.4.0 1.4.1 All 35 releases
wpdirectorykit / elementor-elements / classes / wdk-listing-agent.php

wdk-listing-agent.php in WP Directory Kit 1.2.3, at elementor-elements/classes/wdk-listing-agent.php

577 lines 19.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 WdkListinAgent 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 if ($this->is_edit_mode_load()) {
48 $this->enqueue_styles_scripts();
49 }
50
51 parent::__construct($data, $args);
52
53 }
54
55 /**
56 * Retrieve the list of categories the widget belongs to.
57 *
58 * Used to determine where to display the widget in the editor.
59 *
60 * Note that currently Elementor supports only one category.
61 * When multiple categories passed, Elementor uses the first one.
62 *
63 * @since 1.1.0
64 *
65 * @access public
66 *
67 * @return array Widget categories.
68 */
69 public function get_categories() {
70 return [ 'wdk-elementor-listing-preview' ];
71 }
72
73 /**
74 * Retrieve the widget name.
75 *
76 * @since 1.1.0
77 *
78 * @access public
79 *
80 * @return string Widget name.
81 */
82 public function get_name() {
83 return 'wdk-listing-agent';
84 }
85
86 /**
87 * Retrieve the widget title.
88 *
89 * @since 1.1.0
90 *
91 * @access public
92 *
93 * @return string Widget title.
94 */
95 public function get_title() {
96 return esc_html__('Wdk Listing Agent', 'wpdirectorykit');
97 }
98
99 /**
100 * Retrieve the widget icon.
101 *
102 * @since 1.1.0
103 *
104 * @access public
105 *
106 * @return string Widget icon.
107 */
108 public function get_icon() {
109 return 'eicon-user-circle-o';
110 }
111
112 /**
113 * Register the widget controls.
114 *
115 * Adds different input fields to allow the user to change and customize the widget settings.
116 *
117 * @since 1.1.0
118 *
119 * @access protected
120 */
121 protected function register_controls() {
122 $this->generate_controls_conf();
123 $this->generate_controls_layout();
124 $this->generate_controls_styles();
125 $this->generate_controls_content();
126
127 $this->insert_pro_message('1');
128 parent::register_controls();
129 }
130
131 /**
132 * Render the widget output on the frontend.
133 *
134 * Written in PHP and used to generate the final HTML.
135 *
136 * @since 1.1.0
137 *
138 * @access protected
139 */
140 protected function render() {
141 parent::render();
142 global $wdk_listing_id;
143
144 $this->data['id_element'] = $this->get_id();
145 $this->data['settings'] = $this->get_settings();
146
147 $this->WMVC->model('listing_m');
148 $user = NULL;
149 $listing = $this->WMVC->listing_m->get($wdk_listing_id, TRUE);
150 $this->data['userdata'] = false;
151 $this->data['user_id'] = false;
152
153 if($this->data['settings']['user_editor_disabled'] !='yes') {
154 if(wmvc_show_data('user_id_editor', $listing, '',TRUE, TRUE)) {
155 $this->data['user_id'] = wmvc_show_data('user_id_editor', $listing);
156 // Get user data by user id
157 $this->data['userdata'] = get_userdata($this->data['user_id']);
158 }
159 }
160
161 $this->WMVC->model('listingusers_m');
162
163 if(Plugin::$instance->editor->is_edit_mode()) {
164 $this->WMVC->db->limit(3);
165 }
166
167 $this->data['listing_alt_agents'] = array();
168 if($this->data['settings']['alternative_agents_disabled'] !='yes') {
169 $this->data['listing_alt_agents'] = $this->WMVC->listingusers_m->get($wdk_listing_id);
170 }
171
172 $this->data['is_edit_mode']= false;
173 if(Plugin::$instance->editor->is_edit_mode()) {
174 $this->data['is_edit_mode']= true;
175 } else {
176
177 }
178
179 echo $this->view('wdk-listing-agent', $this->data);
180 }
181
182
183 private function generate_controls_conf() {
184 $this->start_controls_section(
185 'tab_conf_main_section',
186 [
187 'label' => esc_html__('Main', 'wpdirectorykit'),
188 'tab' => '1',
189 ]
190 );
191
192
193 $this->add_control(
194 'layout',
195 [
196 'label' => __( 'Layout', 'wpdirectorykit' ),
197 'type' => \Elementor\Controls_Manager::SELECT,
198 'default' => '',
199 'options' => array(
200 '' => __( 'Horizontal', 'wpdirectorykit' ),
201 'vertical' => __( 'Vertical', 'wpdirectorykit' ),
202 ),
203 'separator' => 'after',
204 ]
205 );
206
207 $this->add_control (
208 'user_editor_disabled',
209 [
210 'label' => __( 'Hide Agent Editor', 'wpdirectorykit' ),
211 'type' => Controls_Manager::SWITCHER,
212 'label_on' => __( 'Hide', 'wpdirectorykit' ),
213 'label_off' => __( 'Show', 'wpdirectorykit' ),
214 'return_value' => 'yes',
215 'default' => '',
216 ]
217 );
218
219 $this->add_control(
220 'alternative_agents_disabled',
221 [
222 'label' => __( 'Hide Alternative agents', 'wpdirectorykit' ),
223 'type' => Controls_Manager::SWITCHER,
224 'label_on' => __( 'Hide', 'wpdirectorykit' ),
225 'label_off' => __( 'Show', 'wpdirectorykit' ),
226 'return_value' => 'yes',
227 'default' => '',
228 'separator' => 'after',
229 ]
230 );
231 $this->add_responsive_control(
232 'row_gap_col',
233 [
234 'label' => __( 'Columns', 'wpdirectorykit' ),
235 'type' => Controls_Manager::SELECT,
236 'options' => [
237 '' => esc_html__('Default', 'wpdirectorykit'),
238 'auto' => esc_html__('Auto', 'wpdirectorykit'),
239 '100%' => '1',
240 '50%' => '2',
241 'calc(100% / 3)' => '3',
242 '25%' => '4',
243 '20%' => '5',
244 'auto_flexible' => 'auto flexible',
245 ],
246 'selectors_dictionary' => [
247 'auto' => '-webkit-flex:1 2 auto;flex:1 2 auto',
248 '100%' => '-webkit-flex:1 2 100%;flex:1 2 100%',
249 '50%' => '-webkit-flex:1 2 50%;flex:1 2 50%',
250 'calc(100% / 3)' => '-webkit-flex:1 2 calc(100% / 3);flex:1 2 calc(100% / 3)',
251 '25%' => '-webkit-flex:1 2 25%;flex:1 2 25%',
252 '20%' => '-webkit-flex:1 2 20%;flex:1 2 20%',
253 'auto' => '-webkit-flex:1 2 auto;flex:1 2 auto',
254 'auto_flexible' => '-webkit-flex:1 2 auto;flex:1 2 auto',
255 ],
256 'selectors' => [
257 '{{WRAPPER}} .wdk-element.wdk-element-listing-agent .wdk-row .wdk-col' => '{{UNIT}}',
258 ],
259 'default' => '100%',
260 'separator' => 'before',
261 ]
262 );
263
264 $this->add_responsive_control(
265 'column_gap',
266 [
267 'label' => esc_html__('Columns Gap', 'wpdirectorykit'),
268 'type' => Controls_Manager::SLIDER,
269 'default' => [
270 'size' => 10,
271 ],
272 'range' => [
273 'px' => [
274 'min' => 0,
275 'max' => 60,
276 ],
277 ],
278 'selectors' => [
279 '{{WRAPPER}} .wdk-element.wdk-element-listing-agent .wdk-row .wdk-col' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};;',
280 '{{WRAPPER}} .wdk-element.wdk-element-listing-agent .wdk-row' => 'margin-left: -{{SIZE}}{{UNIT}};margin-right: -{{SIZE}}{{UNIT}};',
281 ],
282 ]
283 );
284
285 $this->add_responsive_control(
286 'row_gap',
287 [
288 'label' => esc_html__('Rows Gap', 'wpdirectorykit'),
289 'type' => Controls_Manager::SLIDER,
290 'default' => [
291 'size' => 10,
292 ],
293 'range' => [
294 'px' => [
295 'min' => 0,
296 'max' => 60,
297 ],
298 ],
299 'selectors' => [
300 '{{WRAPPER}} .wdk-element.wdk-element-listing-agent .wdk-row .wdk-col' => 'margin-bottom: {{SIZE}}{{UNIT}};',
301 '{{WRAPPER}} .wdk-element.wdk-element-listing-agent .wdk-row' => 'margin-bottom: -{{SIZE}}{{UNIT}};',
302 ],
303 ]
304 );
305
306
307 $this->add_control(
308 'thumbnail_hide',
309 [
310 'label' => __( 'Thumbnail hide', 'wpdirectorykit' ),
311 'type' => Controls_Manager::SWITCHER,
312 'label_on' => __( 'Show', 'wpdirectorykit' ),
313 'label_off' => __( 'Hide', 'wpdirectorykit' ),
314 'return_value' => 'none',
315 'default' => '',
316 'selectors' => [
317 '{{WRAPPER}} .wdk-element .wdk-listing-agent .agent-thumbnail' => 'display: {{VALUE}};',
318 ],
319 'separator' => 'before',
320 ]
321 );
322
323 $this->add_responsive_control (
324 'thumbnail_width',
325 [
326 'label' => esc_html__('Thumbnail width', 'wpdirectorykit'),
327 'type' => Controls_Manager::SLIDER,
328 'range' => [
329 'px' => [
330 'min' => 10,
331 'max' => 3000,
332 ],
333 'vw' => [
334 'min' => 0,
335 'max' => 100,
336 ],
337 ],
338 'size_units' => [ 'px', 'vw' ],
339 'default' => [
340 'size' => 90,
341 'unit' => 'px',
342 ],
343 'selectors' => [
344 '{{WRAPPER}} .wdk-element .wdk-listing-agent .agent-thumbnail' => 'flex: 0 0 {{SIZE}}{{UNIT}};
345 min-width: {{SIZE}}{{UNIT}};
346 width: {{SIZE}}{{UNIT}}',
347 ],
348 'conditions' => [
349 'terms' => [
350 [
351 'name' => 'layout',
352 'operator' => '==',
353 'value' => '',
354 ],
355 [
356 'name' => 'thumbnail_hide',
357 'operator' => '==',
358 'value' => '',
359 ]
360 ],
361 ],
362 ]
363 );
364
365 $this->add_responsive_control (
366 'thumbnail_height_max',
367 [
368 'label' => esc_html__('Max Thumbnail height', 'wpdirectorykit'),
369 'type' => Controls_Manager::SLIDER,
370 'range' => [
371 'px' => [
372 'min' => 5,
373 'max' => 500,
374 ],
375 'vw' => [
376 'min' => 0,
377 'max' => 100,
378 ],
379 ],
380 'size_units' => [ 'px', 'vw' ],
381 'selectors' => [
382 '{{WRAPPER}} .wdk-element .wdk-listing-agent .agent-thumbnail img' => 'max-height: {{SIZE}}{{UNIT}};',
383 ],
384 'conditions' => [
385 'terms' => [
386 [
387 'name' => 'layout',
388 'operator' => '==',
389 'value' => '',
390 ],
391 [
392 'name' => 'thumbnail_hide',
393 'operator' => '==',
394 'value' => '',
395 ]
396 ],
397 ],
398 ]
399 );
400
401 $this->add_responsive_control (
402 'thumbnail_height',
403 [
404 'label' => esc_html__('Thumbnail max height', 'wpdirectorykit'),
405 'type' => Controls_Manager::SLIDER,
406 'range' => [
407 'px' => [
408 'min' => 10,
409 'max' => 3000,
410 ],
411 'vw' => [
412 'min' => 0,
413 'max' => 100,
414 ],
415 ],
416 'size_units' => [ 'px', 'vw' ],
417 'default' => [
418 'size' => 250,
419 'unit' => 'px',
420 ],
421 'selectors' => [
422 '{{WRAPPER}} .wdk-element .wdk-listing-agent .agent-thumbnail img' => 'max-height:{{SIZE}}{{UNIT}}',
423 ],
424 'conditions' => [
425 'terms' => [
426 [
427 'name' => 'layout',
428 'operator' => '==',
429 'value' => 'vertical',
430 ],
431 [
432 'name' => 'thumbnail_hide',
433 'operator' => '==',
434 'value' => '',
435 ]
436 ],
437 ],
438 ]
439 );
440
441 $meta_fields = array(
442 '' => __('Not Selected', 'wpdirectorykit'),
443 'wdk_phone' => __('Phone', 'wpdirectorykit'),
444 'user_email' => __('Email', 'wpdirectorykit'),
445 'user_url' => __('Url', 'wpdirectorykit'),
446 'display_name' => __('Display Name', 'wpdirectorykit'),
447 'description' => __('Bio', 'wpdirectorykit'),
448 'wdk_facebook' => __('Facebook', 'wpdirectorykit'),
449 'wdk_youtube' => __('Youtube', 'wpdirectorykit'),
450 'wdk_address' => __('Address', 'wpdirectorykit'),
451 'wdk_city' => __('City', 'wpdirectorykit'),
452 'wdk_position_title' => __('Position Title', 'wpdirectorykit'),
453 'wdk_linkedin' => __('Linkedin', 'wpdirectorykit'),
454 'wdk_twitter' => __('Twitter', 'wpdirectorykit'),
455 'wdk_telegram' => __('Telegram', 'wpdirectorykit'),
456 'wdk_whatsapp' => __('What`s App', 'wpdirectorykit'),
457 'wdk_viber' => __('Viber', 'wpdirectorykit'),
458 'wdk_iban' => __('IBAN', 'wpdirectorykit'),
459 'wdk_company_name' => __('Company name', 'wpdirectorykit'),
460 );
461
462 $repeater = new Repeater();
463 $repeater->start_controls_tabs( 'meta_fields' );
464 $repeater->add_control(
465 'meta_field',
466 [
467 'label' => __( 'Meta Fields', 'wpdirectorykit' ),
468 'type' => \Elementor\Controls_Manager::SELECT,
469 'description' => __( 'Only one field per type will be visible', 'wpdirectorykit' ),
470 'default' => '',
471 'options' => $meta_fields
472 ]
473 );
474
475 $repeater->end_controls_tabs();
476
477
478 $this->add_control(
479 'meta_title',
480 [
481 'label' => __( 'Meta Fields', 'wpdirectorykit' ),
482 'type' => \Elementor\Controls_Manager::HEADING,
483 'separator' => 'before',
484 ]
485 );
486
487 $this->add_control(
488 'meta_fields_list',
489 [
490 'type' => Controls_Manager::REPEATER,
491 'fields' => $repeater->get_controls(),
492 'default' => [
493 [
494 'meta_field' => 'wdk_phone',
495 ],
496 [
497 'meta_field' => 'user_email',
498 ],
499 ],
500 'title_field' => '{{{ meta_field }}}',
501 ]
502 );
503
504
505 $this->end_controls_section();
506
507 }
508
509 private function generate_controls_layout() {
510 }
511
512
513 private function generate_controls_styles() {
514 $items = [
515 [
516 'key'=>'agent_cont',
517 'label'=> esc_html__('Content Box', 'wpdirectorykit'),
518 'selector'=>'.wdk-listing-agent .agent-cont',
519 'options'=> 'block',
520 ],
521 [
522 'key'=>'agent_title',
523 'label'=> esc_html__('Agent Name', 'wpdirectorykit'),
524 'selector'=>'.wdk-listing-agent .agent-cont .title',
525 'options'=>'full',
526 ],
527 [
528 'key'=>'agent_meta',
529 'label'=> esc_html__('Agent Meta', 'wpdirectorykit'),
530 'selector'=>'.wdk-element .wdk-listing-agent .agent-cont .meta-item',
531 'options'=>'full',
532 ],
533 [
534 'key'=>'agent_meta_icon',
535 'label'=> esc_html__('Agent Meta Icon', 'wpdirectorykit'),
536 'selector'=>'.wdk-element .wdk-listing-agent .agent-cont .meta-item i',
537 'options'=>'full',
538 ]
539 ];
540
541 foreach ($items as $item) {
542 $this->start_controls_section(
543 $item['key'].'_section',
544 [
545 'label' => $item['label'],
546 'tab' => 'tab_layout'
547 ]
548 );
549
550 if( $item ['key'] == 'field_value'){
551 $selectors = array(
552 'normal' => '{{WRAPPER}} .wdk-listing-agent',
553 );
554 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic_align', ['align']);
555 }
556
557 $selectors = array(
558 'normal' => '{{WRAPPER}} '.$item['selector'],
559 'hover'=>'{{WRAPPER}} '.$item['selector'].'%1$s'
560 );
561 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options'], ['align']);
562
563 $this->end_controls_section();
564 /* END special for some elements */
565 }
566
567 }
568
569 private function generate_controls_content() {
570
571 }
572
573 public function enqueue_styles_scripts() {
574 wp_enqueue_style('wdk-listing-agent');
575 }
576 }
577