PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / paypal / controllers / FrmPayPalLiteSettingsController.php

FrmPayPalLiteSettingsController.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More trunk, at paypal/controllers/FrmPayPalLiteSettingsController.php

83 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 class FrmPayPalLiteSettingsController {
7
8 /**
9 * Add PayPal section to Global Settings.
10 *
11 * @since 6.31
12 *
13 * @param array $sections
14 *
15 * @return array
16 */
17 public static function add_settings_section( $sections ) {
18 $sections['paypal'] = array(
19 'class' => self::class,
20 'function' => 'route',
21 'icon' => 'frm_icon_font frm_paypal_icon',
22 );
23
24 return $sections;
25 }
26
27 /**
28 * Handle global settings routing.
29 *
30 * @return void
31 */
32 public static function route() {
33 self::global_settings_form();
34 }
35
36 /**
37 * Print the PayPal section for Global settings.
38 *
39 * @param array $atts
40 *
41 * @return void
42 */
43 public static function global_settings_form( $atts = array() ) {
44 include FrmPayPalLiteAppHelper::plugin_path() . '/views/settings/form.php';
45 }
46
47 /**
48 * Handle processing changes to global PayPal Settings.
49 *
50 * @return void
51 */
52 public static function process_form() {
53 $settings = FrmPayPalLiteAppHelper::get_settings();
54 // phpcs:ignore WordPress.Security.NonceVerification.Missing
55 $settings->update( $_POST );
56 $settings->store();
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 }
82 }
83