diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php index 812209dbb..c95af0f8f 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php @@ -53,14 +53,10 @@ public function __construct( SV_WC_Payment_Gateway_Plugin $plugin ) { $this->plugin = $plugin; - parent::__construct( $plugin->get_plugin_name() ); + parent::__construct(); // add the action & filter hooks $this->add_hooks(); - - // add the token exporters & erasers - $this->add_exporter( "wc-{$plugin->get_id_dasherized()}-customer-tokens", __( "{$plugin->get_plugin_name()} Payment Tokens", 'woocommerce-plugin-framework' ), array( $this, 'customer_tokens_exporter' ) ); - $this->add_eraser( "wc-{$plugin->get_id_dasherized()}-customer-tokens", __( "{$plugin->get_plugin_name()} Payment Tokens", 'woocommerce-plugin-framework' ), array( $this, 'customer_tokens_eraser' ) ); } @@ -71,6 +67,9 @@ public function __construct( SV_WC_Payment_Gateway_Plugin $plugin ) { */ protected function add_hooks() { + // initializes data exporters and erasers + add_action('init', [$this, 'registerExportersAndErasers']); + // add the gateway data to customer data exports add_filter( 'woocommerce_privacy_export_customer_personal_data', array( $this, 'add_export_customer_data' ), 10, 2 ); @@ -84,6 +83,20 @@ protected function add_hooks() { add_action( 'woocommerce_privacy_remove_order_personal_data', array( $this, 'remove_order_personal_data' ) ); } + /** + * Initial registration of privacy erasers and exporters. + * + * Due to the use of translation functions, this should run only on/after init. + */ + public function registerExportersAndErasers() + { + $this->name = $this->plugin->get_plugin_name(); + + // add the token exporters & erasers + $this->add_exporter("wc-{$this->plugin->get_id_dasherized()}-customer-tokens", __("{$this->plugin->get_plugin_name()} Payment Tokens", 'woocommerce-plugin-framework'), [$this, 'customer_tokens_exporter']); + $this->add_eraser("wc-{$this->plugin->get_id_dasherized()}-customer-tokens", __("{$this->plugin->get_plugin_name()} Payment Tokens", 'woocommerce-plugin-framework'), [$this, 'customer_tokens_eraser']); + } + /** Customer methods ******************************************************/