start_controls_section( 'section_content', array( 'label' => __( 'FAQ', 'aiforya-faq-generator' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'post_id', array( 'label' => __( 'Post ID (empty = current)', 'aiforya-faq-generator' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'placeholder' => __( '0 = current post', 'aiforya-faq-generator' ), 'default' => 0, 'description' => __( 'Display the FAQ from a post other than the current one.', 'aiforya-faq-generator' ), ) ); $this->add_control( 'title', array( 'label' => __( 'Custom title (optional)', 'aiforya-faq-generator' ), 'type' => \Elementor\Controls_Manager::TEXT, 'placeholder' => __( 'Frequently Asked Questions', 'aiforya-faq-generator' ), 'description' => __( 'Overrides the title set in Settings.', 'aiforya-faq-generator' ), ) ); $this->add_control( 'preview_note', array( 'type' => \Elementor\Controls_Manager::RAW_HTML, 'raw' => '
' . esc_html__( 'Appearance (colors, layout) is managed in: Settings → Appearance.', 'aiforya-faq-generator' ) . '
', 'content_classes' => 'elementor-control-field-description', ) ); $this->end_controls_section(); } protected function render(): void { $settings = $this->get_settings_for_display(); $post_id = absint( $settings['post_id'] ?? 0 ); $title = (string) ( $settings['title'] ?? '' ); if ( ! class_exists( 'Aiforya_Faq_Generator_Frontend' ) ) { echo '[AIFORYA FAQ: service not loaded]
'; return; } $shortcode_atts = ''; if ( $post_id ) { $shortcode_atts .= ' post_id="' . esc_attr( (string) $post_id ) . '"'; } if ( '' !== $title ) { $shortcode_atts .= ' title="' . esc_attr( $title ) . '"'; } echo do_shortcode( '[aiforya_faq' . $shortcode_atts . ']' ); } /** * Aperçu pour mode édition Elementor (si shortcode rendu vide). */ public function render_plain_content(): void { $settings = $this->get_settings_for_display(); $post_id = absint( $settings['post_id'] ?? 0 ); $title = $settings['title'] ?? ''; $atts = ''; if ( $post_id ) $atts .= ' post_id="' . $post_id . '"'; if ( $title ) $atts .= ' title="' . $title . '"'; echo '[aiforya_faq' . esc_html( $atts ) . ']'; } }