when its optimized markup is on, * as core widgets such as Shortcode do. */ public function has_widget_inner_wrapper(): bool { $experiments = \Elementor\Plugin::$instance->experiments ?? null; return ! ( is_object( $experiments ) && method_exists( $experiments, 'is_feature_active' ) && $experiments->is_feature_active( 'e_optimized_markup' ) ); } /** * Widget settings: the form picker and a link to manage forms. */ protected function register_controls(): void { $this->start_controls_section( 'section_form', array( 'label' => __( 'Form', 'flexsolutions-form-builder' ), ) ); $choices = Page_Builders::form_choices(); $options = array( '' => __( '— Select a form —', 'flexsolutions-form-builder' ) ); foreach ( $choices as $id => $label ) { $options[ (string) $id ] = $label; } $this->add_control( 'form_id', array( 'label' => __( 'Form', 'flexsolutions-form-builder' ), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => $options, 'default' => '', ) ); $this->add_control( 'forms_help', array( 'type' => \Elementor\Controls_Manager::RAW_HTML, 'raw' => array() === $choices ? esc_html__( 'No published forms yet. Create one under Flexsolutions Form Builder → Add New Form.', 'flexsolutions-form-builder' ) : sprintf( '%s', esc_url( admin_url( 'edit.php?post_type=' . Form_Post_Type::POST_TYPE ) ), esc_html__( 'Manage forms', 'flexsolutions-form-builder' ) ), 'content_classes' => 'elementor-descriptor', ) ); $this->end_controls_section(); } /** * Prints the form. In the editor the form is shown but cannot be used, * like the block's preview, and a missing choice shows a hint. */ protected function render(): void { $form_id = absint( $this->get_settings_for_display( 'form_id' ) ); $edit_mode = self::is_edit_mode(); if ( 0 === $form_id ) { if ( $edit_mode ) { printf( '
%s
', esc_html__( 'Flexsolutions Form Builder: choose a form in the widget settings.', 'flexsolutions-form-builder' ) ); } return; } $html = Renderer::render_by_id( $form_id ); if ( '' === $html ) { return; } if ( $edit_mode ) { // inert: no focus, typing or submitting; clicks still select the widget. $html = '