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

607 lines 20.4 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_city' => __('City', 'wpdirectorykit'),
481 'wdk_position_title' => __('Position Title', 'wpdirectorykit'),
482 'wdk_linkedin' => __('Linkedin', 'wpdirectorykit'),
483 'wdk_twitter' => __('Twitter', 'wpdirectorykit'),
484 'wdk_telegram' => __('Telegram', 'wpdirectorykit'),
485 'wdk_whatsapp' => __('What`s App', 'wpdirectorykit'),
486 'wdk_viber' => __('Viber', 'wpdirectorykit'),
487 'wdk_iban' => __('IBAN', 'wpdirectorykit'),
488 'wdk_company_name' => __('Company name', 'wpdirectorykit'),
489 'agency_name' => __('Agency Name', 'wpdirectorykit'),
490 );
491
492 $repeater = new Repeater();
493 $repeater->start_controls_tabs( 'meta_fields' );
494 $repeater->add_control(
495 'meta_field',
496 [
497 'label' => __( 'Meta Fields', 'wpdirectorykit' ),
498 'type' => \Elementor\Controls_Manager::SELECT,
499 'description' => __( 'Only one field per type will be visible', 'wpdirectorykit' ),
500 'default' => '',
501 'options' => $meta_fields
502 ]
503 );
504
505 $repeater->end_controls_tabs();
506
507
508 $this->add_control(
509 'meta_title',
510 [
511 'label' => __( 'Meta Fields', 'wpdirectorykit' ),
512 'type' => \Elementor\Controls_Manager::HEADING,
513 'separator' => 'before',
514 ]
515 );
516
517 $this->add_control(
518 'meta_fields_list',
519 [
520 'type' => Controls_Manager::REPEATER,
521 'fields' => $repeater->get_controls(),
522 'default' => [
523 [
524 'meta_field' => 'wdk_phone',
525 ],
526 [
527 'meta_field' => 'user_email',
528 ],
529 ],
530 'title_field' => '{{{ meta_field }}}',
531 ]
532 );
533
534
535 $this->end_controls_section();
536
537 }
538
539 private function generate_controls_layout() {
540 }
541
542
543 private function generate_controls_styles() {
544 $items = [
545 [
546 'key'=>'agent_cont',
547 'label'=> esc_html__('Content Box', 'wpdirectorykit'),
548 'selector'=>'.wdk-listing-agent .agent-cont',
549 'options'=> 'block',
550 ],
551 [
552 'key'=>'agent_title',
553 'label'=> esc_html__('Agent Name', 'wpdirectorykit'),
554 'selector'=>'.wdk-listing-agent .agent-cont .title',
555 'options'=>'full',
556 ],
557 [
558 'key'=>'agent_meta',
559 'label'=> esc_html__('Agent Meta', 'wpdirectorykit'),
560 'selector'=>'.wdk-element .wdk-listing-agent .agent-cont .meta-item',
561 'options'=>'full',
562 ],
563 [
564 'key'=>'agent_meta_icon',
565 'label'=> esc_html__('Agent Meta Icon', 'wpdirectorykit'),
566 'selector'=>'.wdk-element .wdk-listing-agent .agent-cont .meta-item i',
567 'options'=>'full',
568 ]
569 ];
570
571 foreach ($items as $item) {
572 $this->start_controls_section(
573 $item['key'].'_section',
574 [
575 'label' => $item['label'],
576 'tab' => 'tab_layout'
577 ]
578 );
579
580 if( $item ['key'] == 'field_value'){
581 $selectors = array(
582 'normal' => '{{WRAPPER}} .wdk-listing-agent',
583 );
584 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic_align', ['align']);
585 }
586
587 $selectors = array(
588 'normal' => '{{WRAPPER}} '.$item['selector'],
589 'hover'=>'{{WRAPPER}} '.$item['selector'].'%1$s'
590 );
591 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options'], ['align']);
592
593 $this->end_controls_section();
594 /* END special for some elements */
595 }
596
597 }
598
599 private function generate_controls_content() {
600
601 }
602
603 public function enqueue_styles_scripts() {
604 wp_enqueue_style('wdk-listing-agent');
605 }
606 }
607