𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /home/builxejc/public_html/wp-content/plugins/kinsley-plugin/elementor/widgets//contact-form.php
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Kinsley Contact Form Widget.
*
* @since 1.0
*/
class Kinsley_Contact_Form_Widget extends Widget_Base {
public function get_name() {
return 'kinsley-contact-form';
}
public function get_title() {
return esc_html__( 'Contact Form', 'kinsley-plugin' );
}
public function get_icon() {
return 'eicon-parallax';
}
public function get_categories() {
return [ 'kinsley-category' ];
}
/**
* Register widget controls.
*
* @since 1.0
*/
protected function register_controls() {
$this->start_controls_section(
'heading_tab',
[
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'heading',
[
'label' => esc_html__( 'Heading', 'kinsley-plugin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'kinsley-plugin' ),
'label_off' => __( 'Hide', 'kinsley-plugin' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_control(
'title',
[
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter title', 'kinsley-plugin' ),
'default' => esc_html__( 'Title', 'kinsley-plugin' ),
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'title_tag',
[
'label' => esc_html__( 'Title Tag', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'h2',
'options' => [
'h1' => __( 'H1', 'kinsley-plugin' ),
'h2' => __( 'H2', 'kinsley-plugin' ),
'h3' => __( 'H3', 'kinsley-plugin' ),
'h4' => __( 'H4', 'kinsley-plugin' ),
'div' => __( 'DIV', 'kinsley-plugin' ),
],
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'description',
[
'label' => esc_html__( 'Description', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter description', 'kinsley-plugin' ),
'default' => esc_html__( 'Description', 'kinsley-plugin' ),
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'more',
[
'label' => esc_html__( 'Button (label)', 'kinsley-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Button', 'kinsley-plugin' ),
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'link',
[
'label' => esc_html__( 'Button (link)', 'kinsley-plugin' ),
'type' => Controls_Manager::URL,
'show_external' => true,
'condition' => [
'heading' => 'yes'
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'form_tab',
[
'label' => esc_html__( 'Form', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'hide_form',
[
'label' => esc_html__( 'Hide Form?', 'kinsley-plugin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'kinsley-plugin' ),
'label_off' => __( 'Hide', 'kinsley-plugin' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_control(
'contact_form',
[
'label' => esc_html__( 'Select CF7 Form', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 1,
'options' => $this->contact_form_list(),
]
);
$this->end_controls_section();
$this->start_controls_section(
'settings_tab',
[
'label' => esc_html__( 'Settings', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'container_type',
[
'label' => esc_html__( 'Container', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'basic',
'options' => [
'basic' => __( 'Basic', 'kinsley-plugin' ),
'full' => __( 'Full', 'kinsley-plugin' ),
],
]
);
$this->add_control(
'bg_position',
[
'label' => esc_html__( 'BG Transition Position', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'none',
'options' => [
'top' => __( 'Top', 'kinsley-plugin' ),
'bottom' => __( 'Bottom', 'kinsley-plugin' ),
'middle' => __( 'Middle', 'kinsley-plugin' ),
'none' => __( 'None', 'kinsley-plugin' ),
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'title_styling',
[
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Title Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-title--h' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => esc_html__( 'Title Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-title-frame .knsl-title--h',
]
);
$this->add_control(
'desc_color',
[
'label' => esc_html__( 'Description Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-text' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'desc_typography',
'label' => esc_html__( 'Description Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-title-frame .knsl-text',
]
);
$this->add_control(
'button_color',
[
'label' => esc_html__( 'Button Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-btn' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'button_bgcolor',
[
'label' => esc_html__( 'Button BG Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-btn' => 'background-color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'button_typography',
'label' => esc_html__( 'Button Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-title-frame .knsl-btn',
]
);
$this->end_controls_section();
$this->start_controls_section(
'form_styling',
[
'label' => esc_html__( 'Form Styles', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'form_btn_color',
[
'label' => esc_html__( 'Button Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .row .knsl-btn' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'form_btn_bgcolor',
[
'label' => esc_html__( 'Button Background Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .row .knsl-btn' => 'background-color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'form_btn_typography',
'label' => esc_html__( 'Button Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .row .knsl-btn',
]
);
$this->end_controls_section();
}
/**
* Render Contact Form List.
*
* @since 1.0
*/
protected function contact_form_list() {
$cf7_posts = get_posts( 'post_type="wpcf7_contact_form"&numberposts=-1' );
$cf7_forms = array();
$cf7_forms[0] = esc_attr__( 'Select form', 'kinsley-plugin' );
if ( $cf7_posts ) {
foreach ( $cf7_posts as $cf7_form ) {
$cf7_forms[ $cf7_form->ID ] = $cf7_form->post_title;
}
} else {
$cf7_forms[ esc_html__( 'No contact forms found', 'kinsley-plugin' ) ] = 0;
}
return $cf7_forms;
}
/**
* Render widget output on the frontend.
*
* @since 1.0
*/
protected function render() {
$settings = $this->get_settings_for_display();
$this->add_inline_editing_attributes( 'more', 'none' );
$this->add_inline_editing_attributes( 'title', 'basic' );
$this->add_inline_editing_attributes( 'description', 'basic' );
?>
<section class="knsl-transition-<?php echo esc_attr( $settings['bg_position'] ); ?> knsl-p-0-100">
<?php kinsley_deco_svg( 'both' ); ?>
<?php if ( $settings['container_type'] == 'basic' ) : ?><div class="container"><?php endif; ?>
<div class="row">
<?php if ( $settings['title'] || $settings['more'] || $settings['description'] ) : ?>
<div class="col-lg-12">
<div class="knsl-center knsl-title-frame knsl-scroll-animation knsl-mb-100">
<?php if ( $settings['title'] ) : ?>
<<?php echo esc_attr( $settings['title_tag'] ); ?> class="knsl-title--h knsl-mb-20">
<span <?php echo $this->get_render_attribute_string( 'title' ); ?>>
<?php echo wp_kses_post( $settings['title'] ); ?>
</span>
</<?php echo esc_attr( $settings['title_tag'] ); ?>>
<?php endif; ?>
<?php if ( $settings['description'] ) : ?>
<p class="knsl-text knsl-mb-30">
<span <?php echo $this->get_render_attribute_string( 'description' ); ?>>
<?php echo wp_kses_post( $settings['description'] ); ?>
</span>
</p>
<?php endif; ?>
<?php if ( $settings['more'] ) : ?>
<a<?php if ( $settings['link'] ) : if ( $settings['link']['is_external'] ) : ?> target="_blank"<?php endif; ?><?php if ( $settings['link']['nofollow'] ) : ?> rel="nofollow"<?php endif; ?> href="<?php echo esc_url( $settings['link']['url'] ); ?>"<?php endif; ?> class="knsl-btn knsl-btn-md">
<span <?php echo $this->get_render_attribute_string( 'more' ); ?>>
<?php echo wp_kses_post( $settings['more'] ); ?>
</span>
</a>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php if ( $settings['contact_form'] && $settings['hide_form'] != 'yes' ) : ?>
<div class="col-lg-12">
<div class="knsl-scroll-animation-default">
<?php echo do_shortcode( '[contact-form-7 id="'. $settings['contact_form'] .'"]' ); ?>
</div>
</div>
<?php endif; ?>
</div>
<?php if ( $settings['container_type'] == 'basic' ) : ?></div><?php endif; ?>
</section>
<?php
}
}
Plugin::instance()->widgets_manager->register( new Kinsley_Contact_Form_Widget() );