init(); // Load Batch API endpoints require_once plugin_dir_path(__FILE__) . 'api/class-ailm-batch-endpoints.php'; $batch_endpoints = new AILM_Batch_Endpoints(); $batch_endpoints->init(); // Schedule WP-Cron cleanup for stale batches (>48h) if (!wp_next_scheduled('ailm_cleanup_stale_batches')) { wp_schedule_event(time(), 'daily', 'ailm_cleanup_stale_batches'); } add_action('ailm_cleanup_stale_batches', ['AILM_Batch_Endpoints', 'cleanup_stale_batches']); // Enqueue admin scripts/styles for the new UI add_action('admin_enqueue_scripts', [__CLASS__, 'enqueue_assets']); // Render the modal window in the admin footer add_action('admin_footer', [__CLASS__, 'render_modal']); } public static function enqueue_assets($hook) { // Limit loading to our plugin pages if (strpos($hook, 'ailinkmaster') === false) { return; } // JS wp_enqueue_script( 'ailm-semantic-admin-js', plugin_dir_url(__FILE__) . 'ailm-semantic-admin.js', ['jquery'], time(), true ); // from PHP to JS wp_localize_script('ailm-semantic-admin-js', 'ailm_semantic_vars', [ 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('ailm_semantic_nonce'), 'review_queue_url' => admin_url('admin.php?page=ailinkmaster-internal-auto-manager-review-queue') ]); } /** * Prints the HTML for the AI Smart Link Modal. */ public static function render_modal() { $screen = get_current_screen(); if (!$screen || strpos($screen->id, 'ailinkmaster') === false) { return; } ?>