mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Add upgrading event on plugins loaded
This commit is contained in:
parent
f746c41a83
commit
2c8d0fcf8a
2 changed files with 26 additions and 4 deletions
|
@ -54,10 +54,22 @@ class VaultingModule implements ModuleInterface {
|
|||
'init',
|
||||
function () {
|
||||
add_rewrite_endpoint( 'ppcp-paypal-payment-tokens', EP_PAGES );
|
||||
if ( ! get_option( 'woocommerce-ppcp-payment-tokens-flushed', false ) ) {
|
||||
flush_rewrite_rules();
|
||||
add_option( 'woocommerce-ppcp-payment-tokens-flushed', true );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_gateway_migrate',
|
||||
function () {
|
||||
add_rewrite_endpoint( 'ppcp-paypal-payment-tokens', EP_PAGES );
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
);
|
||||
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_gateway_activate',
|
||||
function () {
|
||||
add_rewrite_endpoint( 'ppcp-paypal-payment-tokens', EP_PAGES );
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -81,6 +81,16 @@ define( 'PPCP_FLAG_SUBSCRIPTION', true );
|
|||
'plugins_loaded',
|
||||
function () {
|
||||
init();
|
||||
|
||||
if ( ! function_exists( 'get_plugin_data' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
$plugin_data = get_plugin_data( __DIR__ . '/woocommerce-paypal-payments.php' );
|
||||
$plugin_version = $plugin_data['Version'] ?? null;
|
||||
if ( get_option( 'woocommerce-ppcp-upgrading-version' ) !== $plugin_version ) {
|
||||
do_action( 'woocommerce_paypal_payments_gateway_migrate' );
|
||||
update_option( 'woocommerce-ppcp-upgrading-version', $plugin_version );
|
||||
}
|
||||
}
|
||||
);
|
||||
register_activation_hook(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue