PluginProbe
WP Directory Kit / 1.3.4
WP Directory Kit v1.3.4
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.3.4, at elementor-elements/classes/wdk-listing-agent.php

608 lines 20.5 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, $Winter_MVC_wdk_membership;
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['listing_agency'] = false;
173 if($this->data['settings']['listing_agency_disabled'] !='yes') {
174 if(function_exists('run_wdk_membership') && file_exists(WDK_MEMBERSHIP_PATH.'application/models/Agency_agent_m.php')) {
175 if(wmvc_show_data('user_id_editor', $listing, '',TRUE, TRUE)) {
176 $Winter_MVC_wdk_membership->model('agency_agent_m');
177 $agent_id = wmvc_show_data('user_id_editor', $listing, '',TRUE, TRUE);
178 $agent_agency = $Winter_MVC_wdk_membership->agency_agent_m->get_by(array('agent_id' => $agent_id, 'status' => 'CONFIRMED'), TRUE);
179 if($agent_agency) {
180 $user = wdk_get_user_data( wmvc_show_data('agency_id', $agent_agency, 0));
181 if($user){
182 $this->data['listing_agency'] = $user;
183 }
184 }
185 }
186 }
187 }
188
189 $this->data['is_edit_mode']= false;
190 if(Plugin::$instance->editor->is_edit_mode()) {
191 $this->data['is_edit_mode']= true;
192 echo $this->view('wdk-listing-agent-demo', $this->data);
193 } else {
194 echo $this->view('wdk-listing-agent', $this->data);
195 }
196
197 }
198
199
200 private function generate_controls_conf() {
201 $this->start_controls_section(
202 'tab_conf_main_section',
203 [
204 'label' => esc_html__('Main', 'wpdirectorykit'),
205 'tab' => '1',
206 ]
207 );
208
209
210 $this->add_control(
211 'layout',
212 [
213 'label' => __( 'Layout', 'wpdirectorykit' ),
214 'type' => \Elementor\Controls_Manager::SELECT,
215 'default' => '',
216 'options' => array(
217 '' => __( 'Horizontal', 'wpdirectorykit' ),
218 'vertical' => __( 'Vertical', 'wpdirectorykit' ),
219 ),
220 'separator' => 'after',
221 ]
222 );
223
224 $this->add_control (
225 'listing_agency_disabled',
226 [
227 'label' => __( 'Hide Agency', 'wpdirectorykit' ),
228 'type' => Controls_Manager::SWITCHER,
229 'label_on' => __( 'Hide', 'wpdirectorykit' ),
230 'label_off' => __( 'Show', 'wpdirectorykit' ),
231 'return_value' => 'yes',
232 'default' => '',
233 ]
234 );
235
236 $this->add_control (
237 'user_editor_disabled',
238 [
239 'label' => __( 'Hide Agent Editor', 'wpdirectorykit' ),
240 'type' => Controls_Manager::SWITCHER,
241 'label_on' => __( 'Hide', 'wpdirectorykit' ),
242 'label_off' => __( 'Show', 'wpdirectorykit' ),
243 'return_value' => 'yes',
244 'default' => '',
245 ]
246 );
247
248 $this->add_control(
249 'alternative_agents_disabled',
250 [
251 'label' => __( 'Hide Alternative agents', 'wpdirectorykit' ),
252 'type' => Controls_Manager::SWITCHER,
253 'label_on' => __( 'Hide', 'wpdirectorykit' ),
254 'label_off' => __( 'Show', 'wpdirectorykit' ),
255 'return_value' => 'yes',
256 'default' => '',
257 'separator' => 'after',
258 ]
259 );
260 $this->add_responsive_control(
261 'row_gap_col',
262 [
263 'label' => __( 'Columns', 'wpdirectorykit' ),
264 'type' => Controls_Manager::SELECT,
265 'options' => [
266 '' => esc_html__('Default', 'wpdirectorykit'),
267 'auto' => esc_html__('Auto', 'wpdirectorykit'),
268 '100%' => '1',
269 '50%' => '2',
270 'calc(100% / 3)' => '3',
271 '25%' => '4',
272 '20%' => '5',
273 'auto_flexible' => 'auto flexible',
274 ],
275 'selectors_dictionary' => [
276 'auto' => '-webkit-flex:1 2 auto;flex:1 2 auto',
277 '100%' => '-webkit-flex:1 2 100%;flex:1 2 100%',
278 '50%' => '-webkit-flex:1 2 50%;flex:1 2 50%',
279 'calc(100% / 3)' => '-webkit-flex:1 2 calc(100% / 3);flex:1 2 calc(100% / 3)',
280 '25%' => '-webkit-flex:1 2 25%;flex:1 2 25%',
281 '20%' => '-webkit-flex:1 2 20%;flex:1 2 20%',
282 'auto' => '-webkit-flex:1 2 auto;flex:1 2 auto',
283 'auto_flexible' => '-webkit-flex:1 2 auto;flex:1 2 auto',
284 ],
285 'selectors' => [
286 '{{WRAPPER}} .wdk-element.wdk-element-listing-agent .wdk-row .wdk-col' => '{{UNIT}}',
287 ],
288 'default' => '100%',
289 'separator' => 'before',
290 ]
291 );
292
293 $this->add_responsive_control(
294 'column_gap',
295 [
296 'label' => esc_html__('Columns Gap', 'wpdirectorykit'),
297 'type' => Controls_Manager::SLIDER,
298 'default' => [
299 'size' => 10,
300 ],
301 'range' => [
302 'px' => [
303 'min' => 0,
304 'max' => 60,
305 ],
306 ],
307 'selectors' => [
308 '{{WRAPPER}} .wdk-element.wdk-element-listing-agent .wdk-row .wdk-col' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};;',
309 '{{WRAPPER}} .wdk-element.wdk-element-listing-agent .wdk-row' => 'margin-left: -{{SIZE}}{{UNIT}};margin-right: -{{SIZE}}{{UNIT}};',
310 ],
311 ]
312 );
313
314 $this->add_responsive_control(
315 'row_gap',
316 [
317 'label' => esc_html__('Rows Gap', 'wpdirectorykit'),
318 'type' => Controls_Manager::SLIDER,
319 'default' => [
320 'size' => 10,
321 ],
322 'range' => [
323 'px' => [
324 'min' => 0,
325 'max' => 60,
326 ],
327 ],
328 'selectors' => [
329 '{{WRAPPER}} .wdk-element.wdk-element-listing-agent .wdk-row .wdk-col' => 'margin-bottom: {{SIZE}}{{UNIT}};',
330 '{{WRAPPER}} .wdk-element.wdk-element-listing-agent .wdk-row' => 'margin-bottom: -{{SIZE}}{{UNIT}};',
331 ],
332 ]
333 );
334
335
336 $this->add_control(
337 'thumbnail_hide',
338 [
339 'label' => __( 'Thumbnail hide', 'wpdirectorykit' ),
340 'type' => Controls_Manager::SWITCHER,
341 'label_on' => __( 'Show', 'wpdirectorykit' ),
342 'label_off' => __( 'Hide', 'wpdirectorykit' ),
343 'return_value' => 'none',
344 'default' => '',
345 'selectors' => [
346 '{{WRAPPER}} .wdk-element .wdk-listing-agent .agent-thumbnail' => 'display: {{VALUE}};',
347 ],
348 'separator' => 'before',
349 ]
350 );
351
352 $this->add_responsive_control (
353 'thumbnail_width',
354 [
355 'label' => esc_html__('Thumbnail width', 'wpdirectorykit'),
356 'type' => Controls_Manager::SLIDER,
357 'range' => [
358 'px' => [
359 'min' => 10,
360 'max' => 3000,
361 ],
362 'vw' => [
363 'min' => 0,
364 'max' => 100,
365 ],
366 ],
367 'size_units' => [ 'px', 'vw' ],
368 'default' => [
369 'size' => 90,
370 'unit' => 'px',
371 ],
372 'selectors' => [
373 '{{WRAPPER}} .wdk-element .wdk-listing-agent .agent-thumbnail' => 'flex: 0 0 {{SIZE}}{{UNIT}};
374 min-width: {{SIZE}}{{UNIT}};
375 width: {{SIZE}}{{UNIT}}',
376 ],
377 'conditions' => [
378 'terms' => [
379 [
380 'name' => 'layout',
381 'operator' => '==',
382 'value' => '',
383 ],
384 [
385 'name' => 'thumbnail_hide',
386 'operator' => '==',
387 'value' => '',
388 ]
389 ],
390 ],
391 ]
392 );
393
394 $this->add_responsive_control (
395 'thumbnail_height_max',
396 [
397 'label' => esc_html__('Max Thumbnail height', 'wpdirectorykit'),
398 'type' => Controls_Manager::SLIDER,
399 'range' => [
400 'px' => [
401 'min' => 5,
402 'max' => 500,
403 ],
404 'vw' => [
405 'min' => 0,
406 'max' => 100,
407 ],
408 ],
409 'size_units' => [ 'px', 'vw' ],
410 'selectors' => [
411 '{{WRAPPER}} .wdk-element .wdk-listing-agent .agent-thumbnail img' => 'max-height: {{SIZE}}{{UNIT}};',
412 ],
413 'conditions' => [
414 'terms' => [
415 [
416 'name' => 'layout',
417 'operator' => '==',
418 'value' => '',
419 ],
420 [
421 'name' => 'thumbnail_hide',
422 'operator' => '==',
423 'value' => '',
424 ]
425 ],
426 ],
427 ]
428 );
429
430 $this->add_responsive_control (
431 'thumbnail_height',
432 [
433 'label' => esc_html__('Thumbnail max height', 'wpdirectorykit'),
434 'type' => Controls_Manager::SLIDER,
435 'range' => [
436 'px' => [
437 'min' => 10,
438 'max' => 3000,
439 ],
440 'vw' => [
441 'min' => 0,
442 'max' => 100,
443 ],
444 ],
445 'size_units' => [ 'px', 'vw' ],
446 'default' => [
447 'size' => 250,
448 'unit' => 'px',
449 ],
450 'selectors' => [
451 '{{WRAPPER}} .wdk-element .wdk-listing-agent .agent-thumbnail img' => 'max-height:{{SIZE}}{{UNIT}}',
452 ],
453 'conditions' => [
454 'terms' => [
455 [
456 'name' => 'layout',
457 'operator' => '==',
458 'value' => 'vertical',
459 ],
460 [
461 'name' => 'thumbnail_hide',
462 'operator' => '==',
463 'value' => '',
464 ]
465 ],
466 ],
467 ]
468 );
469
470 $meta_fields = array(
471 '' => __('Not Selected', 'wpdirectorykit'),
472 'wdk_phone' => __('Phone', 'wpdirectorykit'),
473 'user_email' => __('Email', 'wpdirectorykit'),
474 'user_url' => __('Url', 'wpdirectorykit'),
475 'display_name' => __('Display Name', 'wpdirectorykit'),
476 'description' => __('Bio', 'wpdirectorykit'),
477 'wdk_facebook' => __('Facebook', 'wpdirectorykit'),
478 'wdk_youtube' => __('Youtube', 'wpdirectorykit'),
479 'wdk_address' => __('Address', 'wpdirectorykit'),
480 'wdk_country' => __('Country', 'wdk-membership'),
481 'wdk_city' => __('City', 'wpdirectorykit'),
482 'wdk_position_title' => __('Position Title', 'wpdirectorykit'),
483 'wdk_linkedin' => __('Linkedin', 'wpdirectorykit'),
484 'wdk_twitter' => __('Twitter', 'wpdirectorykit'),
485 'wdk_telegram' => __('Telegram', 'wpdirectorykit'),
486 'wdk_whatsapp' => __('WhatsApp', 'wpdirectorykit'),
487 'wdk_viber' => __('Viber', 'wpdirectorykit'),
488 'wdk_iban' => __('IBAN', 'wpdirectorykit'),
489 'wdk_company_name' => __('Company name', 'wpdirectorykit'),
490 'agency_name' => __('Agency Name', 'wpdirectorykit'),
491 );
492
493 $repeater = new Repeater();
494 $repeater->start_controls_tabs( 'meta_fields' );
495 $repeater->add_control(
496 'meta_field',
497 [
498 'label' => __( 'Meta Fields', 'wpdirectorykit' ),
499 'type' => \Elementor\Controls_Manager::SELECT,
500 'description' => __( 'Only one field per type will be visible', 'wpdirectorykit' ),
501 'default' => '',
502 'options' => $meta_fields
503 ]
504 );
505
506 $repeater->end_controls_tabs();
507
508
509 $this->add_control(
510 'meta_title',
511 [
512 'label' => __( 'Meta Fields', 'wpdirectorykit' ),
513 'type' => \Elementor\Controls_Manager::HEADING,
514 'separator' => 'before',
515 ]
516 );
517
518 $this->add_control(
519 'meta_fields_list',
520 [
521 'type' => Controls_Manager::REPEATER,
522 'fields' => $repeater->get_controls(),
523 'default' => [
524 [
525 'meta_field' => 'wdk_phone',
526 ],
527 [
528 'meta_field' => 'user_email',
529 ],
530 ],
531 'title_field' => '{{{ meta_field }}}',
532 ]
533 );
534
535
536 $this->end_controls_section();
537
538 }
539
540 private function generate_controls_layout() {
541 }
542
543
544 private function generate_controls_styles() {
545 $items = [
546 [
547 'key'=>'agent_cont',
548 'label'=> esc_html__('Content Box', 'wpdirectorykit'),
549 'selector'=>'.wdk-listing-agent .agent-cont',
550 'options'=> 'block',
551 ],
552 [
553 'key'=>'agent_title',
554 'label'=> esc_html__('Agent Name', 'wpdirectorykit'),
555 'selector'=>'.wdk-listing-agent .agent-cont .title',
556 'options'=>'full',
557 ],
558 [
559 'key'=>'agent_meta',
560 'label'=> esc_html__('Agent Meta', 'wpdirectorykit'),
561 'selector'=>'.wdk-element .wdk-listing-agent .agent-cont .meta-item',
562 'options'=>'full',
563 ],
564 [
565 'key'=>'agent_meta_icon',
566 'label'=> esc_html__('Agent Meta Icon', 'wpdirectorykit'),
567 'selector'=>'.wdk-element .wdk-listing-agent .agent-cont .meta-item i',
568 'options'=>'full',
569 ]
570 ];
571
572 foreach ($items as $item) {
573 $this->start_controls_section(
574 $item['key'].'_section',
575 [
576 'label' => $item['label'],
577 'tab' => 'tab_layout'
578 ]
579 );
580
581 if( $item ['key'] == 'field_value'){
582 $selectors = array(
583 'normal' => '{{WRAPPER}} .wdk-listing-agent',
584 );
585 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic_align', ['align']);
586 }
587
588 $selectors = array(
589 'normal' => '{{WRAPPER}} '.$item['selector'],
590 'hover'=>'{{WRAPPER}} '.$item['selector'].'%1$s'
591 );
592 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options'], ['align']);
593
594 $this->end_controls_section();
595 /* END special for some elements */
596 }
597
598 }
599
600 private function generate_controls_content() {
601
602 }
603
604 public function enqueue_styles_scripts() {
605 wp_enqueue_style('wdk-listing-agent');
606 }
607 }
608