File "cf7-tab-widget.php"
Full Path: /home/leadltht/fastlinkinternet.com/admin/wp-content/plugins/bdevs-element/widgets/cf7-tab/cf7-tab-widget.php
File size: 18.87 KB
MIME-type: text/x-php
Charset: utf-8
<?php
namespace BdevsElement\Widget;
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Group_Control_Typography;
Use \Elementor\Core\Schemes\Typography;
use \Elementor\Repeater;
defined( 'ABSPATH' ) || die();
class Bdevs_Cf7_Tab extends BDevs_El_Widget {
/**
* Get widget name.
*
* Retrieve Bdevs Element widget name.
*
* @since 1.0.0
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'cf7_tab';
}
/**
* Get widget title.
*
* @since 1.0.0
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'Contact Form 7 TAB', 'bdevselement' );
}
public function get_custom_help_url() {
return 'http://elementor.bdevs.net//widgets/contact-7-form/';
}
/**
* Get widget icon.
*
* @since 1.0.0
* @access public
*
* @return string Widget icon.
*/
public function get_icon() {
return 'eicon-shortcode';
}
public function get_keywords() {
return [ 'form', 'contact', 'cf7', 'contact form', 'gravity', 'ninja' ];
}
protected function register_content_controls() {
$this->start_controls_section(
'_section_cf7',
[
'label' => bdevs_element_is_cf7_activated() ? __( 'Contact Form 7', 'bdevselement' ) : __( 'Missing Notice', 'bdevselement' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
if ( ! bdevs_element_is_cf7_activated() ) {
$this->add_control(
'_cf7_missing_notice',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => sprintf(
__( 'Hello %2$s, looks like %1$s is missing in your site. Please click on the link below and install/activate %1$s. Make sure to refresh this page after installation or activation.', 'bdevselement' ),
'<a href="'.esc_url( admin_url( 'plugin-install.php?s=Contact+Form+7&tab=search&type=term' ) )
.'" target="_blank" rel="noopener">Contact Form 7</a>',
bdevs_element_get_current_user_display_name()
),
'content_classes' => 'elementor-panel-alert elementor-panel-alert-danger',
]
);
$this->add_control(
'_cf7_install',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => '<a href="'.esc_url( admin_url( 'plugin-install.php?s=Contact+Form+7&tab=search&type=term' ) ).'" target="_blank" rel="noopener">Click to install or activate Contact Form 7</a>',
]
);
$this->end_controls_section();
return;
}
$repeater = new Repeater();
$repeater->add_control(
'form_id',
[
'label' => __( 'Select Your Form', 'bdevselement' ),
'type' => Controls_Manager::SELECT,
'label_block' => true,
'options' => ['' => __( '', 'bdevselement' ) ] + \bdevs_element_get_cf7_forms(),
]
);
$repeater->add_control(
'title',
[
'type' => Controls_Manager::TEXT,
'label_block' => true,
'label' => __( 'Tab Title', 'bdevselement' ),
'placeholder' => __( 'Type tab title here', 'bdevselement' ),
'dynamic' => [
'active' => true,
]
]
);
$this->add_control(
'slides',
[
'show_label' => false,
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'title_field' => '<# print(title || "Carousel Item"); #>',
]
);
$this->add_control(
'html_class',
[
'label' => __( 'HTML Class', 'bdevselement' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'description' => __( 'Add CSS custom class to the form.', 'bdevselement' ),
]
);
$this->end_controls_section();
}
protected function register_style_controls() {
$this->start_controls_section(
'_section_fields_style',
[
'label' => __( 'Form Fields', 'bdevselement' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'field_width',
[
'label' => __( 'Width', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'unit' => '%',
],
'tablet_default' => [
'unit' => '%',
],
'mobile_default' => [
'unit' => '%',
],
'size_units' => [ '%', 'px' ],
'range' => [
'%' => [
'min' => 1,
'max' => 100,
],
'px' => [
'min' => 1,
'max' => 500,
],
],
'selectors' => [
'{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)' => 'width: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .bdevs-cf7-form label' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'field_margin',
[
'label' => __( 'Spacing Bottom', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)' => 'margin-bottom: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'field_padding',
[
'label' => __( 'Padding', 'bdevselement' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'field_border_radius',
[
'label' => __( 'Border Radius', 'bdevselement' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'hr',
[
'type' => Controls_Manager::DIVIDER,
'style' => 'thick',
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'field_typography',
'label' => __( 'Typography', 'bdevselement' ),
'selector' => '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)',
'scheme' => Typography::TYPOGRAPHY_3
]
);
$this->add_control(
'field_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'field_placeholder_color',
[
'label' => __( 'Placeholder Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} ::-webkit-input-placeholder' => 'color: {{VALUE}};',
'{{WRAPPER}} ::-moz-placeholder' => 'color: {{VALUE}};',
'{{WRAPPER}} ::-ms-input-placeholder' => 'color: {{VALUE}};',
],
]
);
$this->start_controls_tabs( 'tabs_field_state' );
$this->start_controls_tab(
'tab_field_normal',
[
'label' => __( 'Normal', 'bdevselement' ),
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'field_border',
'selector' => '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)',
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'field_box_shadow',
'selector' => '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)',
]
);
$this->add_control(
'field_bg_color',
[
'label' => __( 'Background Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)' => 'background-color: {{VALUE}}',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'tab_field_focus',
[
'label' => __( 'Focus', 'bdevselement' ),
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'field_focus_border',
'selector' => '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit):focus',
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'field_focus_box_shadow',
'exclude' => [
'box_shadow_position',
],
'selector' => '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit):focus',
]
);
$this->add_control(
'field_focus_bg_color',
[
'label' => __( 'Background Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit):focus' => 'background-color: {{VALUE}}',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
$this->start_controls_section(
'submit',
[
'label' => __( 'Submit Button', 'bdevselement' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'submit_margin',
[
'label' => __( 'Margin', 'bdevselement' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .wpcf7-submit' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'submit_padding',
[
'label' => __( 'Padding', 'bdevselement' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .wpcf7-submit' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'submit_typography',
'selector' => '{{WRAPPER}} .wpcf7-submit',
'scheme' => Typography::TYPOGRAPHY_4
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'submit_border',
'selector' => '{{WRAPPER}} .wpcf7-submit',
]
);
$this->add_control(
'submit_border_radius',
[
'label' => __( 'Border Radius', 'bdevselement' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .wpcf7-submit' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'submit_box_shadow',
'selector' => '{{WRAPPER}} .wpcf7-submit',
]
);
$this->add_control(
'hr4',
[
'type' => Controls_Manager::DIVIDER,
'style' => 'thick',
]
);
$this->start_controls_tabs( 'tabs_button_style' );
$this->start_controls_tab(
'tab_button_normal',
[
'label' => __( 'Normal', 'bdevselement' ),
]
);
$this->add_control(
'submit_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .wpcf7-submit' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'submit_bg_color',
[
'label' => __( 'Background Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .wpcf7-submit' => 'background-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'tab_button_hover',
[
'label' => __( 'Hover', 'bdevselement' ),
]
);
$this->add_control(
'submit_hover_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .wpcf7-submit:hover, {{WRAPPER}} .wpcf7-submit:focus' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'submit_hover_bg_color',
[
'label' => __( 'Background Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .wpcf7-submit:hover, {{WRAPPER}} .wpcf7-submit:focus' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'submit_hover_border_color',
[
'label' => __( 'Border Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .wpcf7-submit:hover, {{WRAPPER}} .wpcf7-submit:focus' => 'border-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
}
protected function render() {
if ( ! bdevs_element_is_cf7_activated() ) {
return;
}
$settings = $this->get_settings_for_display(); ?>
<div class="contact-area pt-110 pb-110 bg_img" data-overlay="94">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="contact-buttons">
<ul class="nav text-center" id="myTab" role="tablist">
<?php foreach ( $settings['slides'] as $id => $slide ) :
$active_tab = ($id == 0) ? 'active show' : ''; ?>
<li class="nav-item">
<a class="nav-link <?php echo esc_attr($active_tab); ?>" id="tab-<?php echo esc_attr($id); ?>" data-toggle="tab" href="#contact-<?php echo esc_attr($id); ?>" role="tab"
aria-controls="contact-<?php echo esc_attr($id); ?>" aria-selected="true"><?php echo esc_html($slide['title']); ?></a>
</li>
<?php endforeach; ?>
</ul>
</div>
<div class="row">
<div class="col-lg-12">
<div class="tab-content" id="myTabContent">
<?php foreach ( $settings['slides'] as $id => $slide ) :
$active_tab = ($id == 0) ? 'active show' : ''; ?>
<div class="tab-pane fade <?php echo esc_attr($active_tab); ?>" id="contact-<?php echo esc_attr($id); ?>" role="tabpanel">
<div class="contact-form">
<?php if ( ! empty( $slide['form_id'] ) ) {
echo bdevs_element_do_shortcode( 'contact-form-7', [
'id' => $slide['form_id'],
'html_class' => 'bdevs-cf7-form ' . bdevs_element_sanitize_html_class_param( $settings['html_class'] ),
] );
} ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
}