← All changes
|
paypal/controllers/FrmPayPalLiteSettingsController.php
+24
-0
6.31
→
trunk
View file →
| @@ -54,5 +54,29 @@ | ||
| 54 | 54 | // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 55 | 55 | $settings->update( $_POST ); |
| 56 | 56 | $settings->store(); |
| 57 | 57 | } |
| 58 | + | |
| 59 | + /** | |
| 60 | + * Preserve test_mode when the PayPal add-on updates frm_paypal_options. | |
| 61 | + * This hooks into update_option to ensure test_mode isn't lost. | |
| 62 | + * | |
| 63 | + * @param mixed $old_value The old option value. | |
| 64 | + * @param mixed $new_value The new option value. | |
| 65 | + * | |
| 66 | + * @return void | |
| 67 | + */ | |
| 68 | + public static function preserve_test_mode_on_update( $old_value, $new_value ) { | |
| 69 | + if ( ! is_object( $old_value ) || ! is_object( $new_value ) ) { | |
| 70 | + return; | |
| 71 | + } | |
| 72 | + | |
| 73 | + // If old value had test_mode but new value doesn't, preserve it | |
| 74 | + if ( ! isset( $old_value->test_mode ) || isset( $new_value->test_mode ) ) { | |
| 75 | + return; | |
| 76 | + } | |
| 77 | + | |
| 78 | + $new_value->test_mode = $old_value->test_mode; | |
| 79 | + // Update the option with the preserved test_mode | |
| 80 | + update_option( 'frm_paypal_options', $new_value ); | |
| 81 | + } | |
| 58 | 82 | } |