| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 |
- <?php
- namespace Elementor;
- if ( ! defined( 'ABSPATH' ) ) {
- exit; // Exit if accessed directly.
- }
- /**
- * Elementor common widget.
- *
- * Elementor base widget that gives you all the advanced options of the basic
- * widget.
- *
- * @since 1.0.0
- */
- class Widget_Common extends Widget_Base {
- /**
- * Get widget name.
- *
- * Retrieve common widget name.
- *
- * @since 1.0.0
- * @access public
- *
- * @return string Widget name.
- */
- public function get_name() {
- return 'common';
- }
- /**
- * Show in panel.
- *
- * Whether to show the common widget in the panel or not.
- *
- * @since 1.0.0
- * @access public
- *
- * @return bool Whether to show the widget in the panel.
- */
- public function show_in_panel() {
- return false;
- }
- /**
- * Register common widget controls.
- *
- * Adds different input fields to allow the user to change and customize the widget settings.
- *
- * @since 1.0.0
- * @access protected
- */
- protected function _register_controls() {
- $this->start_controls_section(
- '_section_style',
- [
- 'label' => __( 'Advanced', 'elementor' ),
- 'tab' => Controls_Manager::TAB_ADVANCED,
- ]
- );
- $this->add_control(
- '_title',
- [
- 'label' => __( 'Title', 'elementor' ),
- 'type' => Controls_Manager::HIDDEN,
- 'render_type' => 'none',
- ]
- );
- $this->add_responsive_control(
- '_margin',
- [
- 'label' => __( 'Margin', 'elementor' ),
- 'type' => Controls_Manager::DIMENSIONS,
- 'size_units' => [ 'px', '%' ],
- 'selectors' => [
- '{{WRAPPER}} > .elementor-widget-container' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
- ],
- ]
- );
- $this->add_responsive_control(
- '_padding',
- [
- 'label' => __( 'Padding', 'elementor' ),
- 'type' => Controls_Manager::DIMENSIONS,
- 'size_units' => [ 'px', 'em', '%' ],
- 'selectors' => [
- '{{WRAPPER}} > .elementor-widget-container' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
- ],
- ]
- );
- $this->add_control(
- '_z_index',
- [
- 'label' => __( 'Z-Index', 'elementor' ),
- 'type' => Controls_Manager::NUMBER,
- 'min' => 0,
- 'selectors' => [
- '{{WRAPPER}}' => 'z-index: {{VALUE}};',
- ],
- 'label_block' => false,
- ]
- );
- $this->add_control(
- '_animation',
- [
- 'label' => __( 'Entrance Animation', 'elementor' ),
- 'type' => Controls_Manager::ANIMATION,
- 'default' => '',
- 'prefix_class' => 'animated ',
- 'label_block' => false,
- 'frontend_available' => true,
- ]
- );
- $this->add_control(
- 'animation_duration',
- [
- 'label' => __( 'Animation Duration', 'elementor' ),
- 'type' => Controls_Manager::SELECT,
- 'default' => '',
- 'options' => [
- 'slow' => __( 'Slow', 'elementor' ),
- '' => __( 'Normal', 'elementor' ),
- 'fast' => __( 'Fast', 'elementor' ),
- ],
- 'prefix_class' => 'animated-',
- 'condition' => [
- '_animation!' => '',
- ],
- ]
- );
- $this->add_control(
- '_animation_delay',
- [
- 'label' => __( 'Animation Delay', 'elementor' ) . ' (ms)',
- 'type' => Controls_Manager::NUMBER,
- 'default' => '',
- 'min' => 0,
- 'step' => 100,
- 'condition' => [
- '_animation!' => '',
- ],
- 'render_type' => 'none',
- 'frontend_available' => true,
- ]
- );
- $this->add_control(
- '_element_id',
- [
- 'label' => __( 'CSS ID', 'elementor' ),
- 'type' => Controls_Manager::TEXT,
- 'default' => '',
- 'title' => __( 'Add your custom id WITHOUT the Pound key. e.g: my-id', 'elementor' ),
- 'label_block' => false,
- 'style_transfer' => false,
- ]
- );
- $this->add_control(
- '_css_classes',
- [
- 'label' => __( 'CSS Classes', 'elementor' ),
- 'type' => Controls_Manager::TEXT,
- 'default' => '',
- 'prefix_class' => '',
- 'title' => __( 'Add your custom class WITHOUT the dot. e.g: my-class', 'elementor' ),
- 'label_block' => false,
- ]
- );
- $this->end_controls_section();
- $this->start_controls_section(
- '_section_background',
- [
- 'label' => __( 'Background', 'elementor' ),
- 'tab' => Controls_Manager::TAB_ADVANCED,
- ]
- );
- $this->start_controls_tabs( '_tabs_background' );
- $this->start_controls_tab(
- '_tab_background_normal',
- [
- 'label' => __( 'Normal', 'elementor' ),
- ]
- );
- $this->add_group_control(
- Group_Control_Background::get_type(),
- [
- 'name' => '_background',
- 'selector' => '{{WRAPPER}} > .elementor-widget-container',
- ]
- );
- $this->end_controls_tab();
- $this->start_controls_tab(
- '_tab_background_hover',
- [
- 'label' => __( 'Hover', 'elementor' ),
- ]
- );
- $this->add_group_control(
- Group_Control_Background::get_type(),
- [
- 'name' => '_background_hover',
- 'selector' => '{{WRAPPER}}:hover .elementor-widget-container',
- ]
- );
- $this->add_control(
- '_background_hover_transition',
- [
- 'label' => __( 'Transition Duration', 'elementor' ),
- 'type' => Controls_Manager::SLIDER,
- 'range' => [
- 'px' => [
- 'max' => 3,
- 'step' => 0.1,
- ],
- ],
- 'render_type' => 'ui',
- 'separator' => 'before',
- ]
- );
- $this->end_controls_tab();
- $this->end_controls_tabs();
- $this->end_controls_section();
- $this->start_controls_section(
- '_section_border',
- [
- 'label' => __( 'Border', 'elementor' ),
- 'tab' => Controls_Manager::TAB_ADVANCED,
- ]
- );
- $this->start_controls_tabs( '_tabs_border' );
- $this->start_controls_tab(
- '_tab_border_normal',
- [
- 'label' => __( 'Normal', 'elementor' ),
- ]
- );
- $this->add_group_control(
- Group_Control_Border::get_type(),
- [
- 'name' => '_border',
- 'selector' => '{{WRAPPER}} > .elementor-widget-container',
- ]
- );
- $this->add_control(
- '_border_radius',
- [
- 'label' => __( 'Border Radius', 'elementor' ),
- 'type' => Controls_Manager::DIMENSIONS,
- 'size_units' => [ 'px', '%' ],
- 'selectors' => [
- '{{WRAPPER}} > .elementor-widget-container' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
- ],
- ]
- );
- $this->add_group_control(
- Group_Control_Box_Shadow::get_type(),
- [
- 'name' => '_box_shadow',
- 'selector' => '{{WRAPPER}} > .elementor-widget-container',
- ]
- );
- $this->end_controls_tab();
- $this->start_controls_tab(
- '_tab_border_hover',
- [
- 'label' => __( 'Hover', 'elementor' ),
- ]
- );
- $this->add_group_control(
- Group_Control_Border::get_type(),
- [
- 'name' => '_border_hover',
- 'selector' => '{{WRAPPER}}:hover .elementor-widget-container',
- ]
- );
- $this->add_control(
- '_border_radius_hover',
- [
- 'label' => __( 'Border Radius', 'elementor' ),
- 'type' => Controls_Manager::DIMENSIONS,
- 'size_units' => [ 'px', '%' ],
- 'selectors' => [
- '{{WRAPPER}}:hover > .elementor-widget-container' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
- ],
- ]
- );
- $this->add_group_control(
- Group_Control_Box_Shadow::get_type(),
- [
- 'name' => '_box_shadow_hover',
- 'selector' => '{{WRAPPER}}:hover .elementor-widget-container',
- ]
- );
- $this->add_control(
- '_border_hover_transition',
- [
- 'label' => __( 'Transition Duration', 'elementor' ),
- 'type' => Controls_Manager::SLIDER,
- 'separator' => 'before',
- 'range' => [
- 'px' => [
- 'max' => 3,
- 'step' => 0.1,
- ],
- ],
- 'selectors' => [
- '{{WRAPPER}} .elementor-widget-container' => 'transition: background {{_background_hover_transition.SIZE}}s, border {{SIZE}}s, border-radius {{SIZE}}s, box-shadow {{SIZE}}s',
- ],
- ]
- );
- $this->end_controls_tab();
- $this->end_controls_tabs();
- $this->end_controls_section();
- $this->start_controls_section(
- '_section_responsive',
- [
- 'label' => __( 'Responsive', 'elementor' ),
- 'tab' => Controls_Manager::TAB_ADVANCED,
- ]
- );
- $this->add_control(
- 'responsive_description',
- [
- 'raw' => __( 'Attention: The display settings (show/hide for mobile, tablet or desktop) will only take effect once you are on the preview or live page, and not while you\'re in editing mode in Elementor.', 'elementor' ),
- 'type' => Controls_Manager::RAW_HTML,
- 'content_classes' => 'elementor-descriptor',
- ]
- );
- $this->add_control(
- 'hide_desktop',
- [
- 'label' => __( 'Hide On Desktop', 'elementor' ),
- 'type' => Controls_Manager::SWITCHER,
- 'default' => '',
- 'prefix_class' => 'elementor-',
- 'label_on' => 'Hide',
- 'label_off' => 'Show',
- 'return_value' => 'hidden-desktop',
- ]
- );
- $this->add_control(
- 'hide_tablet',
- [
- 'label' => __( 'Hide On Tablet', 'elementor' ),
- 'type' => Controls_Manager::SWITCHER,
- 'default' => '',
- 'prefix_class' => 'elementor-',
- 'label_on' => 'Hide',
- 'label_off' => 'Show',
- 'return_value' => 'hidden-tablet',
- ]
- );
- $this->add_control(
- 'hide_mobile',
- [
- 'label' => __( 'Hide On Mobile', 'elementor' ),
- 'type' => Controls_Manager::SWITCHER,
- 'default' => '',
- 'prefix_class' => 'elementor-',
- 'label_on' => 'Hide',
- 'label_off' => 'Show',
- 'return_value' => 'hidden-phone',
- ]
- );
- $this->end_controls_section();
- Plugin::$instance->controls_manager->add_custom_css_controls( $this );
- }
- }
|