Skip to content

Instantly share code, notes, and snippets.

@ibrahim-kardi
Last active April 4, 2023 12:41
Show Gist options
  • Save ibrahim-kardi/26487301dba00838e6246422ed903704 to your computer and use it in GitHub Desktop.
Save ibrahim-kardi/26487301dba00838e6246422ed903704 to your computer and use it in GitHub Desktop.
<?php
/**
* @author none
* @since 1.0
* @version 1.0
*/
namespace WPC\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
if (!defined('ABSPATH')) {
exit;
}
class Multi_Image_Widget extends Widget_Base
{
public function __construct($data = [], $args = null)
{
$this->rt_name = esc_html__('Multi Image', 'elements');
$this->rt_base = 'rt-main-multi';
parent::__construct($data, $args);
}
/**
* Get widget name.
*
* Retrieve Pricing widget name.
*
* @since 1.0.0
* @access public
*
* @return string Widget name.
*/
public function get_name()
{
return 'banner_multi';
}
/**
* Get widget title.
*
* Retrieve Pricing widget title.
*
* @since 1.0.0
* @access public
*
* @return string Widget title.
*/
public function get_title()
{
return __('Multi Image', 'elements');
}
/**
* Get widget icon.
*
* Retrieve Pricing widget icon.
*
* @since 1.0.0
* @access public
*
* @return string Widget icon.
*/
public function get_icon()
{
return 'dashicons dashicons-list-view';
}
/**
* Get widget categories.
*
* Retrieve the list of categories the Pricing widget belongs to.
*
* @since 1.0.0
* @access public
*
* @return array Widget categories.
*/
public function get_categories()
{
return ['elemeta-category'];
}
protected function register_controls()
{
$this->start_controls_section(
'section_rt_multi',
[
'label' => __('Multi Image', 'elements'),
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'multi_image',
[
'label' => __('Multi Image', 'elements'),
'type' => \Elementor\Controls_Manager::MEDIA,
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
],
]
);
$repeater->add_control(
'text_align',
[
'label' => __('Alignment', 'elements'),
'type' => \Elementor\Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __('Left', 'elements'),
'icon' => 'fa fa-align-left',
],
'center' => [
'title' => __('Center', 'elements'),
'icon' => 'fa fa-align-center',
],
'right' => [
'title' => __('Right', 'elements'),
'icon' => 'fa fa-align-right',
],
],
'default' => 'center',
'selectors' => [
'{{WRAPPER}} {{CURRENT_ITEM}} .multi-inner-wrapper' => 'text-align: {{VALUE}};',
],
]
);
$repeater->add_control(
'_position',
[
'label' => esc_html__('Position', 'elementor'),
'type' => Controls_Manager::SELECT,
'default' => '',
'options' => [
'' => esc_html__('Default', 'elementor'),
'absolute' => esc_html__('Absolute', 'elementor'),
],
'prefix_class' => 'elementor-',
'frontend_available' => true,
]
);
$start = is_rtl() ? esc_html__('Right', 'elementor') : esc_html__('Left', 'elementor');
$end = !is_rtl() ? esc_html__('Right', 'elementor') : esc_html__('Left', 'elementor');
$repeater->add_control(
'_offset_orientation_h',
[
'label' => esc_html__('Horizontal Orientation', 'elementor'),
'type' => Controls_Manager::CHOOSE,
'toggle' => false,
'default' => 'start',
'options' => [
'start' => [
'title' => $start,
'icon' => 'eicon-h-align-left',
],
'end' => [
'title' => $end,
'icon' => 'eicon-h-align-right',
],
],
'classes' => 'elementor-control-start-end',
'render_type' => 'ui',
'condition' => [
'_position!' => '',
],
]
);
$repeater->add_responsive_control(
'_offset_x',
[
'label' => esc_html__('Offset', 'elementor'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => -1000,
'max' => 1000,
'step' => 1,
],
'%' => [
'min' => -200,
'max' => 200,
],
'vw' => [
'min' => -200,
'max' => 200,
],
'vh' => [
'min' => -200,
'max' => 200,
],
],
'default' => [
'size' => '0',
],
'size_units' => ['px', '%', 'vw', 'vh'],
'selectors' => [
'body:not(.rtl) {{WRAPPER}} ' => 'left: {{SIZE}}{{UNIT}}',
'body.rtl {{WRAPPER}}' => 'right: {{SIZE}}{{UNIT}}',
],
'condition' => [
'_offset_orientation_h!' => 'end',
'_position!' => '',
],
]
);
$repeater->add_responsive_control(
'_offset_x_end',
[
'label' => esc_html__('Offset', 'elementor'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => -1000,
'max' => 1000,
'step' => 0.1,
],
'%' => [
'min' => -200,
'max' => 200,
],
'vw' => [
'min' => -200,
'max' => 200,
],
'vh' => [
'min' => -200,
'max' => 200,
],
],
'default' => [
'size' => '0',
],
'size_units' => ['px', '%', 'vw', 'vh'],
'selectors' => [
'body:not(.rtl) {{WRAPPER}} ' => 'right: {{SIZE}}{{UNIT}}',
'body.rtl {{WRAPPER}} ' => 'left: {{SIZE}}{{UNIT}}',
],
'condition' => [
'_offset_orientation_h' => 'end',
'_position!' => '',
],
]
);
$repeater->add_control(
'_offset_orientation_v',
[
'label' => esc_html__('Vertical Orientation', 'elementor'),
'type' => Controls_Manager::CHOOSE,
'toggle' => false,
'default' => 'start',
'options' => [
'start' => [
'title' => esc_html__('Top', 'elementor'),
'icon' => 'eicon-v-align-top',
],
'end' => [
'title' => esc_html__('Bottom', 'elementor'),
'icon' => 'eicon-v-align-bottom',
],
],
'render_type' => 'ui',
'condition' => [
'_position!' => '',
],
]
);
$repeater->add_responsive_control(
'_offset_y',
[
'label' => esc_html__('Offset', 'elementor'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => -1000,
'max' => 1000,
'step' => 1,
],
'%' => [
'min' => -200,
'max' => 200,
],
'vh' => [
'min' => -200,
'max' => 200,
],
'vw' => [
'min' => -200,
'max' => 200,
],
],
'size_units' => ['px', '%', 'vh', 'vw'],
'default' => [
'size' => '0',
],
'selectors' => [
'{{WRAPPER}} ' => 'top: {{SIZE}}{{UNIT}}',
],
'condition' => [
'_offset_orientation_v!' => 'end',
'_position!' => '',
],
]
);
$repeater->add_responsive_control(
'_offset_y_end',
[
'label' => esc_html__('Offset', 'elementor'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => -1000,
'max' => 1000,
'step' => 1,
],
'%' => [
'min' => -200,
'max' => 200,
],
'vh' => [
'min' => -200,
'max' => 200,
],
'vw' => [
'min' => -200,
'max' => 200,
],
],
'size_units' => ['px', '%', 'vh', 'vw'],
'default' => [
'size' => '0',
],
'selectors' => [
'{{WRAPPER}}' => 'bottom: {{SIZE}}{{UNIT}}',
],
'condition' => [
'_offset_orientation_v' => 'end',
'_position!' => '',
],
]
);
$repeater->add_control(
'z-index',
[
'label' => __('Z-index', 'elements'),
'type' => Controls_Manager::NUMBER,
'default' => 1,
'render_type' => 'none',
]
);
$this->add_control(
'effect',
[
'label' => __('Effect', 'elements'),
'type' => Controls_Manager::SELECT,
'default' => 'slide',
'options' => [
'slide' => __('Slide', 'elements'),
'fade' => __('Fade', 'elements'),
],
]
);
$this->add_control(
'multis',
[
'label' => __('Multi Items', 'elements'),
'type' => \Elementor\Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
]
);
$this->add_group_control(
\Elementor\Group_Control_Image_Size::get_type(),
[
'name' => 'thumbnail',
'default' => 'full',
'separator' => 'before',
'exclude' => [
'custom',
],
]
);
}
protected function render()
{
$data = $this->get_settings();
$settings = $this->get_settings_for_display();
$settings = $this->get_settings();
require dirname(__FILE__) . '/view.php';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment