PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0.07
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0.07
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/FrmForm.php +94 -545 6.265.0.07 View file →
@@ -5,49 +5,38 @@
5 5
6 6 class FrmForm {
7 7
8 8 /**
9 - * @param array $values
10 - *
11 - * @return bool|int id on success or false on failure.
9 + * @return int|boolean id on success or false on failure
12 10 */
13 11 public static function create( $values ) {
14 12 global $wpdb;
15 13
16 - $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) );
17 -
18 14 $new_values = array(
19 15 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
20 16 'name' => $values['name'],
21 17 'description' => $values['description'],
22 - 'status' => $values['status'] ?? 'published',
23 - 'logged_in' => $values['logged_in'] ?? 0,
18 + 'status' => isset( $values['status'] ) ? $values['status'] : 'published',
19 + 'logged_in' => isset( $values['logged_in'] ) ? $values['logged_in'] : 0,
24 20 'is_template' => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0,
25 21 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
26 22 'editable' => isset( $values['editable'] ) ? (int) $values['editable'] : 0,
27 - 'created_at' => $values['created_at'] ?? current_time( 'mysql', 1 ),
23 + 'created_at' => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ),
28 24 );
29 25
30 26 $options = isset( $values['options'] ) ? (array) $values['options'] : array();
31 27 FrmFormsHelper::fill_form_options( $options, $values );
32 28
33 - $options['before_html'] = $values['options']['before_html'] ?? FrmFormsHelper::get_default_html( 'before' );
34 - $options['after_html'] = $values['options']['after_html'] ?? FrmFormsHelper::get_default_html( 'after' );
35 - $options['submit_html'] = $values['options']['submit_html'] ?? FrmFormsHelper::get_default_html( 'submit' );
29 + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
30 + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
31 + $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
36 32
37 - /**
38 - * Allows modifying form options before updating or creating.
39 - *
40 - * @since 5.4 Add the third param.
41 - *
42 - * @param array $options Form options.
43 - * @param array $values Form data.
44 - * @param bool $update Is form updating or creating. It's `true` if is updating.
45 - */
46 - $options = apply_filters( 'frm_form_options_before_update', $options, $values, false );
47 - $options = self::maybe_filter_form_options( $options );
33 + $options = apply_filters( 'frm_form_options_before_update', $options, $values );
48 34 $new_values['options'] = serialize( $options );
49 35
36 + //if(isset($values['id']) && is_numeric($values['id']))
37 + // $new_values['id'] = $values['id'];
38 +
50 39 $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
51 40
52 41 $id = $wpdb->insert_id;
53 42
@@ -57,36 +46,14 @@
57 46 return $id;
58 47 }
59 48
60 49 /**
61 - * @since 5.0.08
62 - *
63 - * @param array $options
64 - *
65 - * @return array
50 + * @return int|boolean ID on success or false on failure
66 51 */
67 - private static function maybe_filter_form_options( $options ) {
68 - if ( ! FrmAppHelper::allow_unfiltered_html() && ! empty( $options['submit_html'] ) ) {
69 - $options['submit_html'] = FrmAppHelper::kses_submit_button( $options['submit_html'] );
70 - }
71 - return FrmAppHelper::maybe_filter_array( $options, array( 'submit_value', 'success_msg', 'before_html', 'after_html' ) );
72 - }
73 -
74 - /**
75 - * Duplicate a form.
76 - *
77 - * @param int $id Form ID to duplicate.
78 - * @param bool $template Whether the duplicated form is a template.
79 - * @param bool $copy_keys Whether to copy the original form key.
80 - * @param false|int $blog_id Blog ID when duplicating across sites, or false for current site.
81 - *
82 - * @return bool|int ID on success or false on failure
83 - */
84 52 public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
85 53 global $wpdb;
86 54
87 55 $values = self::getOne( $id, $blog_id );
88 -
89 56 if ( ! $values ) {
90 57 return false;
91 58 }
92 59
@@ -103,10 +70,10 @@
103 70 'is_template' => $template ? 1 : 0,
104 71 );
105 72
106 73 if ( $blog_id ) {
107 - $new_values['status'] = 'published';
108 - $new_options = $values->options;
74 + $new_values['status'] = 'published';
75 + $new_options = $values->options;
109 76 FrmAppHelper::unserialize_or_decode( $new_options );
110 77 $new_options['email_to'] = get_option( 'admin_email' );
111 78 $new_options['copy'] = false;
112 79 $new_values['options'] = $new_options;
@@ -135,16 +102,10 @@
135 102
136 103 return false;
137 104 }
138 105
139 - /**
140 - * @param int $form_id
141 - * @param array $values
142 - *
143 - * @return void
144 - */
145 106 public static function after_duplicate( $form_id, $values ) {
146 - $new_opts = $values['options'];
107 + $new_opts = $values['options'];
147 108 FrmAppHelper::unserialize_or_decode( $new_opts );
148 109 $values['options'] = $new_opts;
149 110
150 111 if ( isset( $new_opts['success_msg'] ) ) {
@@ -156,100 +117,13 @@
156 117 if ( $new_opts != $values['options'] ) {
157 118 global $wpdb;
158 119 $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) );
159 120 }
160 -
161 - self::switch_field_ids_in_fields( $form_id );
162 121 }
163 122
164 123 /**
165 - * Switches field ID in fields.
166 - *
167 - * @since 5.3
168 - *
169 - * @param int $form_id Form ID.
170 - *
171 - * @return void
124 + * @return int|boolean
172 125 */
173 - private static function switch_field_ids_in_fields( $form_id ) {
174 - global $wpdb;
175 -
176 - // Keys of fields that you want to check to replace field ID.
177 - $keys = array( 'default_value', 'field_options' );
178 - $sql_cols = 'fi.id';
179 -
180 - foreach ( $keys as $key ) {
181 - $sql_cols .= ',fi.' . $key;
182 - }
183 -
184 - $fields = FrmDb::get_results(
185 - "{$wpdb->prefix}frm_fields AS fi LEFT OUTER JOIN {$wpdb->prefix}frm_forms AS fr ON fi.form_id = fr.id",
186 - array(
187 - 'or' => 1,
188 - 'fi.form_id' => $form_id,
189 - 'fr.parent_form_id' => $form_id,
190 - ),
191 - $sql_cols
192 - );
193 -
194 - if ( ! $fields || ! is_array( $fields ) ) {
195 - return;
196 - }
197 -
198 - foreach ( $fields as $field ) {
199 - self::switch_field_ids_in_field( (array) $field );
200 - }
201 - }
202 -
203 - /**
204 - * Switches field ID in a field.
205 - *
206 - * @since 5.3
207 - *
208 - * @param array $field Field array.
209 - *
210 - * @return void
211 - */
212 - private static function switch_field_ids_in_field( $field ) {
213 - $new_values = array();
214 -
215 - foreach ( $field as $key => $value ) {
216 - if ( 'id' === $key || ! $value ) {
217 - continue;
218 - }
219 -
220 - if ( ! is_string( $value ) && ! is_array( $value ) ) {
221 - continue;
222 - }
223 -
224 - if ( 'field_options' === $key ) {
225 - // Need to loop through field_options to prevent breaking serialized string when length changed.
226 - FrmAppHelper::unserialize_or_decode( $value );
227 - $new_val = FrmFieldsHelper::switch_field_ids( $value );
228 - $new_val = serialize( $new_val );
229 - } else {
230 - $new_val = FrmFieldsHelper::switch_field_ids( $value );
231 - }
232 -
233 - if ( $new_val !== $value ) {
234 - $new_values[ $key ] = $new_val;
235 - }
236 - }//end foreach
237 -
238 - if ( ! empty( $new_values ) ) {
239 - FrmField::update( $field['id'], $new_values );
240 - }
241 - }
242 -
243 - /**
244 - * Update a form.
245 - *
246 - * @param int $id Form ID.
247 - * @param array $values Form values to update.
248 - * @param bool $create_link Whether this is being called from link creation.
249 - *
250 - * @return bool|int
251 - */
252 126 public static function update( $id, $values, $create_link = false ) {
253 127 global $wpdb;
254 128
255 129 $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) );
@@ -263,9 +137,9 @@
263 137 }
264 138
265 139 $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
266 140
267 - $new_values = self::set_update_options( array(), $values, array( 'form_id' => $id ) );
141 + $new_values = self::set_update_options( array(), $values );
268 142
269 143 foreach ( $values as $value_key => $value ) {
270 144 if ( $value_key && in_array( $value_key, $form_fields ) ) {
271 145 $new_values[ $value_key ] = $value;
@@ -271,15 +145,14 @@
271 145 $new_values[ $value_key ] = $value;
272 146 }
273 147 }
274 148
275 - if ( ! empty( $values['new_status'] ) ) {
149 + if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
276 150 $new_values['status'] = $values['new_status'];
277 151 }
278 152
279 153 if ( ! empty( $new_values ) ) {
280 154 $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) );
281 -
282 155 if ( $query_results ) {
283 156 self::clear_form_cache();
284 157 }
285 158 } else {
@@ -295,38 +168,25 @@
295 168 return $query_results;
296 169 }
297 170
298 171 /**
299 - * @param array $new_values
300 - * @param array $values
301 - * @param array $args
302 - *
303 172 * @return array
304 173 */
305 - public static function set_update_options( $new_values, $values, $args = array() ) {
174 + public static function set_update_options( $new_values, $values ) {
306 175 if ( ! isset( $values['options'] ) ) {
307 176 return $new_values;
308 177 }
309 178
310 - $options = ! empty( $values['options'] ) ? (array) $values['options'] : array();
179 + $options = isset( $values['options'] ) ? (array) $values['options'] : array();
311 180 FrmFormsHelper::fill_form_options( $options, $values );
312 181
313 - $options['custom_style'] = $values['options']['custom_style'] ?? 0;
314 - $options['before_html'] = $values['options']['before_html'] ?? FrmFormsHelper::get_default_html( 'before' );
315 - $options['after_html'] = $values['options']['after_html'] ?? FrmFormsHelper::get_default_html( 'after' );
316 - $options['submit_html'] = isset( $values['options']['submit_html'] ) && '' !== $values['options']['submit_html'] ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
182 + $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0;
183 + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
184 + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
185 + $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && '' !== $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
317 186
318 - /**
319 - * Allows modifying form options before updating or creating.
320 - *
321 - * @since 5.4 Added the third param.
322 - *
323 - * @param array $options Form options.
324 - * @param array $values Form data.
325 - * @param bool $update Is form updating or creating. It's `true` if is updating.
326 - */
327 - $options = apply_filters( 'frm_form_options_before_update', $options, $values, true );
328 - $options = self::maybe_filter_form_options( $options );
187 + $options = apply_filters( 'frm_form_options_before_update', $options, $values );
188 + $options = FrmAppHelper::maybe_filter_array( $options, array( 'submit_value', 'success_msg', 'before_html', 'after_html', 'submit_html' ) );
329 189 $new_values['options'] = serialize( $options );
330 190
331 191 return $new_values;
332 192 }
@@ -331,11 +191,8 @@
331 191 return $new_values;
332 192 }
333 193
334 194 /**
335 - * @param int $id Form ID.
336 - * @param array $values Form values array.
337 - *
338 195 * @return array
339 196 */
340 197 public static function update_fields( $id, $values ) {
341 198
@@ -343,9 +200,8 @@
343 200 return $values;
344 201 }
345 202
346 203 $all_fields = FrmField::get_all_for_form( $id );
347 -
348 204 if ( empty( $all_fields ) ) {
349 205 return $values;
350 206 }
351 207
@@ -354,9 +210,8 @@
354 210 }
355 211
356 212 $field_array = array();
357 213 $existing_keys = array_keys( $values['item_meta'] );
358 -
359 214 foreach ( $all_fields as $fid ) {
360 215 if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
361 216 $values['item_meta'][ $fid->id ] = '';
362 217 }
@@ -375,9 +230,8 @@
375 230 continue;
376 231 }
377 232
378 233 $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
379 -
380 234 if ( $is_settings_page ) {
381 235 self::get_settings_page_html( $values, $field );
382 236
383 237 if ( ! defined( 'WP_IMPORTING' ) ) {
@@ -384,20 +238,15 @@
384 238 continue;
385 239 }
386 240 }
387 241
388 - // Updating the form.
242 + //updating the form
389 243 $update_options = FrmFieldsHelper::get_default_field_options_from_field( $field );
390 - // Don't check for POST html.
391 - unset( $update_options['custom_html'] );
244 + unset( $update_options['custom_html'] ); // don't check for POST html
392 245 $update_options = apply_filters( 'frm_field_options_to_update', $update_options );
393 246
394 - if ( ! is_array( $field->field_options ) ) {
395 - $field->field_options = array();
396 - }
397 -
398 247 foreach ( $update_options as $opt => $default ) {
399 - $field->field_options[ $opt ] = $values['field_options'][ $opt . '_' . $field_id ] ?? $default;
248 + $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? $values['field_options'][ $opt . '_' . $field_id ] : $default;
400 249 self::sanitize_field_opt( $opt, $field->field_options[ $opt ] );
401 250 }
402 251
403 252 $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
@@ -406,94 +255,32 @@
406 255 'field_options' => $field->field_options,
407 256 'default_value' => isset( $values[ 'default_value_' . $field_id ] ) ? FrmAppHelper::maybe_json_encode( $values[ 'default_value_' . $field_id ] ) : '',
408 257 );
409 258
410 - if ( ! FrmAppHelper::allow_unfiltered_html() && isset( $values['field_options'][ 'options_' . $field_id ] ) && is_array( $values['field_options'][ 'options_' . $field_id ] ) ) {
411 - foreach ( $values['field_options'][ 'options_' . $field_id ] as $option_key => $option ) {
412 - if ( is_array( $option ) ) {
413 - foreach ( $option as $key => $item ) {
414 - $values['field_options'][ 'options_' . $field_id ][ $option_key ][ $key ] = FrmAppHelper::kses( $item, 'all' );
415 - }
416 - }
417 - }
418 - }
419 -
420 259 self::prepare_field_update_values( $field, $values, $new_field );
421 - self::maybe_update_max_option( $field, $values, $new_field );
422 260
423 261 FrmField::update( $field_id, $new_field );
424 262
425 263 FrmField::delete_form_transient( $field->form_id );
426 - }//end foreach
264 + }
427 265 self::clear_form_cache();
428 266
429 267 return $values;
430 268 }
431 269
432 - /**
433 - * Resets the 'max' option of a field when changing paragraph field type to other field types like text, email etc.
434 - *
435 - * @since 6.7
436 - *
437 - * @param array $field
438 - * @param array $values
439 - * @param array $new_field
440 - *
441 - * @return void
442 - */
443 - private static function maybe_update_max_option( $field, $values, &$new_field ) {
444 - if ( $field->type === 'textarea' &&
445 - ! empty( $values['field_options'][ 'type_' . $field->id ] ) &&
446 - in_array( $values['field_options'][ 'type_' . $field->id ], array( 'text', 'email', 'url', 'password', 'phone' ), true ) ) {
447 -
448 - $new_field['field_options']['max'] = '';
449 -
450 - /**
451 - * Update posted field setting so that new 'max' option is displayed after form is saved and page reloads.
452 - * FrmFieldsHelper::fill_default_field_opts populates field options by calling self::get_posted_field_setting.
453 - */
454 - $_POST['field_options'][ 'max_' . $field->id ] = '';
455 - }
456 - }
457 -
458 - /**
459 - * @param string $opt
460 - * @param mixed $value
461 - *
462 - * @return void
463 - */
464 270 private static function sanitize_field_opt( $opt, &$value ) {
465 - if ( ! is_string( $value ) ) {
466 - return;
271 + if ( is_string( $value ) ) {
272 + if ( $opt === 'calc' ) {
273 + $value = self::sanitize_calc( $value );
274 + } else {
275 + $value = FrmAppHelper::kses( $value, 'all' );
276 + }
277 + $value = trim( $value );
467 278 }
468 -
469 - /**
470 - * Allow the option to turn off sanitization for a field. This way a custom rule can be used instead.
471 - * Make sure to add custom sanitization using the frm_update_field_options filter as the data will no longer be sanitized.
472 - *
473 - * @since 6.0
474 - *
475 - * @param bool $should_sanitize
476 - * @param string $opt
477 - */
478 - $should_sanitize = apply_filters( 'frm_should_sanitize_field_opt_string', true, $opt );
479 -
480 - if ( ! $should_sanitize ) {
481 - return;
482 - }
483 -
484 - if ( $opt === 'calc' ) {
485 - $value = self::sanitize_calc( $value );
486 - } else {
487 - $value = FrmAppHelper::kses( $value, 'all' );
488 - }
489 -
490 - $value = trim( $value );
491 279 }
492 280
493 281 /**
494 282 * @param string $value
495 - *
496 283 * @return string
497 284 */
498 285 private static function sanitize_calc( $value ) {
499 286 if ( false !== strpos( $value, '<' ) ) {
@@ -498,10 +285,9 @@
498 285 private static function sanitize_calc( $value ) {
499 286 if ( false !== strpos( $value, '<' ) ) {
500 287 $value = self::normalize_calc_spaces( $value );
501 288 }
502 - // Allow <= and >=.
503 - $allow = array( '<= ', ' >=' );
289 + $allow = array( '<= ', ' >=' ); // Allow <= and >=
504 290 $temp = array( '< = ', ' > =' );
505 291 $value = str_replace( $allow, $temp, $value );
506 292 $value = strip_tags( $value );
507 293 $value = str_replace( $temp, $allow, $value );
@@ -512,44 +298,35 @@
512 298 * Format a comparison like 5<10 to 5 < 10. Also works on 5< 10, 5 <10, 5<=10 variations.
513 299 * This is to avoid an issue with unspaced calculations being recognized as HTML that gets removed when strip_tags is called.
514 300 *
515 301 * @param string $calc
516 - *
517 302 * @return string
518 303 */
519 304 private static function normalize_calc_spaces( $calc ) {
520 305 // Check for a pattern with 5 parts
521 - // $1 \d|\] the first comparison digit or the end of a comparison shortcode.
306 + // $1 \d the first comparison digit.
522 307 // $2 a space (optional).
523 308 // $3 an equals sign (optional) that follows the < operator for <= comparisons.
524 309 // $4 another space (optional).
525 - // $5 \d|\[ the second comparison digit or the start of a comparison shortcode.
526 - $calc = preg_replace( '/(\d|\])( ){0,1}<(=){0,1}( ){0,1}(\d|\[)/', '$1 <$3 $5', $calc );
527 -
528 - return $calc;
310 + // $5 \d the second comparison digit.
311 + return preg_replace( '/(\d)( ){0,1}<(=){0,1}( ){0,1}(\d)/', '$1 <$3 $5', $calc );
529 312 }
530 313
531 314 /**
532 315 * Updating the settings page
533 - *
534 - * @param array $values Form values array.
535 - * @param object $field Field object, passed by reference.
536 - *
537 - * @return void
538 316 */
539 317 private static function get_settings_page_html( $values, &$field ) {
540 318 if ( isset( $values['field_options'][ 'custom_html_' . $field->id ] ) ) {
541 319 $prev_opts = array();
542 - $fallback_html = $field->field_options['custom_html'] ?? FrmFieldsHelper::get_default_html( $field->type );
320 + $fallback_html = isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type );
543 321
544 - $field->field_options['custom_html'] = $values['field_options'][ 'custom_html_' . $field->id ] ?? $fallback_html;
545 - } elseif ( $field->type === 'hidden' || $field->type === 'user_id' ) {
322 + $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field->id ] ) ? $values['field_options'][ 'custom_html_' . $field->id ] : $fallback_html;
323 + } elseif ( $field->type == 'hidden' || $field->type == 'user_id' ) {
546 324 $prev_opts = $field->field_options;
547 325 }
548 326
549 327 if ( isset( $prev_opts ) ) {
550 328 $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
551 -
552 329 if ( $prev_opts != $field->field_options ) {
553 330 FrmField::update( $field->id, array( 'field_options' => $field->field_options ) );
554 331 }
555 332 }
@@ -554,15 +331,8 @@
554 331 }
555 332 }
556 333 }
557 334
558 - /**
559 - * @param object $field
560 - * @param array $values
561 - * @param array $new_field
562 - *
563 - * @return void
564 - */
565 335 private static function prepare_field_update_values( $field, $values, &$new_field ) {
566 336 $field_cols = array(
567 337 'field_order' => 0,
568 338 'field_key' => '',
@@ -571,16 +341,12 @@
571 341 'description' => '',
572 342 'options' => '',
573 343 'name' => '',
574 344 );
575 -
576 345 foreach ( $field_cols as $col => $default ) {
577 - $default = $default === '' ? $field->{$col} : $default;
578 - $new_field[ $col ] = $values['field_options'][ $col . '_' . $field->id ] ?? $default;
579 - }
346 + $default = ( $default === '' ) ? $field->{$col} : $default;
580 347
581 - if ( $field->type === 'submit' && isset( $new_field['field_order'] ) && (int) $new_field['field_order'] === FrmSubmitHelper::DEFAULT_ORDER ) {
582 - $new_field['field_order'] = $field->field_order;
348 + $new_field[ $col ] = isset( $values['field_options'][ $col . '_' . $field->id ] ) ? $values['field_options'][ $col . '_' . $field->id ] : $default;
583 349 }
584 350
585 351 // Don't save the template option.
586 352 if ( is_array( $new_field['options'] ) && isset( $new_field['options']['000'] ) ) {
@@ -592,12 +358,9 @@
592 358 * Get a list of all form settings that should be translated
593 359 * on a multilingual site.
594 360 *
595 361 * @since 3.06.01
596 - *
597 - * @param object $form The form object.
598 - *
599 - * @return array
362 + * @param object $form - The form object
600 363 */
601 364 public static function translatable_strings( $form ) {
602 365 $strings = array(
603 366 'name',
@@ -604,12 +367,8 @@
604 367 'description',
605 368 'submit_value',
606 369 'submit_msg',
607 370 'success_msg',
608 - 'invalid_msg',
609 - 'failed_msg',
610 - 'login_msg',
611 - 'admin_permission',
612 371 );
613 372
614 373 return apply_filters( 'frm_form_strings', $strings, $form );
615 374 }
@@ -614,12 +373,11 @@
614 373 return apply_filters( 'frm_form_strings', $strings, $form );
615 374 }
616 375
617 376 /**
618 - * @param int $id
619 377 * @param string $status
620 378 *
621 - * @return bool|int
379 + * @return int|boolean
622 380 */
623 381 public static function set_status( $id, $status ) {
624 382 if ( 'trash' == $status ) {
625 383 return self::trash( $id );
@@ -625,10 +383,9 @@
625 383 return self::trash( $id );
626 384 }
627 385
628 386 $statuses = array( 'published', 'draft', 'trash' );
629 -
630 - if ( ! in_array( $status, $statuses, true ) ) {
387 + if ( ! in_array( $status, $statuses ) ) {
631 388 return false;
632 389 }
633 390
634 391 global $wpdb;
@@ -641,9 +398,9 @@
641 398 );
642 399 FrmDb::get_where_clause_and_values( $where );
643 400 array_unshift( $where['values'], $status );
644 401
645 - $query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
402 + $query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) ); // WPCS: unprepared SQL ok.
646 403 } else {
647 404 $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) );
648 405 $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) );
649 406 }
@@ -655,11 +412,9 @@
655 412 return $query_results;
656 413 }
657 414
658 415 /**
659 - * @param int|string $id Form ID.
660 - *
661 - * @return bool|int
416 + * @return int|boolean
662 417 */
663 418 public static function trash( $id ) {
664 419 if ( ! EMPTY_TRASH_DAYS ) {
665 420 return self::destroy( $id );
@@ -665,17 +420,12 @@
665 420 return self::destroy( $id );
666 421 }
667 422
668 423 $form = self::getOne( $id );
669 -
670 424 if ( ! $form ) {
671 425 return false;
672 426 }
673 427
674 - if ( $form->status === 'trash' ) {
675 - return false;
676 - }
677 -
678 428 $options = $form->options;
679 429 $options['trash_time'] = time();
680 430
681 431 global $wpdb;
@@ -708,26 +458,21 @@
708 458 return $query_results;
709 459 }
710 460
711 461 /**
712 - * @param int|string $id Form ID.
713 - *
714 - * @return bool|int
462 + * @return int|boolean
715 463 */
716 464 public static function destroy( $id ) {
717 465 global $wpdb;
718 466
719 467 $form = self::getOne( $id );
720 -
721 468 if ( ! $form ) {
722 469 return false;
723 470 }
724 -
725 471 $id = $form->id;
726 472
727 473 // Disconnect the entries from this form
728 474 $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
729 -
730 475 foreach ( $entries as $entry_id ) {
731 476 FrmEntry::destroy( $entry_id );
732 477 unset( $entry_id );
733 478 }
@@ -735,14 +480,10 @@
735 480 // Disconnect the fields from this form
736 481 $wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) );
737 482
738 483 $query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) );
739 -
740 484 if ( $query_results ) {
741 485 // Delete all form actions linked to this form
742 - /**
743 - * @var FrmFormAction
744 - */
745 486 $action_control = FrmFormActionsController::get_form_actions( 'email' );
746 487 $action_control->destroy( $id, 'all' );
747 488
748 489 // Clear form caching
@@ -757,19 +498,17 @@
757 498
758 499 /**
759 500 * Delete trashed forms based on how long they have been trashed
760 501 *
761 - * @param int|string $delete_timestamp Timestamp cutoff for deletion.
762 - *
763 502 * @return int The number of forms deleted
764 503 */
765 504 public static function scheduled_delete( $delete_timestamp = '' ) {
766 505 global $wpdb;
767 506
768 - $trash_forms = FrmDb::get_results( $wpdb->prefix . 'frm_forms', array( 'status' => 'trash' ), 'id, parent_form_id, options' );
507 + $trash_forms = FrmDb::get_results( $wpdb->prefix . 'frm_forms', array( 'status' => 'trash' ), 'id, options' );
769 508
770 509 if ( ! $trash_forms ) {
771 - return 0;
510 + return;
772 511 }
773 512
774 513 if ( empty( $delete_timestamp ) ) {
775 514 $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
@@ -775,18 +514,13 @@
775 514 $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
776 515 }
777 516
778 517 $count = 0;
779 -
780 518 foreach ( $trash_forms as $form ) {
781 519 FrmAppHelper::unserialize_or_decode( $form->options );
782 -
783 520 if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
784 521 self::destroy( $form->id );
785 -
786 - if ( empty( $form->parent_form_id ) ) {
787 - ++$count;
788 - }
522 + $count ++;
789 523 }
790 524
791 525 unset( $form );
792 526 }
@@ -794,15 +528,12 @@
794 528 return $count;
795 529 }
796 530
797 531 /**
798 - * @param int|string $id Form ID or key.
799 - *
800 532 * @return string form name
801 533 */
802 534 public static function getName( $id ) {
803 535 $form = FrmDb::check_cache( $id, 'frm_form' );
804 -
805 536 if ( $form ) {
806 537 $r = stripslashes( $form->name );
807 538
808 539 return $r;
@@ -809,12 +540,10 @@
809 540 }
810 541
811 542 $query_key = is_numeric( $id ) ? 'id' : 'form_key';
812 543 $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
544 + $r = stripslashes( $r );
813 545
814 - // An empty form name can result in a null value.
815 - $r = is_null( $r ) ? '' : stripslashes( $r );
816 -
817 546 return $r;
818 547 }
819 548
820 549 /**
@@ -830,9 +559,9 @@
830 559
831 560 /**
832 561 * @since 3.0
833 562 *
834 - * @param int|string $id
563 + * @param int $id
835 564 *
836 565 * @return string form key
837 566 */
838 567 public static function get_key_by_id( $id ) {
@@ -837,9 +566,8 @@
837 566 */
838 567 public static function get_key_by_id( $id ) {
839 568 $id = (int) $id;
840 569 $cache = FrmDb::check_cache( $id, 'frm_form' );
841 -
842 570 if ( $cache ) {
843 571 return $cache->form_key;
844 572 }
845 573
@@ -850,13 +578,11 @@
850 578
851 579 /**
852 580 * If $form is numeric, get the form object
853 581 *
582 + * @param object|int $form
583 + *
854 584 * @since 2.0.9
855 - *
856 - * @param int|object $form
857 - *
858 - * @return void
859 585 */
860 586 public static function maybe_get_form( &$form ) {
861 587 if ( ! is_object( $form ) && ! is_array( $form ) && ! empty( $form ) ) {
862 588 $form = self::getOne( $form );
@@ -863,28 +589,27 @@
863 589 }
864 590 }
865 591
866 592 /**
867 - * @param int|string $id
868 - * @param false|int $blog_id
869 - *
870 - * @return stdClass|null
593 + * @return object form
871 594 */
872 595 public static function getOne( $id, $blog_id = false ) {
873 596 global $wpdb;
874 597
875 598 if ( $blog_id && is_multisite() ) {
876 - $prefix = $wpdb->get_blog_prefix( $blog_id );
599 + global $wpmuBaseTablePrefix;
600 + $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id );
601 +
877 602 $table_name = $prefix . 'frm_forms';
878 603 } else {
879 604 $table_name = $wpdb->prefix . 'frm_forms';
880 605 $cache = wp_cache_get( $id, 'frm_form' );
881 -
882 606 if ( $cache ) {
883 607 if ( isset( $cache->options ) ) {
884 608 FrmAppHelper::unserialize_or_decode( $cache->options );
885 609 }
886 - return self::prepare_form_row_data( $cache );
610 +
611 + return wp_unslash( $cache );
887 612 }
888 613 }
889 614
890 615 if ( is_numeric( $id ) ) {
@@ -899,49 +624,17 @@
899 624 FrmDb::set_cache( $results->id, $results, 'frm_form' );
900 625 FrmAppHelper::unserialize_or_decode( $results->options );
901 626 }
902 627
903 - return self::prepare_form_row_data( $results );
628 + return apply_filters( 'frm_form_object', wp_unslash( $results ) );
904 629 }
905 630
906 631 /**
907 - * Make sure that if $row is an object, that $row->options is an array and not a string.
908 - *
909 - * @since 6.8.3
910 - *
911 - * @param stdClass|null $row The database row for a target form.
912 - *
913 - * @return stdClass|null
632 + * @return object|array of objects
914 633 */
915 - private static function prepare_form_row_data( $row ) {
916 - $row = wp_unslash( $row );
917 -
918 - if ( ! is_object( $row ) ) {
919 - return $row;
920 - }
921 -
922 - if ( ! is_array( $row->options ) ) {
923 - $row->options = FrmFormsHelper::get_default_opts();
924 - }
925 -
926 - /**
927 - * @since 4.03.02
928 - *
929 - * @param stdClass $row
930 - */
931 - return apply_filters( 'frm_form_object', $row );
932 - }
933 -
934 - /**
935 - * @param array|string $where Where conditions array or raw WHERE string.
936 - * @param string $order_by Order by clause.
937 - * @param int|string $limit Limit clause or number.
938 - *
939 - * @return array|object of objects
940 - */
941 634 public static function getAll( $where = array(), $order_by = '', $limit = '' ) {
942 635 if ( is_array( $where ) && ! empty( $where ) ) {
943 - if ( ! empty( $where['is_template'] ) && ! isset( $where['status'] ) && ! isset( $where['status !'] ) ) {
636 + if ( isset( $where['is_template'] ) && $where['is_template'] && ! isset( $where['status'] ) && ! isset( $where['status !'] ) ) {
944 637 // don't get trashed templates
945 638 $where['status'] = array( null, '', 'published' );
946 639 }
947 640
@@ -948,11 +641,11 @@
948 641 $results = FrmDb::get_results( 'frm_forms', $where, '*', compact( 'order_by', 'limit' ) );
949 642 } else {
950 643 global $wpdb;
951 644
952 - // The query has already been prepared if this is not an array.
645 + // the query has already been prepared if this is not an array
953 646 $query = 'SELECT * FROM ' . $wpdb->prefix . 'frm_forms' . FrmDb::prepend_and_or_where( ' WHERE ', $where ) . FrmDb::esc_order( $order_by ) . FrmDb::esc_limit( $limit );
954 - $results = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
647 + $results = $wpdb->get_results( $query ); // WPCS: unprepared SQL ok.
955 648 }
956 649
957 650 if ( $results ) {
958 651 foreach ( $results as $result ) {
@@ -960,9 +653,9 @@
960 653 FrmAppHelper::unserialize_or_decode( $result->options );
961 654 }
962 655 }
963 656
964 - if ( $limit === ' LIMIT 1' || $limit == 1 ) {
657 + if ( $limit == ' LIMIT 1' || $limit == 1 ) {
965 658 // return the first form object if we are only getting one form
966 659 $results = reset( $results );
967 660 }
968 661
@@ -972,20 +665,14 @@
972 665 /**
973 666 * Get all published forms
974 667 *
975 668 * @since 2.0
976 - *
977 - * @param array $query
978 - * @param int $limit
979 - * @param string $inc_children
980 - *
981 - * @return array|object of forms A single form object would be passed if $limit was set to 1.
669 + * @return array of forms
982 670 */
983 671 public static function get_published_forms( $query = array(), $limit = 999, $inc_children = 'exclude' ) {
984 672 $query['is_template'] = 0;
985 673 $query['status'] = array( null, '', 'published' );
986 -
987 - if ( $inc_children === 'exclude' ) {
674 + if ( $inc_children == 'exclude' ) {
988 675 $query['parent_form_id'] = array( null, 0 );
989 676 }
990 677
991 678 $forms = self::getAll( $query, 'name', $limit );
@@ -1001,14 +688,13 @@
1001 688
1002 689 $cache_key = 'frm_form_counts';
1003 690
1004 691 $counts = wp_cache_get( $cache_key, 'frm_form' );
1005 -
1006 692 if ( false !== $counts ) {
1007 693 return $counts;
1008 694 }
1009 695
1010 - $results = FrmDb::get_results(
696 + $results = (array) FrmDb::get_results(
1011 697 'frm_forms',
1012 698 array(
1013 699 'or' => 1,
1014 700 'parent_form_id' => null,
@@ -1022,18 +708,18 @@
1022 708
1023 709 foreach ( $results as $row ) {
1024 710 if ( 'trash' != $row->status ) {
1025 711 if ( $row->is_template ) {
1026 - ++$counts['template'];
712 + $counts['template'] ++;
1027 713 } else {
1028 - ++$counts['published'];
714 + $counts['published'] ++;
1029 715 }
1030 716 } else {
1031 - ++$counts['trash'];
717 + $counts['trash'] ++;
1032 718 }
1033 719
1034 720 if ( 'draft' == $row->status ) {
1035 - ++$counts['draft'];
721 + $counts['draft'] ++;
1036 722 }
1037 723
1038 724 unset( $row );
1039 725 }
@@ -1049,10 +735,8 @@
1049 735 * Called when a form is created, updated, duplicated, or deleted
1050 736 * or when the form status is changed
1051 737 *
1052 738 * @since 2.0.4
1053 - *
1054 - * @return void
1055 739 */
1056 740 public static function clear_form_cache() {
1057 741 FrmDb::cache_delete_group( 'frm_form' );
1058 742 }
@@ -1057,22 +741,16 @@
1057 741 FrmDb::cache_delete_group( 'frm_form' );
1058 742 }
1059 743
1060 744 /**
1061 - * @param array $values Form values to validate.
1062 - *
1063 745 * @return array of errors
1064 746 */
1065 747 public static function validate( $values ) {
1066 748 $errors = array();
749 +
1067 750 return apply_filters( 'frm_validate_form', $errors, $values );
1068 751 }
1069 752
1070 - /**
1071 - * @param object|null $form
1072 - *
1073 - * @return array
1074 - */
1075 753 public static function get_params( $form = null ) {
1076 754 global $frm_vars;
1077 755
1078 756 if ( ! $form ) {
@@ -1084,9 +762,9 @@
1084 762 if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
1085 763 return $frm_vars['form_params'][ $form->id ];
1086 764 }
1087 765
1088 - $action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; // phpcs:ignore WordPress.Security.NonceVerification.Missing
766 + $action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; // WPCS: CSRF ok.
1089 767 $action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
1090 768
1091 769 $default_values = array(
1092 770 'id' => '',
@@ -1102,17 +780,16 @@
1102 780 );
1103 781
1104 782 $values = array();
1105 783 $values['posted_form_id'] = FrmAppHelper::get_param( 'form_id', '', 'get', 'absint' );
1106 -
1107 784 if ( ! $values['posted_form_id'] ) {
1108 785 $values['posted_form_id'] = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
1109 786 }
1110 787
1111 788 if ( $form->id == $values['posted_form_id'] ) {
1112 - // If there are two forms on the same page, make sure not to submit both.
789 + //if there are two forms on the same page, make sure not to submit both
1113 790 foreach ( $default_values as $var => $default ) {
1114 - if ( $var === 'action' ) {
791 + if ( $var == 'action' ) {
1115 792 $values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
1116 793 } else {
1117 794 $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
1118 795 }
@@ -1125,9 +802,9 @@
1125 802 }
1126 803 }
1127 804
1128 805 if ( in_array( $values['action'], array( 'create', 'update' ) ) &&
1129 - ( ! $_POST || ( ! isset( $_POST['action'] ) && ! isset( $_POST['frm_action'] ) ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
806 + ( ! $_POST || ( ! isset( $_POST['action'] ) && ! isset( $_POST['frm_action'] ) ) ) // WPCS: CSRF ok.
1130 807 ) {
1131 808 $values['action'] = 'new';
1132 809 }
1133 810
@@ -1133,11 +810,8 @@
1133 810
1134 811 return $values;
1135 812 }
1136 813
1137 - /**
1138 - * @return array
1139 - */
1140 814 public static function list_page_params() {
1141 815 $values = array();
1142 816 $defaults = array(
1143 817 'template' => 0,
@@ -1147,9 +821,8 @@
1147 821 'search' => '',
1148 822 'sort' => '',
1149 823 'sdir' => '',
1150 824 );
1151 -
1152 825 foreach ( $defaults as $var => $default ) {
1153 826 $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
1154 827 }
1155 828
@@ -1155,16 +828,10 @@
1155 828
1156 829 return $values;
1157 830 }
1158 831
1159 - /**
1160 - * @param int|object|string|null $form
1161 - *
1162 - * @return array
1163 - */
1164 832 public static function get_admin_params( $form = null ) {
1165 833 $form_id = $form;
1166 -
1167 834 if ( $form === null ) {
1168 835 $form_id = self::get_current_form_id();
1169 836 } elseif ( $form && is_object( $form ) ) {
1170 837 $form_id = $form->id;
@@ -1182,9 +849,8 @@
1182 849 'sdir' => '',
1183 850 'fid' => '',
1184 851 'keep_post' => '',
1185 852 );
1186 -
1187 853 foreach ( $defaults as $var => $default ) {
1188 854 $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
1189 855 }
1190 856
@@ -1190,39 +856,27 @@
1190 856
1191 857 return $values;
1192 858 }
1193 859
1194 - /**
1195 - * @param string $default_form
1196 - *
1197 - * @return int|string
1198 - */
1199 860 public static function get_current_form_id( $default_form = 'none' ) {
1200 - if ( 'first' === $default_form ) {
861 + if ( 'first' == $default_form ) {
1201 862 $form = self::get_current_form();
1202 863 } else {
1203 864 $form = self::maybe_get_current_form();
1204 865 }
1205 -
1206 866 $form_id = $form ? $form->id : 0;
1207 867
1208 868 return $form_id;
1209 869 }
1210 870
1211 - /**
1212 - * @param int|string $form_id
1213 - *
1214 - * @return false|int|object|string
1215 - */
1216 871 public static function maybe_get_current_form( $form_id = 0 ) {
1217 872 global $frm_vars;
1218 873
1219 - if ( ! empty( $frm_vars['current_form'] ) && ( ! $form_id || $form_id == $frm_vars['current_form']->id ) ) {
874 + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && ( ! $form_id || $form_id == $frm_vars['current_form']->id ) ) {
1220 875 return $frm_vars['current_form'];
1221 876 }
1222 877
1223 878 $form_id = FrmAppHelper::get_param( 'form', $form_id, 'get', 'absint' );
1224 -
1225 879 if ( $form_id ) {
1226 880 $form_id = self::set_current_form( $form_id );
1227 881 }
1228 882
@@ -1228,16 +882,10 @@
1228 882
1229 883 return $form_id;
1230 884 }
1231 885
1232 - /**
1233 - * @param int $form_id
1234 - *
1235 - * @return false|object
1236 - */
1237 886 public static function get_current_form( $form_id = 0 ) {
1238 887 $form = self::maybe_get_current_form( $form_id );
1239 -
1240 888 if ( is_numeric( $form ) ) {
1241 889 $form = self::set_current_form( $form );
1242 890 }
1243 891
@@ -1243,18 +891,12 @@
1243 891
1244 892 return $form;
1245 893 }
1246 894
1247 - /**
1248 - * @param int $form_id
1249 - *
1250 - * @return false|object
1251 - */
1252 895 public static function set_current_form( $form_id ) {
1253 896 global $frm_vars;
1254 897
1255 898 $query = array();
1256 -
1257 899 if ( $form_id ) {
1258 900 $query['id'] = $form_id;
1259 901 }
1260 902
@@ -1262,19 +904,11 @@
1262 904
1263 905 return $frm_vars['current_form'];
1264 906 }
1265 907
1266 - /**
1267 - * @param object $form
1268 - * @param int|string $this_load
1269 - * @param bool $global_load
1270 - *
1271 - * @return bool
1272 - */
1273 908 public static function is_form_loaded( $form, $this_load, $global_load ) {
1274 909 global $frm_vars;
1275 910 $small_form = new stdClass();
1276 -
1277 911 foreach ( array( 'id', 'form_key', 'name' ) as $var ) {
1278 912 $small_form->{$var} = $form->{$var};
1279 913 unset( $var );
1280 914 }
@@ -1285,9 +919,9 @@
1285 919 $global_load = true;
1286 920 $frm_vars['load_css'] = true;
1287 921 }
1288 922
1289 - return empty( $frm_vars['css_loaded'] ) && $global_load;
923 + return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load );
1290 924 }
1291 925
1292 926 /**
1293 927 * @since 4.06.03
@@ -1302,26 +936,13 @@
1302 936 } else {
1303 937 $visible = true;
1304 938 }
1305 939
1306 - /**
1307 - * @since 6.25
1308 - *
1309 - * @param bool $visible
1310 - * @param object $form
1311 - */
1312 - $visible = (bool) apply_filters( 'frm_form_is_visible', $visible, $form );
1313 -
1314 940 return $visible;
1315 941 }
1316 942
1317 - /**
1318 - * @param object $form
1319 - *
1320 - * @return bool
1321 - */
1322 943 public static function show_submit( $form ) {
1323 - $show = ( ! $form->is_template && $form->status === 'published' && ! FrmAppHelper::is_admin() );
944 + $show = ( ! $form->is_template && $form->status == 'published' && ! FrmAppHelper::is_admin() );
1324 945 $show = apply_filters( 'frm_show_submit_button', $show, $form );
1325 946
1326 947 return $show;
1327 948 }
@@ -1327,18 +948,14 @@
1327 948 }
1328 949
1329 950 /**
1330 951 * @since 2.3
1331 - *
1332 - * @param array $atts Attributes including form, option, and default.
1333 - *
1334 - * @return mixed
1335 952 */
1336 953 public static function get_option( $atts ) {
1337 - $form = $atts['form'];
1338 - $default = $atts['default'] ?? '';
954 + $form = $atts['form'];
955 + $default = isset( $atts['default'] ) ? $atts['default'] : '';
1339 956
1340 - return $form->options[ $atts['option'] ] ?? $default;
957 + return isset( $form->options[ $atts['option'] ] ) ? $form->options[ $atts['option'] ] : $default;
1341 958 }
1342 959
1343 960 /**
1344 961 * Get the link to edit this form.
@@ -1343,12 +960,9 @@
1343 960 /**
1344 961 * Get the link to edit this form.
1345 962 *
1346 963 * @since 4.0
1347 - *
1348 964 * @param int $form_id The id of the form.
1349 - *
1350 - * @return string
1351 965 */
1352 966 public static function get_edit_link( $form_id ) {
1353 967 return admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id );
1354 968 }
@@ -1353,67 +967,9 @@
1353 967 return admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id );
1354 968 }
1355 969
1356 970 /**
1357 - * Check if the "Submit this form with AJAX" setting is toggled on.
1358 - *
1359 - * @since 6.2
1360 - *
1361 - * @param stdClass $form
1362 - *
1363 - * @return bool
1364 - */
1365 - public static function is_ajax_on( $form ) {
1366 - return ! empty( $form->options['ajax_submit'] );
1367 - }
1368 -
1369 - /**
1370 - * Get the latest form available.
1371 - *
1372 - * @since 6.8
1373 - *
1374 - * @return object
1375 - */
1376 - public static function get_latest_form() {
1377 -
1378 - $args = array(
1379 - array(
1380 - 'or' => 1,
1381 - 'parent_form_id' => null,
1382 - 'parent_form_id <' => 1,
1383 - ),
1384 - 'is_template' => 0,
1385 - 'status !' => 'trash',
1386 - );
1387 -
1388 - return self::getAll( $args, 'created_at desc', 1 );
1389 - }
1390 -
1391 - /**
1392 - * Count and return total forms.
1393 - *
1394 - * @since 6.8
1395 - *
1396 - * @return int
1397 - */
1398 - public static function get_forms_count() {
1399 -
1400 - $args = array(
1401 - array(
1402 - 'or' => 1,
1403 - 'parent_form_id' => null,
1404 - 'parent_form_id <' => 1,
1405 - ),
1406 - 'is_template' => 0,
1407 - 'status !' => 'trash',
1408 - );
1409 -
1410 - return FrmDb::get_count( 'frm_forms', $args );
1411 - }
1412 -
1413 - /**
1414 - * @deprecated 2.03.05 This is still referenced in a few add ons (API, locations).
1415 - *
971 + * @deprecated 3.0
1416 972 * @codeCoverageIgnore
1417 973 *
1418 974 * @param string $key
1419 975 *
@@ -1419,22 +975,15 @@
1419 975 *
1420 976 * @return int form id
1421 977 */
1422 978 public static function getIdByKey( $key ) {
1423 - _deprecated_function( __FUNCTION__, '2.03.05', 'FrmForm::get_id_by_key' );
1424 - return self::get_id_by_key( $key );
979 + return FrmFormDeprecated::getIdByKey( $key );
1425 980 }
1426 981
1427 982 /**
1428 - * @deprecated 2.03.05 This is still referenced in the API add on as of v1.13.
1429 - *
983 + * @deprecated 3.0
1430 984 * @codeCoverageIgnore
1431 - *
1432 - * @param int|string $id
1433 - *
1434 - * @return string
1435 985 */
1436 986 public static function getKeyById( $id ) {
1437 - _deprecated_function( __FUNCTION__, '2.03.05', 'FrmForm::get_key_by_id' );
1438 - return self::get_key_by_id( $id );
987 + return FrmFormDeprecated::getKeyById( $id );
1439 988 }
1440 989 }