filtres poses une seule fois. add_action( 'plugins_loaded', array( 'Aiforya_Schema_AI_Marking', 'init' ) ); // ============================================================================= // 2bis. Services métier internes. // ============================================================================= require_once AIFORYA_SM_DIR . 'includes/class-aiforya-schema-markup-db.php'; require_once AIFORYA_SM_DIR . 'includes/class-aiforya-schema-markup-detector.php'; require_once AIFORYA_SM_DIR . 'includes/class-aiforya-schema-markup-rules.php'; require_once AIFORYA_SM_DIR . 'includes/class-aiforya-schema-markup-builder.php'; require_once AIFORYA_SM_DIR . 'includes/class-aiforya-schema-markup-generator.php'; require_once AIFORYA_SM_DIR . 'includes/class-aiforya-schema-markup-optimizer.php'; require_once AIFORYA_SM_DIR . 'includes/class-aiforya-schema-markup-migration.php'; require_once AIFORYA_SM_DIR . 'includes/class-aiforya-schema-markup-health.php'; require_once AIFORYA_SM_DIR . 'includes/class-aiforya-schema-markup-cron.php'; require_once AIFORYA_SM_DIR . 'includes/class-aiforya-schema-markup-ajax.php'; require_once AIFORYA_SM_DIR . 'public/class-aiforya-schema-markup-frontend.php'; // ============================================================================= // 3. Activator — DOIT être chargé AVANT register_activation_hook. // ============================================================================= require_once AIFORYA_SM_DIR . 'includes/class-aiforya-schema-markup-activator.php'; register_activation_hook( __FILE__, [ 'Aiforya_Schema_Markup_Activator', 'activate' ] ); register_deactivation_hook( __FILE__, [ 'Aiforya_Schema_Markup_Activator', 'deactivate' ] ); if ( method_exists( 'Aiforya_Schema_Markup_Activator', 'maybe_upgrade' ) ) { add_action( 'plugins_loaded', [ 'Aiforya_Schema_Markup_Activator', 'maybe_upgrade' ], 5 ); } // ============================================================================= // 4bis. Enqueue défensif des assets du shell. // ============================================================================= add_action( 'admin_enqueue_scripts', static function ( string $hook ): void { if ( class_exists( 'AIFORYA_SCHEMA_Shell' ) && method_exists( 'AIFORYA_SCHEMA_Shell', 'maybe_enqueue_assets' ) ) { AIFORYA_SCHEMA_Shell::maybe_enqueue_assets( $hook ); } }, 5 ); add_action( 'admin_enqueue_scripts', static function ( string $hook ): void { $vendor_url = AIFORYA_SM_URL . 'vendor-aiforya/assets/'; wp_enqueue_style( 'aiforya-ui-bbf8d166', $vendor_url . 'aiforya-ui.css', [], AIFORYA_SM_VERSION ); wp_enqueue_script( 'aiforya-ui-bbf8d166', $vendor_url . 'aiforya-ui.js', [], AIFORYA_SM_VERSION, true ); wp_localize_script( 'aiforya-ui-bbf8d166', 'aiforyaUiI18n', [ 'confirm' => __( 'OK', 'aiforya-schema-markup' ), 'cancel' => __( 'Cancel', 'aiforya-schema-markup' ), ] ); }, 5 ); // ============================================================================= // 5. Services métier — instanciés tôt. // ============================================================================= add_action( 'plugins_loaded', static function (): void { new Aiforya_Schema_Markup_Detector(); new Aiforya_Schema_Markup_Generator(); new Aiforya_Schema_Markup_Cron(); new Aiforya_Schema_Markup_Ajax(); new Aiforya_Schema_Markup_Frontend(); Aiforya_Schema_Markup_Optimizer::get_instance(); Aiforya_Schema_Markup_Migration::get_instance(); Aiforya_Schema_Markup_Health::get_instance(); }, 5 ); // ============================================================================= // 5bis. Boot du moteur (menu admin + onglets) — sur init prio 11 (textdomain dispo). // ============================================================================= add_action( 'init', static function (): void { if ( ! class_exists( 'Aiforya_Schema_Engine' ) ) { return; } Aiforya_Schema_Engine::boot( AIFORYA_SM_DIR, [ 'slug' => AIFORYA_SM_SLUG, 'requires_activation' => false, // Extension gratuite .org : aucun ecran d'activation licence. 'title' => 'AIFORYA Schema Markup', 'description' => 'Generates Schema.org structured data (JSON-LD) for your content to earn rich results in Google.', 'icon' => 'dashicons-search', 'category' => 'SEO', 'capability' => 'manage_options', 'position' => 20, 'plugin_basename' => AIFORYA_SM_BASENAME, 'plugin_image' => plugins_url( 'assets/images/cover.png', __FILE__ ), 'faq' => static function () { return [ [ 'q' => __( 'What is Schema.org and why does it matter?', 'aiforya-schema-markup' ), 'a' => __( 'Schema.org provides a structured data vocabulary that search engines use to understand your pages better. It can unlock rich results (stars, prices, event dates, FAQs, recipes and so on) in Google, improving your visibility and your click-through rate.', 'aiforya-schema-markup' ) ], [ 'q' => __( 'How is the schema type chosen?', 'aiforya-schema-markup' ), 'a' => __( 'By rules, with no AI: your advanced rules first, then the content type to schema type mapping (Types tab), then keyword detection on the title and the content. You can always pick the type by hand.', 'aiforya-schema-markup' ) ], [ 'q' => __( 'Do I need an API key or an account?', 'aiforya-schema-markup' ), 'a' => __( 'No. This version runs entirely on your own site, with no API key and no external service. The JSON-LD is generated on your server and cached.', 'aiforya-schema-markup' ) ], [ 'q' => __( 'Does the plugin slow my site down?', 'aiforya-schema-markup' ), 'a' => __( 'No. Generation happens in the background (cron / admin), the result is cached and then injected into the
read-only. No network call is made while your pages load.', 'aiforya-schema-markup' ) ], [ 'q' => __( 'Which content types are supported?', 'aiforya-schema-markup' ), 'a' => __( 'A broad Schema.org catalog: Article, BlogPosting, NewsArticle, WebPage, Product, Recipe, Event, FAQPage, HowTo, LocalBusiness, Course, JobPosting, Organization, Person, BreadcrumbList and many more.', 'aiforya-schema-markup' ) ], [ 'q' => __( 'Can I import my schemas from Yoast / Rank Math / AIOSEO?', 'aiforya-schema-markup' ), 'a' => __( 'Yes. The Migration tab detects the SEO plugins you have installed and converts their schemas into native ones, with no loss.', 'aiforya-schema-markup' ) ], [ 'q' => __( 'How do I validate my schemas?', 'aiforya-schema-markup' ), 'a' => __( 'The test button opens Google\'s Rich Results Test, pre-filled with your URL, after a local check of the fields each schema type requires.', 'aiforya-schema-markup' ) ], [ 'q' => __( 'Is there a version with AI?', 'aiforya-schema-markup' ), 'a' => __( 'Yes. The advanced version adds AI detection of the best schema type, competitive SERP analysis, emerging type predictions, A/B testing and Google Search Console integration. See aiforya.fr.', 'aiforya-schema-markup' ) ], ]; }, ] ); }, 11 ); // ============================================================================= // 6. Liens dans la liste des extensions WordPress. // ============================================================================= add_filter( 'plugin_row_meta', static function ( array $links, string $file ): array { if ( $file !== AIFORYA_SM_BASENAME ) { return $links; } $links[] = '' . esc_html__( 'User guide', 'aiforya-schema-markup' ) . ''; return $links; }, 10, 2 ); add_filter( 'plugin_action_links_' . AIFORYA_SM_BASENAME, static function ( array $links ): array { $settings_link = '' . esc_html__( 'Settings', 'aiforya-schema-markup' ) . ''; array_unshift( $links, $settings_link ); return $links; } );