PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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 +31 -27 6.28 → trunk View file →
@@ -16,9 +16,9 @@
16 16 $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) );
17 17
18 18 $new_values = array(
19 19 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
20 - 'name' => $values['name'],
20 + 'name' => FrmAppHelper::truncate( $values['name'], 255, 1, '', true ),
21 21 'description' => $values['description'],
22 22 'status' => $values['status'] ?? 'published',
23 23 'logged_in' => $values['logged_in'] ?? 0,
24 24 'is_template' => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0,
@@ -165,8 +165,10 @@
165 165 /**
166 166 * Switches field ID in fields.
167 167 *
168 168 * @since 5.3
169 + * @since 6.35 The description column is checked too, so a field id in a description survives a
170 + * duplicate or import when the field it points at is created afterwards.
169 171 *
170 172 * @param int $form_id Form ID.
171 173 *
172 174 * @return void
@@ -174,9 +176,9 @@
174 176 private static function switch_field_ids_in_fields( $form_id ) {
175 177 global $wpdb;
176 178
177 179 // Keys of fields that you want to check to replace field ID.
178 - $keys = array( 'default_value', 'field_options' );
180 + $keys = array( 'default_value', 'description', 'field_options' );
179 181 $sql_cols = 'fi.id';
180 182
181 183 foreach ( $keys as $key ) {
182 184 $sql_cols .= ',fi.' . $key;
@@ -267,9 +269,9 @@
267 269 $new_values = self::set_update_options( array(), $values, array( 'form_id' => $id ) );
268 270
269 271 foreach ( $values as $value_key => $value ) {
270 272 if ( $value_key && in_array( $value_key, $form_fields, true ) ) {
271 - $new_values[ $value_key ] = $value;
273 + $new_values[ $value_key ] = 'name' === $value_key ? FrmAppHelper::truncate( $value, 255, 1, '', true ) : $value;
272 274 }
273 275 }
274 276
275 277 if ( ! empty( $values['new_status'] ) ) {
@@ -406,13 +408,15 @@
406 408 );
407 409
408 410 if ( ! FrmAppHelper::allow_unfiltered_html() && isset( $values['field_options'][ 'options_' . $field_id ] ) && is_array( $values['field_options'][ 'options_' . $field_id ] ) ) { // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
409 411 foreach ( $values['field_options'][ 'options_' . $field_id ] as $option_key => $option ) {
410 - if ( is_array( $option ) ) {
411 - foreach ( $option as $key => $item ) {
412 - $values['field_options'][ 'options_' . $field_id ][ $option_key ][ $key ] = FrmAppHelper::kses( $item, 'all' );
413 - }
412 + if ( ! is_array( $option ) ) {
413 + continue;
414 414 }
415 +
416 + foreach ( $option as $key => $item ) {
417 + $values['field_options'][ 'options_' . $field_id ][ $option_key ][ $key ] = FrmAppHelper::kses( $item, 'all' );
418 + }
415 419 }
416 420 }
417 421
418 422 self::prepare_field_update_values( $field, $values, $new_field );
@@ -438,19 +442,21 @@
438 442 *
439 443 * @return void
440 444 */
441 445 private static function maybe_update_max_option( $field, $values, &$new_field ) {
442 - if ( $field->type === 'textarea' &&
443 - ! empty( $values['field_options'][ 'type_' . $field->id ] ) &&
444 - in_array( $values['field_options'][ 'type_' . $field->id ], array( 'text', 'email', 'url', 'password', 'phone' ), true ) ) {
445 - $new_field['field_options']['max'] = '';
446 + if ( $field->type !== 'textarea' ||
447 + empty( $values['field_options'][ 'type_' . $field->id ] ) ||
448 + ! in_array( $values['field_options'][ 'type_' . $field->id ], array( 'text', 'email', 'url', 'password', 'phone' ), true ) ) {
449 + return;
450 + }
446 451
447 - /**
448 - * Update posted field setting so that new 'max' option is displayed after form is saved and page reloads.
449 - * FrmFieldsHelper::fill_default_field_opts populates field options by calling self::get_posted_field_setting.
450 - */
451 - $_POST['field_options'][ 'max_' . $field->id ] = '';
452 - }
452 + $new_field['field_options']['max'] = '';
453 +
454 + /**
455 + * Update posted field setting so that new 'max' option is displayed after form is saved and page reloads.
456 + * FrmFieldsHelper::fill_default_field_opts populates field options by calling self::get_posted_field_setting.
457 + */
458 + $_POST['field_options'][ 'max_' . $field->id ] = '';
453 459 }
454 460
455 461 /**
456 462 * @param string $opt
@@ -997,16 +1003,14 @@
997 1003 $statuses = array( 'published', 'draft', 'template', 'trash' );
998 1004 $counts = array_fill_keys( $statuses, 0 );
999 1005
1000 1006 foreach ( $results as $row ) {
1001 - if ( 'trash' !== $row->status ) {
1002 - if ( $row->is_template ) {
1003 - ++$counts['template'];
1004 - } else {
1005 - ++$counts['published'];
1006 - }
1007 + if ( 'trash' === $row->status ) {
1008 + ++$counts['trash'];
1009 + } elseif ( $row->is_template ) {
1010 + ++$counts['template'];
1007 1011 } else {
1008 - ++$counts['trash'];
1012 + ++$counts['published'];
1009 1013 }
1010 1014
1011 1015 if ( 'draft' === $row->status ) {
1012 1016 ++$counts['draft'];
@@ -1051,12 +1055,12 @@
1051 1055 */
1052 1056 public static function get_params( $form = null ) {
1053 1057 global $frm_vars;
1054 1058
1055 - if ( ! $form ) {
1059 + if ( $form ) {
1060 + self::maybe_get_form( $form );
1061 + } else {
1056 1062 $form = self::getAll( array(), 'name', 1 );
1057 - } else {
1058 - self::maybe_get_form( $form );
1059 1063 }
1060 1064
1061 1065 if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
1062 1066 return $frm_vars['form_params'][ $form->id ];