__( '— Select a form —', 'htforms-builder' ) ); foreach ( HTForm_API::list_forms() as $form ) { if ( isset( $form['id'], $form['name'], $form['status'] ) && 'published' === $form['status'] && HTForm_API::valid_form_id( $form['id'] ) ) { $options[ $form['id'] ] = sanitize_text_field( $form['name'] ); } } $this->start_controls_section( 'htform_form', array( 'label' => __( 'HTforms', 'htforms-builder' ) ) ); // SELECT2 opens a searchable popup listing every published form. $this->add_control( 'form_id', array( 'label' => __( 'Form', 'htforms-builder' ), 'type' => \Elementor\Controls_Manager::SELECT2, 'options' => $options, 'default' => '', 'label_block' => true, 'description' => __( 'Only published forms appear. Publish in HTforms, then reopen this panel to refresh the list.', 'htforms-builder' ), ) ); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); $id = isset( $settings['form_id'] ) ? (string) $settings['form_id'] : ''; if ( '' === $id ) { if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) { echo '
' . esc_html__( 'Select a published HTforms form from the panel on the left.', 'htforms-builder' ) . '
'; } return; } // Same server path as the [htform] shortcode, so the editor shows the real // form HTML immediately after choosing it (no browser-only template). $editing = \Elementor\Plugin::$instance->editor->is_edit_mode() || ( isset( \Elementor\Plugin::$instance->preview ) && \Elementor\Plugin::$instance->preview->is_preview_mode() ); echo HTForm_Frontend::render( $id, $editing ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } }