Current File : /home/kelaby89/huss-kelaby.cv/wp-content/plugins/arter-plugin/elementor/widgets/contact-form.php |
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Arter Contacts Widget.
*
* @since 1.0
*/
class Arter_Contact_Form_Widget extends Widget_Base {
public function get_name() {
return 'arter-contact-form';
}
public function get_title() {
return esc_html__( 'Contact Form', 'arter-plugin' );
}
public function get_icon() {
return 'fas fa-headset';
}
public function get_categories() {
return [ 'arter-category' ];
}
/**
* Register widget controls.
*
* @since 1.0
*/
protected function register_controls() {
$this->start_controls_section(
'heading_tab',
[
'label' => esc_html__( 'Title', 'arter-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'title',
[
'label' => esc_html__( 'Title', 'arter-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter title', 'arter-plugin' ),
'default' => esc_html__( 'Title', 'arter-plugin' ),
'dynamic' => [
'active' => true,
],
]
);
$this->add_control(
'title_tag',
[
'label' => esc_html__( 'Title Tag', 'arter-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'h4',
'options' => [
'h1' => __( 'H1', 'arter-plugin' ),
'h2' => __( 'H2', 'arter-plugin' ),
'h3' => __( 'H3', 'arter-plugin' ),
'h4' => __( 'H4', 'arter-plugin' ),
'div' => __( 'DIV', 'arter-plugin' ),
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'form_tab',
[
'label' => esc_html__( 'Form', 'arter-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'contact_form',
[
'label' => esc_html__( 'Select CF7 Form', 'arter-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 1,
'options' => $this->contact_form_list(),
]
);
$this->end_controls_section();
$this->start_controls_section(
'title_styling',
[
'label' => esc_html__( 'Title', 'arter-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Color', 'arter-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .art-section-title .art-title-frame .art-title-h' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'selector' => '{{WRAPPER}} .art-section-title .art-title-frame .art-title-h',
]
);
$this->end_controls_section();
$this->start_controls_section(
'form_styling',
[
'label' => esc_html__( 'Form', 'arter-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'button_color',
[
'label' => esc_html__( 'Button Color', 'arter-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .art-submit-frame .art-submit' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'button_bg_color',
[
'label' => esc_html__( 'Button Background Color', 'arter-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .art-submit-frame .art-submit' => 'background-color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'button_typography',
'label' => esc_html__( 'Button Typography', 'arter-plugin' ),
'selector' => '{{WRAPPER}} .art-submit-frame .art-submit',
]
);
$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();
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', 'arter-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( 'title', 'basic' );
?>
<!-- container -->
<div class="container-fluid">
<!-- row -->
<div class="row">
<?php if ( $settings['title'] ) : ?>
<!-- col -->
<div class="col-lg-12">
<!-- section title -->
<div class="art-section-title">
<!-- title frame -->
<div class="art-title-frame">
<!-- title -->
<<?php echo esc_attr( $settings['title_tag'] ); ?> class="art-title-h">
<span <?php echo $this->get_render_attribute_string( 'title' ); ?>>
<?php echo wp_kses_post( $settings['title'] ); ?>
</span>
</<?php echo esc_attr( $settings['title_tag'] ); ?>>
</div>
<!-- title frame end -->
</div>
<!-- section title end -->
</div>
<!-- col end -->
<?php endif; ?>
<?php if ( $settings['contact_form'] ) : ?>
<!-- col -->
<div class="col-lg-12">
<!-- contact form frame -->
<div class="art-a art-card">
<?php echo do_shortcode( '[contact-form-7 id="'. $settings['contact_form'] .'"]' ); ?>
</div>
<!-- contact form frame end -->
</div>
<!-- col end -->
<?php endif; ?>
</div>
<!-- row end -->
</div>
<!-- container end -->
<?php
}
}
Plugin::instance()->widgets_manager->register( new Arter_Contact_Form_Widget() );