__( 'First name', 'ai-eshop-optimizer' ), 'last_name' => __( 'Last name', 'ai-eshop-optimizer' ), 'phone' => __( 'Phone', 'ai-eshop-optimizer' ), 'city' => __( 'City', 'ai-eshop-optimizer' ), 'country' => __( 'Country', 'ai-eshop-optimizer' ), 'company' => __( 'Company', 'ai-eshop-optimizer' ), 'message' => __( 'Message', 'ai-eshop-optimizer' ), ); } public function get_name() { return 'aieo_contact_form'; } public function get_title() { return __( 'Contact form (Rooster One)', 'ai-eshop-optimizer' ); } public function get_icon() { return 'eicon-form-horizontal'; } public function get_categories() { return array( 'general' ); } public function get_keywords() { return array( 'contact', 'form', 'enquiry', 'rooster', 'επικοινωνία' ); } protected function register_controls() { $this->start_controls_section( 'aieo_cf_content', array( 'label' => __( 'Contact form', 'ai-eshop-optimizer' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'title', array( 'label' => __( 'Title', 'ai-eshop-optimizer' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '', 'description' => __( 'Blank uses the title set in Rooster One, or none.', 'ai-eshop-optimizer' ), ) ); $this->add_control( 'company_label', array( 'label' => __( 'Company field label', 'ai-eshop-optimizer' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '', 'placeholder' => __( 'e.g. Hotel name', 'ai-eshop-optimizer' ), ) ); $this->add_control( 'button', array( 'label' => __( 'Button text', 'ai-eshop-optimizer' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '', ) ); $this->end_controls_section(); $s = class_exists( 'AIEO_Contact_Form_Settings' ) ? AIEO_Contact_Form_Settings::get( true ) : array(); $cfg = class_exists( 'AIEO_Contact_Form_Settings' ) ? AIEO_Contact_Form_Settings::placement( $s ) : array( 'show' => array(), 'req' => array(), 'names' => 'inline', 'rows' => 6 ); $this->start_controls_section( 'aieo_cf_fields', array( 'label' => __( 'Fields', 'ai-eshop-optimizer' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'aieo_cf_email_note', array( 'type' => \Elementor\Controls_Manager::RAW_HTML, 'raw' => esc_html__( 'Email is always shown and always required.', 'ai-eshop-optimizer' ), ) ); foreach ( $this->aieo_toggles() as $key => $label ) { $this->add_control( 'show_' . $key, array( 'label' => $label, 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => in_array( $key, (array) $cfg['show'], true ) ? 'yes' : '', 'separator' => 'before', ) ); $this->add_control( 'req_' . $key, array( 'label' => sprintf( __( '%s required', 'ai-eshop-optimizer' ), $label ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => in_array( $key, (array) $cfg['req'], true ) ? 'yes' : '', 'condition' => array( 'show_' . $key => 'yes' ), ) ); } $this->end_controls_section(); $this->start_controls_section( 'aieo_cf_layout', array( 'label' => __( 'Layout', 'ai-eshop-optimizer' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'names', array( 'label' => __( 'First and last name', 'ai-eshop-optimizer' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => (string) $cfg['names'], 'options' => array( 'inline' => __( 'Side by side (stacked on phones)', 'ai-eshop-optimizer' ), 'stacked' => __( 'One under the other', 'ai-eshop-optimizer' ), ), ) ); $this->add_control( 'rows', array( 'label' => __( 'Message box height (rows)', 'ai-eshop-optimizer' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'min' => 3, 'max' => 15, 'step' => 1, 'default' => (int) $cfg['rows'], ) ); $this->end_controls_section(); } protected function render() { if ( ! class_exists( 'AIEO_Contact_Form' ) ) { return; } $st = $this->get_settings_for_display(); $show = array( 'email' ); $req = array( 'email' ); foreach ( array_keys( $this->aieo_toggles() ) as $key ) { if ( isset( $st[ 'show_' . $key ] ) && 'yes' === $st[ 'show_' . $key ] ) { $show[] = $key; if ( isset( $st[ 'req_' . $key ] ) && 'yes' === $st[ 'req_' . $key ] ) { $req[] = $key; } } } echo AIEO_Contact_Form::render( array( 'title' => isset( $st['title'] ) ? (string) $st['title'] : '', 'company_label' => isset( $st['company_label'] ) ? (string) $st['company_label'] : '', 'button' => isset( $st['button'] ) ? (string) $st['button'] : '', 'fields' => $show, 'required' => $req, 'names' => isset( $st['names'] ) ? (string) $st['names'] : '', 'rows' => isset( $st['rows'] ) ? (int) $st['rows'] : 0, ) ); } } }