mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Add plugin update hook & run PayLater migration if plugin is updated
This commit is contained in:
parent
769699763d
commit
13b72db35a
2 changed files with 12 additions and 4 deletions
|
@ -200,7 +200,7 @@ class CompatModule implements ModuleInterface {
|
|||
}
|
||||
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_gateway_migrate',
|
||||
'woocommerce_paypal_payments_gateway_migrate_on_update',
|
||||
function () use ( $c, $is_pay_later_settings_migrated_option_name ) {
|
||||
$settings = $c->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof Settings );
|
||||
|
|
|
@ -90,13 +90,21 @@ define( 'PPCP_FLAG_SUBSCRIPTION', true );
|
|||
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-version' ) !== $plugin_version ) {
|
||||
$plugin_data = get_plugin_data( __DIR__ . '/woocommerce-paypal-payments.php' );
|
||||
$plugin_version = $plugin_data['Version'] ?? null;
|
||||
$installed_plugin_version = get_option( 'woocommerce-ppcp-version' );
|
||||
if ( $installed_plugin_version !== $plugin_version ) {
|
||||
/**
|
||||
* The hook fired when the plugin is installed or updated.
|
||||
*/
|
||||
do_action( 'woocommerce_paypal_payments_gateway_migrate' );
|
||||
|
||||
if ( $installed_plugin_version ) {
|
||||
/**
|
||||
* The hook fired when the plugin is updated.
|
||||
*/
|
||||
do_action( 'woocommerce_paypal_payments_gateway_migrate_on_update' );
|
||||
}
|
||||
update_option( 'woocommerce-ppcp-version', $plugin_version );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue