PluginProbe
Sight – Professional Image Gallery and Portfolio / 1.0.4
Sight – Professional Image Gallery and Portfolio v1.0.4
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8
sight / elementor / widget-portfolio.php

widget-portfolio.php in Sight – Professional Image Gallery and Portfolio 1.0.4, at elementor/widget-portfolio.php

1,093 lines 24.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Widget Portfolio.
4 *
5 * @package Sight
6 */
7
8 namespace Sight_Elementor\Widgets;
9
10 use Elementor\Widget_Base;
11 use Elementor\Controls_Manager;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Elementor Widget
19 *
20 * @since 1.0.0
21 */
22 class Sight_Widget_Portfolio extends Widget_Base {
23
24 /**
25 * Retrieve the widget name.
26 *
27 * @since 1.0.0
28 *
29 * @access public
30 *
31 * @return string Widget name.
32 */
33 public function get_name() {
34 return 'sight-portfolio-widget';
35 }
36
37 /**
38 * Retrieve the widget title.
39 *
40 * @since 1.0.0
41 *
42 * @access public
43 *
44 * @return string Widget title.
45 */
46 public function get_title() {
47 return esc_html__( 'Portfolio', 'sight' );
48 }
49
50 /**
51 * Retrieve the widget icon.
52 *
53 * @since 1.0.0
54 *
55 * @access public
56 *
57 * @return string Widget icon.
58 */
59 public function get_icon() {
60 return 'eicon-call-to-action';
61 }
62
63 /**
64 * Retrieve the list of categories the widget belongs to.
65 *
66 * Used to determine where to display the widget in the editor.
67 *
68 * Note that currently Elementor supports only one category.
69 * When multiple categories passed, Elementor uses the first one.
70 *
71 * @since 1.0.0
72 *
73 * @access public
74 *
75 * @return array Widget categories.
76 */
77 public function get_categories() {
78 return array( 'basic' );
79 }
80
81 /**
82 * Registers layouts of block.
83 */
84 public function widget_layouts() {
85 $layouts = array(
86 'standard' => array(
87 'name' => esc_html__( 'Standard', 'sight' ),
88 'template' => SIGHT_PATH . 'render/handler/post-area-init.php',
89 ),
90 );
91
92 // Return.
93 return apply_filters( 'sight_widget_portfolio_layouts', $layouts );
94 }
95
96 /**
97 * Get layouts (format: array)
98 *
99 * @access protected
100 */
101 protected function get_array_layouts() {
102 $widget_layouts = $this->widget_layouts();
103
104 $layouts = array();
105
106 foreach ( $widget_layouts as $key => $attrs ) {
107 $layouts[ $key ] = $attrs['name'];
108 }
109
110 return $layouts;
111 }
112
113 /**
114 * Register the widget controls.
115 *
116 * Adds different input fields to allow the user to change and customize the widget settings.
117 *
118 * @since 1.0.0
119 *
120 * @access protected
121 */
122 protected function _register_controls() {
123
124 $this->start_controls_section(
125 'layout_section',
126 array(
127 'label' => esc_html__( 'Layout', 'sight' ),
128 )
129 );
130
131 do_action( 'sight/widget/fields/before', $this );
132
133 $this->add_control(
134 'layout',
135 array(
136 'label' => esc_html__( 'Layout', 'sight' ),
137 'type' => Controls_Manager::SELECT,
138 'default' => 'standard',
139 'options' => $this->get_array_layouts(),
140 )
141 );
142
143 $this->end_controls_section();
144
145 $this->start_controls_section(
146 'general',
147 array(
148 'label' => esc_html__( 'General Settings', 'sight' ),
149 )
150 );
151
152 do_action( 'sight/widget/fields/general/before', $this );
153
154 $this->add_control(
155 'source',
156 array(
157 'label' => esc_html__( 'Source', 'sight' ),
158 'type' => Controls_Manager::SELECT,
159 'default' => 'projects',
160 'options' => array(
161 'projects' => esc_html__( 'Projects', 'sight' ),
162 'custom' => esc_html__( 'Images', 'sight' ),
163 'categories' => esc_html__( 'Categories', 'sight' ),
164 'post' => esc_html__( 'Post Attachments', 'sight' ),
165 ),
166 )
167 );
168
169 /* Type Projects */
170
171 $this->add_control(
172 'video',
173 array(
174 'label' => esc_html__( 'Video Background', 'sight' ),
175 'type' => Controls_Manager::SELECT,
176 'default' => 'always',
177 'options' => array(
178 'none' => esc_html__( 'None', 'sight' ),
179 'always' => esc_html__( 'Always', 'sight' ),
180 'hover' => esc_html__( 'On Hover', 'sight' ),
181 ),
182 'conditions' => array(
183 'relation' => 'and',
184 'terms' => array(
185 array(
186 'name' => 'source',
187 'operator' => '==',
188 'value' => 'projects',
189 ),
190 ),
191 ),
192 )
193 );
194
195 $this->add_control(
196 'video_controls',
197 array(
198 'label' => esc_html__( 'Enable video controls', 'sight' ),
199 'type' => Controls_Manager::SWITCHER,
200 'return_value' => 'true',
201 'default' => 'true',
202 'conditions' => array(
203 'relation' => 'and',
204 'terms' => array(
205 array(
206 'name' => 'source',
207 'operator' => '==',
208 'value' => 'projects',
209 ),
210 array(
211 'name' => 'video',
212 'operator' => '!=',
213 'value' => 'none',
214 ),
215 ),
216 ),
217 )
218 );
219
220 /* Post */
221
222 $this->add_control(
223 'custom_post',
224 array(
225 'label' => esc_html__( 'Post', 'sight' ),
226 'type' => 'custom_post',
227 'conditions' => array(
228 'relation' => 'and',
229 'terms' => array(
230 array(
231 'name' => 'source',
232 'operator' => '==',
233 'value' => 'post',
234 ),
235 ),
236 ),
237 )
238 );
239
240 /* Type Custom */
241
242 $this->add_control(
243 'custom_images',
244 array(
245 'label' => esc_html__( 'Images', 'sight' ),
246 'type' => Controls_Manager::GALLERY,
247 'conditions' => array(
248 'relation' => 'and',
249 'terms' => array(
250 array(
251 'name' => 'source',
252 'operator' => '==',
253 'value' => 'custom',
254 ),
255 ),
256 ),
257 )
258 );
259
260 /* Common end */
261
262 $this->add_control(
263 'number_items',
264 array(
265 'label' => esc_html__( 'Number of Items', 'sight' ),
266 'type' => Controls_Manager::NUMBER,
267 'min' => 1,
268 'max' => 100,
269 'step' => 1,
270 'default' => 10,
271 )
272 );
273
274 do_action( 'sight/widget/fields/general/after', $this );
275
276 $this->end_controls_section();
277
278 $this->start_controls_section(
279 'meta',
280 array(
281 'label' => esc_html__( 'Meta Settings', 'sight' ),
282 )
283 );
284
285 do_action( 'sight/widget/fields/meta/after', $this );
286
287 $this->add_control(
288 'meta_title',
289 array(
290 'label' => esc_html__( 'Display item title', 'sight' ),
291 'type' => Controls_Manager::SWITCHER,
292 'return_value' => 'true',
293 'default' => 'true',
294 'conditions' => array(
295 'relation' => 'and',
296 'terms' => array(
297 array(
298 'name' => 'source',
299 'operator' => '!=',
300 'value' => 'post',
301 ),
302 array(
303 'name' => 'source',
304 'operator' => '!=',
305 'value' => 'custom',
306 ),
307 ),
308 ),
309 )
310 );
311
312 $this->add_control(
313 'meta_caption',
314 array(
315 'label' => esc_html__( 'Display item caption', 'sight' ),
316 'type' => Controls_Manager::SWITCHER,
317 'return_value' => 'true',
318 'default' => 'true',
319 )
320 );
321
322 $this->add_control(
323 'meta_caption_length',
324 array(
325 'label' => esc_html__( 'Caption length', 'sight' ),
326 'type' => Controls_Manager::NUMBER,
327 'min' => 1,
328 'max' => 1000,
329 'step' => 1,
330 'default' => 100,
331 'conditions' => array(
332 'relation' => 'and',
333 'terms' => array(
334 array(
335 'name' => 'meta_caption',
336 'operator' => '==',
337 'value' => 'true',
338 ),
339 ),
340 ),
341 )
342 );
343
344 $this->add_control(
345 'meta_category',
346 array(
347 'label' => esc_html__( 'Display meta category', 'sight' ),
348 'type' => Controls_Manager::SWITCHER,
349 'return_value' => 'true',
350 'conditions' => array(
351 'relation' => 'and',
352 'terms' => array(
353 array(
354 'name' => 'source',
355 'operator' => '==',
356 'value' => 'projects',
357 ),
358 array(
359 'name' => 'projects_filter_post_type',
360 'operator' => '==',
361 'value' => 'sight-projects',
362 ),
363 ),
364 ),
365 )
366 );
367
368 $this->add_control(
369 'meta_date',
370 array(
371 'label' => esc_html__( 'Display meta date', 'sight' ),
372 'type' => Controls_Manager::SWITCHER,
373 'return_value' => 'true',
374 'conditions' => array(
375 'relation' => 'and',
376 'terms' => array(
377 array(
378 'name' => 'source',
379 'operator' => '!=',
380 'value' => 'categories',
381 ),
382 ),
383 ),
384 )
385 );
386
387 do_action( 'sight/widget/fields/meta/after', $this );
388
389 $this->end_controls_section();
390
391 $this->start_controls_section(
392 'media',
393 array(
394 'label' => esc_html__( 'Media Settings', 'sight' ),
395 )
396 );
397
398 do_action( 'sight/widget/fields/media/before', $this );
399
400 $this->add_control(
401 'attachment_lightbox',
402 array(
403 'label' => esc_html__( 'Enable lightbox', 'sight' ),
404 'type' => Controls_Manager::SWITCHER,
405 'return_value' => 'true',
406 )
407 );
408
409 $this->add_control(
410 'attachment_lightbox_icon',
411 array(
412 'label' => esc_html__( 'Display lightbox zoom icon', 'sight' ),
413 'type' => Controls_Manager::SWITCHER,
414 'return_value' => 'true',
415 'default' => 'true',
416 'conditions' => array(
417 'relation' => 'and',
418 'terms' => array(
419 array(
420 'name' => 'attachment_lightbox',
421 'operator' => '==',
422 'value' => 'true',
423 ),
424 ),
425 ),
426 )
427 );
428
429 $this->add_control(
430 'attachment_link_to',
431 array(
432 'label' => esc_html__( 'Link To', 'sight' ),
433 'description' => sight_is_archive() ? null : esc_html__( 'If the source is "Categories" then the "Page" value will be ignored.', 'sight' ),
434 'type' => Controls_Manager::SELECT,
435 'default' => 'page',
436 'options' => array(
437 'none' => esc_html__( 'None', 'sight' ),
438 'media' => esc_html__( 'Media File', 'sight' ),
439 'page' => esc_html__( 'Page', 'sight' ),
440 ),
441 'conditions' => array(
442 'relation' => 'and',
443 'terms' => array(
444 array(
445 'name' => 'attachment_lightbox',
446 'operator' => '!=',
447 'value' => 'true',
448 ),
449 ),
450 ),
451 )
452 );
453
454 $this->add_control(
455 'attachment_view_more',
456 array(
457 'label' => esc_html__( 'Enable view more', 'sight' ),
458 'type' => Controls_Manager::SWITCHER,
459 'return_value' => 'true',
460 'conditions' => array(
461 'relation' => 'and',
462 'terms' => array(
463 array(
464 'name' => 'attachment_lightbox',
465 'operator' => '!=',
466 'value' => 'true',
467 ),
468 array(
469 'name' => 'attachment_link_to',
470 'operator' => '!=',
471 'value' => 'none',
472 ),
473 ),
474 ),
475 )
476 );
477
478 $this->add_control(
479 'attachment_size',
480 array(
481 'label' => esc_html__( 'Size', 'sight' ),
482 'type' => Controls_Manager::SELECT,
483 'default' => 'large',
484 'options' => sight_get_list_available_image_sizes(),
485 )
486 );
487
488 $this->add_control(
489 'attachment_orientation',
490 array(
491 'label' => esc_html__( 'Orientation', 'sight' ),
492 'type' => Controls_Manager::SELECT,
493 'default' => 'landscape-16-9',
494 'options' => array(
495 'original' => esc_html__( 'Original', 'sight' ),
496 'landscape-4-3' => esc_html__( 'Landscape 4:3', 'sight' ),
497 'landscape-3-2' => esc_html__( 'Landscape 3:2', 'sight' ),
498 'landscape-16-9' => esc_html__( 'Landscape 16:9', 'sight' ),
499 'portrait-3-4' => esc_html__( 'Portrait 3:4', 'sight' ),
500 'portrait-2-3' => esc_html__( 'Portrait 2:3', 'sight' ),
501 'square' => esc_html__( 'Square', 'sight' ),
502 ),
503 )
504 );
505
506 do_action( 'sight/widget/fields/media/after', $this );
507
508 $this->end_controls_section();
509
510 $this->start_controls_section(
511 'typography',
512 array(
513 'label' => esc_html__( 'Typography Settings', 'sight' ),
514 )
515 );
516
517 do_action( 'sight/widget/fields/typography/before', $this );
518
519 $this->add_control(
520 'typography_heading',
521 array(
522 'label' => esc_html__( 'Heading Font Size', 'sight' ),
523 'type' => Controls_Manager::TEXT,
524 'default' => '',
525 'conditions' => array(
526 'relation' => 'and',
527 'terms' => array(
528 array(
529 'name' => 'source',
530 'operator' => '!=',
531 'value' => 'post',
532 ),
533 array(
534 'name' => 'source',
535 'operator' => '!=',
536 'value' => 'custom',
537 ),
538 array(
539 'name' => 'meta_title',
540 'operator' => '==',
541 'value' => 'true',
542 ),
543 ),
544 ),
545 )
546 );
547
548 $this->add_control(
549 'typography_heading_tag',
550 array(
551 'label' => esc_html__( 'Heading Tag', 'sight' ),
552 'type' => Controls_Manager::SELECT,
553 'default' => 'h3',
554 'options' => array(
555 'h1' => esc_html__( 'H1', 'sight' ),
556 'h2' => esc_html__( 'H2', 'sight' ),
557 'h3' => esc_html__( 'H3', 'sight' ),
558 'h4' => esc_html__( 'H4', 'sight' ),
559 'h5' => esc_html__( 'H5', 'sight' ),
560 'h6' => esc_html__( 'H6', 'sight' ),
561 'p' => esc_html__( 'P', 'sight' ),
562 'div' => esc_html__( 'DIV', 'sight' ),
563 ),
564 'conditions' => array(
565 'relation' => 'and',
566 'terms' => array(
567 array(
568 'name' => 'source',
569 'operator' => '!=',
570 'value' => 'post',
571 ),
572 array(
573 'name' => 'source',
574 'operator' => '!=',
575 'value' => 'custom',
576 ),
577 array(
578 'name' => 'meta_title',
579 'operator' => '==',
580 'value' => 'true',
581 ),
582 ),
583 ),
584 )
585 );
586
587 $this->add_control(
588 'typography_caption',
589 array(
590 'label' => esc_html__( 'Caption Font Size', 'sight' ),
591 'type' => Controls_Manager::TEXT,
592 'default' => '',
593 'conditions' => array(
594 'relation' => 'and',
595 'terms' => array(
596 array(
597 'name' => 'meta_caption',
598 'operator' => '==',
599 'value' => 'true',
600 ),
601 ),
602 ),
603 )
604 );
605
606 do_action( 'sight/widget/fields/typography/after', $this );
607
608 $this->end_controls_section();
609
610 $this->start_controls_section(
611 'query',
612 array(
613 'label' => esc_html__( 'Query Settings', 'sight' ),
614 'conditions' => array(
615 'relation' => 'or',
616 'terms' => array(
617 array(
618 'name' => 'source',
619 'operator' => '==',
620 'value' => 'projects',
621 ),
622 array(
623 'name' => 'source',
624 'operator' => '==',
625 'value' => 'categories',
626 ),
627 ),
628 ),
629 )
630 );
631
632 do_action( 'sight/widget/fields/query/before', $this );
633
634 $this->add_control(
635 'projects_filter_post_type',
636 array(
637 'label' => esc_html__( 'Filter by Post Type', 'sight' ),
638 'type' => Controls_Manager::SELECT,
639 'default' => 'sight-projects',
640 'options' => sight_get_post_types_stack(),
641 'conditions' => array(
642 'relation' => 'and',
643 'terms' => array(
644 array(
645 'name' => 'source',
646 'operator' => '==',
647 'value' => 'projects',
648 ),
649 ),
650 ),
651 )
652 );
653
654 $this->add_control(
655 'projects_filter_categories',
656 array(
657 'label' => esc_html__( 'Filter by Categories', 'sight' ),
658 'type' => Controls_Manager::SELECT,
659 'options' => sight_get_categories_stack(),
660 'conditions' => array(
661 'relation' => 'and',
662 'terms' => array(
663 array(
664 'name' => 'source',
665 'operator' => '==',
666 'value' => 'projects',
667 ),
668 array(
669 'name' => 'projects_filter_post_type',
670 'operator' => '==',
671 'value' => 'sight-projects',
672 ),
673 ),
674 ),
675 )
676 );
677
678 $this->add_control(
679 'projects_filter_offset',
680 array(
681 'label' => esc_html__( 'Offset', 'sight' ),
682 'type' => Controls_Manager::TEXT,
683 'conditions' => array(
684 'relation' => 'and',
685 'terms' => array(
686 array(
687 'name' => 'source',
688 'operator' => '==',
689 'value' => 'projects',
690 ),
691 ),
692 ),
693 )
694 );
695
696 $this->add_control(
697 'projects_orderby',
698 array(
699 'label' => esc_html__( 'Order By', 'sight' ),
700 'type' => Controls_Manager::SELECT,
701 'default' => 'date',
702 'options' => array(
703 'date' => esc_html__( 'Published Date', 'sight' ),
704 'modified' => esc_html__( 'Modified Date', 'sight' ),
705 'title' => esc_html__( 'Title', 'sight' ),
706 'rand' => esc_html__( 'Random', 'sight' ),
707 'views' => esc_html__( 'Views', 'sight' ),
708 'comment_count' => esc_html__( 'Comment Count', 'sight' ),
709 'ID' => esc_html__( 'ID', 'sight' ),
710 ),
711 'conditions' => array(
712 'relation' => 'and',
713 'terms' => array(
714 array(
715 'name' => 'source',
716 'operator' => '==',
717 'value' => 'projects',
718 ),
719 ),
720 ),
721 )
722 );
723
724 $this->add_control(
725 'projects_order',
726 array(
727 'label' => esc_html__( 'Order', 'sight' ),
728 'type' => Controls_Manager::SELECT,
729 'default' => 'DESC',
730 'options' => array(
731 'DESC' => esc_html__( 'Descending', 'sight' ),
732 'ASC' => esc_html__( 'Ascending', 'sight' ),
733 ),
734 'conditions' => array(
735 'relation' => 'and',
736 'terms' => array(
737 array(
738 'name' => 'source',
739 'operator' => '==',
740 'value' => 'projects',
741 ),
742 ),
743 ),
744 )
745 );
746
747 $this->add_control(
748 'categories_filter_ids',
749 array(
750 'label' => esc_html__( 'Filter by Categories', 'sight' ),
751 'type' => Controls_Manager::SELECT,
752 'options' => sight_get_categories_stack(),
753 'conditions' => array(
754 'relation' => 'and',
755 'terms' => array(
756 array(
757 'name' => 'source',
758 'operator' => '==',
759 'value' => 'categories',
760 ),
761 ),
762 ),
763 )
764 );
765
766 $this->add_control(
767 'categories_orderby',
768 array(
769 'label' => esc_html__( 'Order By', 'sight' ),
770 'type' => Controls_Manager::SELECT,
771 'default' => 'name',
772 'options' => array(
773 'name' => esc_html__( 'Name', 'sight' ),
774 'count' => esc_html__( 'Posts count', 'sight' ),
775 'include' => esc_html__( 'Filter include', 'sight' ),
776 'ID' => esc_html__( 'ID', 'sight' ),
777 ),
778 'conditions' => array(
779 'relation' => 'and',
780 'terms' => array(
781 array(
782 'name' => 'source',
783 'operator' => '==',
784 'value' => 'categories',
785 ),
786 ),
787 ),
788 )
789 );
790
791 $this->add_control(
792 'categories_order',
793 array(
794 'label' => esc_html__( 'Order', 'sight' ),
795 'type' => Controls_Manager::SELECT,
796 'default' => 'ASC',
797 'options' => array(
798 'DESC' => esc_html__( 'Descending', 'sight' ),
799 'ASC' => esc_html__( 'Ascending', 'sight' ),
800 ),
801 'conditions' => array(
802 'relation' => 'and',
803 'terms' => array(
804 array(
805 'name' => 'source',
806 'operator' => '==',
807 'value' => 'categories',
808 ),
809 ),
810 ),
811 )
812 );
813
814 do_action( 'sight/widget/fields/query/after', $this );
815
816 $this->end_controls_section();
817
818 $this->start_controls_section(
819 'color',
820 array(
821 'label' => esc_html__( 'Color Settings', 'sight' ),
822 )
823 );
824
825 do_action( 'sight/widget/fields/color/before', $this );
826
827 $this->add_control(
828 'color_heading',
829 array(
830 'label' => esc_html__( 'Heading Color', 'sight' ),
831 'type' => Controls_Manager::COLOR,
832 'conditions' => array(
833 'relation' => 'and',
834 'terms' => array(
835 array(
836 'name' => 'source',
837 'operator' => '!=',
838 'value' => 'post',
839 ),
840 array(
841 'name' => 'source',
842 'operator' => '!=',
843 'value' => 'custom',
844 ),
845 array(
846 'name' => 'meta_title',
847 'operator' => '==',
848 'value' => 'true',
849 ),
850 ),
851 ),
852 )
853 );
854
855 $this->add_control(
856 'color_heading_hover',
857 array(
858 'label' => esc_html__( 'Heading Hover Color', 'sight' ),
859 'type' => Controls_Manager::COLOR,
860 'conditions' => array(
861 'relation' => 'and',
862 'terms' => array(
863 array(
864 'name' => 'source',
865 'operator' => '!=',
866 'value' => 'post',
867 ),
868 array(
869 'name' => 'source',
870 'operator' => '!=',
871 'value' => 'custom',
872 ),
873 array(
874 'name' => 'meta_title',
875 'operator' => '==',
876 'value' => 'true',
877 ),
878 ),
879 ),
880 )
881 );
882
883 $this->add_control(
884 'color_caption',
885 array(
886 'label' => esc_html__( 'Caption Color', 'sight' ),
887 'type' => Controls_Manager::COLOR,
888 'conditions' => array(
889 'relation' => 'and',
890 'terms' => array(
891 array(
892 'name' => 'meta_caption',
893 'operator' => '==',
894 'value' => 'true',
895 ),
896 ),
897 ),
898 )
899 );
900
901 do_action( 'sight/widget/fields/color/after', $this );
902
903 $this->end_controls_section();
904
905 do_action( 'sight/widget/fields/after', $this );
906 }
907
908 /**
909 * Render attributes from widget.
910 *
911 * @param array $attributes The attributes.
912 * @param string $layout The layout.
913 */
914 public function render_attributes( $attributes, $layout ) {
915
916 // Change type for bool attributes.
917 foreach ( $attributes as $key => $value ) {
918 if ( 'true' === $attributes[ $key ] ) {
919 $attributes[ $key ] = true;
920 } elseif ( 'false' === $attributes[ $key ] ) {
921 $attributes[ $key ] = false;
922 }
923 }
924
925 // Set attribute for field 'Images'.
926 if ( $attributes['custom_images'] ) {
927 $attributes['custom_images'] = wp_list_pluck( $attributes['custom_images'], 'id' );
928 }
929
930 return $attributes;
931 }
932
933 /**
934 * Render options from widget.
935 *
936 * @param array $attributes The attributes.
937 * @param string $layout The layout.
938 */
939 public function render_options( $attributes, $layout ) {
940 $options = array();
941
942 // Get layouts.
943 $layouts = $this->widget_layouts();
944
945 // Render stack.
946 foreach ( $attributes as $key => $settings ) {
947
948 $clear_key = str_replace( $layout . '_', '', $key );
949
950 $search = $layout . '_' . $clear_key;
951
952 if ( array_key_exists( $search, $attributes ) ) {
953 $options[ $clear_key ] = $attributes[ $search ];
954 }
955 }
956
957 return $options;
958 }
959
960 /**
961 * Render the widget output on the frontend.
962 *
963 * Written in PHP and used to generate the final HTML.
964 *
965 * @since 1.0.0
966 *
967 * @access protected
968 */
969 protected function render() {
970 $attributes = $this->get_settings_for_display();
971
972 $layouts = $this->widget_layouts();
973
974 // Set id.
975 $id = $this->get_id();
976
977 // Set layout.
978 $layout = $attributes['layout'];
979
980 // Render attributes.
981 $attributes = $this->render_attributes( $attributes, $layout );
982
983 // Render options.
984 $options = $this->render_options( $attributes, $layout );
985
986 // Set classes.
987 $classes = " sight-block-portfolio-id-{$id}";
988 $classes .= " sight-block-portfolio-layout-{$layout}";
989
990 // Output.
991 ?>
992 <div class="sight-block-portfolio <?php echo esc_attr( $classes ); ?>">
993 <?php
994 if ( isset( $layouts[ $layout ]['template'] ) && file_exists( $layouts[ $layout ]['template'] ) ) {
995
996 // Require custom template.
997 require $layouts[ $layout ]['template'];
998 } else {
999
1000 // Default template.
1001 require SIGHT_PATH . 'render/handler/post-area-init.php';
1002 }
1003 ?>
1004 </div>
1005
1006 <?php sight_portfolio_render_style( $attributes, $options, $id ); ?>
1007 <?php
1008 }
1009 }
1010
1011 /**
1012 * Elementor Widget Layouts
1013 *
1014 * @since 1.0.0
1015 */
1016 class Sight_Widget_Portfolio_Layouts {
1017
1018 /**
1019 * Initialize
1020 */
1021 public function __construct() {
1022 add_action( 'sight/widget/fields/general/after', array( $this, 'widget_portfolio_standard_fields' ), 5, 1 );
1023 }
1024
1025 /**
1026 * Add controls for standard layout.
1027 *
1028 * @param object $object The object.
1029 */
1030 public function widget_portfolio_standard_fields( $object ) {
1031 $object->add_control(
1032 'standard_filter_items',
1033 array(
1034 'label' => esc_html__( 'Display category filter', 'sight' ),
1035 'type' => Controls_Manager::SWITCHER,
1036 'return_value' => 'true',
1037 'default' => 'true',
1038 'conditions' => array(
1039 'relation' => 'and',
1040 'terms' => array(
1041 array(
1042 'name' => 'layout',
1043 'operator' => '==',
1044 'value' => 'standard',
1045 ),
1046 array(
1047 'name' => 'source',
1048 'operator' => '==',
1049 'value' => 'projects',
1050 ),
1051 array(
1052 'name' => 'projects_filter_post_type',
1053 'operator' => '==',
1054 'value' => 'sight-projects',
1055 ),
1056 ),
1057 ),
1058 )
1059 );
1060
1061 $object->add_control(
1062 'standard_pagination_type',
1063 array(
1064 'label' => esc_html__( 'Pagination type', 'sight' ),
1065 'type' => Controls_Manager::SELECT,
1066 'default' => 'ajax',
1067 'options' => array(
1068 'none' => esc_html__( 'None', 'sight' ),
1069 'ajax' => esc_html__( 'Load More', 'sight' ),
1070 'infinite' => esc_html__( 'Infinite Load', 'sight' ),
1071 ),
1072 'conditions' => array(
1073 'relation' => 'and',
1074 'terms' => array(
1075 array(
1076 'name' => 'layout',
1077 'operator' => '==',
1078 'value' => 'standard',
1079 ),
1080 array(
1081 'name' => 'source',
1082 'operator' => '==',
1083 'value' => 'projects',
1084 ),
1085 ),
1086 ),
1087 )
1088 );
1089 }
1090 }
1091
1092 new Sight_Widget_Portfolio_Layouts();
1093