Current File : /home/bravrvjk/cepurhuye.rw/wp-content/plugins/bopea-function/block//custom-banner.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_section_custom_banner extends Widget_Base {
public function get_name() {
return 'bopea-section-custom-banner';
}
public function get_title() {
return esc_html__( 'Custom banner', 'bopea-function' );
}
public function get_icon() {
return 'eicon-elementor-circle jl-icons';
}
public function get_categories() {
return [ 'bopea-elements' ];
}
protected function register_controls() {
$this->start_controls_section(
'section_cus_banenr',
[
'label' => __( 'Custom banner settings', 'bopea-function' ),
]
);
$this->add_control(
'cb_smt', [
'label' => esc_html__( 'Small title', 'bopea-function' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => esc_html__('Our Featured', 'bopea-function' ),
]
);
$this->add_control(
'cb_tt', [
'label' => esc_html__( 'Banner title', 'bopea-function' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => esc_html__('Earn cash back for the things you buy', 'bopea-function' ),
]
);
$this->add_control(
'cb_desc', [
'label' => esc_html__( 'Banner description', 'bopea-function' ),
'type' => Controls_Manager::TEXTAREA,
'label_block' => true,
'default' => esc_html__('Follow these steps when your router has no internet access.', 'bopea-function' ),
]
);
$this->add_control(
'cb_btn', [
'label' => esc_html__( 'Banner button text', 'bopea-function' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => esc_html__('Learn More', 'bopea-function' ),
]
);
$this->add_control(
'tag',
[
'label' => __( 'Title Tag', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'options' => [
'h1' => 'H1',
'h2' => 'H2',
'h3' => 'H3',
'h4' => 'H4',
'h5' => 'H5',
'h6' => 'H6',
'div' => 'div',
'span' => 'span',
'p' => 'p',
],
'default' => 'h2',
]
);
$this->add_control(
'cb_url',
[
'label' =>esc_html__( 'Banner URL', 'bopea-function' ),
'label_block' => true,
'type' => Controls_Manager::URL,
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_tab_style', [
'label' => esc_html__( 'Custom banner style', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_group_control(
\Elementor\Group_Control_Background::get_type(),
[
'name' => 'jl_cb_bg',
'types' => [ 'classic', 'gradient', 'video' ],
'fields_options' => [
'background' => [
'label' => esc_html__( 'Banner background', 'bopea-function' )
],
],
'selector' => '{{WRAPPER}} .jl_cus_ban_inner',
]
);
$this->add_responsive_control(
'cb_main_align',
[
'label' => __( 'Banner alignment', 'bopea-function' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'flex-start' => [
'title' => __( 'Left', 'bopea-function' ),
'icon' => 'eicon-h-align-left',
],
'center' => [
'title' => __( 'Center', 'bopea-function' ),
'icon' => 'eicon-h-align-center',
],
'flex-end' => [
'title' => __( 'Right', 'bopea-function' ),
'icon' => 'eicon-h-align-right',
],
],
'toggle' => true,
'selectors' => [
'{{WRAPPER}}' => '--jl-cbma-align: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'jl_cb_max',
[
'label' => __( 'Banner max width', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 1,
'max' => 3000,
],
],
'selectors' => [
'{{WRAPPER}}' => '--jl-bmax: {{SIZE}}px',
],
]
);
$this->add_responsive_control(
'jl_cb_cmax',
[
'label' => __( 'Content max width', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 1,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}}' => '--jl-cmax: {{SIZE}}%',
],
]
);
$this->add_responsive_control(
'jl_cb_height',
[
'label' => __( 'Banner height', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 1,
'max' => 2500,
],
],
'selectors' => [
'{{WRAPPER}}' => '--jl-cb-height: {{SIZE}}px',
],
]
);
$this->add_responsive_control(
'jl_cb_gap',
[
'label' => __( 'Banner gap', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 1,
'max' => 300,
],
],
'selectors' => [
'{{WRAPPER}}' => '--jl-cb-gap: {{SIZE}}px',
],
]
);
$this->add_responsive_control(
'jl_cb_radius',
[
'label' => __( 'Banner radius', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 1,
'max' => 300,
],
],
'selectors' => [
'{{WRAPPER}}' => '--jl-cbradus: {{SIZE}}px',
],
]
);
$this->add_responsive_control(
'jl_text_align',
array(
'label' => __( 'Text alignment', 'bopea-function' ),
'type' => Controls_Manager::CHOOSE,
'options' => array(
'left' => array(
'title' => __( 'Left', 'bopea-function' ),
'icon' => 'eicon-text-align-left',
),
'center' => array(
'title' => __( 'Center', 'bopea-function' ),
'icon' => 'eicon-text-align-center',
),
'right' => array(
'title' => __( 'Right', 'bopea-function' ),
'icon' => 'eicon-text-align-right',
),
),
'toggle' => false,
'selectors' => array(
'{{WRAPPER}}' => '--jl-cb-align: {{VALUE}};',
)
)
);
$this->add_responsive_control(
'cap_h_align',
[
'label' => __( 'Horizontal alignment', 'bopea-function' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'flex-start' => [
'title' => __( 'Left', 'bopea-function' ),
'icon' => 'eicon-h-align-left',
],
'center' => [
'title' => __( 'Center', 'bopea-function' ),
'icon' => 'eicon-h-align-center',
],
'flex-end' => [
'title' => __( 'Right', 'bopea-function' ),
'icon' => 'eicon-h-align-right',
],
],
'toggle' => true,
'selectors' => [
'{{WRAPPER}}' => '--jl-cbh-align: {{VALUE}}',
],
]
);
$this->add_control(
'cap_v_align',
[
'label' => __( 'Vertical alignment', 'bopea-function' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'start' => [
'title' => __( 'Top', 'bopea-function' ),
'icon' => 'eicon-v-align-top',
],
'center' => [
'title' => __( 'Middle', 'bopea-function' ),
'icon' => 'eicon-v-align-middle',
],
'end' => [
'title' => __( 'Bottom', 'bopea-function' ),
'icon' => 'eicon-v-align-bottom',
],
],
'toggle' => true,
'selectors' => [
'{{WRAPPER}}' => '--jl-cbv-align: {{VALUE}}',
]
]
);
$this->add_responsive_control(
'jl_cb_padding',
[
'label' => __( 'Banner padding', 'bopea-function' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px'],
'selectors' => [
'{{WRAPPER}}' => '--jl-cb-padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
]
]
);
$this->add_group_control(
\Elementor\Group_Control_Background::get_type(),
[
'name' => 'jl_cb_ovbg',
'types' => [ 'classic', 'gradient', 'video' ],
'fields_options' => [
'background' => [
'label' => esc_html__( 'Overlay background color', 'bopea-function' )
],
],
'selector' => '{{WRAPPER}} .jl_cb_ov',
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_cb_smt', [
'label' => esc_html__( 'Banner small title style', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'jl_cb_smt_color',
[
'label' => __( 'Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-cbsm-color: {{VALUE}};',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'jl_cb_smt_typo',
'label' =>esc_html__( 'Typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl_cb_smt',
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_cb_mtitle', [
'label' => esc_html__( 'Banner title style', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'jl_cb_mm_color',
[
'label' => __( 'Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-cbmm-color: {{VALUE}};',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'jl_cb_mm_typo',
'label' =>esc_html__( 'Typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl-cb-head',
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_cb_desc', [
'label' => esc_html__( 'Banner description style', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'jl_cb_desc_color',
[
'label' => __( 'Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-cbdes-color: {{VALUE}};',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'jl_cb_des_typo',
'label' =>esc_html__( 'Typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl_cb_desc',
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_cb_btn', [
'label' => esc_html__( 'Banner button style', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'jl_cb_btn_bg',
[
'label' => __( 'Background', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-btnbg: {{VALUE}};',
]
]
);
$this->add_control(
'jl_cb_btn_color',
[
'label' => __( 'Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-btncolor: {{VALUE}};',
]
]
);
$this->add_control(
'jl_cb_btn_hbg',
[
'label' => __( 'Hover background', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-btnhbg: {{VALUE}};',
]
]
);
$this->add_control(
'jl_cb_btn_hcolor',
[
'label' => __( 'Hover color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-btnhcolor: {{VALUE}};',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'jl_cb_btn_typo',
'label' =>esc_html__( 'Typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl_cb_btn',
]
);
$this->add_responsive_control(
'jl_cb_btn_padding',
[
'label' => __( 'Padding', 'bopea-function' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px'],
'selectors' => [
'{{WRAPPER}}' => '--jl-cbbtn-padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
]
]
);
$this->add_responsive_control(
'jl_cb_btnradius',
[
'label' => __( 'Border radius', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 1,
'max' => 300,
],
],
'selectors' => [
'{{WRAPPER}}' => '--jl-button-radius: {{SIZE}}px',
],
]
);
$this->add_responsive_control(
'jl_cb_btnmar',
[
'label' => __( 'Button margin', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 1,
'max' => 300,
],
],
'selectors' => [
'{{WRAPPER}}' => '--jl-btn-mt: {{SIZE}}px',
],
]
);
$this->end_controls_section();
}
protected function render( ) {
$settings = $this->get_settings_for_display();
$cb_smt = $settings['cb_smt'];
$cb_tt = $settings['cb_tt'];
$cb_desc = $settings['cb_desc'];
$cb_btn = $settings['cb_btn'];
$tag = $settings['tag'];
?>
<div class="jl_cus_bw">
<div class="jl_cus_ban_inner">
<span class="jl_cb_ov"></span>
<?php if(!empty($cb_smt)){?>
<span class="jl_cb_smt"><?php echo wp_kses_post($cb_smt);?></span>
<?php }?>
<?php if(!empty($cb_tt)){?>
<<?php echo esc_html($tag); ?> class="jl-cb-head"><?php echo wp_kses_post($cb_tt);?></<?php echo esc_html($tag); ?>>
<?php }?>
<?php if(!empty($cb_desc)){?>
<span class="jl_cb_desc"><?php echo wp_kses_post($cb_desc);?></span>
<?php }?>
<?php if(!empty($cb_btn)){?>
<?php if ( ! empty( $settings['cb_url']['url'] ) ) {
$this->add_render_attribute( 'cb_btn_url', 'class', 'jl_cb_btn', true );
$this->add_link_attributes( 'cb_btn_url', $settings['cb_url'] ); ?><a <?php echo $this->get_render_attribute_string( 'cb_btn_url' ); ?>><?php echo wp_kses_post($cb_btn);?></a><?php }else{?>
<span class="jl_cb_btn"><?php echo wp_kses_post($cb_btn);?></span>
<?php }}?>
<?php if ( ! empty( $settings['cb_url']['url'] ) ) {
$this->add_render_attribute( 'cb_url', 'class', 'jl_cb_url', true );
$this->add_link_attributes( 'cb_url', $settings['cb_url'] ); ?><a <?php echo $this->get_render_attribute_string( 'cb_url' ); ?>></a><?php }?>
</div>
</div>
<?php
}
}