<?php
/**
 * @package     productive-commerce
 * @author      productiveminds.com
 * @copyright   productiveminds.com
 */

if ( !defined( 'ABSPATH' ) ) {
    die();
}

/**
 * Productive Wishlist List Widget for Elementor.
 *
 */
class Productive_Elementor_Widget_Wishlist_List extends \Elementor\Widget_Base {

    /**
     *
     * Widget Name (System).
     */
    public function get_name() {
        return 'productive_elementor_widget_wishlist_list';
    }

    /**
     *
     * Widget Name (Visible).
     */
    public function get_title() {
        return esc_html__( 'Wishlist Page', 'productive-commerce' );
    }

    /**
     *
     * Widget Icon
     */
    public function get_icon() {
        return 'eicon-circle-o';
    }

    /**
     *
     * Widget Support Url
     */
    public function get_custom_help_url() {
        return PRODUCTIVE_GLOBAL_PRODUCT_SUPPORT_BASE_URL;
    }

    /**
     *
     * Category in Element Admin Area
     */
    public function get_categories() {
        return [ 'productiveminds' ];
    }

    /**
     *
     * Widget Keywords
     */
    public function get_keywords() {
        return [ 'productive_elementor_widget_wishlist_list', 'Wishlist', 'Wishlist Page', 'productiveminds', 'productiveminds.com' ];
    }

    /**
     *
     * Widget Controls
     */
    protected function register_controls() {
        require( plugin_dir_path( __FILE__ ) . 'partials/partial-productive-elementor-widget-layout.php' );
        require( plugin_dir_path( __FILE__ ) . 'partials/partial-productive-elementor-widget-header.php' );
        require( plugin_dir_path( __FILE__ ) . 'partials/partial-productive-elementor-widget-summary.php' );
        require( plugin_dir_path( __FILE__ ) . 'partials/partial-productive-elementor-widget-content.php' );
        require( plugin_dir_path( __FILE__ ) . 'partials/partial-productive-elementor-widget-share.php' ); 
        require( plugin_dir_path( __FILE__ ) . 'partials/partial-productive-elementor-widget-settings.php' );
    }
    
    public function get_script_depends() {
        return [ 'productiveminds_lib_elementor_productive_commerce_js_handle' ];
    }
    
    /**
     *
     * Widget Rendered Content
     */
    protected function render() {
        $settings = $this->get_settings_for_display();
        
        if ( !isset($settings['section_content_header_is_show_section_header']) || empty($settings['section_content_header_is_show_section_header'])) {
            $settings['section_content_header_is_show_section_header'] = 0;
        } else {
            $settings['section_content_header_is_show_section_header'] = 1;
        }
        
        if ( !isset($settings['section_style_content_button_hover_animation']) || empty($settings['section_style_content_button_hover_animation']) ) {
            $settings['section_style_content_button_hover_animation'] = '';
        } else {
            $this->add_render_attribute( 'wrapper', 'class', $settings['section_style_content_button_hover_animation'] );
            $settings['section_style_content_button_hover_animation'] = 'elementor-animation-' . $settings['section_style_content_button_hover_animation'];
        }
        
        if ( !isset($settings['section_style_other_buttons_hover_animation']) || empty($settings['section_style_other_buttons_hover_animation']) ) {
            $settings['section_style_other_buttons_hover_animation'] = '';
        } else {
            $this->add_render_attribute( 'wrapper', 'class', $settings['section_style_other_buttons_hover_animation'] );
            $settings['section_style_other_buttons_hover_animation'] = 'elementor-animation-' . $settings['section_style_other_buttons_hover_animation'];
        }
        
        if ( !isset($settings['section_content_show_url_button']) || empty($settings['section_content_show_url_button'])) {
            $settings['section_content_show_url_button'] = 0;
        } else {
            $settings['section_content_show_url_button'] = 1;
        }
        
        $settings['section_content_show_url_button_icon'] = 0;
        
        $section_content_social_media_share_icon_size = 20;
        if( isset($settings['section_content_social_media_share_icon_size'] ) && isset( $settings['section_content_social_media_share_icon_size']['size'] ) ) {
            $section_content_social_media_share_icon_size = $settings['section_content_social_media_share_icon_size']['size'];
        }
        
        if( !isset($settings['social_media_share_icons_icons_boxes_spread']) ) {
            $settings['social_media_share_icons_icons_boxes_spread'] = '';
        }
        
        $settings['section_content_widget_specific_content'] = 0;
        $settings['slider_swiper_css_class_from_elementor'] = 'via_elementor_slider';
        
        $cpt_section_args = array(
            'section_initiator'                                     => 'elementor',
            'section_content_settings_unique_id'                    => $settings['section_content_settings_unique_id'],
            'section_content_header_is_show_section_header'         => $settings['section_content_header_is_show_section_header'],
            'section_content_summary_is_show_section_summary'       => $settings['section_content_summary_is_show_section_summary'],
            'section_content_summary_is_show_product_subtotal'      => $settings['section_content_summary_is_show_product_subtotal'],
            'section_content_summary_is_show_product_grandtotal'    => $settings['section_content_summary_is_show_product_grandtotal'],
            'section_content_summary_is_show_product_count'         => $settings['section_content_summary_is_show_product_count'],
            'section_content_summary_is_show_add_all_to_cart'       => $settings['section_content_summary_is_show_add_all_to_cart'],
            'section_content_summary_is_show_clear_all_button'      => $settings['section_content_summary_is_show_clear_all_button'],
            'section_title_html_tag'                                => $settings['section_title_html_tag'],
            'section_intro'                                 => $settings['section_intro'],
            'section_show_content_title'                    => $settings['section_show_content_title'],
            'section_show_content_price'                    => $settings['section_show_content_price'],
            'section_show_content_on_sale_banner'           => $settings['section_show_content_on_sale_banner'],
            'section_show_content_stock'                    => $settings['section_show_content_stock'],
            'section_show_content_ratings'                  => $settings['section_show_content_ratings'],
            'section_content_show_quickview_button'         => $settings['section_content_show_quickview_button'],
            'section_content_show_date_added'               => $settings['section_content_show_date_added'],
            'section_content_show_divider'                  => $settings['section_content_show_divider'],
            'section_content_date_added_copy'               => $settings['section_content_date_added_copy'],
            'section_content_show_url_button'               => $settings['section_content_show_url_button'],
            'section_content_show_url_button_icon'          => $settings['section_content_show_url_button_icon'],
            'section_content_show_remove_icon'              => $settings['section_content_show_remove_icon'],
            'section_content_show_quantity_field'           => $settings['section_content_show_quantity_field'],
            'section_content_show_mngt_button'              => 1,
            'section_content_layout_format'                 => $settings['section_content_layout_format'],
            'productiveminds_woo_archives_style'            => $settings['productiveminds_woo_archives_style'],
            'columns_per_row'                               => $settings['columns_per_row'],
            'slider_navigation_arrows_control_position'     => $settings['slider_navigation_arrows_control_position'],
            'slider_pagination_control_position'            => $settings['slider_pagination_control_position'],
            'slider_navigation_arrows_control_shape'        => $settings['slider_navigation_arrows_control_shape'],
            'slider_pagination_control_shape'               => $settings['slider_pagination_control_shape'],
            'productive_cpt_is_show_image_or_icon'          => $settings['productive_cpt_is_show_image_or_icon'],
            'section_style_content_button_hover_animation'  => $settings['section_style_content_button_hover_animation'],
            'section_style_other_buttons_hover_animation'   => $settings['section_style_other_buttons_hover_animation'],
            'section_content_widget_specific_content'       => $settings['section_content_widget_specific_content'],
            'slider_swiper_css_class_from_elementor'        => $settings['slider_swiper_css_class_from_elementor'],
            
            'section_show_social_media_share'                   => $settings['section_show_social_media_share'],
            'section_show_social_media_share_on_copy'           => $settings['section_show_social_media_share_on_copy'],
            'section_show_social_media_share_on_copy_location'  => $settings['section_show_social_media_share_on_copy_location'],
            'social_media_share_icons_icons_boxes_layout'       => $settings['social_media_share_icons_icons_boxes_layout'],
            'display_contact_social_media_icons_style'          => $settings['display_contact_social_media_icons_style'],
            'social_media_share_icons_icons_boxes_spread'       => $settings['social_media_share_icons_icons_boxes_spread'],
            'section_show_social_media_platform_name'           => $settings['section_show_social_media_platform_name'],
            'section_content_social_media_share_icon_size'      => $section_content_social_media_share_icon_size,
            'do_social_share_linkedin'                          => $settings['do_social_share_linkedin'],
            'do_social_share_facebook'                          => $settings['do_social_share_facebook'],
            'do_social_share_twitter'                           => $settings['do_social_share_twitter'],
            'do_social_share_pinterest'                         => $settings['do_social_share_pinterest'],
            'do_social_share_instagram'                         => $settings['do_social_share_instagram'],
            'do_social_share_whatsapp'                          => $settings['do_social_share_whatsapp'],
            'do_social_share_email'                             => $settings['do_social_share_email'],
        );
        
        
        $section_gtbg_align_none = 'align_page_none';
        $settings['section_bg_color_scheme'] = 'section_with_themed_bg';
        $settings['section_block_max_width'] = 'siteMaxWidth_Std';
        $settings['section_block_spacing'] = 'section_spacing_none';
        $settings['section_content_media_item_shape'] = 'shapeable-image-default';

        $section_bg_color_scheme        = 'productive-paddable-section page_main_section_container ' . $section_gtbg_align_none 
                . ' ' . $settings['section_bg_color_scheme'] . ' ' . $settings['section_block_max_width'] . ' ' . $settings['section_block_spacing'] . ' ' . $settings['section_content_media_item_shape'];

        $section_content_content_box_shape = '';
        if( isset($settings['section_content_content_box_shape']) ) {
            $section_content_content_box_shape = $settings['section_content_content_box_shape'];
        }
        $section_content_icon_size = '';
        if( isset($settings['section_content_icon_size']) ) {
            $section_content_icon_size = $settings['section_content_icon_size'];
        }
        $section_content_icon_alignment_h = '';
        if( isset($settings['section_content_icon_alignment_h']) ) {
            $section_content_icon_alignment_h = $settings['section_content_icon_alignment_h'];
        }
        $section_content_content_box_alignment_h = '';
        if( isset($settings['section_content_content_box_alignment_h']) ) {
            $section_content_content_box_alignment_h = $settings['section_content_content_box_alignment_h'];
        }
        $section_content_show_url_button_shape = '';
        if( isset($settings['section_content_show_url_button_shape']) ) {
            $section_content_show_url_button_shape = $settings['section_content_show_url_button_shape'];
        }
        $section_content_show_url_button_width = '';
        if( isset($settings['section_content_show_url_button_width']) ) {
            $section_content_show_url_button_width = $settings['section_content_show_url_button_width'];
        }
        $section_content_items_css_classes = ' ' . $section_content_content_box_shape . ' ' . $section_content_icon_size
                . ' ' . $section_content_icon_alignment_h . ' ' . $section_content_content_box_alignment_h . ' ' . $section_content_show_url_button_shape . ' ' . $section_content_show_url_button_width;
        
        do_action( 'productive_global_render_content_wrapper_full_full_top', $section_bg_color_scheme );
            do_action( 'productive_global_render_content_wrapper_full_top', $section_content_items_css_classes );
                productive_commerce_render_user_wishlist( $cpt_section_args );
            do_action('productive_global_render_content_wrapper_full_bottom');
        do_action('productive_global_render_content_wrapper_full_full_bottom');
        
    }
    
}
