Skip to content

Delay usage of get_plugin_name() in payment gateway privacy class to after init #764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}


Expand All @@ -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 );

Expand All @@ -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 ******************************************************/

Expand Down
Loading