update_meta_data()), never * through post meta directly, so it is genuinely compatible — this just says so. */ add_action( 'before_woocommerce_init', function () { if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) { \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', AFFCLIX_WC_FILE, true); \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('cart_checkout_blocks', AFFCLIX_WC_FILE, true); } } ); /** * Boot, but only once WooCommerce is actually present. * * Activating this on a site without WooCommerce must not fatal — WordPress * would leave the site white-screened with no way back in through the admin. */ add_action( 'plugins_loaded', function () { if (! class_exists('WooCommerce')) { add_action( 'admin_notices', function () { echo '

'; esc_html_e('AffClix for WooCommerce needs WooCommerce to be installed and active.', 'affclix-for-woocommerce'); echo '

'; } ); return; } Affclix_Attribution::init(); Affclix_Order_Meta::init(); Affclix_Webhook::init(); if (is_admin()) { Affclix_Admin::init(); } } ); /** * Deactivation tells AffClix the store is gone. * * Best-effort and deliberately non-blocking on failure: a merchant deactivating * a plugin must never see an error because our API was unreachable. The store * is also deactivated server-side when its webhooks stop arriving. */ register_deactivation_hook( AFFCLIX_WC_FILE, function () { wp_clear_scheduled_hook('affclix_daily_refresh'); // WooCommerce may already be gone — deactivating both at once is the // common case — and its webhook and key tables go with it. if (! class_exists('WooCommerce')) { return; } Affclix_Client::disconnect(); Affclix_Webhook::delete_all(); Affclix_Rest_Key::revoke(); } );