filtres poses une seule fois. add_action( 'plugins_loaded', array( 'Aiforya_Faq_AI_Marking', 'init' ) ); // ============================================================================= // 2bis. Services métier internes (DB, détection Q&A, AJAX, frontend). // ============================================================================= require_once AIFORYA_FG_DIR . 'includes/class-aiforya-faq-generator-db.php'; require_once AIFORYA_FG_DIR . 'includes/class-aiforya-fg-parser.php'; require_once AIFORYA_FG_DIR . 'includes/class-aiforya-faq-generator-ajax.php'; require_once AIFORYA_FG_DIR . 'public/class-aiforya-faq-generator-frontend.php'; // ============================================================================= // 3. Activator — DOIT être chargé AVANT register_activation_hook. // ============================================================================= require_once AIFORYA_FG_DIR . 'includes/class-aiforya-faq-generator-activator.php'; register_activation_hook( __FILE__, [ 'Aiforya_Faq_Generator_Activator', 'activate' ] ); register_deactivation_hook( __FILE__, [ 'Aiforya_Faq_Generator_Activator', 'deactivate' ] ); // ============================================================================= // 4bis. Enqueue défensif des assets du shell + de l'interface commune. // ============================================================================= add_action( 'admin_enqueue_scripts', static function ( string $hook ): void { if ( class_exists( 'AIFORYA_FAQ_Shell' ) && method_exists( 'AIFORYA_FAQ_Shell', 'maybe_enqueue_assets' ) ) { AIFORYA_FAQ_Shell::maybe_enqueue_assets( $hook ); } }, 5 ); add_action( 'admin_enqueue_scripts', static function ( string $hook ): void { $vendor_url = AIFORYA_FG_URL . 'vendor-aiforya/assets/'; wp_enqueue_style( 'aiforya-ui-bbf8d166', $vendor_url . 'aiforya-ui.css', [], AIFORYA_FG_VERSION ); wp_enqueue_script( 'aiforya-ui-bbf8d166', $vendor_url . 'aiforya-ui.js', [], AIFORYA_FG_VERSION, true ); wp_localize_script( 'aiforya-ui-bbf8d166', 'aiforyaUiI18n', [ 'confirm' => __( 'OK', 'aiforya-faq-generator' ), 'cancel' => __( 'Cancel', 'aiforya-faq-generator' ), ] ); }, 5 ); // ============================================================================= // 4ter. Anti-pollution : supprime les notifications publicitaires des autres // extensions sur les pages admin AIFORYA (UX cohérente). // ============================================================================= add_action( 'in_admin_header', static function (): void { $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; if ( strpos( $page, 'aiforya-' ) !== 0 ) { return; } remove_all_actions( 'admin_notices' ); remove_all_actions( 'all_admin_notices' ); remove_all_actions( 'user_admin_notices' ); remove_all_actions( 'network_admin_notices' ); }, 1 ); // ============================================================================= // 5. Boot du moteur (menu admin + onglets). // ============================================================================= add_action( 'plugins_loaded', static function (): void { if ( ! class_exists( 'Aiforya_Faq_Engine' ) ) { return; } Aiforya_Faq_Engine::boot( AIFORYA_FG_DIR, [ 'slug' => AIFORYA_FG_SLUG, 'requires_activation' => false, // Extension gratuite .org : aucun ecran d'activation licence. 'title' => 'AIFORYA FAQ Generator', // ⛔ CES CHAÎNES NE SONT PAS DES APPELS GETTEXT — la bascule FR→EN ne les voit pas, // et le build ne traduit que le readme. Elles s'affichent pourtant dans l'en-tête de // la page admin et dans l'onglet FAQ intégré. Mesuré le 11/08 : corrigé le `Description:` // de l'en-tête du fichier en croyant que c'était la même source — ce ne l'était pas. // Toute bascule d'une des 49 restantes doit inclure CE tableau. 'description' => 'Build FAQs by hand or detect them automatically from your posts (no AI), with accordion display, shortcode, Gutenberg block and schema.org FAQPage structured data.', 'icon' => 'dashicons-editor-help', 'category' => 'SEO', 'capability' => 'manage_options', 'position' => 26, 'plugin_basename' => AIFORYA_FG_BASENAME, 'plugin_image' => plugins_url( 'assets/images/cover.png', __FILE__ ), 'faq' => static function () { return [ [ 'q' => __( 'Do I need an API key or an account to create FAQs?', 'aiforya-faq-generator' ), 'a' => __( 'No. This free version runs entirely on your own server, with no API key and no external service. You write your questions and answers by hand, or detect them automatically from the content of your posts.', 'aiforya-faq-generator' ), ], [ 'q' => __( 'How does automatic question detection work?', 'aiforya-faq-generator' ), 'a' => __( 'The plugin reads the structure of your post (no AI, no network call): every H2/H3 heading ending with a question mark becomes a question, and the paragraph that follows becomes the answer. You get a pre-filled FAQ, free to adjust afterwards.', 'aiforya-faq-generator' ), ], [ 'q' => __( 'Are the FAQs compatible with Google rich results?', 'aiforya-faq-generator' ), 'a' => __( 'Yes. Every FAQ is marked up as schema.org FAQPage (JSON-LD), which makes it eligible for "rich snippets" in Google search results.', 'aiforya-faq-generator' ), ], [ 'q' => __( 'How do I display a FAQ on my site?', 'aiforya-faq-generator' ), 'a' => __( 'Three ways:

1. Automatic display: Settings, position "Automatic — after the post content" — the FAQ appears at the bottom of every post that has one.

2. Gutenberg block: add the "AIFORYA FAQ" block (Widgets category).

3. Shortcode: insert [aiforya_faq] wherever you want.', 'aiforya-faq-generator' ), ], [ 'q' => __( 'Does the shortcode work with Elementor, Divi and other page builders?', 'aiforya-faq-generator' ), 'a' => __( 'Yes. A native "AIFORYA FAQ" widget is available in Elementor. For Divi, WPBakery, Oxygen, Avada and the rest, use the [aiforya_faq] shortcode inside a Code or Text module: it works everywhere.', 'aiforya-faq-generator' ), ], [ 'q' => __( 'Is there a version with AI?', 'aiforya-faq-generator' ), 'a' => __( 'Yes. The advanced AIFORYA version automatically generates a complete, optimized FAQ from the content of your posts, with multilingual translation and bulk generation, using your own API key. See aiforya.fr.', 'aiforya-faq-generator' ), ], ]; }, ] ); // 5b. Instanciation des services métier (singleton). Aiforya_Faq_Generator_Ajax::get_instance(); $svc_frontend = Aiforya_Faq_Generator_Frontend::get_instance(); if ( method_exists( $svc_frontend, 'register_hooks' ) ) { $svc_frontend->register_hooks(); } }, 5 ); // ============================================================================= // 6. Liens dans la liste des extensions WordPress. // ============================================================================= add_filter( 'plugin_row_meta', static function ( array $links, string $file ): array { if ( $file !== AIFORYA_FG_BASENAME ) { return $links; } $links[] = '' . esc_html__( 'User guide', 'aiforya-faq-generator' ) . ''; return $links; }, 10, 2 ); add_filter( 'plugin_action_links_' . AIFORYA_FG_BASENAME, static function ( array $links ): array { $settings_link = '' . esc_html__( 'Settings', 'aiforya-faq-generator' ) . ''; array_unshift( $links, $settings_link ); return $links; } );