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

129 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 *
38 * @return void
39 */
40 public function set_default_options( $settings = false ) {
41 $default_settings = $this->default_options();
42
43 if ( ! $settings ) {
44 $settings = $this->get_options();
45 } elseif ( $settings === true ) {
46 $settings = new stdClass();
47 }
48
49 if ( ! isset( $this->settings ) ) {
50 $this->settings = new stdClass();
51 }
52
53 foreach ( $default_settings as $setting => $default ) {
54 if ( is_object( $settings ) && isset( $settings->{$setting} ) ) {
55 $this->settings->{$setting} = $settings->{$setting};
56 }
57
58 if ( ! isset( $this->settings->{$setting} ) ) {
59 $this->settings->{$setting} = $default;
60 }
61 }
62 }
63
64 /**
65 * @return object
66 */
67 public function get_options() {
68 $settings = get_option( 'frm_' . $this->param() . '_options' );
69
70 if ( is_object( $settings ) ) {
71 $this->set_default_options( $settings );
72 } elseif ( $settings ) {
73 // Workaround for W3 total cache conflict.
74 $this->settings = unserialize( serialize( $settings ) );
75 } else {
76 $this->set_default_options( true );
77 $this->store();
78 }
79
80 return $this->settings;
81 }
82
83 /**
84 * @param array $params
85 *
86 * @return void
87 */
88 public function update( $params ) {
89 $settings = $this->default_options();
90
91 foreach ( $settings as $setting => $default ) {
92 if ( isset( $params[ 'frm_' . $this->param() . '_' . $setting ] ) ) {
93 $this->settings->{$setting} = trim( sanitize_text_field( $params[ 'frm_' . $this->param() . '_' . $setting ] ) );
94 }
95 }
96
97 $this->settings->test_mode = isset( $params['frm_strp_test_mode'] ) ? absint( $params['frm_strp_test_mode'] ) : 0;
98 }
99
100 /**
101 * @return void
102 */
103 public function store() {
104 // Save the posted value in the database.
105 update_option( 'frm_' . $this->param() . '_options', $this->settings );
106 }
107
108 /**
109 * @return string
110 */
111 public function get_active_publishable_key() {
112 return $this->settings->test_mode ? $this->get_frm_publishable_test_key() : $this->get_frm_publishable_live_key();
113 }
114
115 /**
116 * @return string
117 */
118 private function get_frm_publishable_test_key() {
119 return 'pk_test_51I8ZwGAifsV2HHSa8NKsdEEVTa8o69bZykSf1zM3OsonXFblw7mEuNkyYUjLgGwYrgF95CmpkJSJtaWyrQNKaMMJ00y2Q7Y0jz';
120 }
121
122 /**
123 * @return string
124 */
125 private function get_frm_publishable_live_key() {
126 return 'pk_live_51I8ZwGAifsV2HHSa0jgLD6S16izScuihE2WtExBWzbyBsawOazS9cjt1aFyBsdSuK9nYwDD7Vh7LUOoa0Evb7Evb00yVEpTIJL';
127 }
128 }
129