PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.13
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.13
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 / stripe / models / FrmStrpLiteSettings.php

FrmStrpLiteSettings.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.13, at stripe/models/FrmStrpLiteSettings.php

124 lines 2.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 #[\AllowDynamicProperties]
7 class FrmStrpLiteSettings {
8
9 /**
10 * @var stdClass|null
11 */
12 public $settings;
13
14 public function __construct() {
15 $this->set_default_options();
16 }
17
18 /**
19 * @return string
20 */
21 public function param() {
22 return 'strp';
23 }
24
25 /**
26 * @return array
27 */
28 public function default_options() {
29 return array(
30 'test_mode' => 1,
31 'processing_message' => __( 'This payment may take several days to finish processing.', 'formidable' ),
32 );
33 }
34
35 /**
36 * @param mixed $settings
37 * @return void
38 */
39 public function set_default_options( $settings = false ) {
40 $default_settings = $this->default_options();
41
42 if ( ! $settings ) {
43 $settings = $this->get_options();
44 } elseif ( $settings === true ) {
45 $settings = new stdClass();
46 }
47
48 if ( ! isset( $this->settings ) ) {
49 $this->settings = new stdClass();
50 }
51
52 foreach ( $default_settings as $setting => $default ) {
53 if ( is_object( $settings ) && isset( $settings->{$setting} ) ) {
54 $this->settings->{$setting} = $settings->{$setting};
55 }
56
57 if ( ! isset( $this->settings->{$setting} ) ) {
58 $this->settings->{$setting} = $default;
59 }
60 }
61 }
62
63 public function get_options() {
64 $settings = get_option( 'frm_' . $this->param() . '_options' );
65
66 if ( is_object( $settings ) ) {
67 $this->set_default_options( $settings );
68 } elseif ( $settings ) {
69 // Workaround for W3 total cache conflict.
70 $this->settings = unserialize( serialize( $settings ) );
71 } else {
72 $this->set_default_options( true );
73 $this->store();
74 }
75
76 return $this->settings;
77 }
78
79 /**
80 * @param array $params
81 * @return void
82 */
83 public function update( $params ) {
84 $settings = $this->default_options();
85
86 foreach ( $settings as $setting => $default ) {
87 if ( isset( $params[ 'frm_' . $this->param() . '_' . $setting ] ) ) {
88 $this->settings->{$setting} = trim( sanitize_text_field( $params[ 'frm_' . $this->param() . '_' . $setting ] ) );
89 }
90 }
91
92 $this->settings->test_mode = isset( $params['frm_strp_test_mode'] ) ? absint( $params['frm_strp_test_mode'] ) : 0;
93 }
94
95 /**
96 * @return void
97 */
98 public function store() {
99 // Save the posted value in the database.
100 update_option( 'frm_' . $this->param() . '_options', $this->settings );
101 }
102
103 /**
104 * @return string
105 */
106 public function get_active_publishable_key() {
107 return $this->settings->test_mode ? $this->get_frm_publishable_test_key() : $this->get_frm_publishable_live_key();
108 }
109
110 /**
111 * @return string
112 */
113 private function get_frm_publishable_test_key() {
114 return 'pk_test_51I8ZwGAifsV2HHSa8NKsdEEVTa8o69bZykSf1zM3OsonXFblw7mEuNkyYUjLgGwYrgF95CmpkJSJtaWyrQNKaMMJ00y2Q7Y0jz';
115 }
116
117 /**
118 * @return string
119 */
120 private function get_frm_publishable_live_key() {
121 return 'pk_live_51I8ZwGAifsV2HHSa0jgLD6S16izScuihE2WtExBWzbyBsawOazS9cjt1aFyBsdSuK9nYwDD7Vh7LUOoa0Evb7Evb00yVEpTIJL';
122 }
123 }
124