is_edit_mode_load()) { $this->enqueue_styles_scripts(); } parent::__construct($data, $args); } /** * Retrieve the list of categories the widget belongs to. * * Used to determine where to display the widget in the editor. * * Note that currently Elementor supports only one category. * When multiple categories passed, Elementor uses the first one. * * @since 1.1.0 * * @access public * * @return array Widget categories. */ public function get_categories() { return [ 'wdk-elementor-listing-preview' ]; } /** * Retrieve the widget name. * * @since 1.1.0 * * @access public * * @return string Widget name. */ public function get_name() { return 'wdk-field-images'; } /** * Retrieve the widget title. * * @since 1.1.0 * * @access public * * @return string Widget title. */ public function get_title() { return esc_html__('Wdk Listing Gallery', 'wpdirectorykit'); } /** * Retrieve the widget icon. * * @since 1.1.0 * * @access public * * @return string Widget icon. */ public function get_icon() { return 'eicon-image'; } /** * Register the widget controls. * * Adds different input fields to allow the user to change and customize the widget settings. * * @since 1.1.0 * * @access protected */ protected function register_controls() { $this->generate_controls_conf(); $this->generate_controls_layout(); $this->generate_controls_styles(); $this->generate_controls_content(); $this->insert_pro_message('1'); parent::register_controls(); } /** * Render the widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @since 1.1.0 * * @access protected */ protected function render() { parent::render(); global $wdk_listing_id; /* test data */ $this->data['id_element'] = $this->get_id(); $this->data['settings'] = $this->get_settings(); $this->data['images'] = array(); if(!Plugin::$instance->editor->is_edit_mode()) { $this->data['images'] = wdk_listing_images (array('listing_images'=>wdk_field_value ('listing_images', $wdk_listing_id)), 'full'); $this->data['images'] = array_slice($this->data['images'], ($this->data['settings']['offset_images']-1), $this->data['settings']['limit_images']); } else { $this->data['images'] = array_fill(0, $this->data['settings']['limit_images'], wdk_placeholder_image_src()); } $this->data['is_edit_mode']= false; if(Plugin::$instance->editor->is_edit_mode()) { $this->data['is_edit_mode']= true; } else { /* return false if no content */ } echo $this->view('wdk-field-images', $this->data); } private function generate_controls_conf() { $this->start_controls_section( 'tab_conf_main_section', [ 'label' => esc_html__('Main', 'wpdirectorykit'), 'tab' => '1', ] ); $this->add_control( 'limit_images', [ 'label' => __( 'Limit Images', 'wpdirectorykit' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'min' => 1, 'max' => 100, 'step' => 1, 'default' => 10, ] ); $this->add_control( 'offset_images', [ 'label' => __( 'Offset Images', 'wpdirectorykit' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'min' => 1, 'max' => 100, 'step' => 1, 'default' => 1, ] ); $this->add_control( 'enable_js_gallery', [ 'label' => __( 'Enable Gallery Popup', 'wpdirectorykit' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __( 'True', 'wpdirectorykit' ), 'label_off' => __( 'False', 'wpdirectorykit' ), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'wdk_listing_video_disabled', [ 'label' => __( 'Disable Video', 'wpdirectorykit' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __( 'True', 'wpdirectorykit' ), 'label_off' => __( 'False', 'wpdirectorykit' ), 'return_value' => '1', 'default' => '', ] ); $this->end_controls_section(); } private function generate_controls_layout() { } private function generate_controls_styles() { $this->start_controls_section( 'styles_thmbn_section', [ 'label' => esc_html__('Main', 'wpdirectorykit'), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'row_gap_col', [ 'label' => __( 'Columns', 'wpdirectorykit' ), 'type' => Controls_Manager::SELECT, 'options' => [ '' => esc_html__('Default', 'wpdirectorykit'), 'auto' => esc_html__('Auto', 'wpdirectorykit'), '100%' => '1', '50%' => '2', 'calc(100% / 3)' => '3', '25%' => '4', '20%' => '5', 'auto_flexible' => 'auto flexible', ], 'selectors_dictionary' => [ 'auto' => 'width:auto;-webkit-flex:0 0 auto;flex:0 0 auto', '100%' => 'width:100%;-webkit-flex:0 0 100%;flex:0 0 100%', '50%' => 'width:50%;-webkit-flex:0 0 50%;flex:0 0 50%', 'calc(100% / 3)' => 'width:calc(100% / 3);-webkit-flex:0 0 calc(100% / 3);flex:0 0 calc(100% / 3)', '25%' => 'width:25%;-webkit-flex:0 0 25%;flex:0 0 25%', '20%' => 'width:20%;-webkit-flex:0 0 20%;flex:0 0 20%', 'auto' => 'width:auto;-webkit-flex:0 0 auto;flex:0 0 auto', 'auto_flexible' => 'width:auto;-webkit-flex:1 2 auto;flex:1 2 auto', ], 'selectors' => [ '{{WRAPPER}} .wdk-row .wdk-col' => '{{UNIT}}', ], 'default' => '25%', 'separator' => 'before', ] ); $this->add_responsive_control( 'column_gap', [ 'label' => esc_html__('Columns Gap', 'wpdirectorykit'), 'type' => Controls_Manager::SLIDER, 'default' => [ 'size' => 10, ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 60, ], ], 'selectors' => [ '{{WRAPPER}} .wdk-row .wdk-col' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};;', '{{WRAPPER}} .wdk-row' => 'margin-left: -{{SIZE}}{{UNIT}};margin-right: -{{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'row_gap', [ 'label' => esc_html__('Rows Gap', 'wpdirectorykit'), 'type' => Controls_Manager::SLIDER, 'default' => [ 'size' => 10, ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 60, ], ], 'selectors' => [ '{{WRAPPER}} .wdk-row .wdk-col' => 'margin-bottom: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wdk-row' => 'margin-bottom: -{{SIZE}}{{UNIT}};', ], ] ); $this->end_controls_section(); $this->start_controls_section( 'styles_thmbn_type', [ 'label' => esc_html__('Thumbnail', 'wpdirectorykit'), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'layout_image_design', [ 'label' => __( 'Size style thumbnail', 'wpdirectorykit' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'cover', 'options' => [ 'none' => __( 'None', 'wpdirectorykit' ), 'contain' => __( 'Contain', 'wpdirectorykit' ), 'cover' => __( 'Cover', 'wpdirectorykit' ), ], 'selectors' => [ '{{WRAPPER}} .wdk-field-images .wdk-listing-image' => 'object-fit: {{VALUE}}', ], ] ); $selectors = array( 'normal' => '{{WRAPPER}} .wdk-field-images .wdk-listing-image', ); $this->generate_renders_tabs($selectors, 'layout_image_dynamic', 'block'); $this->add_control( 'enable_fixed_height', [ 'label' => __( 'Fixed Height', 'wpdirectorykit' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __( 'True', 'wpdirectorykit' ), 'label_off' => __( 'False', 'wpdirectorykit' ), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_responsive_control ( 'styles_thmbn_des_height', [ 'label' => esc_html__('Height', 'wpdirectorykit'), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 100, 'max' => 1500, ], 'vw' => [ 'min' => 0, 'max' => 100, ], ], 'size_units' => [ 'px', 'vw' ], 'selectors' => [ '{{WRAPPER}} .wdk-field-images .wdk-listing-image' => 'height: {{SIZE}}{{UNIT}}', ], 'separator' => 'after', 'conditions' => [ 'terms' => [ [ 'name' => 'enable_fixed_height', 'operator' => '==', 'value' => 'yes', ] ], ], ] ); $this->end_controls_section(); $items = [ [ 'key'=>'card', 'label'=> esc_html__('Card', 'wpdirectorykit'), 'selector'=>'.wdk-field-images .wdk-listing-image-card', 'selector_hover'=>'.wdk-field-images .wdk-listing-image-card%1$s', 'options'=>'block', ], ]; foreach ($items as $item) { $this->start_controls_section( $item['key'].'_section', [ 'label' => $item['label'], 'tab' => Controls_Manager::TAB_STYLE, ] ); $selectors = array( 'normal' => '{{WRAPPER}} '.$item['selector'], 'hover'=>'{{WRAPPER}} '.$item['selector_hover'], ); $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']); $this->end_controls_section(); } } private function generate_controls_content() { } public function enqueue_styles_scripts() { wp_enqueue_style('wdk-field-images'); wp_enqueue_style('blueimp-gallery'); wp_enqueue_script('blueimp-gallery'); wp_enqueue_script('wdk-blueimp-gallery'); } }