<?php
namespace ElementorPro\Modules\Pricing\Widgets;
use Elementor\Controls_Manager;
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use Elementor\Group_Control_Image_Size;
use Elementor\Group_Control_Typography;
use Elementor\Repeater;
use ElementorPro\Base\Base_Widget;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class Price_List extends Base_Widget {
public function get_name() {
return 'price-list';
}
public function get_title() {
return __( 'Price List', 'elementor-pro' );
}
public function get_icon() {
return 'eicon-price-list';
}
public function get_keywords() {
return [ 'pricing', 'list', 'product', 'image', 'menu' ];
}
protected function register_controls() {
$this->start_controls_section(
'section_list',
[
'label' => __( 'List', 'elementor-pro' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$repeater = new Repeater();
$repeater->add_control(
'price',
[
'label' => __( 'Price', 'elementor-pro' ),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
]
);
$repeater->add_control(
'title',
[
'label' => __( 'Title', 'elementor-pro' ),
'type' => Controls_Manager::TEXT,
'default' => '',
'label_block' => 'true',
'dynamic' => [
'active' => true,
],
]
);
$repeater->add_control(
'item_description',
[
'label' => __( 'Description', 'elementor-pro' ),
'type' => Controls_Manager::TEXTAREA,
'default' => '',
'dynamic' => [
'active' => true,
],
]
);
$repeater->add_control(
'image',
[
'label' => __( 'Image', 'elementor-pro' ),
'type' => Controls_Manager::MEDIA,
'default' => [],
'dynamic' => [
'active' => true,
],
]
);
$repeater->add_control(
'link',
[
'label' => __( 'Link', 'elementor-pro' ),
'type' => Controls_Manager::URL,
'default' => [ 'url' => '#' ],
'dynamic' => [
'active' => true,
],
]
);
$this->add_control(
'price_list',
[
'label' => __( 'List Items', 'elementor-pro' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'title' => __( 'First item on the list', 'elementor-pro' ),
'item_description' => __( 'Lorem ipsum dolor sit amet consectetur adipiscing elit dolor', 'elementor-pro' ),
'price' => '$20',
'link' => [ 'url' => '#' ],
],
[
'title' => __( 'Second item on the list', 'elementor-pro' ),
'item_description' => __( 'Lorem ipsum dolor sit amet consectetur adipiscing elit dolor', 'elementor-pro' ),
'price' => '$9',
'link' => [ 'url' => '#' ],
],
[
'title' => __( 'Third item on the list', 'elementor-pro' ),
'item_description' => __( 'Lorem ipsum dolor sit amet consectetur adipiscing elit dolor', 'elementor-pro' ),
'price' => '$32',
'link' => [ 'url' => '#' ],
],
],
'title_field' => '{{{ title }}}',
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_list_style',
[
'label' => __( 'List', 'elementor-pro' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'heading__title',
[
'label' => __( 'Title & Price', 'elementor-pro' ),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'heading_color',
[
'label' => __( 'Color', 'elementor-pro' ),
'type' => Controls_Manager::COLOR,
'global' => [
'default' => Global_Colors::COLOR_PRIMARY,
],
'selectors' => [
'{{WRAPPER}} .elementor-price-list-header' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'heading_typography',
'global' => [
'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
],
'selector' => '{{WRAPPER}} .elementor-price-list-header',
]
);
$this->add_control(
'heading_item_description',
[
'label' => __( 'Description', 'elementor-pro' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'description_color',
[
'label' => __( 'Color', 'elementor-pro' ),
'type' => Controls_Manager::COLOR,
'global' => [
'default' => Global_Colors::COLOR_TEXT,
],
'selectors' => [
'{{WRAPPER}} .elementor-price-list-description' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'description_typography',
'global' => [
'default' => Global_Typography::TYPOGRAPHY_TEXT,
],
'selector' => '{{WRAPPER}} .elementor-price-list-description',
]
);
$this->add_control(
'heading_separator',
[
'label' => __( 'Separator', 'elementor-pro' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'separator_style',
[
'label' => __( 'Style', 'elementor-pro' ),
'type' => Controls_Manager::SELECT,
'options' => [
'solid' => __( 'Solid', 'elementor-pro' ),
'dotted' => __( 'Dotted', 'elementor-pro' ),
'dashed' => __( 'Dashed', 'elementor-pro' ),
'double' => __( 'Double', 'elementor-pro' ),
'none' => __( 'None', 'elementor-pro' ),
],
'default' => 'dotted',
'render_type' => 'template',
'selectors' => [
'{{WRAPPER}} .elementor-price-list-separator' => 'border-bottom-style: {{VALUE}}',
],
]
);
$this->add_control(
'separator_weight',
[
'label' => __( 'Weight', 'elementor-pro' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'max' => 10,
],
],
'condition' => [
'separator_style!' => 'none',
],
'selectors' => [
'{{WRAPPER}} .elementor-price-list-separator' => 'border-bottom-width: {{SIZE}}{{UNIT}}',
],
'default' => [
'size' => 2,
],
]
);
$this->add_control(
'separator_color',
[
'label' => __( 'Color', 'elementor-pro' ),
'type' => Controls_Manager::COLOR,
'global' => [
'default' => Global_Colors::COLOR_SECONDARY,
],
'selectors' => [
'{{WRAPPER}} .elementor-price-list-separator' => 'border-bottom-color: {{VALUE}};',
],
'condition' => [
'separator_style!' => 'none',
],
]
);
$this->add_control(
'separator_spacing',
[
'label' => __( 'Spacing', 'elementor-pro' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'max' => 40,
],
],
'condition' => [
'separator_style!' => 'none',
],
'selectors' => [
'{{WRAPPER}} .elementor-price-list-separator' => 'margin-left: {{SIZE}}{{UNIT}}; margin-right: {{SIZE}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_image_style',
[
'label' => __( 'Image', 'elementor-pro' ),
'tab' => Controls_Manager::TAB_STYLE,
'show_label' => false,
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'name' => 'image_size',
'default' => 'thumbnail',
]
);
$this->add_control(
'border_radius',
[
'label' => __( 'Border Radius', 'elementor-pro' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .elementor-price-list-image img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'image_spacing',
[
'label' => __( 'Spacing', 'elementor-pro' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'max' => 50,
],
],
'selectors' => [
'body.rtl {{WRAPPER}} .elementor-price-list-image' => 'padding-left: calc({{SIZE}}{{UNIT}}/2);',
'body.rtl {{WRAPPER}} .elementor-price-list-image + .elementor-price-list-text' => 'padding-right: calc({{SIZE}}{{UNIT}}/2);',
'body:not(.rtl) {{WRAPPER}} .elementor-price-list-image' => 'padding-right: calc({{SIZE}}{{UNIT}}/2);',
'body:not(.rtl) {{WRAPPER}} .elementor-price-list-image + .elementor-price-list-text' => 'padding-left: calc({{SIZE}}{{UNIT}}/2);',
],
'default' => [
Loading ...