PluginProbe
WP Directory Kit / 1.3.3
WP Directory Kit v1.3.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-related-listings-table.php

wdk-listing-related-listings-table.php in WP Directory Kit 1.3.3, at elementor-elements/classes/wdk-listing-related-listings-table.php

507 lines 16.9 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 WdkListingRelatedListingsTable extends WdkElementorBase {
26
27 public function __construct($data = array(), $args = null) {
28
29 \Elementor\Controls_Manager::add_tab(
30 'tab_conf',
31 esc_html__('Settings', 'wpdirectorykit')
32 );
33
34 \Elementor\Controls_Manager::add_tab(
35 'tab_layout',
36 esc_html__('Layout', 'wpdirectorykit')
37 );
38
39 \Elementor\Controls_Manager::add_tab(
40 'tab_content',
41 esc_html__('Main', 'wpdirectorykit')
42 );
43
44 if ($this->is_edit_mode_load()) {
45 $this->enqueue_styles_scripts();
46 }
47
48 parent::__construct($data, $args);
49 }
50
51 /**
52 * Retrieve the widget name.
53 *
54 * @since 1.1.0
55 *
56 * @access public
57 *
58 * @return string Widget name.
59 */
60 public function get_name() {
61 return 'wdk-listing-related-listings-table';
62 }
63
64 /**
65 * Retrieve the list of categories the widget belongs to.
66 *
67 * Used to determine where to display the widget in the editor.
68 *
69 * Note that currently Elementor supports only one category.
70 * When multiple categories passed, Elementor uses the first one.
71 *
72 * @since 1.1.0
73 *
74 * @access public
75 *
76 * @return array Widget categories.
77 */
78 public function get_categories() {
79 return [ 'wdk-elementor-listing-preview' ];
80 }
81
82 /**
83 * Retrieve the widget title.
84 *
85 * @since 1.1.0
86 *
87 * @access public
88 *
89 * @return string Widget title.
90 */
91 public function get_title() {
92 return esc_html__('Wdk Related Listings Table', 'wpdirectorykit');
93 }
94
95 /**
96 * Retrieve the widget icon.
97 *
98 * @since 1.1.0
99 *
100 * @access public
101 *
102 * @return string Widget icon.
103 */
104 public function get_icon() {
105 return 'eicon-products';
106 }
107
108 /**
109 * Register the widget controls.
110 *
111 * Adds different input fields to allow the user to change and customize the widget settings.
112 *
113 * @since 1.1.0
114 *
115 * @access protected
116 */
117 protected function register_controls() {
118 $this->generate_controls_conf();
119 $this->generate_controls_layout();
120 $this->generate_controls_styles();
121 $this->generate_controls_content();
122
123 $this->insert_pro_message('tab_conf');
124 parent::register_controls();
125 }
126
127 /**
128 * Render the widget output on the frontend.
129 *
130 * Written in PHP and used to generate the final HTML.
131 *
132 * @since 1.1.0
133 *
134 * @access protected
135 */
136 protected function render() {
137 parent::render();
138 global $wdk_listing_id;
139
140 $this->data['id_element'] = $this->get_id();
141 $this->data['settings'] = $this->get_settings();
142
143 $this->data['listings_count'] = 0;
144 $this->data['results'] = array();
145 $this->data['pagination_output'] = '';
146
147 if(Plugin::$instance->editor->is_edit_mode()) {
148 $this->data['results'] = $this->WMVC->listing_m->get_pagination(6, 0, array('is_activated' => 1,'is_approved'=>1));
149 } else {
150 if(!wdk_get_option('wdk_sub_listings_enable')) {
151 return false;
152 }
153
154 if(empty(wdk_field_value('listing_related_ids', $wdk_listing_id))) {
155 return false;
156 }
157
158 $this->WMVC->db->where( $this->WMVC->db->prefix.'wdk_listings.post_id IN(' . wdk_field_value('listing_related_ids', $wdk_listing_id) . ')', null, false);
159 $this->WMVC->db->where(array('is_activated' => 1, 'is_approved'=>1));
160 $this->WMVC->db->order_by('FIELD('.$this->WMVC->db->prefix.'wdk_listings.post_id, '. wdk_field_value('listing_related_ids', $wdk_listing_id) . ')');
161
162 $this->data['results'] = $this->WMVC->listing_m->get();
163 }
164
165
166 $this->data['is_edit_mode'] = false;
167 if(Plugin::$instance->editor->is_edit_mode())
168 $this->data['is_edit_mode'] = true;
169
170
171 echo $this->view('wdk-listing-related-listings-table', $this->data);
172 }
173
174 private function generate_controls_conf()
175 {
176
177 $this->start_controls_section(
178 'tab_conf_main_section_subslistings',
179 [
180 'label' => esc_html__('Related Listings', 'wpdirectorykit'),
181 'tab' => 'tab_conf',
182 ]
183 );
184
185 $fields_data = wdk_cached_field_get();
186 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
187 $order_i = 0;
188
189 $fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
190 $fields_list [(++$order_i).'__idlisting'] = esc_html__('Id listing', 'wpdirectorykit');
191 $fields_list [(++$order_i).'__post_id'] = esc_html__('Post Id', 'wpdirectorykit');
192 $fields_list [(++$order_i).'__counter_views'] = esc_html__('Views counter', 'wpdirectorykit');
193 $fields_list [(++$order_i).'__lat'] = esc_html__('Gps Lat', 'wpdirectorykit');
194 $fields_list [(++$order_i).'__lng'] = esc_html__('Gps Lng', 'wpdirectorykit');
195 $fields_list [(++$order_i).'__date'] = esc_html__('Date', 'wpdirectorykit');
196 $fields_list [(++$order_i).'__date_modified'] = esc_html__('Date Modified', 'wpdirectorykit');
197 $fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit');
198 $fields_list [(++$order_i).'__post_content'] = esc_html__('WP Content', 'wpdirectorykit');
199 $fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit');
200 $fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit');
201 $fields_list [(++$order_i).'__location_id'] = esc_html__('Location', 'wpdirectorykit');
202
203 foreach($fields_data as $field)
204 {
205 if(wmvc_show_data('field_type', $field) == 'SECTION') {
206 $fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
207 } else {
208 $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).']';
209 }
210 }
211
212 $this->add_responsive_control(
213 'related_fields_header',
214 [
215 'label' => esc_html__('Fields', 'wpdirectorykit'),
216 'type' => Controls_Manager::HEADING,
217 ]
218 );
219
220 $this->add_control(
221 'related_fields_header_hr',
222 [
223 'type' => \Elementor\Controls_Manager::DIVIDER,
224 ]
225 );
226
227 $repeater_sublistings_fields = new Repeater();
228 $repeater_sublistings_fields->start_controls_tabs( 'related_fields' );
229 $repeater_sublistings_fields->add_control(
230 'field',
231 [
232 'label' => __( 'Field', 'wpdirectorykit' ),
233 'type' => \Elementor\Controls_Manager::SELECT2,
234 'options' => $fields_list,
235 ]
236 );
237
238 $repeater_sublistings_fields->add_control(
239 'is_stars',
240 [
241 'label' => __( 'Show like stars', 'wpdirectorykit' ),
242 'type' => \Elementor\Controls_Manager::SWITCHER,
243 'label_on' => __( 'On', 'wpdirectorykit' ),
244 'label_off' => __( 'Off', 'wpdirectorykit' ),
245 'return_value' => 'yes',
246 'default' => '',
247 'description' => esc_html__( 'Numeric values required', 'wpdirectorykit' ),
248 ]
249 );
250
251 $repeater_sublistings_fields->add_control(
252 'is_link',
253 [
254 'label' => __( 'Set field like link', 'wpdirectorykit' ),
255 'type' => \Elementor\Controls_Manager::SWITCHER,
256 'label_on' => __( 'On', 'wpdirectorykit' ),
257 'label_off' => __( 'Off', 'wpdirectorykit' ),
258 'return_value' => 'yes',
259 'default' => 'yes',
260 ]
261 );
262
263
264 $repeater_sublistings_fields->add_control(
265 'field_prefix',
266 [
267 'label' => __( 'Text prefix', 'wpdirectorykit' ),
268 'type' => \Elementor\Controls_Manager::TEXT,
269 'default' => '',
270 ]
271 );
272
273 $repeater_sublistings_fields->add_control(
274 'field_suffix',
275 [
276 'label' => __( 'Text suffix', 'wpdirectorykit' ),
277 'type' => \Elementor\Controls_Manager::TEXT,
278 'default' => '',
279 ]
280 );
281
282 $repeater_sublistings_fields->end_controls_tabs();
283
284 $this->add_control(
285 'related_fields_list',
286 [
287 'label' => esc_html__('Fields For Query Similar Listings', 'wpdirectorykit'),
288 'type' => Controls_Manager::REPEATER,
289 'fields' => $repeater_sublistings_fields->get_controls(),
290 'default' => [
291 [
292 'field' => '63',
293 'is_stars' => 'yes',
294 'is_link' => '',
295 ],
296 [
297 'field' => 'post_title',
298 'is_link' => 'yes',
299 ],
300 [
301 'field' => '64',
302 'is_link' => '',
303 'field_suffix' => esc_html__('(persons)', 'wpdirectorykit'),
304 ],
305 ],
306 'title_field' => '{{{ field }}}',
307 ]
308 );
309
310
311 $this->end_controls_section();
312
313 }
314
315 private function generate_controls_layout()
316 {
317 }
318
319 private function generate_controls_styles()
320 {
321
322 $this->start_controls_section(
323 'colors_sections',
324 [
325 'label' => esc_html__('Styles', 'wpdirectorykit'),
326 'tab' => '1'
327 ]
328 );
329
330 $this->add_control(
331 'border_color',
332 [
333 'label' => __('Border Color', 'wpdirectorykit'),
334 'type' => \Elementor\Controls_Manager::COLOR,
335 'selectors' => [
336 '{{WRAPPER}} .wdk-listing-related-listings-table' => '--border_color:{{VALUE}}',
337 ],
338 ]
339 );
340
341 $this->add_control(
342 'border_width',
343 [
344 'label' => __('Border Width', 'wpdirectorykit'),
345 'type' => Controls_Manager::SLIDER,
346 'size_units' => ['px'],
347 'range' => [
348 'px' => [
349 'min' => 0,
350 'max' => 5,
351 'step' => 1,
352 ],
353 ],
354 'selectors' => [
355 '{{WRAPPER}} .wdk-listing-related-listings-table' => '--border_width: {{SIZE}}{{UNIT}};',
356 ],
357 ]
358 );
359
360
361 $this->add_responsive_control(
362 'tr_hover_color',
363 [
364 'label' => esc_html__( 'Line Hover Color', 'wpdirectorykit' ),
365 'type' => Controls_Manager::COLOR,
366 'selectors' => [
367 '{{WRAPPER}} .wdk-listing-related-listings-table table.wdk-table tr:hover' => 'background-color: {{VALUE}};',
368 ],
369 ]
370 );
371 $this->add_control(
372 'related_fields_header_hr1_0',
373 [
374 'type' => \Elementor\Controls_Manager::DIVIDER,
375 ]
376 );
377 $this->add_control(
378 'related_fields_star_image',
379 [
380 'label' => esc_html__('Image', 'wpdirectorykit'),
381 'type' => Controls_Manager::HEADING,
382 ]
383 );
384
385 $this->add_control(
386 'related_fields_header_hr1',
387 [
388 'type' => \Elementor\Controls_Manager::DIVIDER,
389 ]
390 );
391 $this->add_responsive_control(
392 'hide_image',
393 [
394 'label' => esc_html__( 'Hide Image', 'wpdirectorykit' ),
395 'type' => Controls_Manager::SWITCHER,
396 'none' => esc_html__( 'Hide', 'wpdirectorykit' ),
397 'block' => esc_html__( 'Show', 'wpdirectorykit' ),
398 'return_value' => 'none',
399 'default' => '',
400 'selectors' => [
401 '{{WRAPPER}} .wdk-listing-related-listings-table table.wdk-table td:first-child' => 'display: {{VALUE}};',
402 ],
403 ]
404 );
405
406 $selectors = array(
407 'normal' => '{{WRAPPER}} .wdk-listing-related-listings-table .wdk-image',
408 );
409 $this->generate_renders_tabs($selectors, 'image_dynamic', ['margin','border','border_radius','padding','shadow','image_size_control','image_fit_control', 'css_filters']);
410
411
412 $this->add_control(
413 'related_fields_header_hr2_0',
414 [
415 'type' => \Elementor\Controls_Manager::DIVIDER,
416 ]
417 );
418 $this->add_responsive_control(
419 'related_fields_styles',
420 [
421 'label' => esc_html__('Styles Content', 'wpdirectorykit'),
422 'type' => Controls_Manager::HEADING,
423 ]
424 );
425 $this->add_control(
426 'related_fields_header_hr2',
427 [
428 'type' => \Elementor\Controls_Manager::DIVIDER,
429 ]
430 );
431
432 $selectors = array(
433 'normal' => '{{WRAPPER}} .wdk-sublistings-part a, {{WRAPPER}} .wdk-sublistings-part span',
434 'hover'=>'{{WRAPPER}} .wdk-sublistings-part a%1$s'
435 );
436 $this->generate_renders_tabs($selectors, 'related_fields_dynamic', ['color','typo','padding','shadow','transition']);
437
438
439 $this->add_control(
440 'related_fields_header_hr5_0',
441 [
442 'type' => \Elementor\Controls_Manager::DIVIDER,
443 ]
444 );
445 $this->add_control(
446 'related_fields_star_styles',
447 [
448 'label' => esc_html__('Stars', 'wpdirectorykit'),
449 'type' => Controls_Manager::HEADING,
450 ]
451 );
452
453 $this->add_control(
454 'related_fields_header_hr5',
455 [
456 'type' => \Elementor\Controls_Manager::DIVIDER,
457 ]
458 );
459
460 $selectors = array(
461 'active' => '{{WRAPPER}} .wdk-sublistings-part .stars-lst span i.star-active',
462 );
463 $this->generate_renders_tabs($selectors, 'related_fields_star_dynamic', ['margin','padding','font-size', 'color']);
464
465 $this->add_control(
466 'related_fields_header_hr6_0',
467 [
468 'type' => \Elementor\Controls_Manager::DIVIDER,
469 ]
470 );
471 $this->add_control(
472 'related_fields_star_button',
473 [
474 'label' => esc_html__('Button', 'wpdirectorykit'),
475 'type' => Controls_Manager::HEADING,
476 ]
477 );
478
479 $this->add_control(
480 'related_fields_header_hr6',
481 [
482 'type' => \Elementor\Controls_Manager::DIVIDER,
483 ]
484 );
485
486 $selectors = array(
487 'normal' => '{{WRAPPER}} .wdk-listing-related-listings-table table.wdk-table .wdk-btn',
488 'hover'=>'{{WRAPPER}} ..wdk-listing-related-listings-table table.wdk-table .wdk-btn%1$s'
489 );
490 $this->generate_renders_tabs($selectors, 'button_dynamic', ['margin','typo','color','background','border','border_radius','padding','shadow','transition','background_group']);
491
492 $this->end_controls_section();
493
494 }
495
496 private function generate_controls_content()
497 {
498 }
499
500 public function enqueue_styles_scripts() {
501 wp_enqueue_style('wdk-listing-related-listings-table');
502
503 wp_enqueue_style('wdk-notify');
504 wp_enqueue_script('wdk-notify');
505 }
506 }
507