PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.24
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.24
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
← All changes | classes/models/FrmFormState.php +4 -24 6.266.24 View file →
@@ -29,9 +29,8 @@
29 29
30 30 /**
31 31 * @param string $key
32 32 * @param mixed $value
33 - *
34 33 * @return void
35 34 */
36 35 public static function set_initial_value( $key, $value ) {
37 36 if ( is_callable( 'FrmProFormState::set_initial_value' ) ) {
@@ -56,9 +55,8 @@
56 55
57 56 /**
58 57 * @param string $key
59 58 * @param mixed $value
60 - *
61 59 * @return void
62 60 */
63 61 public function set( $key, $value ) {
64 62 $this->state[ $key ] = $value;
@@ -66,9 +64,8 @@
66 64
67 65 /**
68 66 * @param string $key
69 67 * @param mixed $default
70 - *
71 68 * @return mixed
72 69 */
73 70 public static function get_from_request( $key, $default ) {
74 71 if ( self::maybe_initialize() ) {
@@ -76,16 +73,13 @@
76 73 }
77 74 return self::$instance->get( $key, $default );
78 75 }
79 76
80 - /**
81 - * @param string $key
82 - * @param mixed $default
83 - *
84 - * @return mixed
85 - */
86 77 public function get( $key, $default ) {
87 - return $this->state[ $key ] ?? $default;
78 + if ( isset( $this->state[ $key ] ) ) {
79 + return $this->state[ $key ];
80 + }
81 + return $default;
88 82 }
89 83
90 84 /**
91 85 * Render a basic version of the state field from Pro.
@@ -92,9 +86,8 @@
92 86 * This is required only when submitting with AJAX.
93 87 * It is used to track the value of a title=1|0 or description=1|0 option in a [formidable] shortcode.
94 88 *
95 89 * @param stdClass $form
96 - *
97 90 * @return void
98 91 */
99 92 public static function maybe_render_state_field( $form ) {
100 93 if ( is_callable( 'FrmProFormState::maybe_render_state_field' ) ) {
@@ -131,26 +124,20 @@
131 124 * @return bool true if there is valid state data in the request.
132 125 */
133 126 private static function get_state_from_request() {
134 127 $encrypted_state = FrmAppHelper::get_post_param( 'frm_state', '', 'sanitize_text_field' );
135 -
136 128 if ( ! $encrypted_state ) {
137 129 return false;
138 130 }
139 -
140 131 $secret = self::get_encryption_secret();
141 132 $decrypted_state = openssl_decrypt( $encrypted_state, 'AES-128-ECB', $secret );
142 -
143 133 if ( false === $decrypted_state ) {
144 134 return false;
145 135 }
146 -
147 136 $decoded_state = json_decode( $decrypted_state, true );
148 -
149 137 if ( ! is_array( $decoded_state ) ) {
150 138 return false;
151 139 }
152 -
153 140 foreach ( $decoded_state as $key => $value ) {
154 141 self::set_initial_value( self::decompressed_key( $key ), $value );
155 142 }
156 143 return true;
@@ -162,13 +149,11 @@
162 149 public function render_state_field() {
163 150 if ( ! self::open_ssl_is_installed() ) {
164 151 return;
165 152 }
166 -
167 153 if ( ! $this->state && ! self::get_state_from_request() ) {
168 154 return;
169 155 }
170 -
171 156 $state_string = $this->get_state_string();
172 157 echo '<input name="frm_state" type="hidden" value="' . esc_attr( $state_string ) . '" />';
173 158 }
174 159
@@ -178,9 +163,8 @@
178 163 private function get_state_string() {
179 164 if ( ! self::open_ssl_is_installed() ) {
180 165 return '';
181 166 }
182 -
183 167 $secret = self::get_encryption_secret();
184 168 $compressed_state = $this->compressed_state();
185 169 $json_encoded = json_encode( $compressed_state );
186 170 $encrypted = openssl_encrypt( $json_encoded, 'AES-128-ECB', $secret );
@@ -190,9 +174,8 @@
190 174 /**
191 175 * Returns true if open SSL is installed.
192 176 *
193 177 * @since 6.12
194 - *
195 178 * @return bool
196 179 */
197 180 private static function open_ssl_is_installed() {
198 181 return function_exists( 'openssl_encrypt' );
@@ -204,9 +187,8 @@
204 187 * @return array
205 188 */
206 189 private function compressed_state() {
207 190 $compressed = array();
208 -
209 191 foreach ( $this->state as $key => $value ) {
210 192 $compressed[ self::compressed_key( $key ) ] = $value;
211 193 }
212 194 return $compressed;
@@ -217,9 +199,8 @@
217 199 * "title" => "t".
218 200 * "description" => "d".
219 201 *
220 202 * @param string $key
221 - *
222 203 * @return string
223 204 */
224 205 private static function compressed_key( $key ) {
225 206 return $key[0];
@@ -230,9 +211,8 @@
230 211 * Pro supports additional keys include "i" for include_fields and "g" for get params.
231 212 * To avoid conflicts, we should not add "i" or "g" in Lite for another state property.
232 213 *
233 214 * @param string $key
234 - *
235 215 * @return string The full key name if one is found. If nothing is found, the $key param is passed back.
236 216 */
237 217 private static function decompressed_key( $key ) {
238 218 switch ( $key ) {