[
'label' => _x('Curly', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => false,
'supports_amount' => true,
'round' => false,
'group' => 'line',
],
'curved' => [
'label' => _x('Curved', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => false,
'supports_amount' => true,
'round' => false,
'group' => 'line',
],
'multiple' => [
'label' => _x('Multiple', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => false,
'supports_amount' => false,
'round' => false,
'group' => 'pattern',
],
'slashes' => [
'label' => _x('Slashes', 'shapes'),
'shape' => '' .
'' .
'',
'preserve_aspect_ratio' => false,
'supports_amount' => true,
'round' => false,
'view_box' => '0 0 20 16',
'group' => 'line',
],
'squared' => [
'label' => _x('Squared', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => false,
'supports_amount' => true,
'round' => false,
'group' => 'line',
],
'wavy' => [
'label' => _x('Wavy', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => false,
'supports_amount' => true,
'round' => false,
'group' => 'line',
],
'zigzag' => [
'label' => _x('Zigzag', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => false,
'supports_amount' => true,
'round' => false,
'group' => 'line',
],
'arrows' => [
'label' => _x('Arrows', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => true,
'supports_amount' => true,
'round' => true,
'group' => 'pattern',
],
'pluses' => [
'label' => _x('Pluses', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => true,
'supports_amount' => true,
'round' => false,
'group' => 'pattern',
],
'rhombus' => [
'label' => _x('Rhombus', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => false,
'supports_amount' => true,
'round' => false,
'group' => 'pattern',
],
'parallelogram' => [
'label' => _x('Parallelogram', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => false,
'supports_amount' => true,
'round' => false,
'group' => 'pattern',
],
'rectangles' => [
'label' => _x('Rectangles', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => false,
'supports_amount' => true,
'round' => true,
'group' => 'pattern',
'view_box' => '0 0 60 30',
],
'dots_tribal' => [
'label' => _x('Dots', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => true,
'supports_amount' => false,
'round' => false,
'group' => 'tribal',
'view_box' => '0 0 126 26',
],
'trees_2_tribal' => [
'label' => _x('Fir Tree', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => true,
'supports_amount' => false,
'round' => false,
'group' => 'tribal',
'view_box' => '0 0 126 26',
],
'rounds_tribal' => [
'label' => _x('Half Rounds', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => true,
'supports_amount' => false,
'round' => false,
'group' => 'tribal',
'view_box' => '0 0 120 26',
],
'leaves_tribal' => [
'label' => _x('Leaves', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => true,
'supports_amount' => false,
'round' => false,
'group' => 'tribal',
'view_box' => '0 0 117 26',
],
'stripes_tribal' => [
'label' => _x('Stripes', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => true,
'supports_amount' => false,
'round' => false,
'group' => 'tribal',
'view_box' => '0 0 120 26',
],
'squares_tribal' => [
'label' => _x('Squares', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => true,
'supports_amount' => false,
'round' => false,
'group' => 'tribal',
'view_box' => '0 0 126 26',
],
'trees_tribal' => [
'label' => _x('Trees', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => true,
'supports_amount' => false,
'round' => false,
'group' => 'tribal',
'view_box' => '0 0 123 26',
],
'planes_tribal' => [
'label' => _x('Tribal', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => true,
'supports_amount' => false,
'round' => false,
'group' => 'tribal',
'view_box' => '0 0 121 26',
],
'x_tribal' => [
'label' => _x('X', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => true,
'supports_amount' => false,
'round' => false,
'group' => 'tribal',
'view_box' => '0 0 126 26',
],
'zigzag_tribal' => [
'label' => _x('Zigzag', 'shapes'),
'shape' => '',
'preserve_aspect_ratio' => true,
'supports_amount' => false,
'round' => false,
'group' => 'tribal',
'view_box' => '0 0 120 26',
],
]
);
}
private function filterStylesBy($array, $key, $value)
{
return array_filter($array, function ($style) use ($key, $value) {
return $value === $style[$key];
});
}
private function getOptionsByGroups($styles, $group = false)
{
$groups = [
'line' => [
'label' => __('Line'),
'options' => [
'solid' => __('Solid'),
'double' => __('Double'),
'dotted' => __('Dotted'),
'dashed' => __('Dashed'),
],
],
];
foreach ($styles as $key => $style) {
if (!isset($groups[$style['group']])) {
$groups[$style['group']] = [
'label' => ucwords(str_replace('_', '', $style['group'])),
'options' => [],
];
}
$groups[$style['group']]['options'][$key] = $style['label'];
}
if ($group && isset($groups[$group])) {
return $groups[$group];
}
return $groups;
}
/**
* Register divider widget controls.
*
* Adds different input fields to allow the user to change and customize the widget settings.
*
* @since 1.0.0
*/
protected function _registerControls()
{
$styles = $this->getSeparatorStyles();
$this->startControlsSection(
'section_divider',
[
'label' => __('Divider'),
]
);
$this->addControl(
'style',
[
'label' => __('Style'),
'type' => ControlsManager::SELECT,
'groups' => array_values($this->getOptionsByGroups($styles)),
'render_type' => 'template',
'default' => 'solid',
'selectors' => [
'{{WRAPPER}}' => '--divider-border-style: {{VALUE}}',
],
]
);
$this->addControl(
'separator_type',
[
'type' => ControlsManager::HIDDEN,
'default' => 'pattern',
'prefix_class' => 'elementor-widget-divider--separator-type-',
'condition' => [
'style!' => [
'',
'solid',
'double',
'dotted',
'dashed',
],
],
'render_type' => 'template',
]
);
$this->addControl(
'pattern_spacing_flag',
[
'type' => ControlsManager::HIDDEN,
'default' => 'no-spacing',
'prefix_class' => 'elementor-widget-divider--',
'condition' => [
'style' => array_keys($this->filterStylesBy($styles, 'supports_amount', false)),
],
'render_type' => 'template',
]
);
$this->addControl(
'pattern_round_flag',
[
'type' => ControlsManager::HIDDEN,
'default' => 'bg-round',
'prefix_class' => 'elementor-widget-divider--',
'condition' => [
'style' => array_keys($this->filterStylesBy($styles, 'round', true)),
],
]
);
$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' => 'eicon-text-align-left',
],
'center' => [
'title' => __('Center'),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => __('Right'),
'icon' => 'eicon-text-align-right',
],
],
'selectors' => [
'{{WRAPPER}} .elementor-divider' => 'text-align: {{VALUE}}',
'{{WRAPPER}} .elementor-divider-separator' => 'margin: 0 auto; margin-{{VALUE}}: 0',
],
]
);
$this->addControl(
'look',
[
'label' => __('Add Element'),
'type' => ControlsManager::CHOOSE,
'options' => [
'line' => [
'title' => __('None'),
'icon' => 'eicon-ban',
],
'line_text' => [
'title' => __('Text'),
'icon' => 'eicon-t-letter-bold',
],
'line_icon' => [
'title' => __('Icon'),
'icon' => 'eicon-star',
],
],
'separator' => 'before',
'prefix_class' => 'elementor-widget-divider--view-',
'render_type' => 'template',
]
);
$this->addControl(
'view',
[
'label' => __('View'),
'type' => ControlsManager::HIDDEN,
'default' => 'traditional',
]
);
$this->addControl(
'text',
[
'label' => __('Text'),
'type' => ControlsManager::TEXT,
'condition' => [
'look' => 'line_text',
],
'default' => __('Divider'),
'dynamic' => [
'active' => true,
],
]
);
$this->addControl(
'icon',
[
'label' => __('Icon'),
'type' => ControlsManager::ICONS,
'default' => [
'value' => 'fas fa-star',
'library' => 'fa-solid',
],
'condition' => [
'look' => 'line_icon',
],
]
);
$this->endControlsSection();
$this->startControlsSection(
'section_divider_style',
[
'label' => __('Divider'),
'tab' => ControlsManager::TAB_STYLE,
'condition' => [
'style!' => 'none',
],
]
);
$this->addControl(
'color',
[
'label' => __('Color'),
'type' => ControlsManager::COLOR,
'scheme' => [
'type' => SchemeColor::getType(),
'value' => SchemeColor::COLOR_2,
],
'default' => '#000',
'render_type' => 'template',
'selectors' => [
'{{WRAPPER}}' => '--divider-border-color: {{VALUE}}',
],
]
);
$this->addControl(
'weight',
[
'label' => __('Weight'),
'type' => ControlsManager::SLIDER,
'default' => [
'size' => 1,
],
'range' => [
'px' => [
'min' => 1,
'max' => 10,
'step' => 0.1,
],
],
'render_type' => 'template',
'condition' => [
'style' => array_keys($this->getOptionsByGroups($styles, 'line')['options']),
],
'selectors' => [
'{{WRAPPER}}' => '--divider-border-width: {{SIZE}}{{UNIT}}',
],
]
);
$this->addControl(
'pattern_height',
[
'label' => __('Size'),
'type' => ControlsManager::SLIDER,
'selectors' => [
'{{WRAPPER}}' => '--divider-pattern-height: {{SIZE}}{{UNIT}}',
],
'default' => [
'size' => 20,
],
'range' => [
'px' => [
'step' => 0.1,
],
],
'condition' => [
'style!' => [
'',
'solid',
'double',
'dotted',
'dashed',
],
],
]
);
$this->addControl(
'pattern_size',
[
'label' => __('Amount'),
'type' => ControlsManager::SLIDER,
'size_units' => ['%', 'px'],
'selectors' => [
'{{WRAPPER}}' => '--divider-pattern-size: {{SIZE}}{{UNIT}}',
],
'default' => [
'size' => 20,
],
'range' => [
'px' => [
'step' => 0.1,
],
'%' => [
'step' => 0.01,
],
],
'condition' => [
'style!' => array_merge(array_keys($this->filterStylesBy($styles, 'supports_amount', false)), [
'',
'solid',
'double',
'dotted',
'dashed',
]),
],
]
);
$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}};',
],
'separator' => 'before',
]
);
$this->endControlsSection();
$this->startControlsSection(
'section_text_style',
[
'label' => __('Text'),
'tab' => ControlsManager::TAB_STYLE,
'condition' => [
'look' => 'line_text',
],
]
);
$this->addControl(
'text_color',
[
'label' => __('Color'),
'type' => ControlsManager::COLOR,
'scheme' => [
'type' => SchemeColor::getType(),
'value' => SchemeColor::COLOR_2,
],
'selectors' => [
'{{WRAPPER}} .elementor-divider__text' => 'color: {{VALUE}}',
],
]
);
$this->addGroupControl(
GroupControlTypography::getType(),
[
'name' => 'typography',
'scheme' => SchemeTypography::TYPOGRAPHY_2,
'selector' => '{{WRAPPER}} .elementor-divider__text',
]
);
$this->addControl(
'text_align',
[
'label' => __('Position'),
'type' => ControlsManager::CHOOSE,
'options' => [
'left' => [
'title' => __('Left'),
'icon' => 'eicon-h-align-left',
],
'center' => [
'title' => __('Center'),
'icon' => 'eicon-h-align-center',
],
'right' => [
'title' => __('Right'),
'icon' => 'eicon-h-align-right',
],
],
'default' => 'center',
'prefix_class' => 'elementor-widget-divider--element-align-',
]
);
$this->addResponsiveControl(
'text_spacing',
[
'label' => __('Spacing'),
'type' => ControlsManager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 50,
],
],
'selectors' => [
'{{WRAPPER}}' => '--divider-element-spacing: {{SIZE}}{{UNIT}};',
],
]
);
$this->endControlsSection();
$this->startControlsSection(
'section_icon_style',
[
'label' => __('Icon'),
'tab' => ControlsManager::TAB_STYLE,
'condition' => [
'look' => 'line_icon',
],
]
);
$this->addControl(
'icon_view',
[
'label' => __('View'),
'type' => ControlsManager::SELECT,
'options' => [
'default' => __('Default'),
'stacked' => __('Stacked'),
'framed' => __('Framed'),
],
'default' => 'default',
'prefix_class' => 'elementor-view-',
]
);
$this->addResponsiveControl(
'icon_size',
[
'label' => __('Size'),
'type' => ControlsManager::SLIDER,
'range' => [
'px' => [
'min' => 6,
'max' => 300,
],
],
'selectors' => [
'{{WRAPPER}}' => '--divider-icon-size: {{SIZE}}{{UNIT}};',
],
]
);
$this->addControl(
'icon_padding',
[
'label' => __('Padding'),
'type' => ControlsManager::SLIDER,
'selectors' => [
'{{WRAPPER}} .elementor-icon' => 'padding: {{SIZE}}{{UNIT}};',
],
'range' => [
'em' => [
'min' => 0,
'max' => 5,
],
],
'condition' => [
'icon_view!' => 'default',
],
]
);
$this->addControl(
'primary_color',
[
'label' => __('Primary Color'),
'type' => ControlsManager::COLOR,
'selectors' => [
'{{WRAPPER}}.elementor-view-stacked .elementor-icon' => 'background-color: {{VALUE}};',
'{{WRAPPER}}.elementor-view-framed .elementor-icon, {{WRAPPER}}.elementor-view-default .elementor-icon' => 'color: {{VALUE}};',
],
'scheme' => [
'type' => SchemeColor::getType(),
'value' => SchemeColor::COLOR_2,
],
]
);
$this->addControl(
'secondary_color',
[
'label' => __('Secondary Color'),
'type' => ControlsManager::COLOR,
'condition' => [
'icon_view!' => 'default',
],
'selectors' => [
'{{WRAPPER}}.elementor-view-framed .elementor-icon' => 'background-color: {{VALUE}};',
'{{WRAPPER}}.elementor-view-stacked .elementor-icon' => 'color: {{VALUE}};',
],
]
);
$this->addControl(
'icon_align',
[
'label' => __('Position'),
'type' => ControlsManager::CHOOSE,
'options' => [
'left' => [
'title' => __('Left'),
'icon' => 'eicon-h-align-left',
],
'center' => [
'title' => __('Center'),
'icon' => 'eicon-h-align-center',
],
'right' => [
'title' => __('Right'),
'icon' => 'eicon-h-align-right',
],
],
'default' => 'center',
'prefix_class' => 'elementor-widget-divider--element-align-',
]
);
$this->addResponsiveControl(
'icon_spacing',
[
'label' => __('Spacing'),
'type' => ControlsManager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 50,
],
],
'selectors' => [
'{{WRAPPER}}' => '--divider-element-spacing: {{SIZE}}{{UNIT}}',
],
]
);
$this->addResponsiveControl(
'rotate',
[
'label' => __('Rotate'),
'type' => ControlsManager::SLIDER,
'size_units' => ['deg'],
'default' => [
'size' => 0,
'unit' => 'deg',
],
'tablet_default' => [
'unit' => 'deg',
],
'mobile_default' => [
'unit' => 'deg',
],
'selectors' => [
'{{WRAPPER}} .elementor-icon i, {{WRAPPER}} .elementor-icon svg' => 'transform: rotate({{SIZE}}{{UNIT}})',
],
]
);
$this->addControl(
'icon_border_width',
[
'label' => __('Border Width'),
'type' => ControlsManager::SLIDER,
'selectors' => [
'{{WRAPPER}} .elementor-icon' => 'border-width: {{SIZE}}{{UNIT}}',
],
'condition' => [
'icon_view' => 'framed',
],
]
);
$this->addControl(
'border_radius',
[
'label' => __('Border Radius'),
'type' => ControlsManager::SLIDER,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .elementor-icon' => 'border-radius: {{SIZE}}{{UNIT}}',
],
'condition' => [
'icon_view!' => 'default',
],
]
);
$this->endControlsSection();
}
/**
* Build SVG
*
* Build SVG element markup based on the widgets settings.
*
* @return string - An SVG element
*
* @since 2.7.0
*/
private function buildSvg()
{
$settings = $this->getSettingsForDisplay();
if ('pattern' !== $settings['separator_type'] || empty($settings['style'])) {
return '';
}
$svg_shapes = $this->getSeparatorStyles();
$selected_pattern = $svg_shapes[$settings['style']];
$preserve_aspect_ratio = $selected_pattern['preserve_aspect_ratio'] ? 'xMidYMid meet' : 'none';
$view_box = isset($selected_pattern['view_box']) ? $selected_pattern['view_box'] : '0 0 24 24';
$attr = [
'preserveAspectRatio' => $preserve_aspect_ratio,
'overflow' => 'visible',
'height' => '100%',
'viewBox' => $view_box,
];
if ('line' !== $selected_pattern['group']) {
$attr['fill'] = $settings['color'];
$attr['stroke'] = 'none';
} else {
$attr['stroke'] = $settings['color'];
$attr['stroke-width'] = $settings['weight']['size'];
$attr['fill'] = 'none';
$attr['stroke-linecap'] = 'square';
$attr['stroke-miterlimit'] = '10';
}
$this->addRenderAttribute('svg', $attr);
$pattern_attribute_string = $this->getRenderAttributeString('svg');
$shape = $selected_pattern['shape'];
return '';
}
public function svgToDataUri($svg)
{
return str_replace(
['<', '>', '"', '#'],
['%3C', '%3E', "'", '%23'],
$svg
);
}
/**
* Render divider widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 1.0.0
*/
protected function render()
{
$settings = $this->getSettingsForDisplay();
$svg_code = $this->buildSvg();
$has_icon = 'line_icon' === $settings['look'] && !empty($settings['icon']);
$has_text = 'line_text' === $settings['look'] && !empty($settings['text']);
$this->addRenderAttribute('wrapper', 'class', 'elementor-divider');
empty($svg_code) or $this->addRenderAttribute('wrapper', [
'style' => '--divider-pattern-url: url("data:image/svg+xml,' . $this->svgToDataUri($svg_code) . '");',
]); ?>
printRenderAttributeString('wrapper'); ?>>
'true']); ?>
addRenderAttribute('text', 'class', ['elementor-divider__text', 'elementor-divider__element']);
$this->addInlineEditingAttributes('text'); ?>
printRenderAttributeString('text'); ?>>