Files
2025-07-13 11:19:53 +02:00

291 lines
7.2 KiB
PHP

<?php
/**
* Creative Elements - live Theme & Page Builder
*
* @author WebshopWorks, Elementor
* @copyright 2019-2022 WebshopWorks.com & Elementor.com
* @license https://www.gnu.org/licenses/gpl-3.0.html
*/
namespace CE;
defined('_PS_VERSION_') or die;
/**
* Elementor divider widget.
*
* Elementor widget that displays a line that divides different elements in the
* page.
*
* @since 1.0.0
*/
class WidgetDivider extends WidgetBase
{
/**
* Get widget name.
*
* Retrieve divider widget name.
*
* @since 1.0.0
* @access public
*
* @return string Widget name.
*/
public function getName()
{
return 'divider';
}
/**
* Get widget title.
*
* Retrieve divider widget title.
*
* @since 1.0.0
* @access public
*
* @return string Widget title.
*/
public function getTitle()
{
return __('Divider');
}
/**
* Get widget icon.
*
* Retrieve divider widget icon.
*
* @since 1.0.0
* @access public
*
* @return string Widget icon.
*/
public function getIcon()
{
return 'eicon-divider';
}
/**
* Get widget categories.
*
* Retrieve the list of categories the divider widget belongs to.
*
* Used to determine where to display the widget in the editor.
*
* @since 2.0.0
* @access public
*
* @return array Widget categories.
*/
public function getCategories()
{
return ['basic'];
}
/**
* Get widget keywords.
*
* Retrieve the list of keywords the widget belongs to.
*
* @since 2.1.0
* @access public
*
* @return array Widget keywords.
*/
public function getKeywords()
{
return ['divider', 'hr', 'line', 'border'];
}
/**
* Register divider 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 _registerControls()
{
$this->startControlsSection(
'section_divider',
[
'label' => __('Divider'),
]
);
$this->addControl(
'style',
[
'label' => __('Style'),
'type' => ControlsManager::SELECT,
'options' => [
'solid' => __('Solid'),
'double' => __('Double'),
'dotted' => __('Dotted'),
'dashed' => __('Dashed'),
],
'default' => 'solid',
'selectors' => [
'{{WRAPPER}} .elementor-divider-separator' => 'border-top-style: {{VALUE}};',
],
]
);
$this->addControl(
'weight',
[
'label' => __('Weight'),
'type' => ControlsManager::SLIDER,
'default' => [
'size' => 1,
],
'range' => [
'px' => [
'min' => 1,
'max' => 10,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-divider-separator' => 'border-top-width: {{SIZE}}{{UNIT}};',
],
]
);
$this->addControl(
'color',
[
'label' => __('Color'),
'type' => ControlsManager::COLOR,
'default' => '',
'scheme' => [
'type' => SchemeColor::getType(),
'value' => SchemeColor::COLOR_3,
],
'selectors' => [
'{{WRAPPER}} .elementor-divider-separator' => 'border-top-color: {{VALUE}};',
],
]
);
$this->addResponsiveControl(
'width',
[
'label' => __('Width'),
'type' => ControlsManager::SLIDER,
'size_units' => ['%', 'px'],
'range' => [
'px' => [
'max' => 1000,
],
],
'default' => [
'size' => 100,
'unit' => '%',
],
'tablet_default' => [
'unit' => '%',
],
'mobile_default' => [
'unit' => '%',
],
'selectors' => [
'{{WRAPPER}} .elementor-divider-separator' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->addResponsiveControl(
'align',
[
'label' => __('Alignment'),
'type' => ControlsManager::CHOOSE,
'options' => [
'left' => [
'title' => __('Left'),
'icon' => 'fa fa-align-left',
],
'center' => [
'title' => __('Center'),
'icon' => 'fa fa-align-center',
],
'right' => [
'title' => __('Right'),
'icon' => 'fa fa-align-right',
],
],
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-divider' => 'text-align: {{VALUE}};',
],
]
);
$this->addResponsiveControl(
'gap',
[
'label' => __('Gap'),
'type' => ControlsManager::SLIDER,
'default' => [
'size' => 15,
],
'range' => [
'px' => [
'min' => 2,
'max' => 50,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-divider' => 'padding-top: {{SIZE}}{{UNIT}}; padding-bottom: {{SIZE}}{{UNIT}};',
],
]
);
$this->addControl(
'view',
[
'label' => __('View'),
'type' => ControlsManager::HIDDEN,
'default' => 'traditional',
]
);
$this->endControlsSection();
}
/**
* Render divider widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 1.0.0
* @access protected
*/
protected function render()
{
?>
<div class="elementor-divider">
<span class="elementor-divider-separator"></span>
</div>
<?php
}
/**
* Render divider widget output in the editor.
*
* Written as a Backbone JavaScript template and used to generate the live preview.
*
* @since 1.0.0
* @access protected
*/
protected function _contentTemplate()
{
?>
<div class="elementor-divider">
<span class="elementor-divider-separator"></span>
</div>
<?php
}
}