Current File : /home/bravrvjk/cepurhuye.rw/wp-content/plugins/bopea-function/block//contact-form.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;
if ( ! defined( 'ABSPATH' ) ) exit;
class bopea_contact_form extends Widget_Base {
public $base;
public function get_name() {
return 'bopea-contact-form';
}
public function get_title() {
return esc_html__( 'Contact form 7', '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_tab',
[
'label' => esc_html__('Choose your form', 'bopea-function'),
]
);
$this->add_control(
'form_items',
[
'label' => __( 'Choose your form', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'options' => $this->bopea_all_form()
]
);
$this->end_controls_section();
//Form Style Section
$this->start_controls_section(
'section_tab_style', [
'label' => esc_html__( 'Form style', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'jl_form_layout',
[
'label' =>esc_html__( 'Form layout', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'default' => 'jl_c7g',
'options' => [
'jl_c7g' =>esc_html__( 'Form grid', 'bopea-function' ),
'jl_c7in' =>esc_html__( 'Form inline', 'bopea-function' )
],
]
);
$this->add_control(
'jl_c7b_mb',
[
'label' => esc_html__( 'Form input block on mobile', 'bopea-function' ),
'type' => Controls_Manager::SWITCHER,
'condition' => [
'jl_form_layout' => 'jl_c7in'
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'form_typography',
'label' =>esc_html__( 'Form typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl-cf7 form',
]
);
$this->add_responsive_control(
'c7_h_align',
[
'label' => __( 'Form 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-cf7' => 'display: flex; width: 100%;justify-content: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'c7_text_align',
array(
'label' => __( 'Form 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-cf7' => 'text-align: {{VALUE}};',
'{{WRAPPER}} .jl-cf7 .wpcf7-acceptance label' => 'display: flex; align-items: center; text-align: left;',
'{{WRAPPER}} .jl-cf7 .wpcf7-acceptance input[type=checkbox]' => 'margin-right: 6px; margin-top: 4px; align-self: flex-start; display: block;',
)
)
);
$this->add_responsive_control(
'jl_c7_w',
[
'label' => __( 'Form width', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 3000,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}} .jl-cf7 .wpcf7' => 'width: 100%; max-width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'jl_c7_cols',
[
'label' => __( 'Number of columns', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 1,
'max' => 12,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--jlc7-col-num: {{SIZE}};',
],
'condition' => [
'jl_form_layout' => 'jl_c7g'
]
]
);
$this->add_responsive_control(
'jl_col_space',
[
'label' => __( 'Columns space', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 500,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--jl-c7-cgap: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'jl_row_space',
[
'label' => __( 'Row space', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 500,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--jl-c7-rgap: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'in_c7_fcolor',
[
'label' => __( 'Form color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .jl-cf7 form' => 'color: {{VALUE}}',
]
]
);
$this->add_control(
'in_c7_fcolor_dark',
[
'label' => __( 'Form color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}} .jl-cf7 form' => 'color: {{VALUE}}',
]
]
);
$this->end_controls_section();
//Form input Section
$this->start_controls_section(
'section_input_style', [
'label' => esc_html__( 'Form input style', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'input_typography',
'label' =>esc_html__( 'Input typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl-cf7 input:not([type="submit"]):not([type="checkbox"]):not([type="radio"]), {{WRAPPER}} .jl-cf7 textarea, {{WRAPPER}}.jl-cf7 select',
]
);
$this->add_responsive_control(
'jl_c7_input_space',
[
'label' => __( 'Input space', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 500,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--jl-c7-ins: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'jl_c7_input_height',
[
'label' => __( 'Input height', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 500,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--jl-c7-inh: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'jl_c7_input_bw',
[
'label' => __( 'Input border width', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 50,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--jl-c7-bw: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'jl_c7_input_br',
[
'label' => __( 'Input border radius', 'bopea-function' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px'],
'selectors' => [
'{{WRAPPER}}' => '--jl-input-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
]
]
);
$this->start_controls_tabs( 'jl_input_tab_w' );
$this->start_controls_tab( 'jl_ninput_tab', [ 'label' => esc_html__( 'Normal', 'bopea-function' ) ] );
$this->add_control(
'in_c7_bg',
[
'label' => __( 'Background color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jlc7-bg: {{VALUE}}',
]
]
);
$this->add_control(
'in_c7_bg_dark',
[
'label' => __( 'Background color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--jlc7-bg: {{VALUE}}',
]
]
);
$this->add_control(
'in_c7_color',
[
'label' => __( 'Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-txt-color: {{VALUE}}',
]
]
);
$this->add_control(
'in_c7_color_dark',
[
'label' => __( 'Color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--jl-txt-color: {{VALUE}}',
]
]
);
$this->add_control(
'in_c7_line',
[
'label' => __( 'Line color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-post-line-color: {{VALUE}}',
]
]
);
$this->add_control(
'in_c7_line_dark',
[
'label' => __( 'Line color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--jl-post-line-color: {{VALUE}}',
]
]
);
$this->end_controls_tab();
$this->start_controls_tab( 'jl_input_hover', [ 'label' => esc_html__( 'Focus', 'bopea-function' ) ] );
$this->add_control(
'h_in_c7_bg',
[
'label' => __( 'Background color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jlc7-hbg: {{VALUE}}',
]
]
);
$this->add_control(
'h_in_c7_bg_dark',
[
'label' => __( 'Background color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--jlc7-hbg: {{VALUE}}',
]
]
);
$this->add_control(
'h_in_c7_color',
[
'label' => __( 'Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-txt-hcolor: {{VALUE}}',
]
]
);
$this->add_control(
'h_in_c7_color_dark',
[
'label' => __( 'Color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--jl-txt-hcolor: {{VALUE}}',
]
]
);
$this->add_control(
'h_in_c7_line',
[
'label' => __( 'Line color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-post-line-hcolor: {{VALUE}}',
]
]
);
$this->add_control(
'h_in_c7_line_dark',
[
'label' => __( 'Line color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--jl-post-line-hcolor: {{VALUE}}',
]
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->add_control(
'in_c7_holder',
[
'label' => __( 'Placeholder color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .jl-cf7' => '--jl-except-color: {{VALUE}}',
]
]
);
$this->add_control(
'in_c7_holder_dark',
[
'label' => __( 'Placeholder color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}} .jl-cf7' => '--jl-except-color: {{VALUE}}',
]
]
);
$this->end_controls_section();
//Form button Section
$this->start_controls_section(
'section_buton_style', [
'label' => esc_html__( 'Form button style', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'jl_btn_ov',
[
'label' => esc_html__( 'Button overlay', 'bopea-function' ),
'type' => Controls_Manager::SWITCHER,
'selectors' => [
'{{WRAPPER}} .jl-cf7 input[type="submit"], {{WRAPPER}} .jl-cf7 button' => 'position: absolute;',
],
'condition' => [
'jl_form_layout' => 'jl_c7in'
]
]
);
$this->add_responsive_control(
'jl_btn_ov_post',
[
'label' => __( 'Button overlay postion', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 100,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--jl-c7-btnpos: {{SIZE}}{{UNIT}};',
],
'condition' => [
'jl_btn_ov!' => ''
]
]
);
$this->add_control(
'jl_btn_full',
[
'label' => esc_html__( 'Button full width', 'bopea-function' ),
'type' => Controls_Manager::SWITCHER,
'selectors' => [
'{{WRAPPER}} .jl-cf7 input[type="submit"], {{WRAPPER}} .jl-cf7 button' => 'max-width: 100%;',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'button_typography',
'label' =>esc_html__( 'Button typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl-cf7 input[type="submit"], {{WRAPPER}} .jl-cf7 button',
]
);
$this->add_responsive_control(
'jl_c7_button_space',
[
'label' => __( 'Button space', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 500,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--jl-c7-btns: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'jl_c7_button_height',
[
'label' => __( 'Button height', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 500,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--jl-c7-btnh: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'jl_c7_button_br',
[
'label' => __( 'Button border radius', 'bopea-function' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px'],
'selectors' => [
'{{WRAPPER}}' => '--jl-button-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
]
]
);
$this->start_controls_tabs( 'jl_button_tab_w' );
$this->start_controls_tab( 'jl_nbutton_tab', [ 'label' => esc_html__( 'Normal', 'bopea-function' ) ] );
$this->add_control(
'in_c7_btn_bg',
[
'label' => __( 'Background color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jlc7-btnbg: {{VALUE}}',
]
]
);
$this->add_control(
'in_c7_btn_bg_dark',
[
'label' => __( 'Background color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--jlc7-btnbg: {{VALUE}}',
]
]
);
$this->add_control(
'in_c7_btn_color',
[
'label' => __( 'Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-btncolor: {{VALUE}}',
]
]
);
$this->add_control(
'in_c7_btn_color_dark',
[
'label' => __( 'Color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--jl-btncolor: {{VALUE}}',
]
]
);
$this->end_controls_tab();
$this->start_controls_tab( 'jl_button_hover', [ 'label' => esc_html__( 'Hover', 'bopea-function' ) ] );
$this->add_control(
'h_in_c7_btn_bg',
[
'label' => __( 'Background color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jlc7-hbtnbg: {{VALUE}}',
]
]
);
$this->add_control(
'h_in_c7_btn_bg_dark',
[
'label' => __( 'Background color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--jlc7-hbtnbg: {{VALUE}}',
]
]
);
$this->add_control(
'h_in_c7_btn_color',
[
'label' => __( 'Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-hbtncolor: {{VALUE}}',
]
]
);
$this->add_control(
'h_in_c7_btn_color_dark',
[
'label' => __( 'Color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--jl-hbtncolor: {{VALUE}}',
]
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
//Form error Section
$this->start_controls_section(
'section_error_style', [
'label' => esc_html__( 'Form response style', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'jl_hide_response',
[
'label' => esc_html__( 'Hide response', 'bopea-function' ),
'type' => Controls_Manager::SWITCHER,
'selectors' => [
'{{WRAPPER}} .jl-cf7 .wpcf7-form.invalid .wpcf7-response-output' => 'display: none;',
],
'condition' => [
'jl_form_layout' => 'jl_c7in'
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'response_typography',
'label' =>esc_html__( 'Response typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl-cf7 .wpcf7-response-output',
]
);
$this->add_control(
'fc7_error_color',
[
'label' => __( 'Erro Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-c7ecolor: {{VALUE}}',
]
]
);
$this->add_control(
'fc7_success_color',
[
'label' => __( 'Success color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-c7sucolor: {{VALUE}}',
]
]
);
$this->add_responsive_control(
'jl_c7_respace',
[
'label' => __( 'Response space', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => -200,
'max' => 200,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--jl-c7rsp: {{SIZE}}{{UNIT}};',
],
]
);
$this->end_controls_section();
//Form error Section
$this->start_controls_section(
'section_term_style', [
'label' => esc_html__( 'Terms and conditions style', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'term_typography',
'label' =>esc_html__( 'Term typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl-cf7 .wpcf7-acceptance .wpcf7-list-item-label',
]
);
$this->add_control(
'fc7_term_color',
[
'label' => __( 'Term color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--jl-c7tcolor: {{VALUE}}',
]
]
);
$this->add_control(
'fc7_term_color_dark',
[
'label' => __( 'Term color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--jl-c7tcolor: {{VALUE}}',
]
]
);
$this->end_controls_section();
}
protected function render( ) {
$settings = $this->get_settings_for_display();
$form_items = $settings['form_items'];
$jl_form_layout = $settings['jl_form_layout'];
$jl_c7b_mb = $settings['jl_c7b_mb'];
?>
<div class="jl-cf7<?php if(!empty($jl_c7b_mb)){echo ' jlc7bmb';}?> <?php if(!empty($jl_form_layout)){echo esc_attr($jl_form_layout);}?>">
<?php if ( ! empty( $form_items ) ) {
echo do_shortcode( '[contact-form-7 id="' . esc_attr($form_items) . '"]' );
} ?>
</div>
<?php
}
public function bopea_all_form() {
$options = array();
$contact_forms = get_posts( 'post_type="wpcf7_contact_form"&numberposts=-1' );
if ( ! empty( $contact_forms ) ) {
$options[''] = esc_html__( 'Default', 'bopea-function' );
foreach ( $contact_forms as $contact_form ) {
$options[ $contact_form->ID ] = esc_html( $contact_form->post_title );
}
}
return $options;
}
}