new ProductExportModule($api, new ProductExportMapper()), // Export products from Woo to Aikanen 'product_import' => new ProductImportModule($api, new ProductImportMapper()), // Import products from Aikanen to Woo 'stock_sync' => new StockSyncModule($api), // Sync stocks between WooCommerce and Aikanen ]; if (is_admin()) { // Register settings page only for admin (new SettingsPage($modules))->register(); } foreach ($modules as $module) { // Boot enabled modules if ($module->isEnabled()) { $module->register(); } } }); // Add settings link to plugins page add_filter('plugin_action_links_' . plugin_basename(__FILE__), function (array $links): array { $links[] = '' . __('Settings', 'aikanen') . ''; return $links; }); // Clean up on plugin deactivation register_deactivation_hook(__FILE__, function () { // Remove scheduled actions from Action Scheduler as_unschedule_all_actions('aikanen_export_product'); as_unschedule_all_actions('aikanen_push_stock'); as_unschedule_all_actions('aikanen_stock_full_sync'); // Delete transients delete_transient('aikanen_connection_status'); delete_transient('aikanen_preview'); }); // Clean up on plugin uninstallation register_uninstall_hook(__FILE__, 'aikanen_uninstall'); function aikanen_uninstall(): void { // Clean up database entries delete_option('aikanen_api_token'); delete_option('aikanen_webhook_secret'); delete_option('aikanen_vat_map'); delete_option('aikanen_stock_source_of_truth'); delete_option('aikanen_stock_full_sync_interval'); delete_option('aikanen_auto_export'); foreach (['product_export', 'product_import', 'stock_sync'] as $key) { delete_option("aikanen_module_{$key}_enabled"); } }