PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.12
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.12
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 +22 -46 6.256.12 View file →
@@ -17,22 +17,22 @@
17 17 $new_values = array(
18 18 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
19 19 'name' => $values['name'],
20 20 'description' => $values['description'],
21 - 'status' => $values['status'] ?? 'published',
22 - 'logged_in' => $values['logged_in'] ?? 0,
21 + 'status' => isset( $values['status'] ) ? $values['status'] : 'published',
22 + 'logged_in' => isset( $values['logged_in'] ) ? $values['logged_in'] : 0,
23 23 'is_template' => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0,
24 24 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
25 25 'editable' => isset( $values['editable'] ) ? (int) $values['editable'] : 0,
26 - 'created_at' => $values['created_at'] ?? current_time( 'mysql', 1 ),
26 + 'created_at' => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ),
27 27 );
28 28
29 29 $options = isset( $values['options'] ) ? (array) $values['options'] : array();
30 30 FrmFormsHelper::fill_form_options( $options, $values );
31 31
32 - $options['before_html'] = $values['options']['before_html'] ?? FrmFormsHelper::get_default_html( 'before' );
33 - $options['after_html'] = $values['options']['after_html'] ?? FrmFormsHelper::get_default_html( 'after' );
34 - $options['submit_html'] = $values['options']['submit_html'] ?? FrmFormsHelper::get_default_html( 'submit' );
32 + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
33 + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
34 + $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
35 35
36 36 /**
37 37 * Allows modifying form options before updating or creating.
38 38 *
@@ -279,11 +279,11 @@
279 279
280 280 $options = ! empty( $values['options'] ) ? (array) $values['options'] : array();
281 281 FrmFormsHelper::fill_form_options( $options, $values );
282 282
283 - $options['custom_style'] = $values['options']['custom_style'] ?? 0;
284 - $options['before_html'] = $values['options']['before_html'] ?? FrmFormsHelper::get_default_html( 'before' );
285 - $options['after_html'] = $values['options']['after_html'] ?? FrmFormsHelper::get_default_html( 'after' );
283 + $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0;
284 + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
285 + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
286 286 $options['submit_html'] = isset( $values['options']['submit_html'] ) && '' !== $values['options']['submit_html'] ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
287 287
288 288 /**
289 289 * Allows modifying form options before updating or creating.
@@ -354,14 +354,10 @@
354 354 // Don't check for POST html.
355 355 unset( $update_options['custom_html'] );
356 356 $update_options = apply_filters( 'frm_field_options_to_update', $update_options );
357 357
358 - if ( ! is_array( $field->field_options ) ) {
359 - $field->field_options = array();
360 - }
361 -
362 358 foreach ( $update_options as $opt => $default ) {
363 - $field->field_options[ $opt ] = $values['field_options'][ $opt . '_' . $field_id ] ?? $default;
359 + $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? $values['field_options'][ $opt . '_' . $field_id ] : $default;
364 360 self::sanitize_field_opt( $opt, $field->field_options[ $opt ] );
365 361 }
366 362
367 363 $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
@@ -477,16 +473,14 @@
477 473 * @return string
478 474 */
479 475 private static function normalize_calc_spaces( $calc ) {
480 476 // Check for a pattern with 5 parts
481 - // $1 \d|\] the first comparison digit or the end of a comparison shortcode.
477 + // $1 \d the first comparison digit.
482 478 // $2 a space (optional).
483 479 // $3 an equals sign (optional) that follows the < operator for <= comparisons.
484 480 // $4 another space (optional).
485 - // $5 \d|\[ the second comparison digit or the start of a comparison shortcode.
486 - $calc = preg_replace( '/(\d|\])( ){0,1}<(=){0,1}( ){0,1}(\d|\[)/', '$1 <$3 $5', $calc );
487 -
488 - return $calc;
481 + // $5 \d the second comparison digit.
482 + return preg_replace( '/(\d)( ){0,1}<(=){0,1}( ){0,1}(\d)/', '$1 <$3 $5', $calc );
489 483 }
490 484
491 485 /**
492 486 * Updating the settings page
@@ -493,11 +487,11 @@
493 487 */
494 488 private static function get_settings_page_html( $values, &$field ) {
495 489 if ( isset( $values['field_options'][ 'custom_html_' . $field->id ] ) ) {
496 490 $prev_opts = array();
497 - $fallback_html = $field->field_options['custom_html'] ?? FrmFieldsHelper::get_default_html( $field->type );
491 + $fallback_html = isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type );
498 492
499 - $field->field_options['custom_html'] = $values['field_options'][ 'custom_html_' . $field->id ] ?? $fallback_html;
493 + $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field->id ] ) ? $values['field_options'][ 'custom_html_' . $field->id ] : $fallback_html;
500 494 } elseif ( $field->type === 'hidden' || $field->type === 'user_id' ) {
501 495 $prev_opts = $field->field_options;
502 496 }
503 497
@@ -519,14 +513,11 @@
519 513 'options' => '',
520 514 'name' => '',
521 515 );
522 516 foreach ( $field_cols as $col => $default ) {
523 - $default = $default === '' ? $field->{$col} : $default;
524 - $new_field[ $col ] = $values['field_options'][ $col . '_' . $field->id ] ?? $default;
525 - }
517 + $default = $default === '' ? $field->{$col} : $default;
526 518
527 - if ( $field->type === 'submit' && isset( $new_field['field_order'] ) && (int) $new_field['field_order'] === FrmSubmitHelper::DEFAULT_ORDER ) {
528 - $new_field['field_order'] = $field->field_order;
519 + $new_field[ $col ] = isset( $values['field_options'][ $col . '_' . $field->id ] ) ? $values['field_options'][ $col . '_' . $field->id ] : $default;
529 520 }
530 521
531 522 // Don't save the template option.
532 523 if ( is_array( $new_field['options'] ) && isset( $new_field['options']['000'] ) ) {
@@ -609,12 +600,8 @@
609 600 if ( ! $form ) {
610 601 return false;
611 602 }
612 603
613 - if ( $form->status === 'trash' ) {
614 - return false;
615 - }
616 -
617 604 $options = $form->options;
618 605 $options['trash_time'] = time();
619 606
620 607 global $wpdb;
@@ -671,11 +658,8 @@
671 658
672 659 $query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) );
673 660 if ( $query_results ) {
674 661 // Delete all form actions linked to this form
675 - /**
676 - * @var FrmFormAction
677 - */
678 662 $action_control = FrmFormActionsController::get_form_actions( 'email' );
679 663 $action_control->destroy( $id, 'all' );
680 664
681 665 // Clear form caching
@@ -854,9 +838,9 @@
854 838 * @return array|object of objects
855 839 */
856 840 public static function getAll( $where = array(), $order_by = '', $limit = '' ) {
857 841 if ( is_array( $where ) && ! empty( $where ) ) {
858 - if ( ! empty( $where['is_template'] ) && ! isset( $where['status'] ) && ! isset( $where['status !'] ) ) {
842 + if ( isset( $where['is_template'] ) && $where['is_template'] && ! isset( $where['status'] ) && ! isset( $where['status !'] ) ) {
859 843 // don't get trashed templates
860 844 $where['status'] = array( null, '', 'published' );
861 845 }
862 846
@@ -1096,9 +1080,9 @@
1096 1080
1097 1081 public static function maybe_get_current_form( $form_id = 0 ) {
1098 1082 global $frm_vars;
1099 1083
1100 - if ( ! empty( $frm_vars['current_form'] ) && ( ! $form_id || $form_id == $frm_vars['current_form']->id ) ) {
1084 + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && ( ! $form_id || $form_id == $frm_vars['current_form']->id ) ) {
1101 1085 return $frm_vars['current_form'];
1102 1086 }
1103 1087
1104 1088 $form_id = FrmAppHelper::get_param( 'form', $form_id, 'get', 'absint' );
@@ -1145,9 +1129,9 @@
1145 1129 $global_load = true;
1146 1130 $frm_vars['load_css'] = true;
1147 1131 }
1148 1132
1149 - return empty( $frm_vars['css_loaded'] ) && $global_load;
1133 + return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load );
1150 1134 }
1151 1135
1152 1136 /**
1153 1137 * @since 4.06.03
@@ -1162,16 +1146,8 @@
1162 1146 } else {
1163 1147 $visible = true;
1164 1148 }
1165 1149
1166 - /**
1167 - * @since 6.25
1168 - *
1169 - * @param bool $visible
1170 - * @param object $form
1171 - */
1172 - $visible = (bool) apply_filters( 'frm_form_is_visible', $visible, $form );
1173 -
1174 1150 return $visible;
1175 1151 }
1176 1152
1177 1153 public static function show_submit( $form ) {
@@ -1185,11 +1161,11 @@
1185 1161 * @since 2.3
1186 1162 */
1187 1163 public static function get_option( $atts ) {
1188 1164 $form = $atts['form'];
1189 - $default = $atts['default'] ?? '';
1165 + $default = isset( $atts['default'] ) ? $atts['default'] : '';
1190 1166
1191 - return $form->options[ $atts['option'] ] ?? $default;
1167 + return isset( $form->options[ $atts['option'] ] ) ? $form->options[ $atts['option'] ] : $default;
1192 1168 }
1193 1169
1194 1170 /**
1195 1171 * Get the link to edit this form.