@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | * @return void |
| 57 | 57 | */ |
| 58 | 58 | private static function flag_new_unique_key( $unique_id ) { |
| 59 | - if ( ! isset( self::$unique_id_match_checks[ $unique_id ] ) ) { |
|
| 60 | - self::$unique_id_match_checks[ $unique_id ] = false; |
|
| 59 | + if ( ! isset( self::$unique_id_match_checks[$unique_id] ) ) { |
|
| 60 | + self::$unique_id_match_checks[$unique_id] = false; |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | if ( 0 === (int) $meta->field_id ) { |
| 110 | 110 | continue; |
| 111 | 111 | } |
| 112 | - $field_metas[ $meta->field_id ] = $meta->meta_value; |
|
| 112 | + $field_metas[$meta->field_id] = $meta->meta_value; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $filtered_vals = array_filter( $values['item_meta'] ); |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | return false; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if ( isset( self::$unique_id_match_checks[ $unique_id ] ) ) { |
|
| 178 | - return self::$unique_id_match_checks[ $unique_id ]; |
|
| 177 | + if ( isset( self::$unique_id_match_checks[$unique_id] ) ) { |
|
| 178 | + return self::$unique_id_match_checks[$unique_id]; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | $timestamp = strtotime( $created_at ); |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $timestamp = time(); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - self::$unique_id_match_checks[ $unique_id ] = (bool) FrmDb::get_var( |
|
| 186 | + self::$unique_id_match_checks[$unique_id] = (bool) FrmDb::get_var( |
|
| 187 | 187 | 'frm_item_metas', |
| 188 | 188 | array( |
| 189 | 189 | 'field_id' => 0, |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | 'id' |
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | - return self::$unique_id_match_checks[ $unique_id ]; |
|
| 196 | + return self::$unique_id_match_checks[$unique_id]; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -223,10 +223,10 @@ discard block |
||
| 223 | 223 | $reduced = array(); |
| 224 | 224 | foreach ( $filter_vals as $field_id => $value ) { |
| 225 | 225 | $field = FrmFieldFactory::get_field_object( $field_id ); |
| 226 | - $reduced[ $field_id ] = $field->get_value_to_save( $value, array( 'entry_id' => $entry_id ) ); |
|
| 227 | - $reduced[ $field_id ] = $field->set_value_before_save( $reduced[ $field_id ] ); |
|
| 228 | - if ( '' === $reduced[ $field_id ] || ( is_array( $reduced[ $field_id ] ) && 0 === count( $reduced[ $field_id ] ) ) ) { |
|
| 229 | - unset( $reduced[ $field_id ] ); |
|
| 226 | + $reduced[$field_id] = $field->get_value_to_save( $value, array( 'entry_id' => $entry_id ) ); |
|
| 227 | + $reduced[$field_id] = $field->set_value_before_save( $reduced[$field_id] ); |
|
| 228 | + if ( '' === $reduced[$field_id] || ( is_array( $reduced[$field_id] ) && 0 === count( $reduced[$field_id] ) ) ) { |
|
| 229 | + unset( $reduced[$field_id] ); |
|
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | return $reduced; |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | private static function prepare_entries( &$entries ) { |
| 490 | 490 | foreach ( $entries as $k => $entry ) { |
| 491 | 491 | self::prepare_entry( $entry ); |
| 492 | - $entries[ $k ] = $entry; |
|
| 492 | + $entries[$k] = $entry; |
|
| 493 | 493 | } |
| 494 | 494 | } |
| 495 | 495 | |
@@ -515,19 +515,19 @@ discard block |
||
| 515 | 515 | FrmFieldsHelper::prepare_field_value( $meta_val->meta_value, $meta_val->type ); |
| 516 | 516 | |
| 517 | 517 | if ( $meta_val->item_id == $entry->id ) { |
| 518 | - $entry->metas[ $meta_val->field_id ] = $meta_val->meta_value; |
|
| 518 | + $entry->metas[$meta_val->field_id] = $meta_val->meta_value; |
|
| 519 | 519 | if ( $include_key ) { |
| 520 | - $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ]; |
|
| 520 | + $entry->metas[$meta_val->field_key] = $entry->metas[$meta_val->field_id]; |
|
| 521 | 521 | } |
| 522 | 522 | continue; |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | // include sub entries in an array |
| 526 | - if ( ! isset( $entry->metas[ $meta_val->field_id ] ) ) { |
|
| 527 | - $entry->metas[ $meta_val->field_id ] = array(); |
|
| 526 | + if ( ! isset( $entry->metas[$meta_val->field_id] ) ) { |
|
| 527 | + $entry->metas[$meta_val->field_id] = array(); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - $entry->metas[ $meta_val->field_id ][] = $meta_val->meta_value; |
|
| 530 | + $entry->metas[$meta_val->field_id][] = $meta_val->meta_value; |
|
| 531 | 531 | |
| 532 | 532 | unset( $meta_val ); |
| 533 | 533 | } |
@@ -622,16 +622,16 @@ discard block |
||
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | foreach ( $metas as $m_key => $meta_val ) { |
| 625 | - if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
| 625 | + if ( ! isset( $entries[$meta_val->item_id] ) ) { |
|
| 626 | 626 | continue; |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | - if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
| 630 | - $entries[ $meta_val->item_id ]->metas = array(); |
|
| 629 | + if ( ! isset( $entries[$meta_val->item_id]->metas ) ) { |
|
| 630 | + $entries[$meta_val->item_id]->metas = array(); |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | FrmFieldsHelper::prepare_field_value( $meta_val->meta_value, $meta_val->type ); |
| 634 | - $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = $meta_val->meta_value; |
|
| 634 | + $entries[$meta_val->item_id]->metas[$meta_val->field_id] = $meta_val->meta_value; |
|
| 635 | 635 | unset( $m_key, $meta_val ); |
| 636 | 636 | } |
| 637 | 637 | |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | } |
| 815 | 815 | |
| 816 | 816 | private static function get_entry_value( $values, $name, $default ) { |
| 817 | - return $values[ $name ] ?? $default; |
|
| 817 | + return $values[$name] ?? $default; |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | /** |
@@ -1021,7 +1021,7 @@ discard block |
||
| 1021 | 1021 | private static function maybe_add_captcha_meta( $form_id, $entry_id ) { |
| 1022 | 1022 | global $frm_vars; |
| 1023 | 1023 | if ( array_key_exists( 'captcha_scores', $frm_vars ) && array_key_exists( $form_id, $frm_vars['captcha_scores'] ) ) { |
| 1024 | - $captcha_score_meta = array( 'captcha_score' => $frm_vars['captcha_scores'][ $form_id ] ); |
|
| 1024 | + $captcha_score_meta = array( 'captcha_score' => $frm_vars['captcha_scores'][$form_id] ); |
|
| 1025 | 1025 | FrmEntryMeta::add_entry_meta( $entry_id, 0, '', maybe_serialize( $captcha_score_meta ) ); |
| 1026 | 1026 | } |
| 1027 | 1027 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | if ( $new_val !== $value ) { |
| 212 | - $new_values[ $key ] = $new_val; |
|
| 212 | + $new_values[$key] = $new_val; |
|
| 213 | 213 | } |
| 214 | 214 | }//end foreach |
| 215 | 215 | |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | foreach ( $values as $value_key => $value ) { |
| 242 | 242 | if ( $value_key && in_array( $value_key, $form_fields ) ) { |
| 243 | - $new_values[ $value_key ] = $value; |
|
| 243 | + $new_values[$value_key] = $value; |
|
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | |
@@ -323,15 +323,15 @@ discard block |
||
| 323 | 323 | $existing_keys = array_keys( $values['item_meta'] ); |
| 324 | 324 | foreach ( $all_fields as $fid ) { |
| 325 | 325 | if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) { |
| 326 | - $values['item_meta'][ $fid->id ] = ''; |
|
| 326 | + $values['item_meta'][$fid->id] = ''; |
|
| 327 | 327 | } |
| 328 | - $field_array[ $fid->id ] = $fid; |
|
| 328 | + $field_array[$fid->id] = $fid; |
|
| 329 | 329 | } |
| 330 | 330 | unset( $all_fields ); |
| 331 | 331 | |
| 332 | 332 | foreach ( $values['item_meta'] as $field_id => $default_value ) { |
| 333 | - if ( isset( $field_array[ $field_id ] ) ) { |
|
| 334 | - $field = $field_array[ $field_id ]; |
|
| 333 | + if ( isset( $field_array[$field_id] ) ) { |
|
| 334 | + $field = $field_array[$field_id]; |
|
| 335 | 335 | } else { |
| 336 | 336 | $field = FrmField::getOne( $field_id ); |
| 337 | 337 | } |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | continue; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ); |
|
| 343 | + $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) ); |
|
| 344 | 344 | if ( $is_settings_page ) { |
| 345 | 345 | self::get_settings_page_html( $values, $field ); |
| 346 | 346 | |
@@ -356,22 +356,22 @@ discard block |
||
| 356 | 356 | $update_options = apply_filters( 'frm_field_options_to_update', $update_options ); |
| 357 | 357 | |
| 358 | 358 | foreach ( $update_options as $opt => $default ) { |
| 359 | - $field->field_options[ $opt ] = $values['field_options'][ $opt . '_' . $field_id ] ?? $default; |
|
| 360 | - self::sanitize_field_opt( $opt, $field->field_options[ $opt ] ); |
|
| 359 | + $field->field_options[$opt] = $values['field_options'][$opt . '_' . $field_id] ?? $default; |
|
| 360 | + self::sanitize_field_opt( $opt, $field->field_options[$opt] ); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values ); |
| 364 | 364 | |
| 365 | 365 | $new_field = array( |
| 366 | 366 | 'field_options' => $field->field_options, |
| 367 | - 'default_value' => isset( $values[ 'default_value_' . $field_id ] ) ? FrmAppHelper::maybe_json_encode( $values[ 'default_value_' . $field_id ] ) : '', |
|
| 367 | + 'default_value' => isset( $values['default_value_' . $field_id] ) ? FrmAppHelper::maybe_json_encode( $values['default_value_' . $field_id] ) : '', |
|
| 368 | 368 | ); |
| 369 | 369 | |
| 370 | - if ( ! FrmAppHelper::allow_unfiltered_html() && isset( $values['field_options'][ 'options_' . $field_id ] ) && is_array( $values['field_options'][ 'options_' . $field_id ] ) ) { |
|
| 371 | - foreach ( $values['field_options'][ 'options_' . $field_id ] as $option_key => $option ) { |
|
| 370 | + if ( ! FrmAppHelper::allow_unfiltered_html() && isset( $values['field_options']['options_' . $field_id] ) && is_array( $values['field_options']['options_' . $field_id] ) ) { |
|
| 371 | + foreach ( $values['field_options']['options_' . $field_id] as $option_key => $option ) { |
|
| 372 | 372 | if ( is_array( $option ) ) { |
| 373 | 373 | foreach ( $option as $key => $item ) { |
| 374 | - $values['field_options'][ 'options_' . $field_id ][ $option_key ][ $key ] = FrmAppHelper::kses( $item, 'all' ); |
|
| 374 | + $values['field_options']['options_' . $field_id][$option_key][$key] = FrmAppHelper::kses( $item, 'all' ); |
|
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | } |
@@ -401,8 +401,8 @@ discard block |
||
| 401 | 401 | */ |
| 402 | 402 | private static function maybe_update_max_option( $field, $values, &$new_field ) { |
| 403 | 403 | if ( $field->type === 'textarea' && |
| 404 | - ! empty( $values['field_options'][ 'type_' . $field->id ] ) && |
|
| 405 | - in_array( $values['field_options'][ 'type_' . $field->id ], array( 'text', 'email', 'url', 'password', 'phone' ), true ) ) { |
|
| 404 | + ! empty( $values['field_options']['type_' . $field->id] ) && |
|
| 405 | + in_array( $values['field_options']['type_' . $field->id], array( 'text', 'email', 'url', 'password', 'phone' ), true ) ) { |
|
| 406 | 406 | |
| 407 | 407 | $new_field['field_options']['max'] = ''; |
| 408 | 408 | |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | * Update posted field setting so that new 'max' option is displayed after form is saved and page reloads. |
| 411 | 411 | * FrmFieldsHelper::fill_default_field_opts populates field options by calling self::get_posted_field_setting. |
| 412 | 412 | */ |
| 413 | - $_POST['field_options'][ 'max_' . $field->id ] = ''; |
|
| 413 | + $_POST['field_options']['max_' . $field->id] = ''; |
|
| 414 | 414 | } |
| 415 | 415 | } |
| 416 | 416 | |
@@ -488,11 +488,11 @@ discard block |
||
| 488 | 488 | * Updating the settings page |
| 489 | 489 | */ |
| 490 | 490 | private static function get_settings_page_html( $values, &$field ) { |
| 491 | - if ( isset( $values['field_options'][ 'custom_html_' . $field->id ] ) ) { |
|
| 491 | + if ( isset( $values['field_options']['custom_html_' . $field->id] ) ) { |
|
| 492 | 492 | $prev_opts = array(); |
| 493 | 493 | $fallback_html = $field->field_options['custom_html'] ?? FrmFieldsHelper::get_default_html( $field->type ); |
| 494 | 494 | |
| 495 | - $field->field_options['custom_html'] = $values['field_options'][ 'custom_html_' . $field->id ] ?? $fallback_html; |
|
| 495 | + $field->field_options['custom_html'] = $values['field_options']['custom_html_' . $field->id] ?? $fallback_html; |
|
| 496 | 496 | } elseif ( $field->type === 'hidden' || $field->type === 'user_id' ) { |
| 497 | 497 | $prev_opts = $field->field_options; |
| 498 | 498 | } |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | ); |
| 518 | 518 | foreach ( $field_cols as $col => $default ) { |
| 519 | 519 | $default = $default === '' ? $field->{$col} : $default; |
| 520 | - $new_field[ $col ] = $values['field_options'][ $col . '_' . $field->id ] ?? $default; |
|
| 520 | + $new_field[$col] = $values['field_options'][$col . '_' . $field->id] ?? $default; |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | if ( $field->type === 'submit' && isset( $new_field['field_order'] ) && (int) $new_field['field_order'] === FrmSubmitHelper::DEFAULT_ORDER ) { |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) { |
| 709 | 709 | self::destroy( $form->id ); |
| 710 | 710 | if ( empty( $form->parent_form_id ) ) { |
| 711 | - ++$count; |
|
| 711 | + ++ $count; |
|
| 712 | 712 | } |
| 713 | 713 | } |
| 714 | 714 | |
@@ -931,16 +931,16 @@ discard block |
||
| 931 | 931 | foreach ( $results as $row ) { |
| 932 | 932 | if ( 'trash' != $row->status ) { |
| 933 | 933 | if ( $row->is_template ) { |
| 934 | - ++$counts['template']; |
|
| 934 | + ++ $counts['template']; |
|
| 935 | 935 | } else { |
| 936 | - ++$counts['published']; |
|
| 936 | + ++ $counts['published']; |
|
| 937 | 937 | } |
| 938 | 938 | } else { |
| 939 | - ++$counts['trash']; |
|
| 939 | + ++ $counts['trash']; |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | if ( 'draft' == $row->status ) { |
| 943 | - ++$counts['draft']; |
|
| 943 | + ++ $counts['draft']; |
|
| 944 | 944 | } |
| 945 | 945 | |
| 946 | 946 | unset( $row ); |
@@ -981,8 +981,8 @@ discard block |
||
| 981 | 981 | self::maybe_get_form( $form ); |
| 982 | 982 | } |
| 983 | 983 | |
| 984 | - if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) { |
|
| 985 | - return $frm_vars['form_params'][ $form->id ]; |
|
| 984 | + if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) { |
|
| 985 | + return $frm_vars['form_params'][$form->id]; |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | $action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; // phpcs:ignore WordPress.Security.NonceVerification.Missing |
@@ -1011,15 +1011,15 @@ discard block |
||
| 1011 | 1011 | // If there are two forms on the same page, make sure not to submit both. |
| 1012 | 1012 | foreach ( $default_values as $var => $default ) { |
| 1013 | 1013 | if ( $var === 'action' ) { |
| 1014 | - $values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
| 1014 | + $values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
| 1015 | 1015 | } else { |
| 1016 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 1016 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 1017 | 1017 | } |
| 1018 | 1018 | unset( $var, $default ); |
| 1019 | 1019 | } |
| 1020 | 1020 | } else { |
| 1021 | 1021 | foreach ( $default_values as $var => $default ) { |
| 1022 | - $values[ $var ] = $default; |
|
| 1022 | + $values[$var] = $default; |
|
| 1023 | 1023 | unset( $var, $default ); |
| 1024 | 1024 | } |
| 1025 | 1025 | } |
@@ -1045,7 +1045,7 @@ discard block |
||
| 1045 | 1045 | 'sdir' => '', |
| 1046 | 1046 | ); |
| 1047 | 1047 | foreach ( $defaults as $var => $default ) { |
| 1048 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 1048 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | return $values; |
@@ -1073,7 +1073,7 @@ discard block |
||
| 1073 | 1073 | 'keep_post' => '', |
| 1074 | 1074 | ); |
| 1075 | 1075 | foreach ( $defaults as $var => $default ) { |
| 1076 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 1076 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | 1079 | return $values; |
@@ -1176,7 +1176,7 @@ discard block |
||
| 1176 | 1176 | $form = $atts['form']; |
| 1177 | 1177 | $default = $atts['default'] ?? ''; |
| 1178 | 1178 | |
| 1179 | - return $form->options[ $atts['option'] ] ?? $default; |
|
| 1179 | + return $form->options[$atts['option']] ?? $default; |
|
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @return void |
| 60 | 60 | */ |
| 61 | 61 | public function set( $key, $value ) { |
| 62 | - $this->state[ $key ] = $value; |
|
| 62 | + $this->state[$key] = $value; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | public function get( $key, $default ) { |
| 78 | - return $this->state[ $key ] ?? $default; |
|
| 78 | + return $this->state[$key] ?? $default; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | private function compressed_state() { |
| 187 | 187 | $compressed = array(); |
| 188 | 188 | foreach ( $this->state as $key => $value ) { |
| 189 | - $compressed[ self::compressed_key( $key ) ] = $value; |
|
| 189 | + $compressed[self::compressed_key( $key )] = $value; |
|
| 190 | 190 | } |
| 191 | 191 | return $compressed; |
| 192 | 192 | } |
@@ -239,8 +239,8 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | foreach ( $settings as $setting => $default ) { |
| 242 | - if ( isset( $params[ 'frm_' . $setting ] ) ) { |
|
| 243 | - $this->{$setting} = $params[ 'frm_' . $setting ]; |
|
| 242 | + if ( isset( $params['frm_' . $setting] ) ) { |
|
| 243 | + $this->{$setting} = $params['frm_' . $setting]; |
|
| 244 | 244 | } elseif ( ! isset( $this->{$setting} ) ) { |
| 245 | 245 | $this->{$setting} = $default; |
| 246 | 246 | } |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | 'denylist_check', |
| 433 | 433 | ); |
| 434 | 434 | foreach ( $checkboxes as $set ) { |
| 435 | - $this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0; |
|
| 435 | + $this->$set = isset( $params['frm_' . $set] ) ? absint( $params['frm_' . $set] ) : 0; |
|
| 436 | 436 | } |
| 437 | 437 | } |
| 438 | 438 | |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | $frm_roles = FrmAppHelper::frm_capabilities(); |
| 446 | 446 | $roles = get_editable_roles(); |
| 447 | 447 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 448 | - $this->$frm_role = (array) ( $params[ $frm_role ] ?? 'administrator' ); |
|
| 448 | + $this->$frm_role = (array) ( $params[$frm_role] ?? 'administrator' ); |
|
| 449 | 449 | |
| 450 | 450 | // Make sure administrators always have permissions |
| 451 | 451 | if ( ! in_array( 'administrator', $this->$frm_role, true ) ) { |
@@ -208,9 +208,9 @@ discard block |
||
| 208 | 208 | $groups = FrmFormActionsController::form_action_groups(); |
| 209 | 209 | $group = 'misc'; |
| 210 | 210 | |
| 211 | - if ( isset( $action_options['group'] ) && isset( $groups[ $action_options['group'] ] ) ) { |
|
| 211 | + if ( isset( $action_options['group'] ) && isset( $groups[$action_options['group']] ) ) { |
|
| 212 | 212 | $group = $action_options['group']; |
| 213 | - } elseif ( isset( $groups[ $this->id_base ] ) ) { |
|
| 213 | + } elseif ( isset( $groups[$this->id_base] ) ) { |
|
| 214 | 214 | $group = $this->id_base; |
| 215 | 215 | } else { |
| 216 | 216 | foreach ( $groups as $name => $check_group ) { |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - $groups[ $group ]['id'] = $group; |
|
| 225 | - return $groups[ $group ]; |
|
| 224 | + $groups[$group]['id'] = $group; |
|
| 225 | + return $groups[$group]; |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | * @return int $post_id |
| 334 | 334 | */ |
| 335 | 335 | public function maybe_create_action( $action, $forms ) { |
| 336 | - if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[ $action['menu_order'] ] ) && $forms[ $action['menu_order'] ] === 'updated' ) { |
|
| 336 | + if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[$action['menu_order']] ) && $forms[$action['menu_order']] === 'updated' ) { |
|
| 337 | 337 | // Update action only |
| 338 | 338 | $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
| 339 | 339 | $post_id = $this->save_settings( $action ); |
@@ -356,18 +356,18 @@ discard block |
||
| 356 | 356 | $switch = $this->get_global_switch_fields(); |
| 357 | 357 | |
| 358 | 358 | foreach ( (array) $action->post_content as $key => $val ) { |
| 359 | - if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) { |
|
| 360 | - $action->post_content[ $key ] = $frm_duplicate_ids[ $val ]; |
|
| 359 | + if ( is_numeric( $val ) && isset( $frm_duplicate_ids[$val] ) ) { |
|
| 360 | + $action->post_content[$key] = $frm_duplicate_ids[$val]; |
|
| 361 | 361 | } elseif ( ! is_array( $val ) ) { |
| 362 | - $action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val ); |
|
| 363 | - } elseif ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) { |
|
| 362 | + $action->post_content[$key] = FrmFieldsHelper::switch_field_ids( $val ); |
|
| 363 | + } elseif ( isset( $switch[$key] ) && is_array( $switch[$key] ) ) { |
|
| 364 | 364 | // loop through each value if empty |
| 365 | - if ( empty( $switch[ $key ] ) ) { |
|
| 366 | - $switch[ $key ] = array_keys( $val ); |
|
| 365 | + if ( empty( $switch[$key] ) ) { |
|
| 366 | + $switch[$key] = array_keys( $val ); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - foreach ( $switch[ $key ] as $subkey ) { |
|
| 370 | - $action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val ); |
|
| 369 | + foreach ( $switch[$key] as $subkey ) { |
|
| 370 | + $action->post_content[$key] = $this->duplicate_array_walk( $action->post_content[$key], $subkey, $val ); |
|
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | 373 | |
@@ -385,20 +385,20 @@ discard block |
||
| 385 | 385 | foreach ( $subkey as $subkey2 ) { |
| 386 | 386 | foreach ( (array) $val as $ck => $cv ) { |
| 387 | 387 | if ( is_array( $cv ) ) { |
| 388 | - $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv ); |
|
| 389 | - } elseif ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) { |
|
| 390 | - $action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ]; |
|
| 388 | + $action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey2, $cv ); |
|
| 389 | + } elseif ( isset( $cv[$subkey] ) && is_numeric( $cv[$subkey] ) && isset( $frm_duplicate_ids[$cv[$subkey]] ) ) { |
|
| 390 | + $action[$ck][$subkey] = $frm_duplicate_ids[$cv[$subkey]]; |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | 394 | } else { |
| 395 | 395 | foreach ( (array) $val as $ck => $cv ) { |
| 396 | 396 | if ( is_array( $cv ) ) { |
| 397 | - $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv ); |
|
| 398 | - } elseif ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) { |
|
| 399 | - $action[ $ck ] = $frm_duplicate_ids[ $cv ]; |
|
| 397 | + $action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey, $cv ); |
|
| 398 | + } elseif ( $ck == $subkey && isset( $frm_duplicate_ids[$cv] ) ) { |
|
| 399 | + $action[$ck] = $frm_duplicate_ids[$cv]; |
|
| 400 | 400 | } elseif ( $ck == $subkey ) { |
| 401 | - $action[ $ck ] = $this->maybe_switch_field_ids( $action[ $ck ] ); |
|
| 401 | + $action[$ck] = $this->maybe_switch_field_ids( $action[$ck] ); |
|
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | }//end if |
@@ -422,10 +422,10 @@ discard block |
||
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 425 | - if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) { |
|
| 425 | + if ( isset( $_POST[$this->option_name] ) && is_array( $_POST[$this->option_name] ) ) { |
|
| 426 | 426 | // Sanitizing removes scripts and <email> type of values. |
| 427 | 427 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing |
| 428 | - $settings = wp_unslash( $_POST[ $this->option_name ] ); |
|
| 428 | + $settings = wp_unslash( $_POST[$this->option_name] ); |
|
| 429 | 429 | } else { |
| 430 | 430 | return; |
| 431 | 431 | } |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | foreach ( $settings as $number => $new_instance ) { |
| 436 | 436 | $this->_set( $number ); |
| 437 | 437 | |
| 438 | - $old_instance = $all_instances[ $number ] ?? array(); |
|
| 438 | + $old_instance = $all_instances[$number] ?? array(); |
|
| 439 | 439 | |
| 440 | 440 | if ( ! isset( $new_instance['post_status'] ) ) { |
| 441 | 441 | $new_instance['post_status'] = 'draft'; |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | $instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this ); |
| 475 | 475 | |
| 476 | 476 | if ( false !== $instance ) { |
| 477 | - $all_instances[ $number ] = $instance; |
|
| 477 | + $all_instances[$number] = $instance; |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | $action_ids[] = $this->save_settings( $instance ); |
@@ -563,12 +563,12 @@ discard block |
||
| 563 | 563 | // some plugins/themes are formatting the post_excerpt |
| 564 | 564 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
| 565 | 565 | |
| 566 | - if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) { |
|
| 566 | + if ( ! isset( $action_controls[$action->post_excerpt] ) ) { |
|
| 567 | 567 | continue; |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | - $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action ); |
|
| 571 | - $settings[ $action->ID ] = $action; |
|
| 570 | + $action = $action_controls[$action->post_excerpt]->prepare_action( $action ); |
|
| 571 | + $settings[$action->ID] = $action; |
|
| 572 | 572 | |
| 573 | 573 | if ( count( $settings ) >= $limit ) { |
| 574 | 574 | break; |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | * @return int The filtered limit value. |
| 595 | 595 | */ |
| 596 | 596 | public static function get_action_limit( $form_id, $limit = 99 ) { |
| 597 | - $type = 'all'; |
|
| 597 | + $type = 'all'; |
|
| 598 | 598 | return (int) apply_filters( 'frm_form_action_limit', (int) $limit, compact( 'type', 'form_id' ) ); |
| 599 | 599 | } |
| 600 | 600 | |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | 'limit' => 99, |
| 618 | 618 | 'post_status' => $default_status, |
| 619 | 619 | ); |
| 620 | - $args = wp_parse_args( $args, $defaults ); |
|
| 620 | + $args = wp_parse_args( $args, $defaults ); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | /** |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | |
| 688 | 688 | $action = $this->prepare_action( $action ); |
| 689 | 689 | |
| 690 | - $settings[ $action->ID ] = $action; |
|
| 690 | + $settings[$action->ID] = $action; |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | if ( 1 === $limit ) { |
@@ -730,10 +730,10 @@ discard block |
||
| 730 | 730 | |
| 731 | 731 | foreach ( $default_values as $k => $vals ) { |
| 732 | 732 | if ( is_array( $vals ) && ! empty( $vals ) ) { |
| 733 | - if ( 'event' === $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) { |
|
| 733 | + if ( 'event' === $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[$k] ) ) { |
|
| 734 | 734 | continue; |
| 735 | 735 | } |
| 736 | - $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals ); |
|
| 736 | + $action->post_content[$k] = wp_parse_args( $action->post_content[$k], $vals ); |
|
| 737 | 737 | } |
| 738 | 738 | } |
| 739 | 739 | |
@@ -821,9 +821,9 @@ discard block |
||
| 821 | 821 | |
| 822 | 822 | // fill with existing options |
| 823 | 823 | foreach ( $action->post_content as $name => $val ) { |
| 824 | - if ( isset( $form->options[ $name ] ) ) { |
|
| 825 | - $action->post_content[ $name ] = $form->options[ $name ]; |
|
| 826 | - unset( $form->options[ $name ] ); |
|
| 824 | + if ( isset( $form->options[$name] ) ) { |
|
| 825 | + $action->post_content[$name] = $form->options[$name]; |
|
| 826 | + unset( $form->options[$name] ); |
|
| 827 | 827 | } |
| 828 | 828 | } |
| 829 | 829 | |
@@ -883,8 +883,8 @@ discard block |
||
| 883 | 883 | private static function get_value_from_entry( $entry, $field_id ) { |
| 884 | 884 | $observed_value = ''; |
| 885 | 885 | |
| 886 | - if ( isset( $entry->metas[ $field_id ] ) ) { |
|
| 887 | - $observed_value = $entry->metas[ $field_id ]; |
|
| 886 | + if ( isset( $entry->metas[$field_id] ) ) { |
|
| 887 | + $observed_value = $entry->metas[$field_id]; |
|
| 888 | 888 | } elseif ( $entry->post_id && FrmAppHelper::pro_is_installed() ) { |
| 889 | 889 | $field = FrmField::getOne( $field_id ); |
| 890 | 890 | $observed_value = FrmProEntryMetaHelper::get_post_or_meta_value( |
@@ -958,7 +958,7 @@ discard block |
||
| 958 | 958 | $form_fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
| 959 | 959 | return array_filter( |
| 960 | 960 | $form_fields, |
| 961 | - function ( $form_field ) { |
|
| 961 | + function( $form_field ) { |
|
| 962 | 962 | return ! FrmField::is_no_save_field( $form_field->type ); |
| 963 | 963 | } |
| 964 | 964 | ); |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | * @param array $atts |
| 45 | 45 | */ |
| 46 | 46 | private function _set( $param, $atts ) { |
| 47 | - if ( isset( $atts[ $param ] ) ) { |
|
| 48 | - $this->{$param} = $atts[ $param ]; |
|
| 47 | + if ( isset( $atts[$param] ) ) { |
|
| 48 | + $this->{$param} = $atts[$param]; |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $exclude = array( 'field_obj', 'html' ); |
| 91 | 91 | foreach ( $exclude as $ex ) { |
| 92 | - if ( isset( $atts[ $ex ] ) ) { |
|
| 93 | - unset( $this->pass_args[ $ex ] ); |
|
| 92 | + if ( isset( $atts[$ex] ) ) { |
|
| 93 | + unset( $this->pass_args[$ex] ); |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | * @param array $set |
| 103 | 103 | */ |
| 104 | 104 | private function set_from_field( $atts, $set ) { |
| 105 | - if ( isset( $atts[ $set['param'] ] ) ) { |
|
| 106 | - $this->{$set['param']} = $atts[ $set['param'] ]; |
|
| 105 | + if ( isset( $atts[$set['param']] ) ) { |
|
| 106 | + $this->{$set['param']} = $atts[$set['param']]; |
|
| 107 | 107 | } else { |
| 108 | 108 | $this->{$set['param']} = $this->field_obj->get_field_column( $set['default'] ); |
| 109 | 109 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | private function replace_error_shortcode() { |
| 232 | 232 | $this->maybe_add_error_id(); |
| 233 | - $error = $this->pass_args['errors'][ 'field' . $this->field_id ] ?? false; |
|
| 233 | + $error = $this->pass_args['errors']['field' . $this->field_id] ?? false; |
|
| 234 | 234 | |
| 235 | 235 | if ( ! empty( $error ) && false === strpos( $this->html, 'role="alert"' ) && FrmAppHelper::should_include_alert_role_on_field_errors() ) { |
| 236 | 236 | $error_body = self::get_error_body( $this->html ); |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * @since 3.06.02 |
| 272 | 272 | */ |
| 273 | 273 | private function maybe_add_error_id() { |
| 274 | - if ( ! isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ) { |
|
| 274 | + if ( ! isset( $this->pass_args['errors']['field' . $this->field_id] ) ) { |
|
| 275 | 275 | return; |
| 276 | 276 | } |
| 277 | 277 | |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $this->html, $shortcodes, PREG_PATTERN_ORDER ); |
| 352 | 352 | |
| 353 | 353 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
| 354 | - $shortcode_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 354 | + $shortcode_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] ); |
|
| 355 | 355 | $tag = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key ); |
| 356 | 356 | |
| 357 | 357 | $replace_with = ''; |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | $replace_with = $this->replace_input_shortcode( $shortcode_atts ); |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - $this->html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $this->html ); |
|
| 365 | + $this->html = str_replace( $shortcodes[0][$short_key], $replace_with, $this->html ); |
|
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | */ |
| 385 | 385 | private function prepare_input_shortcode_atts( $shortcode_atts ) { |
| 386 | 386 | if ( isset( $shortcode_atts['opt'] ) ) { |
| 387 | - --$shortcode_atts['opt']; |
|
| 387 | + -- $shortcode_atts['opt']; |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | $field_class = $shortcode_atts['class'] ?? ''; |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | */ |
| 449 | 449 | private function get_field_div_classes() { |
| 450 | 450 | // Add error class |
| 451 | - $classes = isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ? ' frm_blank_field' : ''; |
|
| 451 | + $classes = isset( $this->pass_args['errors']['field' . $this->field_id] ) ? ' frm_blank_field' : ''; |
|
| 452 | 452 | |
| 453 | 453 | // Add label position class |
| 454 | 454 | $settings = $this->field_obj->display_field_settings(); |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | // Add 'aria-invalid' attribute to the group if there are errors. |
| 530 | - if ( isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ) { |
|
| 530 | + if ( isset( $this->pass_args['errors']['field' . $this->field_id] ) ) { |
|
| 531 | 531 | $attributes['aria-invalid'] = 'true'; |
| 532 | 532 | } |
| 533 | 533 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | return $errors; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
|
| 30 | + if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) { |
|
| 31 | 31 | $frm_settings = FrmAppHelper::get_settings(); |
| 32 | 32 | $errors['form'] = $frm_settings->admin_permission; |
| 33 | 33 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $args = wp_parse_args( $args, $defaults ); |
| 131 | 131 | |
| 132 | 132 | if ( empty( $args['parent_field_id'] ) ) { |
| 133 | - $value = $values['item_meta'][ $args['id'] ] ?? ''; |
|
| 133 | + $value = $values['item_meta'][$args['id']] ?? ''; |
|
| 134 | 134 | } else { |
| 135 | 135 | // value is from a nested form |
| 136 | 136 | $value = $values; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | if ( $posted_field->required == '1' && FrmAppHelper::is_empty_value( $value ) ) { |
| 154 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
| 154 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
| 155 | 155 | } elseif ( ! isset( $_POST['item_name'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 156 | 156 | self::maybe_add_item_name( $value, $posted_field ); |
| 157 | 157 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | $option_is_valid = (bool) apply_filters( 'frm_option_is_valid', $option_is_valid, $value, $posted_field ); |
| 205 | 205 | |
| 206 | 206 | if ( ! $option_is_valid ) { |
| 207 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'invalid' ); |
|
| 207 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'invalid' ); |
|
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | FrmFieldsHelper::prepare_new_front_field( $values, $field_object ); |
| 329 | 329 | |
| 330 | 330 | $separate_value = FrmField::get_option( $field_object, 'separate_value' ); |
| 331 | - $map_callback = function ( $option ) use ( $separate_value ) { |
|
| 331 | + $map_callback = function( $option ) use ( $separate_value ) { |
|
| 332 | 332 | if ( is_array( $option ) ) { |
| 333 | 333 | $option_value = $separate_value ? $option['value'] : $option['label']; |
| 334 | 334 | } else { |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | $pattern = self::phone_format( $field ); |
| 403 | 403 | |
| 404 | 404 | if ( ! preg_match( $pattern, $value ) ) { |
| 405 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 405 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | 408 | } |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | */ |
| 525 | 525 | private static function form_is_in_progress( $values ) { |
| 526 | 526 | return FrmAppHelper::pro_is_installed() && |
| 527 | - ( isset( $values[ 'frm_page_order_' . $values['form_id'] ] ) || FrmAppHelper::get_post_param( 'frm_next_page' ) ) && |
|
| 527 | + ( isset( $values['frm_page_order_' . $values['form_id']] ) || FrmAppHelper::get_post_param( 'frm_next_page' ) ) && |
|
| 528 | 528 | FrmField::get_all_types_in_form( $values['form_id'], 'break' ); |
| 529 | 529 | } |
| 530 | 530 | |
@@ -734,9 +734,9 @@ discard block |
||
| 734 | 734 | foreach ( $datas['missing_keys'] as $key_index => $key ) { |
| 735 | 735 | $found = self::is_akismet_guest_info_value( $key, $value, $field_id, $datas['name_field_ids'], $values ); |
| 736 | 736 | if ( $found ) { |
| 737 | - $datas[ $key ] = $value; |
|
| 737 | + $datas[$key] = $value; |
|
| 738 | 738 | $datas['frm_duplicated'][] = $field_id; |
| 739 | - unset( $datas['missing_keys'][ $key_index ] ); |
|
| 739 | + unset( $datas['missing_keys'][$key_index] ); |
|
| 740 | 740 | } |
| 741 | 741 | } |
| 742 | 742 | }//end foreach |
@@ -779,11 +779,11 @@ discard block |
||
| 779 | 779 | if ( 'Name' !== $field->name ) { |
| 780 | 780 | continue; |
| 781 | 781 | } |
| 782 | - if ( isset( $fields[ $index + 1 ] ) && 'Last' === $fields[ $index + 1 ]->name ) { |
|
| 783 | - if ( empty( $values[ absint( $fields[ $index + 1 ]->id ) ] ) ) { |
|
| 782 | + if ( isset( $fields[$index + 1] ) && 'Last' === $fields[$index + 1]->name ) { |
|
| 783 | + if ( empty( $values[absint( $fields[$index + 1]->id )] ) ) { |
|
| 784 | 784 | continue; |
| 785 | 785 | } |
| 786 | - $value .= ' ' . $values[ $fields[ $index + 1 ]->id ]; |
|
| 786 | + $value .= ' ' . $values[$fields[$index + 1]->id]; |
|
| 787 | 787 | return true; |
| 788 | 788 | } |
| 789 | 789 | } |
@@ -802,13 +802,13 @@ discard block |
||
| 802 | 802 | */ |
| 803 | 803 | private static function get_name_text_fields( $form_id ) { |
| 804 | 804 | $name_text_fields_is_initialized = is_array( self::$name_text_fields ); |
| 805 | - if ( $name_text_fields_is_initialized && isset( self::$name_text_fields[ $form_id ] ) ) { |
|
| 806 | - return self::$name_text_fields[ $form_id ]; |
|
| 805 | + if ( $name_text_fields_is_initialized && isset( self::$name_text_fields[$form_id] ) ) { |
|
| 806 | + return self::$name_text_fields[$form_id]; |
|
| 807 | 807 | } |
| 808 | 808 | if ( ! $name_text_fields_is_initialized ) { |
| 809 | 809 | self::$name_text_fields = array(); |
| 810 | 810 | } |
| 811 | - self::$name_text_fields[ $form_id ] = FrmDb::get_results( |
|
| 811 | + self::$name_text_fields[$form_id] = FrmDb::get_results( |
|
| 812 | 812 | 'frm_fields', |
| 813 | 813 | array( |
| 814 | 814 | 'form_id' => $form_id, |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | array( 'order_by' => 'field_order ASC' ) |
| 820 | 820 | ); |
| 821 | 821 | |
| 822 | - return self::$name_text_fields[ $form_id ]; |
|
| 822 | + return self::$name_text_fields[$form_id]; |
|
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | private static function add_server_values_to_akismet( &$datas ) { |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | |
| 829 | 829 | // Send any potentially useful $_SERVER vars, but avoid sending junk we don't need. |
| 830 | 830 | if ( $include_value ) { |
| 831 | - $datas[ $key ] = $value; |
|
| 831 | + $datas[$key] = $value; |
|
| 832 | 832 | } |
| 833 | 833 | unset( $key, $value ); |
| 834 | 834 | } |
@@ -845,10 +845,10 @@ discard block |
||
| 845 | 845 | private static function add_comment_content_to_akismet( &$datas, $values ) { |
| 846 | 846 | if ( isset( $datas['frm_duplicated'] ) ) { |
| 847 | 847 | foreach ( $datas['frm_duplicated'] as $index ) { |
| 848 | - if ( isset( $values['item_meta'][ $index ] ) ) { |
|
| 849 | - unset( $values['item_meta'][ $index ] ); |
|
| 848 | + if ( isset( $values['item_meta'][$index] ) ) { |
|
| 849 | + unset( $values['item_meta'][$index] ); |
|
| 850 | 850 | } else { |
| 851 | - unset( $values[ $index ] ); |
|
| 851 | + unset( $values[$index] ); |
|
| 852 | 852 | } |
| 853 | 853 | } |
| 854 | 854 | unset( $datas['frm_duplicated'] ); |
@@ -867,14 +867,14 @@ discard block |
||
| 867 | 867 | private static function skip_adding_values_to_akismet( &$values ) { |
| 868 | 868 | $skipped_fields = self::get_akismet_skipped_field_ids( $values ); |
| 869 | 869 | foreach ( $skipped_fields as $skipped_field ) { |
| 870 | - if ( ! isset( $values['item_meta'][ $skipped_field->id ] ) ) { |
|
| 870 | + if ( ! isset( $values['item_meta'][$skipped_field->id] ) ) { |
|
| 871 | 871 | continue; |
| 872 | 872 | } |
| 873 | 873 | |
| 874 | 874 | if ( self::should_really_skip_field( $skipped_field, $values ) ) { |
| 875 | - unset( $values['item_meta'][ $skipped_field->id ] ); |
|
| 876 | - if ( isset( $values['item_meta']['other'][ $skipped_field->id ] ) ) { |
|
| 877 | - unset( $values['item_meta']['other'][ $skipped_field->id ] ); |
|
| 875 | + unset( $values['item_meta'][$skipped_field->id] ); |
|
| 876 | + if ( isset( $values['item_meta']['other'][$skipped_field->id] ) ) { |
|
| 877 | + unset( $values['item_meta']['other'][$skipped_field->id] ); |
|
| 878 | 878 | } |
| 879 | 879 | } |
| 880 | 880 | } |
@@ -910,14 +910,14 @@ discard block |
||
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | // If a choice field has Other option, but Other is not selected. |
| 913 | - if ( empty( $values['item_meta']['other'][ $field_data->id ] ) ) { |
|
| 913 | + if ( empty( $values['item_meta']['other'][$field_data->id] ) ) { |
|
| 914 | 914 | return true; |
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | // Check if submitted value is same as one of field option. |
| 918 | 918 | foreach ( $field_data->options as $option ) { |
| 919 | 919 | $option_value = ! is_array( $option ) ? $option : ( $option['value'] ?? '' ); |
| 920 | - if ( $values['item_meta']['other'][ $field_data->id ] === $option_value ) { |
|
| 920 | + if ( $values['item_meta']['other'][$field_data->id] === $option_value ) { |
|
| 921 | 921 | return true; |
| 922 | 922 | } |
| 923 | 923 | } |
@@ -989,7 +989,7 @@ discard block |
||
| 989 | 989 | |
| 990 | 990 | // Convert name array to string. |
| 991 | 991 | if ( isset( $value['first'] ) && isset( $value['last'] ) ) { |
| 992 | - $values['item_meta'][ $field_id ] = trim( implode( ' ', $value ) ); |
|
| 992 | + $values['item_meta'][$field_id] = trim( implode( ' ', $value ) ); |
|
| 993 | 993 | $values['name_field_ids'][] = $field_id; |
| 994 | 994 | continue; |
| 995 | 995 | } |
@@ -1010,8 +1010,8 @@ discard block |
||
| 1010 | 1010 | continue; |
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | - if ( ! isset( $values['item_meta'][ $subsubindex ] ) ) { |
|
| 1014 | - $values['item_meta'][ $subsubindex ] = array(); |
|
| 1013 | + if ( ! isset( $values['item_meta'][$subsubindex] ) ) { |
|
| 1014 | + $values['item_meta'][$subsubindex] = array(); |
|
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | 1017 | // Convert name array to string. |
@@ -1021,13 +1021,13 @@ discard block |
||
| 1021 | 1021 | $values['name_field_ids'][] = $subsubindex; |
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | - if ( is_array( $values['item_meta'][ $subsubindex ] ) ) { |
|
| 1025 | - $values['item_meta'][ $subsubindex ][] = $subsubvalue; |
|
| 1024 | + if ( is_array( $values['item_meta'][$subsubindex] ) ) { |
|
| 1025 | + $values['item_meta'][$subsubindex][] = $subsubvalue; |
|
| 1026 | 1026 | } |
| 1027 | 1027 | } |
| 1028 | 1028 | }//end foreach |
| 1029 | 1029 | |
| 1030 | - unset( $values['item_meta'][ $field_id ] ); |
|
| 1030 | + unset( $values['item_meta'][$field_id] ); |
|
| 1031 | 1031 | }//end foreach |
| 1032 | 1032 | |
| 1033 | 1033 | return $form_ids; |
@@ -309,8 +309,8 @@ discard block |
||
| 309 | 309 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 310 | 310 | } |
| 311 | 311 | $plugins = get_plugins(); |
| 312 | - if ( isset( $plugins[ $plugin ] ) && ! empty( $plugins[ $plugin ]['Version'] ) ) { |
|
| 313 | - return $plugins[ $plugin ]['Version']; |
|
| 312 | + if ( isset( $plugins[$plugin] ) && ! empty( $plugins[$plugin]['Version'] ) ) { |
|
| 313 | + return $plugins[$plugin]['Version']; |
|
| 314 | 314 | } |
| 315 | 315 | return false; |
| 316 | 316 | } |
@@ -383,8 +383,8 @@ discard block |
||
| 383 | 383 | $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) ); |
| 384 | 384 | |
| 385 | 385 | foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) { |
| 386 | - if ( isset( $values[ $col ] ) ) { |
|
| 387 | - $new_values[ $col ] = $values[ $col ]; |
|
| 386 | + if ( isset( $values[$col] ) ) { |
|
| 387 | + $new_values[$col] = $values[$col]; |
|
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | $new_values['created_at'] = current_time( 'mysql', 1 ); |
| 397 | 397 | |
| 398 | 398 | if ( isset( $values['id'] ) ) { |
| 399 | - $frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key']; |
|
| 399 | + $frm_duplicate_ids[$values['field_key']] = $new_values['field_key']; |
|
| 400 | 400 | $new_values = apply_filters( 'frm_duplicated_field', $new_values ); |
| 401 | 401 | } |
| 402 | 402 | |
@@ -405,9 +405,9 @@ discard block |
||
| 405 | 405 | foreach ( $new_values as $k => $v ) { |
| 406 | 406 | if ( is_array( $v ) ) { |
| 407 | 407 | if ( $k === 'default_value' ) { |
| 408 | - $new_values[ $k ] = FrmAppHelper::maybe_json_encode( $v ); |
|
| 408 | + $new_values[$k] = FrmAppHelper::maybe_json_encode( $v ); |
|
| 409 | 409 | } else { |
| 410 | - $new_values[ $k ] = serialize( $v ); |
|
| 410 | + $new_values[$k] = serialize( $v ); |
|
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | unset( $k, $v ); |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | if ( isset( $values['id'] ) ) { |
| 430 | - $frm_duplicate_ids[ $values['id'] ] = $new_id; |
|
| 430 | + $frm_duplicate_ids[$values['id']] = $new_id; |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | return $new_id; |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @param array $match Shortcode data. |
| 479 | 479 | * @return string |
| 480 | 480 | */ |
| 481 | - function ( $match ) { |
|
| 481 | + function( $match ) { |
|
| 482 | 482 | $attr = shortcode_parse_atts( $match[3] ); |
| 483 | 483 | |
| 484 | 484 | if ( ! is_array( $attr ) ) { |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | if ( FrmAppHelper::input_key_is_safe( $key, 'update' ) ) { |
| 506 | - $safe_atts[ $key ] = $value; |
|
| 506 | + $safe_atts[$key] = $value; |
|
| 507 | 507 | } |
| 508 | 508 | } |
| 509 | 509 | |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) { |
| 562 | 562 | global $frm_duplicate_ids; |
| 563 | 563 | |
| 564 | - $where = array( |
|
| 564 | + $where = array( |
|
| 565 | 565 | array( |
| 566 | 566 | 'or' => 1, |
| 567 | 567 | 'fi.form_id' => $old_form_id, |
@@ -607,8 +607,8 @@ discard block |
||
| 607 | 607 | |
| 608 | 608 | $values = apply_filters( 'frm_duplicated_field', $values ); |
| 609 | 609 | $new_id = self::create( $values ); |
| 610 | - $frm_duplicate_ids[ $field->id ] = $new_id; |
|
| 611 | - $frm_duplicate_ids[ $field->field_key ] = $new_id; |
|
| 610 | + $frm_duplicate_ids[$field->id] = $new_id; |
|
| 611 | + $frm_duplicate_ids[$field->field_key] = $new_id; |
|
| 612 | 612 | unset( $field ); |
| 613 | 613 | }//end foreach |
| 614 | 614 | } |
@@ -657,11 +657,11 @@ discard block |
||
| 657 | 657 | |
| 658 | 658 | // serialize array values |
| 659 | 659 | foreach ( array( 'field_options', 'options' ) as $opt ) { |
| 660 | - if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) { |
|
| 660 | + if ( isset( $values[$opt] ) && is_array( $values[$opt] ) ) { |
|
| 661 | 661 | if ( 'field_options' === $opt ) { |
| 662 | - $values[ $opt ] = self::maybe_filter_options( $values[ $opt ] ); |
|
| 662 | + $values[$opt] = self::maybe_filter_options( $values[$opt] ); |
|
| 663 | 663 | } |
| 664 | - $values[ $opt ] = serialize( $values[ $opt ] ); |
|
| 664 | + $values[$opt] = serialize( $values[$opt] ); |
|
| 665 | 665 | } |
| 666 | 666 | } |
| 667 | 667 | if ( isset( $values['default_value'] ) && is_array( $values['default_value'] ) ) { |
@@ -848,8 +848,8 @@ discard block |
||
| 848 | 848 | continue; |
| 849 | 849 | } |
| 850 | 850 | |
| 851 | - $fields[ $result->id ] = $result; |
|
| 852 | - ++$count; |
|
| 851 | + $fields[$result->id] = $result; |
|
| 852 | + ++ $count; |
|
| 853 | 853 | if ( $limit == 1 ) { |
| 854 | 854 | $fields = $result; |
| 855 | 855 | break; |
@@ -900,8 +900,8 @@ discard block |
||
| 900 | 900 | $fields = array(); |
| 901 | 901 | $count = 0; |
| 902 | 902 | foreach ( $results as $result ) { |
| 903 | - ++$count; |
|
| 904 | - $fields[ $result->id ] = $result; |
|
| 903 | + ++ $count; |
|
| 904 | + $fields[$result->id] = $result; |
|
| 905 | 905 | if ( ! empty( $limit ) && $count >= $limit ) { |
| 906 | 906 | break; |
| 907 | 907 | } |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | $query_type = $limit === ' LIMIT 1' || $limit == 1 ? 'row' : 'results'; |
| 1016 | 1016 | |
| 1017 | 1017 | if ( is_array( $where ) ) { |
| 1018 | - $args = array( |
|
| 1018 | + $args = array( |
|
| 1019 | 1019 | 'order_by' => $order_by, |
| 1020 | 1020 | 'limit' => $limit, |
| 1021 | 1021 | ); |
@@ -1048,9 +1048,9 @@ discard block |
||
| 1048 | 1048 | FrmDb::set_cache( $result->field_key, $result, 'frm_field' ); |
| 1049 | 1049 | |
| 1050 | 1050 | self::prepare_options( $result ); |
| 1051 | - $results[ $r_key ]->field_options = $result->field_options; |
|
| 1052 | - $results[ $r_key ]->options = $result->options; |
|
| 1053 | - $results[ $r_key ]->default_value = $result->default_value; |
|
| 1051 | + $results[$r_key]->field_options = $result->field_options; |
|
| 1052 | + $results[$r_key]->options = $result->options; |
|
| 1053 | + $results[$r_key]->default_value = $result->default_value; |
|
| 1054 | 1054 | |
| 1055 | 1055 | unset( $r_key, $result ); |
| 1056 | 1056 | } |
@@ -1129,7 +1129,7 @@ discard block |
||
| 1129 | 1129 | |
| 1130 | 1130 | if ( count( $next_fields ) >= self::$transient_size ) { |
| 1131 | 1131 | // if this transient is full, check for another |
| 1132 | - ++$next; |
|
| 1132 | + ++ $next; |
|
| 1133 | 1133 | self::get_next_transient( $fields, $base_name, $next ); |
| 1134 | 1134 | } |
| 1135 | 1135 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
| 1157 | 1157 | return; |
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | - ++$next; |
|
| 1160 | + ++ $next; |
|
| 1161 | 1161 | } |
| 1162 | 1162 | } |
| 1163 | 1163 | |
@@ -1305,7 +1305,7 @@ discard block |
||
| 1305 | 1305 | * @return bool |
| 1306 | 1306 | */ |
| 1307 | 1307 | public static function is_option_true_in_array( $field, $option ) { |
| 1308 | - return ! empty( $field[ $option ] ); |
|
| 1308 | + return ! empty( $field[$option] ); |
|
| 1309 | 1309 | } |
| 1310 | 1310 | |
| 1311 | 1311 | /** |
@@ -1314,7 +1314,7 @@ discard block |
||
| 1314 | 1314 | * @return bool |
| 1315 | 1315 | */ |
| 1316 | 1316 | public static function is_option_true_in_object( $field, $option ) { |
| 1317 | - return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ]; |
|
| 1317 | + return isset( $field->field_options[$option] ) && $field->field_options[$option]; |
|
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | 1320 | /** |
@@ -1323,7 +1323,7 @@ discard block |
||
| 1323 | 1323 | * @return bool |
| 1324 | 1324 | */ |
| 1325 | 1325 | public static function is_option_empty_in_array( $field, $option ) { |
| 1326 | - return empty( $field[ $option ] ); |
|
| 1326 | + return empty( $field[$option] ); |
|
| 1327 | 1327 | } |
| 1328 | 1328 | |
| 1329 | 1329 | /** |
@@ -1332,7 +1332,7 @@ discard block |
||
| 1332 | 1332 | * @return bool |
| 1333 | 1333 | */ |
| 1334 | 1334 | public static function is_option_empty_in_object( $field, $option ) { |
| 1335 | - return empty( $field->field_options[ $option ] ); |
|
| 1335 | + return empty( $field->field_options[$option] ); |
|
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | 1338 | /** |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | * @return bool |
| 1342 | 1342 | */ |
| 1343 | 1343 | public static function is_option_value_in_object( $field, $option ) { |
| 1344 | - return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != ''; |
|
| 1344 | + return isset( $field->field_options[$option] ) && $field->field_options[$option] != ''; |
|
| 1345 | 1345 | } |
| 1346 | 1346 | |
| 1347 | 1347 | /** |
@@ -1367,10 +1367,10 @@ discard block |
||
| 1367 | 1367 | * @return mixed |
| 1368 | 1368 | */ |
| 1369 | 1369 | public static function get_option_in_array( $field, $option ) { |
| 1370 | - if ( isset( $field[ $option ] ) ) { |
|
| 1371 | - $this_option = $field[ $option ]; |
|
| 1372 | - } elseif ( isset( $field['field_options'] ) && is_array( $field['field_options'] ) && isset( $field['field_options'][ $option ] ) ) { |
|
| 1373 | - $this_option = $field['field_options'][ $option ]; |
|
| 1370 | + if ( isset( $field[$option] ) ) { |
|
| 1371 | + $this_option = $field[$option]; |
|
| 1372 | + } elseif ( isset( $field['field_options'] ) && is_array( $field['field_options'] ) && isset( $field['field_options'][$option] ) ) { |
|
| 1373 | + $this_option = $field['field_options'][$option]; |
|
| 1374 | 1374 | } else { |
| 1375 | 1375 | $this_option = ''; |
| 1376 | 1376 | } |
@@ -1384,7 +1384,7 @@ discard block |
||
| 1384 | 1384 | * @return mixed |
| 1385 | 1385 | */ |
| 1386 | 1386 | public static function get_option_in_object( $field, $option ) { |
| 1387 | - return $field->field_options[ $option ] ?? ''; |
|
| 1387 | + return $field->field_options[$option] ?? ''; |
|
| 1388 | 1388 | } |
| 1389 | 1389 | |
| 1390 | 1390 | /** |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | if ( in_array( $type, array( 'data', 'lookup' ), true ) ) { |
| 39 | 39 | $values['field_options']['data_type'] = $setting; |
| 40 | 40 | } else { |
| 41 | - $values['field_options'][ $setting ] = 1; |
|
| 41 | + $values['field_options'][$setting] = 1; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | foreach ( $defaults as $opt => $default ) { |
| 175 | - $values[ $opt ] = $field->field_options[ $opt ] ?? $default; |
|
| 175 | + $values[$opt] = $field->field_options[$opt] ?? $default; |
|
| 176 | 176 | |
| 177 | 177 | if ( $check_post ) { |
| 178 | - self::get_posted_field_setting( $opt . '_' . $field->id, $values[ $opt ] ); |
|
| 178 | + self::get_posted_field_setting( $opt . '_' . $field->id, $values[$opt] ); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | return self::$context_is_safe_to_load_field_options_from_request_data; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - $function = function () { |
|
| 195 | + $function = function() { |
|
| 196 | 196 | if ( ! FrmAppHelper::is_admin_page() ) { |
| 197 | 197 | return false; |
| 198 | 198 | } |
@@ -300,12 +300,12 @@ discard block |
||
| 300 | 300 | * @param mixed $value |
| 301 | 301 | */ |
| 302 | 302 | private static function get_posted_field_setting( $setting, &$value ) { |
| 303 | - if ( ! isset( $_POST['field_options'][ $setting ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 303 | + if ( ! isset( $_POST['field_options'][$setting] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 304 | 304 | return; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | if ( strpos( $setting, 'html' ) !== false ) { |
| 308 | - $value = wp_unslash( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing |
|
| 308 | + $value = wp_unslash( $_POST['field_options'][$setting] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing |
|
| 309 | 309 | |
| 310 | 310 | // Conditionally strip script tags if the user sending $_POST data is not allowed to use unfiltered HTML. |
| 311 | 311 | if ( ! FrmAppHelper::allow_unfiltered_html() ) { |
@@ -313,9 +313,9 @@ discard block |
||
| 313 | 313 | } |
| 314 | 314 | } elseif ( strpos( $setting, 'format_' ) === 0 ) { |
| 315 | 315 | // TODO: Remove stripslashes on output, and use on input only. |
| 316 | - $value = sanitize_text_field( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.NonceVerification.Missing |
|
| 316 | + $value = sanitize_text_field( $_POST['field_options'][$setting] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.NonceVerification.Missing |
|
| 317 | 317 | } else { |
| 318 | - $value = wp_unslash( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing |
|
| 318 | + $value = wp_unslash( $_POST['field_options'][$setting] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing |
|
| 319 | 319 | FrmAppHelper::sanitize_value( 'wp_kses_post', $value ); |
| 320 | 320 | } |
| 321 | 321 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | $values['default_value'] = FrmAppHelper::maybe_json_encode( $field->default_value ); |
| 389 | 389 | |
| 390 | 390 | foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
| 391 | - $values[ $col ] = $field->{$col}; |
|
| 391 | + $values[$col] = $field->{$col}; |
|
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | 394 | |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | ); |
| 427 | 427 | |
| 428 | 428 | $msg = FrmField::get_option( $field, $error ); |
| 429 | - $msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg; |
|
| 429 | + $msg = empty( $msg ) ? $defaults[$error]['part'] : $msg; |
|
| 430 | 430 | $msg = do_shortcode( $msg ); |
| 431 | 431 | |
| 432 | 432 | $msg = self::maybe_replace_substrings_with_field_name( $msg, $error, $field ); |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | 'inside_class' => 'inside', |
| 697 | 697 | 'dismiss-icon' => true, |
| 698 | 698 | ); |
| 699 | - $args = array_merge( $defaults, $args ); |
|
| 699 | + $args = array_merge( $defaults, $args ); |
|
| 700 | 700 | |
| 701 | 701 | include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/inline-modal.php'; |
| 702 | 702 | } |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | continue; |
| 935 | 935 | } |
| 936 | 936 | |
| 937 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] ); |
|
| 937 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] ); |
|
| 938 | 938 | $tag = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key ); |
| 939 | 939 | |
| 940 | 940 | $atts['entry'] = $entry; |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | if ( $replace_with !== null ) { |
| 945 | 945 | $replace_with = self::trigger_shortcode_atts( $replace_with, $atts ); |
| 946 | 946 | self::sanitize_embedded_shortcodes( compact( 'entry' ), $replace_with ); |
| 947 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 947 | + $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content ); |
|
| 948 | 948 | } |
| 949 | 949 | |
| 950 | 950 | unset( $atts, $replace_with ); |
@@ -962,7 +962,7 @@ discard block |
||
| 962 | 962 | $supported_atts = array( 'remove_accents', 'sanitize', 'sanitize_url' ); |
| 963 | 963 | $included_atts = array_intersect( $supported_atts, array_keys( $atts ) ); |
| 964 | 964 | foreach ( $included_atts as $included_att ) { |
| 965 | - if ( '0' === $atts[ $included_att ] ) { |
|
| 965 | + if ( '0' === $atts[$included_att] ) { |
|
| 966 | 966 | // Skip any option that uses 0 so sanitize_url=0 does not encode. |
| 967 | 967 | continue; |
| 968 | 968 | } |
@@ -1040,8 +1040,8 @@ discard block |
||
| 1040 | 1040 | |
| 1041 | 1041 | $dynamic_default = array( 'admin_email', 'siteurl', 'frmurl', 'sitename', 'get', 'default-email', 'default-from-email' ); |
| 1042 | 1042 | |
| 1043 | - if ( isset( $shortcode_values[ $atts['tag'] ] ) ) { |
|
| 1044 | - $replace_with = $shortcode_values[ $atts['tag'] ]; |
|
| 1043 | + if ( isset( $shortcode_values[$atts['tag']] ) ) { |
|
| 1044 | + $replace_with = $shortcode_values[$atts['tag']]; |
|
| 1045 | 1045 | } elseif ( in_array( $atts['tag'], $dynamic_default, true ) ) { |
| 1046 | 1046 | $replace_with = self::dynamic_default_values( $atts['tag'], $atts ); |
| 1047 | 1047 | } elseif ( $clean_tag === 'user_agent' ) { |
@@ -1265,8 +1265,8 @@ discard block |
||
| 1265 | 1265 | self::field_types_for_input( $single_input, $field_selection, $field_types ); |
| 1266 | 1266 | } elseif ( in_array( $type, $multiple_input, true ) ) { |
| 1267 | 1267 | self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
| 1268 | - } elseif ( isset( $field_selection[ $type ] ) ) { |
|
| 1269 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 1268 | + } elseif ( isset( $field_selection[$type] ) ) { |
|
| 1269 | + $field_types[$type] = $field_selection[$type]; |
|
| 1270 | 1270 | } |
| 1271 | 1271 | |
| 1272 | 1272 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type', 'field_selection' ) ); |
@@ -1308,7 +1308,7 @@ discard block |
||
| 1308 | 1308 | foreach ( $inputs as $input ) { |
| 1309 | 1309 | // This may not be set if a field type was removed using the frm_available_fields or frm_pro_available_fields filters. |
| 1310 | 1310 | if ( array_key_exists( $input, $fields ) ) { |
| 1311 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 1311 | + $field_types[$input] = $fields[$input]; |
|
| 1312 | 1312 | } |
| 1313 | 1313 | unset( $input ); |
| 1314 | 1314 | } |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | 'parent' => false, |
| 1342 | 1342 | 'pointer' => false, |
| 1343 | 1343 | ); |
| 1344 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1344 | + $args = wp_parse_args( $args, $defaults ); |
|
| 1345 | 1345 | |
| 1346 | 1346 | $opt_key = $args['opt_key']; |
| 1347 | 1347 | $field = $args['field']; |
@@ -1357,25 +1357,25 @@ discard block |
||
| 1357 | 1357 | |
| 1358 | 1358 | // Check posted vals before checking saved values |
| 1359 | 1359 | // For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero |
| 1360 | - if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 1360 | + if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 1361 | 1361 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 1362 | 1362 | // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 1363 | - $other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ) : ''; |
|
| 1363 | + $other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ) : ''; |
|
| 1364 | 1364 | } else { |
| 1365 | - $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 1365 | + $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 1366 | 1366 | } |
| 1367 | 1367 | |
| 1368 | 1368 | return $other_val; |
| 1369 | 1369 | } |
| 1370 | 1370 | |
| 1371 | - if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 1371 | + if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 1372 | 1372 | // For normal fields |
| 1373 | 1373 | |
| 1374 | 1374 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 1375 | 1375 | // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 1376 | - $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ) : ''; |
|
| 1376 | + $other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ) : ''; |
|
| 1377 | 1377 | } else { |
| 1378 | - $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 1378 | + $other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][$field['id']] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 1379 | 1379 | } |
| 1380 | 1380 | |
| 1381 | 1381 | return $other_val; |
@@ -1385,8 +1385,8 @@ discard block |
||
| 1385 | 1385 | if ( $field['type'] === 'checkbox' && is_array( $field['value'] ) ) { |
| 1386 | 1386 | // Check if there is an "other" val in saved value and make sure the |
| 1387 | 1387 | // "other" val is not equal to the Other checkbox option |
| 1388 | - if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) { |
|
| 1389 | - $other_val = $field['value'][ $opt_key ]; |
|
| 1388 | + if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) { |
|
| 1389 | + $other_val = $field['value'][$opt_key]; |
|
| 1390 | 1390 | } |
| 1391 | 1391 | } else { |
| 1392 | 1392 | /** |
@@ -1398,8 +1398,8 @@ discard block |
||
| 1398 | 1398 | // Multi-select dropdowns - key is not preserved |
| 1399 | 1399 | if ( is_array( $field['value'] ) ) { |
| 1400 | 1400 | $o_key = array_search( $temp_val, $field['value'] ); |
| 1401 | - if ( isset( $field['value'][ $o_key ] ) ) { |
|
| 1402 | - unset( $field['value'][ $o_key ], $o_key ); |
|
| 1401 | + if ( isset( $field['value'][$o_key] ) ) { |
|
| 1402 | + unset( $field['value'][$o_key], $o_key ); |
|
| 1403 | 1403 | } |
| 1404 | 1404 | } elseif ( $temp_val == $field['value'] ) { |
| 1405 | 1405 | // For radio and regular dropdowns |
@@ -1610,11 +1610,11 @@ discard block |
||
| 1610 | 1610 | foreach ( $val as $k => $v ) { |
| 1611 | 1611 | if ( is_string( $v ) ) { |
| 1612 | 1612 | if ( 'custom_html' === $k ) { |
| 1613 | - $val[ $k ] = self::switch_ids_except_strings( $replace, $replace_with, array( '[if description]', '[description]', '[/if description]' ), $v ); |
|
| 1613 | + $val[$k] = self::switch_ids_except_strings( $replace, $replace_with, array( '[if description]', '[description]', '[/if description]' ), $v ); |
|
| 1614 | 1614 | unset( $k, $v ); |
| 1615 | 1615 | continue; |
| 1616 | 1616 | } |
| 1617 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1617 | + $val[$k] = str_replace( $replace, $replace_with, $v ); |
|
| 1618 | 1618 | unset( $k, $v ); |
| 1619 | 1619 | } |
| 1620 | 1620 | } |
@@ -1643,8 +1643,8 @@ discard block |
||
| 1643 | 1643 | if ( false === $index ) { |
| 1644 | 1644 | continue; |
| 1645 | 1645 | } |
| 1646 | - unset( $replace[ $index ] ); |
|
| 1647 | - unset( $replace_with[ $index ] ); |
|
| 1646 | + unset( $replace[$index] ); |
|
| 1647 | + unset( $replace_with[$index] ); |
|
| 1648 | 1648 | } |
| 1649 | 1649 | $value = str_replace( $replace, $replace_with, $value ); |
| 1650 | 1650 | return $value; |
@@ -1992,7 +1992,7 @@ discard block |
||
| 1992 | 1992 | $countries['class'] = 'frm-countries-opts'; |
| 1993 | 1993 | } |
| 1994 | 1994 | |
| 1995 | - $prepop[ __( 'Countries', 'formidable' ) ] = $countries; |
|
| 1995 | + $prepop[__( 'Countries', 'formidable' )] = $countries; |
|
| 1996 | 1996 | |
| 1997 | 1997 | // State abv. |
| 1998 | 1998 | $states = self::get_us_states(); |
@@ -2002,7 +2002,7 @@ discard block |
||
| 2002 | 2002 | $state_abv['class'] = 'frm-state-abv-opts'; |
| 2003 | 2003 | } |
| 2004 | 2004 | |
| 2005 | - $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
|
| 2005 | + $prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv; |
|
| 2006 | 2006 | |
| 2007 | 2007 | // States. |
| 2008 | 2008 | $states = array_values( $states ); |
@@ -2011,7 +2011,7 @@ discard block |
||
| 2011 | 2011 | $states['class'] = 'frm-states-opts'; |
| 2012 | 2012 | } |
| 2013 | 2013 | |
| 2014 | - $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
|
| 2014 | + $prepop[__( 'U.S. States', 'formidable' )] = $states; |
|
| 2015 | 2015 | unset( $state_abv, $states ); |
| 2016 | 2016 | |
| 2017 | 2017 | // Age. |
@@ -2029,7 +2029,7 @@ discard block |
||
| 2029 | 2029 | $ages['class'] = 'frm-age-opts'; |
| 2030 | 2030 | } |
| 2031 | 2031 | |
| 2032 | - $prepop[ __( 'Age', 'formidable' ) ] = $ages; |
|
| 2032 | + $prepop[__( 'Age', 'formidable' )] = $ages; |
|
| 2033 | 2033 | |
| 2034 | 2034 | // Satisfaction. |
| 2035 | 2035 | $satisfaction = array( |
@@ -2044,7 +2044,7 @@ discard block |
||
| 2044 | 2044 | $satisfaction['class'] = 'frm-satisfaction-opts'; |
| 2045 | 2045 | } |
| 2046 | 2046 | |
| 2047 | - $prepop[ __( 'Satisfaction', 'formidable' ) ] = $satisfaction; |
|
| 2047 | + $prepop[__( 'Satisfaction', 'formidable' )] = $satisfaction; |
|
| 2048 | 2048 | |
| 2049 | 2049 | // Importance. |
| 2050 | 2050 | $importance = array( |
@@ -2059,7 +2059,7 @@ discard block |
||
| 2059 | 2059 | $importance['class'] = 'frm-importance-opts'; |
| 2060 | 2060 | } |
| 2061 | 2061 | |
| 2062 | - $prepop[ __( 'Importance', 'formidable' ) ] = $importance; |
|
| 2062 | + $prepop[__( 'Importance', 'formidable' )] = $importance; |
|
| 2063 | 2063 | |
| 2064 | 2064 | // Agreement. |
| 2065 | 2065 | $agreement = array( |
@@ -2074,7 +2074,7 @@ discard block |
||
| 2074 | 2074 | $agreement['class'] = 'frm-agreement-opts'; |
| 2075 | 2075 | } |
| 2076 | 2076 | |
| 2077 | - $prepop[ __( 'Agreement', 'formidable' ) ] = $agreement; |
|
| 2077 | + $prepop[__( 'Agreement', 'formidable' )] = $agreement; |
|
| 2078 | 2078 | |
| 2079 | 2079 | // Likely. |
| 2080 | 2080 | $likely = array( |
@@ -2089,7 +2089,7 @@ discard block |
||
| 2089 | 2089 | $likely['class'] = 'frm-likely-opts'; |
| 2090 | 2090 | } |
| 2091 | 2091 | |
| 2092 | - $prepop[ __( 'Likely', 'formidable' ) ] = $likely; |
|
| 2092 | + $prepop[__( 'Likely', 'formidable' )] = $likely; |
|
| 2093 | 2093 | |
| 2094 | 2094 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
| 2095 | 2095 | } |
@@ -2310,16 +2310,16 @@ discard block |
||
| 2310 | 2310 | */ |
| 2311 | 2311 | private static function fill_image_setting_options( $options, &$args ) { |
| 2312 | 2312 | foreach ( $options as $key => $option ) { |
| 2313 | - $args['options'][ $key ] = $option; |
|
| 2313 | + $args['options'][$key] = $option; |
|
| 2314 | 2314 | |
| 2315 | 2315 | if ( ! empty( $option['addon'] ) ) { |
| 2316 | - $args['options'][ $key ]['custom_attrs'] = self::fill_image_setting_addon_link( $option ); |
|
| 2316 | + $args['options'][$key]['custom_attrs'] = self::fill_image_setting_addon_link( $option ); |
|
| 2317 | 2317 | } |
| 2318 | 2318 | |
| 2319 | - unset( $args['options'][ $key ]['addon'] ); |
|
| 2319 | + unset( $args['options'][$key]['addon'] ); |
|
| 2320 | 2320 | $fill = array( 'upgrade', 'message', 'content' ); |
| 2321 | 2321 | foreach ( $fill as $f ) { |
| 2322 | - unset( $args['options'][ $key ][ $f ], $f ); |
|
| 2322 | + unset( $args['options'][$key][$f], $f ); |
|
| 2323 | 2323 | } |
| 2324 | 2324 | } |
| 2325 | 2325 | } |
@@ -2340,8 +2340,8 @@ discard block |
||
| 2340 | 2340 | |
| 2341 | 2341 | $fill = array( 'upgrade', 'message', 'content' ); |
| 2342 | 2342 | foreach ( $fill as $f ) { |
| 2343 | - if ( isset( $option[ $f ] ) ) { |
|
| 2344 | - $custom_attrs[ 'data-' . $f ] = $option[ $f ]; |
|
| 2343 | + if ( isset( $option[$f] ) ) { |
|
| 2344 | + $custom_attrs['data-' . $f] = $option[$f]; |
|
| 2345 | 2345 | } |
| 2346 | 2346 | } |
| 2347 | 2347 | |
@@ -2407,7 +2407,7 @@ discard block |
||
| 2407 | 2407 | |
| 2408 | 2408 | return array_filter( |
| 2409 | 2409 | $rows, |
| 2410 | - function ( $row ) { |
|
| 2410 | + function( $row ) { |
|
| 2411 | 2411 | FrmAppHelper::unserialize_or_decode( $row->field_options ); |
| 2412 | 2412 | return is_array( $row->field_options ) && ! empty( $row->field_options['draft'] ); |
| 2413 | 2413 | } |
@@ -2470,7 +2470,7 @@ discard block |
||
| 2470 | 2470 | if ( empty( $attributes['data-fid'] ) ) { |
| 2471 | 2471 | unset( $data['plugin-status'] ); |
| 2472 | 2472 | foreach ( $data as $key => $value ) { |
| 2473 | - $attributes[ 'data-' . $key ] = $value; |
|
| 2473 | + $attributes['data-' . $key] = $value; |
|
| 2474 | 2474 | } |
| 2475 | 2475 | } |
| 2476 | 2476 | |