Current File : /home/pacjaorg/www/copwordpres/wp-content/plugins/tiny-portfolio/inc/widgets/tp-portfolio.php
<?php
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\utils;
use Elementor\Scheme_Color;
use Elementor\Group_Control_Typography;
use Elementor\Scheme_Typography;
use Elementor\Group_Control_Image_Size;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

class TP_Portfolio extends Widget_Base {

    public function get_name() {
        return 'tp-portfolio';
    }

    public function get_title() {
        return esc_html__( 'Tiny Portfolio', 'tiny-portfolio' );
    }

    public function get_icon() {
        return 'eicon-posts-grid';
    }

    public function get_categories() {
        return array( 'tiny-portfolio' );
    }

    protected function register_controls() {

        $this->start_controls_section(
            'section_portfolio_items',
            [
                'label' => esc_html__( 'Portfolio Items', 'tiny-portfolio' ),
                'tab'   => Controls_Manager::TAB_CONTENT,
            ]
        );

        $repeater = new \Elementor\Repeater();

        $repeater->add_control(
            'title', [
                'label' => esc_html__( 'Title', 'tiny-portfolio' ),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => esc_html__( 'Portfolio Title' , 'tiny-portfolio' ),
                'label_block' => true,
            ]
        );

        $repeater->add_control(
            'featured_image', [
                'label' => esc_html__( 'Featured Image', 'tiny-portfolio' ),
                'type' => \Elementor\Controls_Manager::MEDIA,
                'label_block' => true,
                'default' => [
                    'url' => Utils::get_placeholder_image_src(),
                ],
            ]
        );

        $repeater->add_control(
            'type', [
                'label' => esc_html__( 'Type', 'tiny-portfolio' ),
                'type' => \Elementor\Controls_Manager::CHOOSE,
                'show_label' => true,
                'default' => 'image',
                'options' => [
                    'image' => [
                        'title' => esc_html__( 'Image', 'elementor' ),
                        'icon' => 'eicon-image',
                    ],
                    'video' => [
                        'title' => esc_html__( 'Video', 'elementor' ),
                        'icon' => 'eicon-video-camera',
                    ],
                    'audio' => [
                        'title' => esc_html__( 'Audio', 'elementor' ),
                        'icon' => 'eicon-headphones',
                    ],
                ]
            ]
        );

        $repeater->add_control(
            'images', [
                'label' => esc_html__( 'Add Images', 'tiny-portfolio' ),
                'type' => Controls_Manager::GALLERY,
                'show_label' => true,
                'dynamic' => [
                    'active' => true,
                ],
                'condition' => [
                    'type' => 'image'
                ]
            ]
        );

        $repeater->add_group_control(
            Group_Control_Image_Size::get_type(),
            [
                'name' => 'gallery', // // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `thumbnail_size` and `thumbnail_custom_dimension`.
                'exclude' => [ 'custom' ],
                'include' => [],
                'default' => 'large',
                'condition' => [
                    'type' => 'image'
                ]
            ]
        );

        $repeater->add_control(
            'video_type', [
                'label' => esc_html__( 'Video Type', 'tiny-portfolio' ),
                'type' => \Elementor\Controls_Manager::SELECT,
                'show_label' => true,
                'default' => 'youtube',
                'options' => [
                    'youtube' => esc_html__( 'Youtube Video', 'tiny-portfolio' ),
                    'vimeo' => esc_html__( 'Vimeo Video', 'tiny-portfolio' )
                ],
                'condition' => [
                    'type' => 'video'
                ]
            ]
        );

        $repeater->add_control(
            'youtube', [
                'label' => esc_html__( 'Youtube Video URL', 'tiny-portfolio' ),
                'type' => \Elementor\Controls_Manager::URL,
                'label_block' => true,
                'show_external' => false,
                'default' => [
                    'url' => 'https://www.youtube.com/watch?v=2OEL4P1Rz04'
                ],
                'condition' => [
                    'type' => 'video',
                    'video_type' => 'youtube'
                ]
            ]
        );

        $repeater->add_control(
            'vimeo', [
                'label' => esc_html__( 'Vimeo Video URL', 'tiny-portfolio' ),
                'type' => \Elementor\Controls_Manager::URL,
                'label_block' => true,
                'show_external' => false,
                'default' => [
                    'url' => 'https://vimeo.com/455516621'
                ],
                'condition' => [
                    'type' => 'video',
                    'video_type' => 'vimeo'
                ]
            ]
        );

        $repeater->add_control(
            'audio', [
                'label' => esc_html__( 'SoundCloud URL', 'tiny-portfolio' ),
                'type' => \Elementor\Controls_Manager::URL,
                'label_block' => true,
                'show_external' => false,
                'default' => [
                    'url' => 'https://soundcloud.com/bmsharp/you-and-yours-acle-kahney-remix'
                ],
                'condition' => [
                    'type' => 'audio'
                ]
            ]
        );

        $repeater->add_control(
            'content', [
                'label' => esc_html__( 'Content', 'tiny-portfolio' ),
                'type' => \Elementor\Controls_Manager::WYSIWYG,
                'show_label' => true,
            ]
        );

        $repeater->add_control(
            'date', [
                'label' => esc_html__( 'Date', 'tiny-portfolio' ),
                'type' => \Elementor\Controls_Manager::TEXT,
                'label_block' => true,
            ]
        );

        $repeater->add_control(
            'services', [
                'label' => esc_html__( 'Services', 'tiny-portfolio' ),
                'type' => \Elementor\Controls_Manager::TEXT,
                'label_block' => true,
            ]
        );

        $repeater->add_control(
            'client', [
                'label' => esc_html__( 'Client', 'tiny-portfolio' ),
                'type' => \Elementor\Controls_Manager::TEXT,
                'label_block' => true,
            ]
        );

        $repeater->add_control(
            'show_excerpt',
            [
                'label' => esc_html__( 'Show Excerpt', 'tiny-portfolio' ),
                'description' => esc_html__( 'If enable this option, it will display 50 words of the content as the excerpt.', 'tiny-portfolio' ),
                'type' => \Elementor\Controls_Manager::SWITCHER,
                'label_on' => esc_html__( 'Yes', 'tiny-portfolio' ),
                'label_off' => esc_html__( 'No', 'tiny-portfolio' ),
                'return_value' => 1,
                'default' => 0
            ]
        );

        $this->add_control(
            'items',
            [
                'label' => esc_html__( 'Portfolio Item', 'tiny-portfolio' ),
                'type' => Controls_Manager::REPEATER,
                'default' => [
                    [
                        'text' => esc_html__( 'Item #1', 'tiny-portfolio' ),
                    ]
                ],
                'fields' => $repeater->get_controls(),
                'title_field' => '{{{ title }}}',
            ]
        );

        $this->end_controls_section();


        $this->start_controls_section(
            'section_portfolio_layout',
            [
                'label' => esc_html__( 'Layout', 'tiny-portfolio' ),
                'tab'   => Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'columns', [
                'label' => esc_html__( 'Columns', 'tiny-portfolio' ),
                'type' => \Elementor\Controls_Manager::SELECT,
                'show_label' => true,
                'default' => '3',
                'options' => [
                    '2' => esc_html__( '2 Columns', 'tiny-portfolio' ),
                    '3' => esc_html__( '3 Columns', 'tiny-portfolio' ),
                    '4' => esc_html__( '4 Columns', 'tiny-portfolio' ),
                    '5' => esc_html__( '5 Columns', 'tiny-portfolio' ),
                ]
            ]
        );

        $this->add_control(
            'title_position', [
                'label' => esc_html__( 'Title Position', 'tiny-portfolio' ),
                'type' => \Elementor\Controls_Manager::SELECT,
                'show_label' => true,
                'default' => 'outside',
                'options' => [
                    'outside' => esc_html__( 'Outside The Box', 'tiny-portfolio' ),
                    'inside' => esc_html__( 'Inside The Box', 'tiny-portfolio' ),
                ]
            ]
        );

        $this->add_responsive_control(
            'featured_image_height',
            [
                'type' => Controls_Manager::SLIDER,
                'label' => esc_html__( 'Featured Image Height', 'tiny-portfolio' ),
                'selectors' => [
                    '{{WRAPPER}} .tp-portfolio .grid-item .grid-thumbnail' => 'height: {{SIZE}}{{UNIT}};',
                ],
                'default' => [
                    'size' => 250,
                ],
                'range' => [
                    'px' => [
                        'min' => 50,
                        'max' => 600,
                        'step' => 1,
                    ]
                ]
            ]
        );

        $this->add_responsive_control(
            'grid_item_height',
            [
                'type' => Controls_Manager::SLIDER,
                'label' => esc_html__( 'Grid Height', 'tiny-portfolio' ),
                'selectors' => [
                    '{{WRAPPER}} .tp-portfolio .grid-item' => 'height: {{SIZE}}{{UNIT}};',
                ],
                'default' => [
                    'size' => 250,
                ],
                'range' => [
                    'px' => [
                        'min' => 50,
                        'max' => 600,
                        'step' => 1,
                    ]
                ]
            ]
        );

        $this->add_responsive_control(
            'grid_item_grap',
            [
                'type' => Controls_Manager::SLIDER,
                'label' => esc_html__( 'Columns Gap', 'tiny-portfolio' ),
                'selectors' => [
                    '{{WRAPPER}} .tp-portfolio .grid-item' => 'margin: 0 {{SIZE}}{{UNIT}} {{SIZE}}{{UNIT}} 0;',
                    '{{WRAPPER}} .tp-portfolio.columns-2 .grid-item' => 'width: calc(1/2*100% - (1 - 1/2)*{{SIZE}}{{UNIT}});',
                    '{{WRAPPER}} .tp-portfolio.columns-3 .grid-item' => 'width: calc(1/3*100% - (1 - 1/3)*{{SIZE}}{{UNIT}});',
                    '{{WRAPPER}} .tp-portfolio.columns-4 .grid-item' => 'width: calc(1/4*100% - (1 - 1/4)*{{SIZE}}{{UNIT}});',
                    '{{WRAPPER}} .tp-portfolio.columns-5 .grid-item' => 'width: calc(1/5*100% - (1 - 1/5)*{{SIZE}}{{UNIT}});'
                ],
                'default' => [
                    'size' => 20,
                ],
                'range' => [
                    'px' => [
                        'min' => 0,
                        'max' => 100,
                        'step' => 1,
                    ]
                ]
            ]
        );

        $this->end_controls_section();

        $this->start_controls_section(
            'section_portfolio_data',
            [
                'label' => esc_html__( 'Data', 'tiny-portfolio' ),
                'tab'   => Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'enable_infinite_scroll',
            [
                'label' => esc_html__( 'Enable Infinite Scroll', 'tiny-portfolio' ),
                'description' => esc_html__( 'If enable Infinite scroll, you should only add one portfolio widget per page.', 'tiny-portfolio' ),
                'type' => Controls_Manager::SWITCHER,
                'label_on' => esc_html__( 'Yes', 'tiny-portfolio' ),
                'label_off' => esc_html__( 'No', 'tiny-portfolio' ),
                'return_value' => '1',
                'default' => '0'
            ]
        );

        $this->add_control(
            'load_more_button',
            [
                'label' => esc_html__( 'Show Load More Button?', 'tiny-portfolio' ),
                'type' => Controls_Manager::SWITCHER,
                'label_on' => esc_html__( 'Yes', 'tiny-portfolio' ),
                'label_off' => esc_html__( 'No', 'tiny-portfolio' ),
                'return_value' => '1',
                'default' => '0',
                'condition' => [
                    'enable_infinite_scroll' => '1',
                ],
            ]
        );

        $this->add_control(
            'load_more_button_text',
            [
                'label' => esc_html__( 'Load More Button Text', 'tiny-portfolio' ),
                'type' => Controls_Manager::TEXT,
                'default' => 'Load More',
                'condition' => [
                    'load_more_button' => '1',
                ],
            ]
        );

        $this->add_control(
            'items_per_page',
            [
                'type' => Controls_Manager::NUMBER,
                'label' => esc_html__( 'Number Items Per Page', 'tiny-portfolio' ),
                'min' => 2,
                'max' => 100,
                'step' => 1,
                'default' => 6
            ]
        );

         $this->end_controls_section();

        $this->start_controls_section(
            'section_portfolio_grid_style',
            [
                'label' => esc_html__( 'Grid View', 'tiny-portfolio' ),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_control(

            'outside_title_color',
            [
                'type' => Controls_Manager::COLOR,
                'label' => esc_html__( 'Title Color', 'tiny-portfolio' ),
                'selectors' => [
                    '{{WRAPPER}} .tp-portfolio .grid-item .grid-title' => 'color: {{VALUE}};',
                ],
                'description'  =>  esc_html__( 'Change the title color which outside the box.', 'tiny-portfolio' ),
                'default' => '',
                'condition' => [
                    'title_position' => 'outside',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'outside_title_typography',
                'label' => esc_html__( 'Title Typography', 'tiny-portfolio' ),
                'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_2,
                'selector' => '{{WRAPPER}} .tp-portfolio .grid-item .grid-title',
                'condition' => [
                    'title_position' => 'outside',
                ],
            ]
        );

        $this->add_control(

            'outside_excerpt_color',
            [
                'type' => Controls_Manager::COLOR,
                'label' => esc_html__( 'Excerpt Color', 'tiny-portfolio' ),
                'selectors' => [
                    '{{WRAPPER}} .tp-portfolio .grid-item .excerpt' => 'color: {{VALUE}};',
                ],
                'description'  =>  esc_html__( 'Change the excerpt color which outside the box.', 'tiny-portfolio' ),
                'default' => '',
                'condition' => [
                    'title_position' => 'outside',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'outside_excerpt_typography',
                'label' => esc_html__( 'Excerpt Typography', 'tiny-portfolio' ),
                'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_2,
                'selector' => '{{WRAPPER}} .tp-portfolio .grid-item .excerpt',
                'condition' => [
                    'title_position' => 'outside',
                ],
            ]
        );

        $this->add_control(

            'inside_title_color',
            [
                'type' => Controls_Manager::COLOR,
                'label' => esc_html__( 'Title Color', 'tiny-portfolio' ),
                'selectors' => [
                    '{{WRAPPER}} .tp-portfolio .grid-item .grid-thumbnail .grid-title' => 'color: {{VALUE}};',
                ],
                'description'  =>  esc_html__( 'Change the title color which inside the box.', 'tiny-portfolio' ),
                'default' => '',
                'condition' => [
                    'title_position' => 'inside',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'inside_title_typography',
                'label' => esc_html__( 'Title Typography', 'tiny-portfolio' ),
                'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_2,
                'selector' => '{{WRAPPER}} .tp-portfolio .grid-item .grid-thumbnail .grid-title',
                'condition' => [
                    'title_position' => 'inside',
                ],
            ]
        );

        $this->add_control(

            'inside_excerpt_color',
            [
                'type' => Controls_Manager::COLOR,
                'label' => esc_html__( 'Excerpt Color', 'tiny-portfolio' ),
                'selectors' => [
                    '{{WRAPPER}} .tp-portfolio .grid-item .grid-thumbnail .excerpt' => 'color: {{VALUE}};',
                ],
                'description'  =>  esc_html__( 'Change the excerpt color which inside the box.', 'tiny-portfolio' ),
                'default' => '#fff',
                'condition' => [
                    'title_position' => 'inside',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'inside_excerpt_typography',
                'label' => esc_html__( 'Excerpt Typography', 'tiny-portfolio' ),
                'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_2,
                'selector' => '{{WRAPPER}} .tp-portfolio .grid-item .grid-thumbnail .excerpt',
                'condition' => [
                    'title_position' => 'inside',
                ],
            ]
        );

        $this->add_control(

            'grid_overlay_color',
            [
                'type' => Controls_Manager::COLOR,
                'label' => esc_html__( 'Grid Overlay Color', 'tiny-portfolio' ),
                'selectors' => [
                    '{{WRAPPER}} .tp-portfolio .grid-item .grid-overlay' => 'background-color: {{VALUE}};',
                ],
                'description'  =>  esc_html__( 'Change the overlay color which inside the box.', 'tiny-portfolio' ),
                'default' => '',
                'condition' => [
                    'title_position' => 'inside',
                ],
            ]
        );

        $this->add_control(
            'grid_overlay_opacity',
            [
                'type' => Controls_Manager::SLIDER,
                'label' => esc_html__( 'Grid Overlay Opacity', 'tiny-portfolio' ),
                'selectors' => [
                    '{{WRAPPER}} .tp-portfolio.grid-layout .grid-item .grid-thumbnail .grid-overlay' => 'opacity: {{SIZE}};',
                ],
                'default' => [
                    'size' => 0.2,
                ],
                'range' => [
                    'px' => [
                        'min' => 0,
                        'max' => 1,
                        'step' => 0.1,
                    ]
                ],
                'condition' => [
                    'title_position' => 'inside',
                ],
            ]
        );

        $this->end_controls_section();

        $this->start_controls_section(
            'section_load_more_button_style',
            [
                'label' => esc_html__( 'Load More Button', 'tiny-portfolio' ),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_control(
            'load_more_alignment',
            [
                'label' => esc_html__( 'Alignment', 'tiny-portfolio' ),
                'type' => Controls_Manager::CHOOSE,
                'default' => 'left',
                'options' => array(
                    'left'    => array(
                        'title' => esc_html__( 'Left', 'tiny-portfolio' ),
                        'icon' => 'fa fa-align-left',
                    ),
                    'center' => array(
                        'title' => esc_html__( 'Center', 'tiny-portfolio' ),
                        'icon' => 'fa fa-align-center',
                    ),
                    'right' => array(
                        'title' => esc_html__( 'Right', 'tiny-portfolio' ),
                        'icon' => 'fa fa-align-right',
                    ),
                ),
                'selectors' => [
                    '{{WRAPPER}} .tp-more-button' => 'text-align: {{VALUE}};',
                ]
            ]
        );

        $this->add_control(
            'load_more_color',
            [
                'label' => esc_html__( 'Background Color', 'tiny-portfolio' ),
                'type' => Controls_Manager::COLOR,
                'default' => '#000',
                'selectors' => [
                    '{{WRAPPER}} .tp-more-button .view-more-button' => 'background-color: {{VALUE}};',
                ]
            ]
        );

        $this->add_control(
            'load_more_text_color',
            [
                'label' => esc_html__( 'Text Color', 'tiny-portfolio' ),
                'type' => Controls_Manager::COLOR,
                'default' => '#fff',
                'selectors' => [
                    '{{WRAPPER}} .tp-more-button .view-more-button' => 'color: {{VALUE}};',
                ]
            ]
        );

        $this->add_control(
            'load_more_border_radius',
            [
                'label' => __( 'Border Radius', 'tiny-portfolio' ),
                'type' => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%' ],
                'selectors' => [
                    '{{WRAPPER}} .tp-more-button .view-more-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Border::get_type(),
            [
                'name' => 'load_more_button_border',
                'selector' => '{{WRAPPER}} .tp-more-button .view-more-button',
                'separator' => 'before',
            ]
        );

        $this->add_group_control(
            Group_Control_Box_Shadow::get_type(),
            [
                'name' => 'load_more_button_box_shadow',
                'selector' => '{{WRAPPER}} .tp-more-button .view-more-button',
            ]
        );

        $this->add_responsive_control(
            'load_more_button_text_padding',
            [
                'label' => __( 'Padding', 'tiny-portfolio' ),
                'type' => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', 'em', '%' ],
                'selectors' => [
                    '{{WRAPPER}} .tp-more-button .view-more-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
                'separator' => 'before',
            ]
        );

        $this->end_controls_section();

    }

    protected function render() {
        $data = (array)$this->get_settings();
        $data['id'] = $this->get_id();
        ob_start();
        tp_load_template( self::get_name(), '', (object)$data );
        echo ob_get_clean();
    }

    protected function content_template() {

    }

}
Site is undergoing maintenance

PACJA Events

Maintenance mode is on

Site will be available soon. Thank you for your patience!