<?php
// Button
use Elementor\Controls_Manager;
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Border;
add_action('elementor/element/button/section_button/after_section_end', function ($element, $args) {
$default_args = [
'section_condition' => [],
];
$args = wp_parse_args($args, $default_args);
$element->update_control(
'button_type',
[
'label' => esc_html__('Type', 'motiox'),
'type' => Controls_Manager::SELECT,
'default' => 'default',
'options' => [
'default' => esc_html__('Default', 'motiox'),
'outline' => esc_html__('OutLine', 'motiox'),
'info' => esc_html__('Info', 'motiox'),
'success' => esc_html__('Success', 'motiox'),
'warning' => esc_html__('Warning', 'motiox'),
'danger' => esc_html__('Danger', 'motiox'),
'link' => esc_html__('Link', 'motiox'),
'bg' => esc_html__('Gradient', 'motiox'),
],
'prefix_class' => 'elementor-button-',
]
);
$element->update_control(
'size',
[
'condition' => array_merge($args['section_condition'], ['size[value]!' => '']),
]
);
}, 10, 2);
add_action('elementor/element/button/section_button/before_section_end', function ($element, $args) {
$element->add_responsive_control(
'icon_button_size',
[
'label' => esc_html__('Icon size', 'motiox'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', '%', 'em', 'rem', 'vw', 'custom'],
'default' => [
'size' => 24,
],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-button-content-wrapper .elementor-button-icon i:before' => 'font-size: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .elementor-button-content-wrapper .elementor-button-icon svg' => 'font-size: {{SIZE}}{{UNIT}};',
],
]
);
$element->add_responsive_control(
'button_width',
[
'label' => esc_html__('Button Width', 'motiox'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', '%', 'em', 'rem', 'vw', 'custom'],
'range' => [
'px' => [
'min' => 0,
'max' => 200,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-button' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$element->add_responsive_control(
'button_height',
[
'label' => esc_html__('Button Height', 'motiox'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', '%', 'em', 'rem', 'vw', 'custom'],
'range' => [
'px' => [
'min' => 0,
'max' => 200,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-button' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
}, 10, 2);
add_action('elementor/element/button/section_style/before_section_end', function ($element, $args) {
$element->add_control(
'icon_button_color',
[
'label' => esc_html__('Icon Color', 'motiox'),
'type' => Controls_Manager::COLOR,
'condition' => [
'selected_icon[value]!' => '',
],
'selectors' => [
'{{WRAPPER}} .elementor-button-content-wrapper .elementor-button-icon i:before' => '-webkit-text-fill-color: {{VALUE}};',
'{{WRAPPER}} .elementor-button-content-wrapper .elementor-button-icon svg' => 'fill: {{VALUE}};',
],
]
);
$element->add_control(
'icon_button_color_hover',
[
'label' => esc_html__('Icon Color Hover', 'motiox'),
'type' => Controls_Manager::COLOR,
'condition' => [
'selected_icon[value]!' => '',
],
'selectors' => [
'{{WRAPPER}} .elementor-button:hover .elementor-button-icon i:before' => '-webkit-text-fill-color: {{VALUE}};',
'{{WRAPPER}} .elementor-button:hover .elementor-button-icon svg' => 'fill: {{VALUE}};',
],
]
);
$element->add_control(
'border_button_color_hover',
[
'label' => esc_html__('Border Color Hover', 'motiox'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .elementor-button:hover' => 'border-color: {{VALUE}};',
],
]
);
$element->add_control(
'style_button_link',
[
'label' => esc_html__('Style Button Link', 'motiox'),
'type' => Controls_Manager::HEADING,
'condition' => [
'button_type' => 'link',
],
]
);
$element->add_group_control(
\Elementor\Group_Control_Border::get_type(),
[
'name' => 'button_link_border',
'selector' => '{{WRAPPER}}.elementor-button-link .elementor-button:after',
'condition' => [
'button_type' => 'link',
],
]
);
$element->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'all_background_button_link',
'label' => esc_html__('Background Button Link', 'motiox'),
'types' => ['classic', 'gradient'],
'selector' => '{{WRAPPER}}.elementor-button-link .elementor-button:after',
'fields_options' => [
'color' => [
'global' => [
'default' => '',
],
],
],
'condition' => [
'button_type' => 'link',
],
]
);
}, 10, 2);