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-field-files.php

wdk-field-files.php in WP Directory Kit 1.2.7, at elementor-elements/classes/wdk-field-files.php

598 lines 20.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 WdkFieldFiles 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 /**
53 * Retrieve the list of categories the widget belongs to.
54 *
55 * Used to determine where to display the widget in the editor.
56 *
57 * Note that currently Elementor supports only one category.
58 * When multiple categories passed, Elementor uses the first one.
59 *
60 * @since 1.1.0
61 *
62 * @access public
63 *
64 * @return array Widget categories.
65 */
66 public function get_categories() {
67 return [ 'wdk-elementor-listing-preview' ];
68 }
69
70 /**
71 * Retrieve the widget name.
72 *
73 * @since 1.1.0
74 *
75 * @access public
76 *
77 * @return string Widget name.
78 */
79 public function get_name() {
80 return 'wdk-field-files';
81 }
82
83 /**
84 * Retrieve the widget title.
85 *
86 * @since 1.1.0
87 *
88 * @access public
89 *
90 * @return string Widget title.
91 */
92 public function get_title() {
93 return esc_html__('Wdk Listing Plans And Documents', 'wpdirectorykit');
94 }
95
96 /**
97 * Retrieve the widget icon.
98 *
99 * @since 1.1.0
100 *
101 * @access public
102 *
103 * @return string Widget icon.
104 */
105 public function get_icon() {
106 return 'eicon-document-file';
107 }
108
109 /**
110 * Register the widget controls.
111 *
112 * Adds different input fields to allow the user to change and customize the widget settings.
113 *
114 * @since 1.1.0
115 *
116 * @access protected
117 */
118 protected function register_controls() {
119 $this->generate_controls_conf();
120 $this->generate_controls_layout();
121 $this->generate_controls_styles();
122 $this->generate_controls_content();
123
124 $this->insert_pro_message('1');
125 parent::register_controls();
126 }
127
128 /**
129 * Render the widget output on the frontend.
130 *
131 * Written in PHP and used to generate the final HTML.
132 *
133 * @since 1.1.0
134 *
135 * @access protected
136 */
137 protected function render() {
138 parent::render();
139 global $wdk_listing_id;
140 /* test data */
141 $this->data['id_element'] = $this->get_id();
142 $this->data['settings'] = $this->get_settings();
143
144 $this->data['images'] = array();
145
146 if(!Plugin::$instance->editor->is_edit_mode()) {
147 $this->data['images'] = wdk_listing_images_data (wdk_field_value('listing_plans_documents', $wdk_listing_id), 'full', '', $this->data['settings']['extension_list']);
148 $this->data['images'] = array_slice($this->data['images'], ($this->data['settings']['offset_images']-1), $this->data['settings']['limit_images']);
149 } else {
150 $this->data['images'] = array_fill(0, $this->data['settings']['limit_images'], wdk_placeholder_image_src());
151 }
152
153 $this->data['is_edit_mode']= false;
154 if(Plugin::$instance->editor->is_edit_mode()) {
155 $this->data['is_edit_mode']= true;
156 } else {
157 /* return false if no content */
158 }
159
160 echo $this->view('wdk-field-files', $this->data);
161 }
162
163
164 private function generate_controls_conf() {
165 $this->start_controls_section(
166 'tab_conf_main_section',
167 [
168 'label' => esc_html__('Main', 'wpdirectorykit'),
169 'tab' => '1',
170 ]
171 );
172
173 $this->add_control(
174 'extension_list',
175 [
176 'label' => __( 'Show Only Files By Extension', 'wpdirectorykit' ),
177 'description' => __( 'Put file`s extension, if you want show only these files, separate like bmp,xml,pdf,jpg. Responsive only on live version', 'wpdirectorykit' ),
178 'type' => \Elementor\Controls_Manager::TEXTAREA,
179 ]
180 );
181
182 $this->add_control(
183 'limit_images',
184 [
185 'label' => __( 'Limit Images', 'wpdirectorykit' ),
186 'type' => \Elementor\Controls_Manager::NUMBER,
187 'min' => 1,
188 'max' => 100,
189 'step' => 1,
190 'default' => 50,
191 ]
192 );
193
194 $this->add_control(
195 'offset_images',
196 [
197 'label' => __( 'Offset Images', 'wpdirectorykit' ),
198 'type' => \Elementor\Controls_Manager::NUMBER,
199 'min' => 1,
200 'max' => 100,
201 'step' => 1,
202 'default' => 1,
203 ]
204 );
205
206 $this->add_control(
207 'enable_js_gallery',
208 [
209 'label' => __( 'Enable Gallery Popup', 'wpdirectorykit' ),
210 'type' => \Elementor\Controls_Manager::SWITCHER,
211 'label_on' => __( 'True', 'wpdirectorykit' ),
212 'label_off' => __( 'False', 'wpdirectorykit' ),
213 'return_value' => 'yes',
214 'default' => 'yes',
215 ]
216 );
217
218 $this->end_controls_section();
219
220 }
221
222 private function generate_controls_layout() {
223 }
224
225 private function generate_controls_styles() {
226 $this->start_controls_section(
227 'styles_thmbn_section',
228 [
229 'label' => esc_html__('Main', 'wpdirectorykit'),
230 'tab' => Controls_Manager::TAB_STYLE,
231 ]
232 );
233
234 $this->add_responsive_control(
235 'row_gap_col',
236 [
237 'label' => __( 'Columns', 'wpdirectorykit' ),
238 'type' => Controls_Manager::SELECT,
239 'options' => [
240 '' => esc_html__('Default', 'wpdirectorykit'),
241 'auto' => esc_html__('Auto', 'wpdirectorykit'),
242 '100%' => '1',
243 '50%' => '2',
244 'calc(100% / 3)' => '3',
245 '25%' => '4',
246 '20%' => '5',
247 'auto_flexible' => 'auto flexible',
248 ],
249 'selectors_dictionary' => [
250 'auto' => 'width:auto;-webkit-flex:0 0 auto;flex:0 0 auto',
251 '100%' => 'width:100%;-webkit-flex:0 0 100%;flex:0 0 100%',
252 '50%' => 'width:50%;-webkit-flex:0 0 50%;flex:0 0 50%',
253 'calc(100% / 3)' => 'width:calc(100% / 3);-webkit-flex:0 0 calc(100% / 3);flex:0 0 calc(100% / 3)',
254 '25%' => 'width:25%;-webkit-flex:0 0 25%;flex:0 0 25%',
255 '20%' => 'width:20%;-webkit-flex:0 0 20%;flex:0 0 20%',
256 'auto' => 'width:auto;-webkit-flex:0 0 auto;flex:0 0 auto',
257 'auto_flexible' => 'width:auto;-webkit-flex:1 2 auto;flex:1 2 auto',
258 ],
259 'selectors' => [
260 '{{WRAPPER}} .wdk-row .wdk-col' => '{{UNIT}}',
261 ],
262 'default' => 'calc(100% / 3)',
263 'separator' => 'before',
264 ]
265 );
266
267 $this->add_responsive_control(
268 'column_gap',
269 [
270 'label' => esc_html__('Columns Gap', 'wpdirectorykit'),
271 'type' => Controls_Manager::SLIDER,
272 'default' => [
273 'size' => 10,
274 ],
275 'range' => [
276 'px' => [
277 'min' => 0,
278 'max' => 60,
279 ],
280 ],
281 'selectors' => [
282 '{{WRAPPER}} .wdk-row .wdk-col' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};;',
283 '{{WRAPPER}} .wdk-row' => 'margin-left: -{{SIZE}}{{UNIT}};margin-right: -{{SIZE}}{{UNIT}};',
284 ],
285 ]
286 );
287
288 $this->add_responsive_control(
289 'row_gap',
290 [
291 'label' => esc_html__('Rows Gap', 'wpdirectorykit'),
292 'type' => Controls_Manager::SLIDER,
293 'range' => [
294 'px' => [
295 'min' => 0,
296 'max' => 60,
297 ],
298 ],
299 'selectors' => [
300 '{{WRAPPER}} .wdk-row .wdk-col' => 'margin-bottom: {{SIZE}}{{UNIT}};',
301 '{{WRAPPER}} .wdk-row' => 'margin-bottom: -{{SIZE}}{{UNIT}};',
302 ],
303 ]
304 );
305
306 $this->end_controls_section();
307
308 $this->start_controls_section(
309 'styles_thmbn_type',
310 [
311 'label' => esc_html__('Thumbnail', 'wpdirectorykit'),
312 'tab' => Controls_Manager::TAB_STYLE,
313 ]
314 );
315
316 $this->add_control(
317 'layout_image_design',
318 [
319 'label' => __( 'Size style thumbnail', 'wpdirectorykit' ),
320 'type' => \Elementor\Controls_Manager::SELECT,
321 'options' => [
322 '' => __( 'None', 'wpdirectorykit' ),
323 'contain' => __( 'Contain', 'wpdirectorykit' ),
324 'cover' => __( 'Cover', 'wpdirectorykit' ),
325 ],
326 'selectors' => [
327 '{{WRAPPER}} .wdk-field-files .wdk-listing-image' => 'object-fit: {{VALUE}}',
328 ],
329 ]
330 );
331
332 $selectors = array(
333 'normal' => '{{WRAPPER}} .wdk-field-files .wdk-listing-image',
334 );
335 $this->generate_renders_tabs($selectors, 'layout_image_dynamic', ['margin','padding','background','border','border_radius','css_filters','shadow','transition']);
336
337 $this->add_control(
338 'enable_fixed_height',
339 [
340 'label' => __( 'Fixed Height', 'wpdirectorykit' ),
341 'type' => \Elementor\Controls_Manager::SWITCHER,
342 'label_on' => __( 'True', 'wpdirectorykit' ),
343 'label_off' => __( 'False', 'wpdirectorykit' ),
344 'return_value' => 'yes',
345 'default' => 'yes',
346 ]
347 );
348
349 $this->add_responsive_control (
350 'styles_thmbn_des_height',
351 [
352 'label' => esc_html__('Height', 'wpdirectorykit'),
353 'type' => Controls_Manager::SLIDER,
354 'range' => [
355 'px' => [
356 'min' => 100,
357 'max' => 1500,
358 ],
359 'vw' => [
360 'min' => 0,
361 'max' => 100,
362 ],
363 ],
364 'size_units' => [ 'px', 'vw' ],
365 'selectors' => [
366 '{{WRAPPER}} .wdk-field-files .wdk-listing-image' => 'height: {{SIZE}}{{UNIT}}',
367 ],
368 'separator' => 'after',
369 'conditions' => [
370 'terms' => [
371 [
372 'name' => 'enable_fixed_height',
373 'operator' => '==',
374 'value' => 'yes',
375 ]
376 ],
377 ],
378 ]
379 );
380
381 $this->end_controls_section();
382
383 $items = [
384 [
385 'key'=>'card',
386 'label'=> esc_html__('Card', 'wpdirectorykit'),
387 'selector'=>'{{WRAPPER}} .wdk-field-files figcaption',
388 'selector_hover'=>'{{WRAPPER}} .wdk-field-files figcaption%1$s',
389 'options'=>['margin','padding','background','border','border_radius','css_filters','shadow','transition'],
390 ],
391 [
392 'key'=>'image',
393 'label'=> esc_html__('Image', 'wpdirectorykit'),
394 'selector'=>'{{WRAPPER}} .wdk-field-files .wdk-listing-image-card .wdk-listing-image',
395 'selector_hover'=>'{{WRAPPER}} .wdk-field-files .wdk-listing-image-card%1$s .wdk-listing-image',
396 'options'=> ['margin','background','border','border_radius','padding','shadow','transition','css_filters'],
397 ],
398 [
399 'key'=>'caption',
400 'label'=> esc_html__('Caption', 'wpdirectorykit'),
401 'selector'=>'{{WRAPPER}} .wdk-field-files figure figcaption',
402 'selector_hover'=>'{{WRAPPER}} .wdk-field-files figure%1$s figcaption',
403 'options'=> ['margin','align','typo','color','background','border','border_radius','padding','shadow','transition'],
404 ],
405 ];
406
407 foreach ($items as $item) {
408 $this->start_controls_section(
409 $item['key'].'_section',
410 [
411 'label' => $item['label'],
412 'tab' => Controls_Manager::TAB_STYLE,
413 ]
414 );
415
416 if($item['key'] == 'caption')
417 $this->add_responsive_control(
418 $item['key'].'_hide',
419 [
420 'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ),
421 'type' => Controls_Manager::SWITCHER,
422 'none' => esc_html__( 'Hide', 'wpdirectorykit' ),
423 'block' => esc_html__( 'Show', 'wpdirectorykit' ),
424 'return_value' => 'none',
425 'default' => '',
426 'selectors' => [
427 $item['selector'] => 'display: {{VALUE}};',
428 ],
429 ]
430 );
431
432 $selectors = array(
433 'normal' => $item['selector'],
434 'hover'=>$item['selector_hover'],
435 );
436 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
437
438 $this->end_controls_section();
439 }
440
441
442 /* files */
443 if(true) {
444
445 $this->start_controls_section(
446 'files_section',
447 [
448 'label' => esc_html__('Files List', 'wpdirectorykit'),
449 'tab' => Controls_Manager::TAB_STYLE,
450 ]
451 );
452
453 $this->add_responsive_control(
454 'files_section_hide',
455 [
456 'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ),
457 'type' => Controls_Manager::SWITCHER,
458 'none' => esc_html__( 'Hide', 'wpdirectorykit' ),
459 'block' => esc_html__( 'Show', 'wpdirectorykit' ),
460 'return_value' => 'yes',
461 'default' => '',
462 ]
463 );
464
465 $this->add_control(
466 'files_section_box_header',
467 [
468 'label' => __('Container', 'wpdirectorykit'),
469 'type' => \Elementor\Controls_Manager::HEADING,
470 ]
471 );
472
473 $selectors = array(
474 'normal' => '{{WRAPPER}} .wdk-field-files .files-row ul.files',
475 );
476
477 $this->generate_renders_tabs($selectors, 'files_section_bo_dynamic', ['background','border','border_radius','padding','margin','shadow','transition' ]);
478
479 $this->add_control(
480 'files_section_li',
481 [
482 'label' => __('List Items', 'wpdirectorykit'),
483 'type' => \Elementor\Controls_Manager::HEADING,
484 ]
485 );
486
487 $this->add_control(
488 'files_section_li_hr',
489 [
490 'type' => \Elementor\Controls_Manager::DIVIDER,
491 ]
492 );
493
494 $this->add_control(
495 'files_section_space',
496 [
497 'label' => __('Vertical Space', 'wpdirectorykit'),
498 'type' => Controls_Manager::SLIDER,
499 'size_units' => ['px'],
500 'range' => [
501 'px' => [
502 'min' => 0,
503 'max' => 250,
504 'step' => 1,
505 ],
506 ],
507 'selectors' => [
508 '{{WRAPPER}} .wdk-field-files .files-row ul.files li:not(:last-child)' => 'margin-bottom: {{SIZE}}{{UNIT}};',
509 ],
510 ]
511 );
512
513 $selectors = array(
514 'normal' => '{{WRAPPER}} .wdk-field-files .files-row ul.files li',
515 );
516
517 $this->generate_renders_tabs($selectors, 'files_section_item_dynamic', ['align','background','border','border_radius','padding','shadow','transition' ]);
518
519 $this->add_control(
520 'files_section_hr',
521 [
522 'type' => \Elementor\Controls_Manager::DIVIDER,
523 ]
524 );
525
526 $this->add_control(
527 'files_section_items',
528 [
529 'label' => __('More Styles', 'wpdirectorykit'),
530 'type' => \Elementor\Controls_Manager::HEADING,
531 ]
532 );
533
534 $items = [
535 [
536 'key'=>'files_icon',
537 'label'=> esc_html__('Icon', 'wpdirectorykit'),
538 'selector'=>'{{WRAPPER}} .wdk-field-files .files-row .list-item a .wdk-listing-file-icon',
539 'selector_hover'=>'{{WRAPPER}} .wdk-field-files .files-row .list-item%1$s a .wdk-listing-file-icon',
540 'options'=> ['margin','background','border','border_radius','padding','shadow','transition','image_size_control','css_filters','hover_animation'],
541 ],
542 [
543 'key'=>'files_caption',
544 'label'=> esc_html__('Caption', 'wpdirectorykit'),
545 'selector'=>'{{WRAPPER}} .wdk-field-files .files-row .list-item a',
546 'selector_hover'=>'{{WRAPPER}} .wdk-field-files .files-row .list-item a%1$s',
547 'options'=> ['margin','align','typo','color','background','border','border_radius','padding','shadow','transition'],
548 ],
549 ];
550
551 foreach ($items as $item) {
552 $this->add_control(
553 $item['key'].'_header',
554 [
555 'label' => $item['label'],
556 'type' => \Elementor\Controls_Manager::HEADING,
557 ]
558 );
559
560 if($item['key'] == 'files_icon')
561 $this->add_responsive_control(
562 $item['key'].'_hide',
563 [
564 'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ),
565 'type' => Controls_Manager::SWITCHER,
566 'none' => esc_html__( 'Hide', 'wpdirectorykit' ),
567 'block' => esc_html__( 'Show', 'wpdirectorykit' ),
568 'return_value' => 'none',
569 'default' => '',
570 'selectors' => [
571 $item['selector'] => 'display: {{VALUE}};',
572 ],
573 ]
574 );
575
576 $selectors = array(
577 'normal' => $item['selector'],
578 'hover'=>$item['selector_hover'],
579 );
580 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
581 }
582
583 $this->end_controls_section();
584 }
585 }
586
587 private function generate_controls_content() {
588
589 }
590
591 public function enqueue_styles_scripts() {
592 wp_enqueue_style('wdk-field-files');
593 wp_enqueue_style('blueimp-gallery');
594 wp_enqueue_script('blueimp-gallery');
595 wp_enqueue_script('wdk-blueimp-gallery');
596 }
597 }
598