start_controls_section( 'content_section', array( 'label' => __( 'Content', 'a1-tools' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'form_title', array( 'label' => __( 'Form Title', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => __( 'Get in touch', 'a1-tools' ), 'label_block' => true, ) ); $this->add_control( 'form_subtitle', array( 'label' => __( 'Subtitle', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::TEXTAREA, 'default' => __( "Tell us a bit about your project and we'll get back to you within a business day.", 'a1-tools' ), 'label_block' => true, ) ); $this->add_control( 'submit_label', array( 'label' => __( 'Submit Button Label', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => __( 'Send message', 'a1-tools' ), ) ); $this->add_control( 'success_message', array( 'label' => __( 'Success Message', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::TEXTAREA, 'default' => __( "Thanks! We've got your message and will reach out shortly.", 'a1-tools' ), 'label_block' => true, ) ); $this->add_control( 'error_message', array( 'label' => __( 'Error Message', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::TEXTAREA, 'default' => __( "Couldn't send your message. Please try again or call us directly.", 'a1-tools' ), 'label_block' => true, ) ); $this->add_control( 'show_preferred_contact', array( 'label' => __( 'Show Preferred Contact Method', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', 'label_on' => __( 'Show', 'a1-tools' ), 'label_off' => __( 'Hide', 'a1-tools' ), 'return_value' => 'yes', ) ); $this->add_control( 'contact_options', array( 'label' => __( 'Available Contact Methods', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::SELECT2, 'multiple' => true, 'default' => array( 'call', 'email', 'sms' ), 'options' => array( 'call' => __( 'Call', 'a1-tools' ), 'email' => __( 'Email', 'a1-tools' ), 'sms' => __( 'SMS', 'a1-tools' ), ), 'condition' => array( 'show_preferred_contact' => 'yes' ), 'description' => __( 'Hide any method you do not offer.', 'a1-tools' ), ) ); $this->end_controls_section(); // ── Form / Container Style ───────────────────────────────── $this->start_controls_section( 'style_form_section', array( 'label' => __( 'Form Container', 'a1-tools' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ) ); $this->add_control( 'form_bg_color', array( 'label' => __( 'Background', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => array( '{{WRAPPER}} .a1tools-web-form' => 'background-color: {{VALUE}};', ), ) ); $this->add_responsive_control( 'form_padding', array( 'label' => __( 'Padding', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', 'em', '%' ), 'default' => array( 'top' => 24, 'right' => 24, 'bottom' => 24, 'left' => 24, 'unit' => 'px', ), 'selectors' => array( '{{WRAPPER}} .a1tools-web-form' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_control( 'form_border_radius', array( 'label' => __( 'Border Radius', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'default' => array( 'top' => 8, 'right' => 8, 'bottom' => 8, 'left' => 8, 'unit' => 'px', ), 'selectors' => array( '{{WRAPPER}} .a1tools-web-form' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), array( 'name' => 'form_box_shadow', 'selector' => '{{WRAPPER}} .a1tools-web-form', ) ); $this->end_controls_section(); // ── Title / Subtitle Typography ─────────────────────────── $this->start_controls_section( 'style_title_section', array( 'label' => __( 'Title & Subtitle', 'a1-tools' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ) ); $this->add_control( 'title_color', array( 'label' => __( 'Title Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#111111', 'selectors' => array( '{{WRAPPER}} .a1tools-web-form__title' => 'color: {{VALUE}};', ), ) ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), array( 'name' => 'title_typography', 'selector' => '{{WRAPPER}} .a1tools-web-form__title', ) ); $this->add_control( 'subtitle_color', array( 'label' => __( 'Subtitle Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#6b7280', 'selectors' => array( '{{WRAPPER}} .a1tools-web-form__subtitle' => 'color: {{VALUE}};', ), ) ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), array( 'name' => 'subtitle_typography', 'selector' => '{{WRAPPER}} .a1tools-web-form__subtitle', ) ); $this->end_controls_section(); // ── Field Style ───────────────────────────────────────── $this->start_controls_section( 'style_field_section', array( 'label' => __( 'Fields', 'a1-tools' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ) ); $this->add_control( 'field_label_color', array( 'label' => __( 'Label Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#374151', 'selectors' => array( '{{WRAPPER}} .a1tools-web-form__label' => 'color: {{VALUE}};', ), ) ); $this->add_control( 'field_text_color', array( 'label' => __( 'Field Text', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#111111', 'selectors' => array( '{{WRAPPER}} .a1tools-web-form__input, {{WRAPPER}} .a1tools-web-form__select, {{WRAPPER}} .a1tools-web-form__textarea' => 'color: {{VALUE}};', ), ) ); $this->add_control( 'field_bg_color', array( 'label' => __( 'Field Background', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#f8f9fa', 'selectors' => array( '{{WRAPPER}} .a1tools-web-form__input, {{WRAPPER}} .a1tools-web-form__select, {{WRAPPER}} .a1tools-web-form__textarea' => 'background-color: {{VALUE}};', ), ) ); $this->add_control( 'field_border_color', array( 'label' => __( 'Field Border', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#e5e7eb', 'selectors' => array( '{{WRAPPER}} .a1tools-web-form__input, {{WRAPPER}} .a1tools-web-form__select, {{WRAPPER}} .a1tools-web-form__textarea' => 'border-color: {{VALUE}};', ), ) ); $this->add_control( 'field_focus_border_color', array( 'label' => __( 'Field Focus Border', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#f49320', 'selectors' => array( '{{WRAPPER}} .a1tools-web-form__input:focus, {{WRAPPER}} .a1tools-web-form__select:focus, {{WRAPPER}} .a1tools-web-form__textarea:focus' => 'border-color: {{VALUE}}; box-shadow: 0 0 0 3px {{VALUE}}33;', ), ) ); $this->add_control( 'field_border_radius', array( 'label' => __( 'Field Border Radius', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'default' => array( 'top' => 6, 'right' => 6, 'bottom' => 6, 'left' => 6, 'unit' => 'px', ), 'selectors' => array( '{{WRAPPER}} .a1tools-web-form__input, {{WRAPPER}} .a1tools-web-form__select, {{WRAPPER}} .a1tools-web-form__textarea' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->end_controls_section(); // ── Submit Button ─────────────────────────────────────── $this->start_controls_section( 'style_button_section', array( 'label' => __( 'Submit Button', 'a1-tools' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ) ); $this->start_controls_tabs( 'button_state_tabs' ); $this->start_controls_tab( 'button_normal_tab', array( 'label' => __( 'Normal', 'a1-tools' ) ) ); $this->add_control( 'button_bg_color', array( 'label' => __( 'Background', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#f49320', 'selectors' => array( '{{WRAPPER}} .a1tools-web-form__submit' => 'background-color: {{VALUE}};', ), ) ); $this->add_control( 'button_text_color', array( 'label' => __( 'Text', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => array( '{{WRAPPER}} .a1tools-web-form__submit' => 'color: {{VALUE}};', ), ) ); $this->end_controls_tab(); $this->start_controls_tab( 'button_hover_tab', array( 'label' => __( 'Hover', 'a1-tools' ) ) ); $this->add_control( 'button_bg_hover_color', array( 'label' => __( 'Background', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#d67d10', 'selectors' => array( '{{WRAPPER}} .a1tools-web-form__submit:hover' => 'background-color: {{VALUE}};', ), ) ); $this->add_control( 'button_text_hover_color', array( 'label' => __( 'Text', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => array( '{{WRAPPER}} .a1tools-web-form__submit:hover' => 'color: {{VALUE}};', ), ) ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), array( 'name' => 'button_typography', 'selector' => '{{WRAPPER}} .a1tools-web-form__submit', ) ); $this->add_control( 'button_border_radius', array( 'label' => __( 'Border Radius', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'default' => array( 'top' => 6, 'right' => 6, 'bottom' => 6, 'left' => 6, 'unit' => 'px', ), 'selectors' => array( '{{WRAPPER}} .a1tools-web-form__submit' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_responsive_control( 'button_padding', array( 'label' => __( 'Padding', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', 'em', '%' ), 'default' => array( 'top' => 14, 'right' => 24, 'bottom' => 14, 'left' => 24, 'unit' => 'px', ), 'selectors' => array( '{{WRAPPER}} .a1tools-web-form__submit' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->end_controls_section(); } // ──────────────────────────────────────────────────────────────── // Render // ──────────────────────────────────────────────────────────────── protected function render() { $settings = $this->get_settings_for_display(); $company_id = (int) get_option( 'a1tools_form_company_id', 0 ); $rest_url = esc_url_raw( rest_url( 'a1-tools/v1/submit-web-form' ) ); $page_url = esc_url( is_singular() ? get_permalink() : home_url( add_query_arg( null, null ) ) ); $show_preferred = ! empty( $settings['show_preferred_contact'] ) && 'yes' === $settings['show_preferred_contact']; $contact_opts = is_array( $settings['contact_options'] ?? null ) ? $settings['contact_options'] : array( 'call', 'email', 'sms' ); $form_id = 'a1tools-web-form-' . wp_unique_id(); ?>

*
__( 'Call me', 'a1-tools' ), 'email' => __( 'Email me', 'a1-tools' ), 'sms' => __( 'Text me', 'a1-tools' ), )[ $opt ] ?? ucfirst( $opt ); ?>
name). Used by the state dropdown. */ function a1tools_web_form_us_states(): array { return array( 'AL' => 'Alabama', 'AK' => 'Alaska', 'AZ' => 'Arizona', 'AR' => 'Arkansas', 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', 'DC' => 'District of Columbia', 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland', 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', 'WI' => 'Wisconsin', 'WY' => 'Wyoming', ); }