logger = new Logger(); $this->api = new Api( $this->logger ); $this->automation = new Automation( $this->api, $this->logger ); new Admin( $this->api, $this->automation, $this->logger ); new Rest( $this->api, $this->logger ); add_action( 'admin_init', array( $this, 'redirect_to_settings_after_activation' ) ); if ( class_exists( 'WooCommerce' ) && Settings::get( 'enabled', 'yes' ) === 'yes' ) { $this->automation->register_hooks(); } add_action( 'authkey_send_automation', array( $this->automation, 'run_scheduled' ), 10, 2 ); } /** Run schema migrations only in the dashboard, not on every front-end request. */ public function maybe_upgrade() : void { Database::maybe_upgrade(); } /** Explain the required WooCommerce dependency when the plugin cannot run. */ public function woocommerce_missing_notice() : void { if ( ! current_user_can( 'activate_plugins' ) ) { return; } echo '
' . esc_html__( 'Authkey requires WooCommerce to be installed and active.', 'authkey' ) . '
' . esc_html__( 'Authkey sends data to the Authkey messaging service only after a site administrator connects an Authkey account and configures a contact sync or automation.', 'authkey' ) . '
'; $content .= '' . esc_html__( 'When a contact list is synced, the selected customer name and billing phone number, together with the chosen list name and country code, are sent to Authkey. When an automation sends a WhatsApp template, the recipient phone number and the WooCommerce values selected by the administrator are sent to Authkey. Selected values can include a customer name, billing email, order number, product names, order total, order status, store name, and store URL.', 'authkey' ) . '
'; $content .= '' . esc_html__( 'The plugin stores its Authkey connection token, automation settings, and (when logging is enabled) delivery logs in this WordPress installation. Delivery logs can contain an order ID, customer name, template, trigger, status, and the Authkey API response. Site owners are responsible for obtaining any consent required to send WhatsApp messages and for reflecting this processing in their privacy policy.', 'authkey' ) . '
'; $content .= '' . sprintf( /* translators: 1: Authkey Privacy Policy URL, 2: Authkey Terms and Conditions URL. */ __( 'For information about Authkey’s handling of data, review its Privacy Policy and Terms and Conditions.', 'authkey' ), esc_url( 'https://authkey.io/privacy-policy' ), esc_url( 'https://authkey.io/term-and-condition' ) ) . '
'; wp_add_privacy_policy_content( __( 'Authkey', 'authkey' ), $content ); } /** Send administrators to the setup screen only on a brand-new installation. */ public function redirect_to_settings_after_activation() : void { if ( ! get_option( 'authkey_activation_redirect', false ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { return; } delete_option( 'authkey_activation_redirect' ); wp_safe_redirect( admin_url( 'admin.php?page=authkey-settings' ) ); exit; } public static function activate() : void { Database::install(); if ( add_option( 'authkey_settings', Settings::defaults() ) ) { add_option( 'authkey_activation_redirect', 'yes' ); } } public static function deactivate() : void { wp_clear_scheduled_hook( 'authkey_send_automation' ); } }