<?php
$pt_supports = ['portfolio'];
pxl_add_custom_widget(
    array(
        'name' => 'pxl_post_slip',
        'title' => esc_html__('Case Post Slip', 'hubsteel' ),
        'icon' => 'eicon-posts-grid',
        'categories' => array('pxltheme-core'),
        'scripts'    => array(
            'gsap',
            'pxl-scroll-trigger',
        ),
        'params' => array(
            'sections' => array(
                array(
                    'name'     => 'layout_section',
                    'label'    => esc_html__( 'Layout', 'hubsteel' ),
                    'tab'      => 'layout',
                    'controls' => array_merge(
                        array(
                            array(
                                'name'     => 'post_type',
                                'label'    => esc_html__( 'Select Post Type', 'hubsteel' ),
                                'type'     => 'select',
                                'multiple' => true,
                                'options'  => hubsteel_get_post_type_options($pt_supports),
                                'default'  => 'portfolio'
                            ) 
                        ),
                        hubsteel_get_post_slip_layout($pt_supports)
                    ),
                ),
                array(
                    'name' => 'section_source',
                    'label' => esc_html__('Source', 'hubsteel' ),
                    'tab' => \Elementor\Controls_Manager::TAB_SETTINGS,
                    'controls' => array_merge(
                        array(
                            array(
                                'name'     => 'select_post_by',
                                'label'    => esc_html__( 'Select posts by', 'hubsteel' ),
                                'type'     => 'select',
                                'multiple' => true,
                                'options'  => [
                                    'term_selected' => esc_html__( 'Terms selected', 'hubsteel' ),
                                    'post_selected' => esc_html__( 'Posts selected ', 'hubsteel' ),
                                ],
                                'default'  => 'term_selected'
                            ) 
                        ),
                        hubsteel_get_grid_term_by_post_type($pt_supports, ['custom_condition' => ['select_post_by' => 'term_selected']]),
                        hubsteel_get_grid_ids_by_post_type($pt_supports, ['custom_condition' => ['select_post_by' => 'post_selected']]),
                        array(
                            array(
                                'name' => 'orderby',
                                'label' => esc_html__('Order By', 'hubsteel' ),
                                'type' => \Elementor\Controls_Manager::SELECT,
                                'default' => 'date',
                                'options' => [
                                    'date' => esc_html__('Date', 'hubsteel' ),
                                    'ID' => esc_html__('ID', 'hubsteel' ),
                                    'author' => esc_html__('Author', 'hubsteel' ),
                                    'title' => esc_html__('Title', 'hubsteel' ),
                                    'rand' => esc_html__('Random', 'hubsteel' ),
                                ],
                            ),
                            array(
                                'name' => 'order',
                                'label' => esc_html__('Sort Order', 'hubsteel' ),
                                'type' => \Elementor\Controls_Manager::SELECT,
                                'default' => 'desc',
                                'options' => [
                                    'desc' => esc_html__('Descending', 'hubsteel' ),
                                    'asc' => esc_html__('Ascending', 'hubsteel' ),
                                ],
                            ),
                            array(
                                'name' => 'limit',
                                'label' => esc_html__('Total items', 'hubsteel' ),
                                'type' => \Elementor\Controls_Manager::NUMBER,
                                'default' => '6',
                            ),
                            array(
                                'name' => 'show_info',
                                'label' => esc_html__('Show Info', 'hubsteel' ),
                                'type' => \Elementor\Controls_Manager::SWITCHER,
                                'default' => 'true',
                                'conditions' => [
                                    'relation' => 'or',
                                    'terms' => [
                                        [
                                            'terms' => [
                                                ['name' => 'post_type', 'operator' => '==', 'value' => 'portfolio'],
                                                ['name' => 'layout_portfolio', 'operator' => 'in', 'value' => ['portfolio-1']]
                                            ]
                                        ],
                                    ],
                                ],
                            ),
                            array(
                                'name' => 'show_category',
                                'label' => esc_html__('Show Category', 'hubsteel' ),
                                'type' => \Elementor\Controls_Manager::SWITCHER,
                                'default' => 'true',
                                'conditions' => [
                                    'relation' => 'or',
                                    'terms' => [
                                        [
                                            'terms' => [
                                                ['name' => 'post_type', 'operator' => '==', 'value' => 'portfolio'],
                                                ['name' => 'layout_portfolio', 'operator' => 'in', 'value' => ['portfolio-1']]
                                            ]
                                        ],
                                    ],
                                ]
                            ),
                            array(
                                'name' => 'show_excerpt',
                                'label' => esc_html__('Show Excerpt', 'hubsteel' ),
                                'type' => \Elementor\Controls_Manager::SWITCHER,
                                'default' => 'true',
                                'conditions' => [
                                    'relation' => 'or',
                                    'terms' => [
                                        [
                                            'terms' => [
                                                ['name' => 'post_type', 'operator' => '==', 'value' => 'portfolio'],
                                                ['name' => 'layout_portfolio', 'operator' => 'in', 'value' => ['portfolio-1']]
                                            ]
                                        ],
                                    ],
                                ]
                            ),
                            array(
                                'name' => 'num_words',
                                'label' => esc_html__('Number of Words', 'hubsteel' ),
                                'type' => \Elementor\Controls_Manager::NUMBER,
                                'default' => 25,
                                'separator' => 'after',
                                'conditions' => [
                                    'relation' => 'or',
                                    'terms' => [
                                        [
                                            'terms' => [
                                                ['name' => 'post_type', 'operator' => '==', 'value' => 'portfolio'],
                                                ['name' => 'layout_portfolio', 'operator' => 'in', 'value' => ['portfolio-1']]
                                            ]
                                        ],
                                    ],
                                ]
                            ),
                            array(
                                'name' => 'show_button',
                                'label' => esc_html__('Show Button Readmore', 'hubsteel' ),
                                'type' => \Elementor\Controls_Manager::SWITCHER,
                                'default' => 'true',
                                'conditions' => [
                                    'relation' => 'or',
                                    'terms' => [
                                        [
                                            'terms' => [
                                                ['name' => 'post_type', 'operator' => '==', 'value' => 'portfolio'],
                                                ['name' => 'layout_portfolio', 'operator' => 'in', 'value' => ['portfolio-1']]
                                            ]
                                        ],
                                    ],
                                ]
                            ),
                            array(
                                'name' => 'button_text',
                                'label' => esc_html__('Button Text', 'hubsteel' ),
                                'type' => \Elementor\Controls_Manager::TEXT,
                                'conditions' => [
                                    'relation' => 'or',
                                    'terms' => [
                                        [
                                            'terms' => [
                                                ['name' => 'post_type', 'operator' => '==', 'value' => 'portfolio'],
                                                ['name' => 'layout_portfolio', 'operator' => 'in', 'value' => ['portfolio-1']]
                                            ]
                                        ],
                                    ],
                                ]
                            ),
                        )
                    ),
                ),
                array(
                    'name' => 'section_display',
                    'label' => esc_html__('Display', 'hubsteel' ),
                    'tab' => \Elementor\Controls_Manager::TAB_SETTINGS,
                    'controls' => array(
                        array(
                            'name' => 'img_size',
                            'label' => esc_html__('Image Size', 'hubsteel' ),
                            'type' => \Elementor\Controls_Manager::TEXT,
                            'description' => 'Enter image size (Example: "thumbnail", "medium", "large", "full" or other sizes defined by theme). Alternatively enter size in pixels (Default: 370x300 (Width x Height)).',
                        ),
                    ),
                ),

            ),
        ),
    ),
    hubsteel_get_class_widget_path()
);