@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | if ( is_array( $sub_field ) ) { |
| 62 | 62 | $sub_field = wp_parse_args( $sub_field, $defaults ); |
| 63 | 63 | $sub_field['name'] = $name; |
| 64 | - $this->sub_fields[ $name ] = $sub_field; |
|
| 64 | + $this->sub_fields[$name] = $sub_field; |
|
| 65 | 65 | continue; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | if ( is_string( $sub_field ) ) { |
| 69 | - $this->sub_fields[ $name ] = wp_parse_args( |
|
| 69 | + $this->sub_fields[$name] = wp_parse_args( |
|
| 70 | 70 | array( |
| 71 | 71 | 'name' => $name, |
| 72 | 72 | 'label' => $sub_field, |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function set_aria_invalid_error( &$shortcode_atts, $args ) { |
| 91 | 91 | foreach ( $this->get_sub_fields() as $sub_field ) { |
| 92 | - $shortcode_atts[ 'aria-invalid-' . $sub_field['name'] ] = isset( $args['errors'][ 'field' . $this->field_id . '-' . $sub_field['name'] ] ) ? 'true' : 'false'; |
|
| 92 | + $shortcode_atts['aria-invalid-' . $sub_field['name']] = isset( $args['errors']['field' . $this->field_id . '-' . $sub_field['name']] ) ? 'true' : 'false'; |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | if ( is_string( $option ) ) { |
| 138 | - $extra_options[ $key . '_' . $option ] = ''; |
|
| 138 | + $extra_options[$key . '_' . $option] = ''; |
|
| 139 | 139 | } elseif ( ! empty( $option['name'] ) ) { |
| 140 | - $extra_options[ $key . '_' . $option['name'] ] = ''; |
|
| 140 | + $extra_options[$key . '_' . $option['name']] = ''; |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | foreach ( $this->sub_fields as $name => $sub_field ) { |
| 164 | 164 | $sub_field['name'] = $name; |
| 165 | 165 | $wrapper_classes = 'frm_grid_container frm_sub_field_options frm_sub_field_options-' . $sub_field['name']; |
| 166 | - if ( ! isset( $processed_sub_fields[ $name ] ) ) { |
|
| 166 | + if ( ! isset( $processed_sub_fields[$name] ) ) { |
|
| 167 | 167 | // Options for this subfield should be hidden. |
| 168 | 168 | $wrapper_classes .= ' frm_hidden'; |
| 169 | 169 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $default_value = array(); |
| 194 | 194 | |
| 195 | 195 | foreach ( $this->sub_fields as $name => $sub_field ) { |
| 196 | - $default_value[ $name ] = ''; |
|
| 196 | + $default_value[$name] = ''; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | return $default_value; |
@@ -375,8 +375,8 @@ discard block |
||
| 375 | 375 | // Placeholder. |
| 376 | 376 | if ( in_array( 'placeholder', $sub_field['options'], true ) ) { |
| 377 | 377 | $placeholders = FrmField::get_option( $field, 'placeholder' ); |
| 378 | - if ( ! empty( $placeholders[ $sub_field['name'] ] ) ) { |
|
| 379 | - $field['placeholder'] = $placeholders[ $sub_field['name'] ]; |
|
| 378 | + if ( ! empty( $placeholders[$sub_field['name']] ) ) { |
|
| 379 | + $field['placeholder'] = $placeholders[$sub_field['name']]; |
|
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | |
@@ -437,9 +437,9 @@ discard block |
||
| 437 | 437 | |
| 438 | 438 | // Validate not empty. |
| 439 | 439 | foreach ( $sub_fields as $name => $sub_field ) { |
| 440 | - if ( empty( $sub_field['optional'] ) && empty( $args['value'][ $name ] ) ) { |
|
| 441 | - $errors[ 'field' . $args['id'] . '-' . $name ] = ''; |
|
| 442 | - $errors[ 'field' . $args['id'] ] = $blank_msg; |
|
| 440 | + if ( empty( $sub_field['optional'] ) && empty( $args['value'][$name] ) ) { |
|
| 441 | + $errors['field' . $args['id'] . '-' . $name] = ''; |
|
| 442 | + $errors['field' . $args['id']] = $blank_msg; |
|
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | $field_key = $this->field->field_key ?? $this->field['field_key']; |
| 459 | 459 | $sub_fields = $this->get_processed_sub_fields(); |
| 460 | 460 | foreach ( $sub_fields as $name => $sub_field ) { |
| 461 | - $headings[ $field_id . '_' . $name ] = $field_name . ' (' . $field_key . ') - ' . $sub_field['label']; |
|
| 461 | + $headings[$field_id . '_' . $name] = $field_name . ' (' . $field_key . ') - ' . $sub_field['label']; |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | return $headings; |
@@ -58,19 +58,19 @@ discard block |
||
| 58 | 58 | $result = array(); |
| 59 | 59 | |
| 60 | 60 | foreach ( $names as $name ) { |
| 61 | - if ( empty( $this->sub_fields[ $name ] ) ) { |
|
| 61 | + if ( empty( $this->sub_fields[$name] ) ) { |
|
| 62 | 62 | continue; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if ( ! isset( $this->sub_fields[ $name ]['wrapper_classes'] ) ) { |
|
| 66 | - $this->sub_fields[ $name ]['wrapper_classes'] = $col_class; |
|
| 67 | - } elseif ( is_array( $this->sub_fields[ $name ]['wrapper_classes'] ) ) { |
|
| 68 | - $this->sub_fields[ $name ]['wrapper_classes'] = implode( ' ', $this->sub_fields[ $name ]['wrapper_classes'] ) . ' ' . $col_class; |
|
| 65 | + if ( ! isset( $this->sub_fields[$name]['wrapper_classes'] ) ) { |
|
| 66 | + $this->sub_fields[$name]['wrapper_classes'] = $col_class; |
|
| 67 | + } elseif ( is_array( $this->sub_fields[$name]['wrapper_classes'] ) ) { |
|
| 68 | + $this->sub_fields[$name]['wrapper_classes'] = implode( ' ', $this->sub_fields[$name]['wrapper_classes'] ) . ' ' . $col_class; |
|
| 69 | 69 | } else { |
| 70 | - $this->sub_fields[ $name ]['wrapper_classes'] .= ' ' . $col_class; |
|
| 70 | + $this->sub_fields[$name]['wrapper_classes'] .= ' ' . $col_class; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - $result[ $name ] = $this->sub_fields[ $name ]; |
|
| 73 | + $result[$name] = $this->sub_fields[$name]; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | return $result; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | // Default desc. |
| 103 | 103 | foreach ( $this->sub_fields as $name => $sub_field ) { |
| 104 | - $extra_options[ $name . '_desc' ] = $sub_field['label']; |
|
| 104 | + $extra_options[$name . '_desc'] = $sub_field['label']; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return $extra_options; |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $name_layout = $this->get_name_layout(); |
| 140 | 140 | |
| 141 | 141 | if ( ! empty( $atts['show'] ) ) { |
| 142 | - return $value[ $atts['show'] ] ?? ''; |
|
| 142 | + return $value[$atts['show']] ?? ''; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $value = wp_parse_args( |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $args['sub_fields'] = $this->sub_fields; |
| 217 | 217 | |
| 218 | 218 | foreach ( $hidden_fields as $name => $hidden_field ) { |
| 219 | - $args['sub_fields'][ $name ]['wrapper_classes'] .= ' frm_hidden'; |
|
| 219 | + $args['sub_fields'][$name]['wrapper_classes'] .= ' frm_hidden'; |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -274,7 +274,7 @@ |
||
| 274 | 274 | return ''; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - return $item_meta[ $field_id ] ?? ''; |
|
| 277 | + return $item_meta[$field_id] ?? ''; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | global $wpdb; |
| 60 | 60 | |
| 61 | - $values = array( |
|
| 61 | + $values = array( |
|
| 62 | 62 | 'item_id' => $entry_id, |
| 63 | 63 | 'field_id' => $field_id, |
| 64 | 64 | ); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - $values_indexed_by_field_id[ $field_id ] = $meta_value; |
|
| 141 | + $values_indexed_by_field_id[$field_id] = $meta_value; |
|
| 142 | 142 | |
| 143 | 143 | self::get_value_to_save( compact( 'field', 'field_id', 'entry_id' ), $meta_value ); |
| 144 | 144 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | if ( ( is_array( $meta_value ) && empty( $meta_value ) ) || ( ! is_array( $meta_value ) && trim( $meta_value ) == '' ) ) { |
| 148 | 148 | // Remove blank fields. |
| 149 | - unset( $values_indexed_by_field_id[ $field_id ] ); |
|
| 149 | + unset( $values_indexed_by_field_id[$field_id] ); |
|
| 150 | 150 | } else { |
| 151 | 151 | // if value exists, then update it |
| 152 | 152 | self::update_entry_meta( $entry_id, $field_id, '', $meta_value ); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | */ |
| 225 | 225 | public static function get_meta_value( $entry, $field_id ) { |
| 226 | 226 | if ( isset( $entry->metas ) ) { |
| 227 | - return $entry->metas[ $field_id ] ?? false; |
|
| 227 | + return $entry->metas[$field_id] ?? false; |
|
| 228 | 228 | } |
| 229 | 229 | return self::get_entry_meta_by_field( $entry->id, $field_id ); |
| 230 | 230 | } |
@@ -246,8 +246,8 @@ discard block |
||
| 246 | 246 | $cached = FrmDb::check_cache( $entry_id, 'frm_entry' ); |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) { |
|
| 250 | - $result = $cached->metas[ $field_id ]; |
|
| 249 | + if ( $cached && isset( $cached->metas ) && isset( $cached->metas[$field_id] ) ) { |
|
| 250 | + $result = $cached->metas[$field_id]; |
|
| 251 | 251 | |
| 252 | 252 | return wp_unslash( $result ); |
| 253 | 253 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | 'stripslashes' => true, |
| 281 | 281 | 'is_draft' => false, |
| 282 | 282 | ); |
| 283 | - $args = wp_parse_args( $args, $defaults ); |
|
| 283 | + $args = wp_parse_args( $args, $defaults ); |
|
| 284 | 284 | |
| 285 | 285 | $query = array(); |
| 286 | 286 | self::meta_field_query( $field_id, $order, $limit, $args, $query ); |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | |
| 296 | 296 | foreach ( $values as $k => $v ) { |
| 297 | 297 | FrmAppHelper::unserialize_or_decode( $v ); |
| 298 | - $values[ $k ] = $v; |
|
| 298 | + $values[$k] = $v; |
|
| 299 | 299 | unset( $k, $v ); |
| 300 | 300 | } |
| 301 | 301 | |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | foreach ( $results as $k => $result ) { |
| 364 | 364 | FrmAppHelper::unserialize_or_decode( $result->meta_value ); |
| 365 | - $results[ $k ]->meta_value = wp_unslash( $result->meta_value ); |
|
| 365 | + $results[$k]->meta_value = wp_unslash( $result->meta_value ); |
|
| 366 | 366 | unset( $k, $result ); |
| 367 | 367 | } |
| 368 | 368 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | 'user_id' => '', |
| 376 | 376 | 'group_by' => '', |
| 377 | 377 | ); |
| 378 | - $args = wp_parse_args( $args, $defaults ); |
|
| 378 | + $args = wp_parse_args( $args, $defaults ); |
|
| 379 | 379 | |
| 380 | 380 | $query = array(); |
| 381 | 381 | self::get_ids_query( $where, $order_by, $limit, $unique, $args, $query ); |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | } elseif ( false !== strpos( $args['is_draft'], ',' ) ) { |
| 479 | 479 | $is_draft = array_reduce( |
| 480 | 480 | explode( ',', $args['is_draft'] ), |
| 481 | - function ( $total, $current ) { |
|
| 481 | + function( $total, $current ) { |
|
| 482 | 482 | if ( is_numeric( $current ) ) { |
| 483 | 483 | $total[] = absint( $current ); |
| 484 | 484 | } |
@@ -40,6 +40,6 @@ |
||
| 40 | 40 | */ |
| 41 | 41 | public function get_video( $type = 'welcome' ) { |
| 42 | 42 | $videos = $this->get_api_info(); |
| 43 | - return $videos[ $type ] ?? array(); |
|
| 43 | + return $videos[$type] ?? array(); |
|
| 44 | 44 | } |
| 45 | 45 | } |
@@ -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 | } |
@@ -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 | ); |