Current File : /home/bravrvjk/cepurhuye.rw/wp-content/plugins/bopea-function/block//element-button.php
<?php
namespace bopeaElementor\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Image_Size;
use Elementor\Group_Control_Typography;
use Elementor\Schemes\Color;
use Elementor\Schemes\Typography;
use Elementor\Utils;
use Elementor\Control_Media;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Group_Control_Background;
use Elementor\Repeater;
use Elementor\Icons_Manager;
defined('ABSPATH') || die();
class bopea_button extends Widget_Base {
public function get_name() {
return 'bopea-button';
}
public function get_title() {
return esc_html__( 'Jelly Button', 'bopea-function' );
}
public function get_icon() {
return 'eicon-button jl-icons';
}
public function get_categories() {
return [ 'bopea-elements' ];
}
protected function register_controls() {
$this->start_controls_section(
'jl_btn_section_content',
array(
'label' => esc_html__( 'Content', 'bopea-function' ),
)
);
$this->add_control(
'btn_layout',
[
'label' => __( 'Button style', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'options' => [
'jl_bnt_bg' => 'Background',
'jl_bnt_border' => 'Bordered',
'jl_bnt_simple' => 'Simple',
],
'default' => 'jl_bnt_bg',
]
);
$this->add_control(
'btn_size',
[
'label' => __( 'Button size', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'options' => [
'jl_bnt_xs' => 'Extra Small',
'jl_bnt_sm' => 'Small',
'jl_bnt_md' => 'Medium',
'jl_bnt_lg' => 'Large',
'jl_bnt_xl' => 'Extra Large'
],
'default' => 'jl_bnt_lg',
]
);
$this->add_control(
'btn_bg_ani',
[
'label' => __( 'Background animation', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'options' => [
'' => 'None',
'jl_b_top_ani' => 'From top',
'jl_b_bottom_ani' => 'From bottom',
'jl_b_left_ani' => 'From left',
'jl_b_right_ani' => 'From right',
],
'default' => '',
'condition' => [
'btn_layout!' => 'jl_bnt_simple'
]
]
);
$this->add_control(
'btn_txt_ani',
[
'label' => __( 'Button text animation', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'options' => [
'' => 'None',
'jl_t_switch_ani' => 'Switch text',
'jl_t_line_ani' => 'Line animation',
],
'default' => '',
]
);
$this->add_control(
'btn_ico_ani',
[
'label' => __( 'Button icons animation', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'options' => [
'' => 'None',
'jl_i_ver_ani' => 'Vertical animation',
'jl_i_hor_ani' => 'Horizontal animation',
],
'default' => '',
]
);
$this->add_control(
'jl_btn_text',
[
'label' =>esc_html__( 'Label', 'bopea-function' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' =>esc_html__( 'Learn more ', 'bopea-function' ),
'placeholder' =>esc_html__( 'Learn more ', 'bopea-function' ),
]
);
$this->add_control(
'jl_btn_url',
[
'label' =>esc_html__( 'URL', 'bopea-function' ),
'type' => Controls_Manager::URL,
'placeholder' =>esc_url('https://jellywp.com/'),
'default' => [
'url' => '#',
],
]
);
$this->add_control(
'jl_btn_section_settings',
[
'label' => esc_html__( 'Settings', 'bopea-function' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'jl_btn_icons__switch',
[
'label' => esc_html__('Add icon? ', 'bopea-function'),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'label_on' =>esc_html__( 'Yes', 'bopea-function' ),
'label_off' =>esc_html__( 'No', 'bopea-function' ),
]
);
$this->add_control(
'jl_btn_icons',
[
'label' =>esc_html__( 'Icon', 'bopea-function' ),
'type' => Controls_Manager::ICONS,
'fa4compatibility' => 'jl_btn_icon',
'label_block' => true,
'default' => [
'value' => '',
],
'condition' => [
'jl_btn_icons__switch' => 'yes'
]
]
);
$this->add_control(
'jl_btn_icon_align',
[
'label' =>esc_html__( 'Icon Position', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'default' => 'right',
'options' => [
'left' =>esc_html__( 'Before', 'bopea-function' ),
'right' =>esc_html__( 'After', 'bopea-function' ),
],
'condition' => [
'jl_btn_icons__switch' => 'yes'
]
]
);
$this->end_controls_section();
$this->start_controls_section(
'jl_btn_section_style',
[
'label' =>esc_html__( 'Button', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'jl_btn_align',
[
'label' =>esc_html__( 'Alignment', 'bopea-function' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' =>esc_html__( 'Left', 'bopea-function' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' =>esc_html__( 'Center', 'bopea-function' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' =>esc_html__( 'Right', 'bopea-function' ),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'center',
'selectors' => [
'{{WRAPPER}} .jl-btn-wraper' => 'text-align: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'width',
[
'label' => esc_html__( 'Width (%)', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'selectors' => [
'{{WRAPPER}} .jlopt-btn' => 'width: {{SIZE}}%;',
],
'condition' => [
'btn_layout!' => 'jl_bnt_simple'
]
]
);
$this->add_responsive_control(
'jl_btn_text_padding',
[
'label' =>esc_html__( 'Padding', 'bopea-function' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .jlopt-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'condition' => [
'btn_layout!' => 'jl_bnt_simple'
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'jl_btn_typography',
'label' =>esc_html__( 'Typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jlopt-btn',
]
);
$this->add_control(
'jl_btn_transform',
[
'label' => esc_html__('Enable hover move to top', 'bopea-function'),
'type' => Controls_Manager::SWITCHER,
'selectors' => [
'{{WRAPPER}} .jl-wid-con .jlopt-btn:hover' => '-webkit-transform: translate3d(0, -3px, 0); -ms-transform: translate3d(0, -3px, 0); transform: translate3d(0, -3px, 0)',
],
]
);
$this->add_responsive_control(
'jl_btn_line_h',
[
'label' => esc_html__( 'Button line height', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'px'
),
'range' => array(
'px' => array(
'min' => -200,
'max' => 200,
)
),
'selectors' => [
'{{WRAPPER}} .jlopt-btn.jl_t_line_ani .jl_btn_txt:after' => 'height: {{SIZE}}px;',
],
'condition' => [
'btn_txt_ani' => 'jl_t_line_ani'
]
]
);
$this->add_responsive_control(
'jl_btn_line_pos',
[
'label' => esc_html__( 'Button line position', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'px'
),
'range' => array(
'px' => array(
'min' => -200,
'max' => 200,
)
),
'selectors' => [
'{{WRAPPER}} .jlopt-btn.jl_t_line_ani .jl_btn_txt:after' => 'bottom: {{SIZE}}px;',
],
'condition' => [
'btn_txt_ani' => 'jl_t_line_ani'
]
]
);
$this->start_controls_tabs( 'jl_btn_tabs_style' );
$this->start_controls_tab(
'jl_btn_tabnormal',
[
'label' =>esc_html__( 'Normal', 'bopea-function' ),
]
);
$this->add_control(
'jl_btn_text_color',
[
'label' =>esc_html__( 'Text Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .jlopt-btn' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'jl_btn_svg_stroke',
[
'label' =>esc_html__( 'SVG stroke color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .jlopt-btn svg' => 'stroke: {{VALUE}};',
],
]
);
$this->add_control(
'jl_btn_svg_fill',
[
'label' =>esc_html__( 'SVG fill color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .jlopt-btn svg' => 'fill: {{VALUE}}; color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
array(
'name' => 'jl_btn_bg_color',
'default' => '',
'selector' => '{{WRAPPER}} .jlopt-btn',
'condition' => [
'btn_layout!' => 'jl_bnt_simple'
]
)
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'jl_btn_shadow',
'label' => __( 'Box Shadow', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl-wid-con .jlopt-btn',
'condition' => [
'btn_layout!' => 'jl_bnt_simple'
]
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'jl_btn_tab_button_hover',
[
'label' =>esc_html__( 'Hover', 'bopea-function' ),
]
);
$this->add_control(
'jl_btn_hover_color',
[
'label' =>esc_html__( 'Text Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .jlopt-btn:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'jl_btn_svg_stroke_h',
[
'label' =>esc_html__( 'SVG stroke color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .jlopt-btn:hover svg' => 'stroke: {{VALUE}};',
],
]
);
$this->add_control(
'jl_btn_svg_fill_h',
[
'label' =>esc_html__( 'SVG fill color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .jlopt-btn:hover svg' => 'fill: {{VALUE}}; color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
array(
'name' => 'jl_btn_bg_hover_color',
'default' => '',
'selector' => '{{WRAPPER}} .jlopt-btn:before',
'condition' => [
'btn_layout!' => 'jl_bnt_simple'
]
)
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'jl_btn_shadow_h',
'label' => __( 'Box Shadow', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl-wid-con .jlopt-btn:hover',
'condition' => [
'btn_layout!' => 'jl_bnt_simple'
]
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
$this->start_controls_section(
'jl_btn_border_style_tabs',
[
'label' =>esc_html__( 'Button Border', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'btn_layout!' => 'jl_bnt_simple'
]
]
);
$this->start_controls_tabs( 'xs_tabs_button_border_style' );
$this->start_controls_tab(
'jl_btn_tab_border_normal',
[
'label' =>esc_html__( 'Normal', 'bopea-function' ),
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
array(
'name' => 'btn_border',
'selector' => '{{WRAPPER}} .jlopt-btn',
)
);
$this->add_responsive_control(
'jl_btn_border_radius',
[
'label' =>esc_html__( 'Border Radius', 'bopea-function' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%'],
'default' => [
'top' => '',
'right' => '',
'bottom' => '' ,
'left' => '',
],
'selectors' => [
'{{WRAPPER}} .jlopt-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'jl_btn_tab_button_border_hover',
[
'label' =>esc_html__( 'Hover', 'bopea-function' ),
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
array(
'name' => 'btn_border_hover',
'selector' => '{{WRAPPER}} .jlopt-btn:hover',
)
);
$this->add_responsive_control(
'jl_btn_border_radius_h',
[
'label' =>esc_html__( 'Border Radius', 'bopea-function' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%'],
'selectors' => [
'{{WRAPPER}} .jlopt-btn:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
$this->start_controls_section(
'jl_btn_iconw_style',
[
'label' =>esc_html__( 'Button Icon', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'jl_btn_icons__switch' => 'yes'
]
]
);
$this->add_responsive_control(
'jl_btn_normal_icon_font_size',
array(
'label' => esc_html__( 'Icons Size', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'px', 'em', 'rem',
),
'range' => array(
'px' => array(
'min' => 1,
'max' => 500,
),
),
'selectors' => array(
'{{WRAPPER}} .jlopt-btn i' => 'font-size: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .jlopt-btn svg' => 'width: {{SIZE}}{{UNIT}}; height: auto;',
),
)
);
$this->add_responsive_control(
'jl_btn_normal_icon_padding_left',
[
'label' => esc_html__( 'Add space after icon', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 300,
'step' => 1,
],
],
'default' => [
'unit' => 'px',
'size' => 10,
],
'selectors' => [
'{{WRAPPER}} .jl-wid-con .jlopt-btn' => 'gap: {{SIZE}}{{UNIT}};',
]
]
);
$this->add_responsive_control(
'jl_btn_normal_icon_vertical_align',
array(
'label' => esc_html__( 'Move icon Vertically', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'px', 'em', 'rem',
),
'range' => array(
'px' => array(
'min' => -200,
'max' => 200,
),
'em' => array(
'min' => -50,
'max' => 50,
),
'rem' => array(
'min' => -50,
'max' => 50,
),
),
'selectors' => array(
'{{WRAPPER}} .jlopt-btn i, {{WRAPPER}} .jlopt-btn svg' => ' -webkit-transform: translateY({{SIZE}}{{UNIT}}); -ms-transform: translateY({{SIZE}}{{UNIT}}); transform: translateY({{SIZE}}{{UNIT}})',
),
)
);
$this->end_controls_section();
}
protected function render( ) {
$settings = $this->get_settings_for_display();
$btn_text = $settings['jl_btn_text'];
$jl_btn_ico = $settings['jl_btn_icons']['value'];
$icon_align = $settings['jl_btn_icon_align'];
if ( ! empty( $settings['jl_btn_url']['url'] ) ) {
$this->add_link_attributes( 'button', $settings['jl_btn_url'] );
}
$atts_btn_class = array();
if ( ! empty( $settings['btn_layout'] ) ) {
$atts_btn_class[] = $settings['btn_layout'];
}
if ( ! empty( $settings['btn_size'] ) ) {
$atts_btn_class[] = $settings['btn_size'];
}
if ( ! empty( $settings['btn_bg_ani'] ) ) {
$atts_btn_class[] = $settings['btn_bg_ani'];
}
if ( ! empty( $settings['btn_txt_ani'] ) ) {
$atts_btn_class[] = $settings['btn_txt_ani'];
}
if ( ! empty( $settings['btn_ico_ani'] ) ) {
$atts_btn_class[] = $settings['btn_ico_ani'];
}
$atts_btn_class = implode( ' ', $atts_btn_class );
?>
<div class="jl-wid-con">
<div class="jl-btn-wraper">
<?php if($icon_align == 'right'): ?>
<a <?php echo $this->get_render_attribute_string( 'button' ); ?> class="jlopt-btn <?php echo esc_attr( $atts_btn_class ); ?>">
<?php if ( ! empty( $settings['btn_txt_ani'] ) && $settings['btn_txt_ani'] == 'jl_t_switch_ani' ){?>
<span class="jl_btn_txt"><span class="jl_btn_inn"><?php echo esc_html( $btn_text ); ?></span><span class="jl_btn_dup"><?php echo esc_html( $btn_text ); ?></span></span>
<?php }else{?>
<span class="jl_btn_txt"><?php echo esc_html( $btn_text ); ?></span>
<?php }?>
<?php
if(empty($jl_btn_ico)){
echo '<span class="jl_btn_ico">';
echo '<svg fill="currentColor" width="16" height="16" viewBox="0 0 16 16"><path d="M8 0L6.59 1.41L12.17 7H0V9H12.17L6.59 14.59L8 16L16 8L8 0Z"></path></svg>';
if ( ! empty( $settings['btn_ico_ani'] ) ) {
echo '<svg fill="currentColor" width="16" height="16" viewBox="0 0 16 16"><path d="M8 0L6.59 1.41L12.17 7H0V9H12.17L6.59 14.59L8 16L16 8L8 0Z"></path></svg>';
}
echo '</span>';
}else{
echo '<span class="jl_btn_ico">';
$migrated = isset( $settings['__fa4_migrated']['jl_btn_icons'] );
$is_new = empty( $settings['jl_btn_icon'] );
if ( $is_new || $migrated ) {
Icons_Manager::render_icon( $settings['jl_btn_icons'], [ 'aria-hidden' => 'true' ] );
if ( ! empty( $settings['btn_ico_ani'] ) ) {
Icons_Manager::render_icon( $settings['jl_btn_icons'], [ 'aria-hidden' => 'true' ] );
}
} else { ?>
<i class="<?php echo esc_attr($settings['jl_btn_icon']); ?>" aria-hidden="true"></i>
<?php if ( ! empty( $settings['btn_ico_ani'] ) ) {?>
<i class="<?php echo esc_attr($settings['jl_btn_icon']); ?>" aria-hidden="true"></i>
<?php }?>
<?php
}
echo '</span>';
}
?>
</a>
<?php elseif ($icon_align == 'left') : ?>
<a <?php echo $this->get_render_attribute_string( 'button' ); ?> class="jlopt-btn <?php echo esc_attr( $atts_btn_class ); ?>">
<?php
if(empty($jl_btn_ico)){
echo '<span class="jl_btn_ico">';
echo '<svg fill="currentColor" width="16" height="16" viewBox="0 0 16 16"><path d="M8 0L6.59 1.41L12.17 7H0V9H12.17L6.59 14.59L8 16L16 8L8 0Z"></path></svg>';
if ( ! empty( $settings['btn_ico_ani'] ) ) {
echo '<svg fill="currentColor" width="16" height="16" viewBox="0 0 16 16"><path d="M8 0L6.59 1.41L12.17 7H0V9H12.17L6.59 14.59L8 16L16 8L8 0Z"></path></svg>';
}
echo '</span>';
}else{
echo '<span class="jl_btn_ico">';
$migrated = isset( $settings['__fa4_migrated']['jl_btn_icons'] );
$is_new = empty( $settings['jl_btn_icon'] );
if ( $is_new || $migrated ) {
Icons_Manager::render_icon( $settings['jl_btn_icons'], [ 'aria-hidden' => 'true' ] );
if ( ! empty( $settings['btn_ico_ani'] ) ) {
Icons_Manager::render_icon( $settings['jl_btn_icons'], [ 'aria-hidden' => 'true' ] );
}
} else { ?>
<i class="<?php echo esc_attr($settings['jl_btn_icon']); ?>" aria-hidden="true"></i>
<?php if ( ! empty( $settings['btn_ico_ani'] ) ) {?>
<i class="<?php echo esc_attr($settings['jl_btn_icon']); ?>" aria-hidden="true"></i>
<?php }?>
<?php
}
echo '</span>';
}
?>
<?php if ( ! empty( $settings['btn_txt_ani'] ) && $settings['btn_txt_ani'] == 'jl_t_switch_ani' ){?>
<span class="jl_btn_txt"><span class="jl_btn_inn"><?php echo esc_html( $btn_text ); ?></span><span class="jl_btn_dup"><?php echo esc_html( $btn_text ); ?></span></span>
<?php }else{?>
<span class="jl_btn_txt"><?php echo esc_html( $btn_text ); ?></span>
<?php }?>
</a>
<?php else : ?>
<a <?php echo $this->get_render_attribute_string( 'button' ); ?> class="jlopt-btn <?php echo esc_attr( $atts_btn_class ); ?>">
<?php if ( ! empty( $settings['btn_txt_ani'] ) && $settings['btn_txt_ani'] == 'jl_t_switch_ani' ){?>
<span class="jl_btn_txt"><span class="jl_btn_inn"><?php echo esc_html( $btn_text ); ?></span><span class="jl_btn_dup"><?php echo esc_html( $btn_text ); ?></span></span>
<?php }else{?>
<span class="jl_btn_txt"><?php echo esc_html( $btn_text ); ?></span>
<?php }?>
</a>
<?php endif; ?>
</div>
</div>
<?php
}
}