Current Path : /var/www/mainsite/wp-content/themes/maxcoach/elementor/widgets/form/ |
Current File : /var/www/mainsite/wp-content/themes/maxcoach/elementor/widgets/form/mailchimp-form.php |
<?php namespace Maxcoach_Elementor; use Elementor\Controls_Manager; use Elementor\Core\Schemes\Color; use Elementor\Group_Control_Typography; defined( 'ABSPATH' ) || exit; class Widget_Mailchimp_Form extends Base { public function get_name() { return 'tm-mailchimp-form'; } public function get_title() { return esc_html__( 'Mailchimp Form', 'maxcoach' ); } public function get_icon_part() { return 'eicon-form-horizontal'; } public function get_keywords() { return [ 'mailchimp', 'form', 'subscribe' ]; } protected function register_controls() { $this->add_content_section(); $this->add_field_style_section(); $this->add_button_style_section(); } private function add_content_section() { $this->start_controls_section( 'content_section', [ 'label' => esc_html__( 'Layout', 'maxcoach' ), ] ); $this->add_control( 'form_id', [ 'label' => esc_html__( 'Form Id', 'maxcoach' ), 'description' => esc_html__( 'Input the id of form. Leave blank to show default form.', 'maxcoach' ), 'type' => Controls_Manager::TEXT, ] ); $this->add_control( 'style', [ 'label' => esc_html__( 'Style', 'maxcoach' ), 'type' => Controls_Manager::SELECT, 'options' => [ '01' => '01', '02' => '02', ], 'default' => '01', 'prefix_class' => 'maxcoach-mailchimp-form-style-', ] ); $this->end_controls_section(); } private function add_field_style_section() { $this->start_controls_section( 'form_field_style_section', [ 'label' => esc_html__( 'Field', 'maxcoach' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'field_padding', [ 'label' => esc_html__( 'Padding', 'maxcoach' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%' ], 'selectors' => [ '{{WRAPPER}} .form-input' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'field_border_width', [ 'label' => esc_html__( 'Border Width', 'maxcoach' ), 'type' => Controls_Manager::DIMENSIONS, 'placeholder' => '1', 'size_units' => [ 'px' ], 'selectors' => [ '{{WRAPPER}} .form-input' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'field_border_radius', [ 'label' => esc_html__( 'Border Radius', 'maxcoach' ), 'type' => Controls_Manager::DIMENSIONS, 'placeholder' => '5', 'size_units' => [ 'px', '%' ], 'selectors' => [ '{{WRAPPER}} .form-input' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'field_typography', 'label' => esc_html__( 'Typography', 'maxcoach' ), 'selector' => '{{WRAPPER}} .form-input', ] ); $this->start_controls_tabs( 'field_colors_tabs' ); $this->start_controls_tab( 'field_colors_normal_tab', [ 'label' => esc_html__( 'Normal', 'maxcoach' ), ] ); $this->add_control( 'field_text_color', [ 'label' => esc_html__( 'Text Color', 'maxcoach' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .form-input' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'field_border_color', [ 'label' => esc_html__( 'Border Color', 'maxcoach' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .form-input' => 'border-color: {{VALUE}};', ], ] ); $this->end_controls_tab(); $this->start_controls_tab( 'field_colors_focus_tab', [ 'label' => esc_html__( 'Focus', 'maxcoach' ), ] ); $this->add_control( 'field_text_focus_color', [ 'label' => esc_html__( 'Text Color', 'maxcoach' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .form-input:focus' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'field_border_focus_color', [ 'label' => esc_html__( 'Border Color', 'maxcoach' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .form-input:focus' => 'border-color: {{VALUE}};', ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); } private function add_button_style_section() { $this->start_controls_section( 'form_button_style_section', [ 'label' => esc_html__( 'Button', 'maxcoach' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'button_padding', [ 'label' => esc_html__( 'Padding', 'maxcoach' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%' ], 'selectors' => [ '{{WRAPPER}} button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'button_border_width', [ 'label' => esc_html__( 'Border Width', 'maxcoach' ), 'type' => Controls_Manager::DIMENSIONS, 'placeholder' => '1', 'size_units' => [ 'px' ], 'selectors' => [ '{{WRAPPER}} button' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'button_border_radius', [ 'label' => esc_html__( 'Border Radius', 'maxcoach' ), 'type' => Controls_Manager::DIMENSIONS, 'placeholder' => '5', 'size_units' => [ 'px', '%' ], 'selectors' => [ '{{WRAPPER}} button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->start_controls_tabs( 'button_colors_tabs' ); $this->start_controls_tab( 'button_colors_normal_tab', [ 'label' => esc_html__( 'Normal', 'maxcoach' ), ] ); $this->add_control( 'button_text_color', [ 'label' => esc_html__( 'Text Color', 'maxcoach' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} button' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'button_border_color', [ 'label' => esc_html__( 'Border Color', 'maxcoach' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} button' => 'border-color: {{VALUE}};', ], ] ); $this->add_control( 'button_background_color', [ 'label' => esc_html__( 'Background Color', 'maxcoach' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} button' => 'background-color: {{VALUE}};', ], ] ); $this->end_controls_tab(); $this->start_controls_tab( 'button_colors_hover_tab', [ 'label' => esc_html__( 'Hover', 'maxcoach' ), ] ); $this->add_control( 'button_text_hover_color', [ 'label' => esc_html__( 'Text Color', 'maxcoach' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} button:hover' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'button_border_hover_color', [ 'label' => esc_html__( 'Border Color', 'maxcoach' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} button:hover' => 'border-color: {{VALUE}};', ], ] ); $this->add_control( 'button_background_hover_color', [ 'label' => esc_html__( 'Background Color', 'maxcoach' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} button:hover' => 'background-color: {{VALUE}};', ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); $form_id = ! empty( $settings['form_id'] ) ? $settings['form_id'] : ''; if ( '' === $form_id && function_exists( 'mc4wp_get_forms' ) ) { $mc_forms = mc4wp_get_forms(); if ( count( $mc_forms ) > 0 ) { $form_id = $mc_forms[0]->ID; } } $this->add_render_attribute( 'box', 'class', 'maxcoach-mailchimp-form' ); ?> <?php if ( function_exists( 'mc4wp_show_form' ) && $form_id !== '' ) : ?> <div <?php $this->print_render_attribute_string( 'box' ) ?>> <?php mc4wp_show_form( $form_id ); ?> </div> <?php endif; ?> <?php } }