@@ -5,15 +5,15 @@ discard block |
||
5 | 5 | |
6 | 6 | class FrmFormAction { |
7 | 7 | |
8 | - public $id_base; // Root id for all actions of this type. |
|
9 | - public $name; // Name for this action type. |
|
8 | + public $id_base; // Root id for all actions of this type. |
|
9 | + public $name; // Name for this action type. |
|
10 | 10 | public $option_name; |
11 | - public $action_options; // Option array passed to wp_register_sidebar_widget() |
|
11 | + public $action_options; // Option array passed to wp_register_sidebar_widget() |
|
12 | 12 | public $control_options; // Option array passed to wp_register_widget_control() |
13 | 13 | |
14 | - public $form_id; // The ID of the form to evaluate |
|
15 | - public $number = false; // Unique ID number of the current instance. |
|
16 | - public $id = ''; // Unique ID string of the current instance (id_base-number) |
|
14 | + public $form_id; // The ID of the form to evaluate |
|
15 | + public $number = false; // Unique ID number of the current instance. |
|
16 | + public $id = ''; // Unique ID string of the current instance (id_base-number) |
|
17 | 17 | public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice. |
18 | 18 | |
19 | 19 | // Member functions that you must over-ride. |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | $groups = FrmFormActionsController::form_action_groups(); |
152 | 152 | $group = 'misc'; |
153 | 153 | |
154 | - if ( isset( $action_options['group'] ) && isset( $groups[ $action_options['group'] ] ) ) { |
|
154 | + if ( isset( $action_options['group'] ) && isset( $groups[$action_options['group']] ) ) { |
|
155 | 155 | $group = $action_options['group']; |
156 | - } elseif ( isset( $groups[ $this->id_base ] ) ) { |
|
156 | + } elseif ( isset( $groups[$this->id_base] ) ) { |
|
157 | 157 | $group = $this->id_base; |
158 | 158 | } else { |
159 | 159 | foreach ( $groups as $name => $check_group ) { |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | - $groups[ $group ]['id'] = $group; |
|
168 | - return $groups[ $group ]; |
|
167 | + $groups[$group]['id'] = $group; |
|
168 | + return $groups[$group]; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return integer $post_id |
268 | 268 | */ |
269 | 269 | public function maybe_create_action( $action, $forms ) { |
270 | - if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[ $action['menu_order'] ] ) && $forms[ $action['menu_order'] ] == 'updated' ) { |
|
270 | + if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[$action['menu_order']] ) && $forms[$action['menu_order']] == 'updated' ) { |
|
271 | 271 | // Update action only |
272 | 272 | $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
273 | 273 | $post_id = $this->save_settings( $action ); |
@@ -287,18 +287,18 @@ discard block |
||
287 | 287 | $switch = $this->get_global_switch_fields(); |
288 | 288 | |
289 | 289 | foreach ( (array) $action->post_content as $key => $val ) { |
290 | - if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) { |
|
291 | - $action->post_content[ $key ] = $frm_duplicate_ids[ $val ]; |
|
290 | + if ( is_numeric( $val ) && isset( $frm_duplicate_ids[$val] ) ) { |
|
291 | + $action->post_content[$key] = $frm_duplicate_ids[$val]; |
|
292 | 292 | } elseif ( ! is_array( $val ) ) { |
293 | - $action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val ); |
|
294 | - } elseif ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) { |
|
293 | + $action->post_content[$key] = FrmFieldsHelper::switch_field_ids( $val ); |
|
294 | + } elseif ( isset( $switch[$key] ) && is_array( $switch[$key] ) ) { |
|
295 | 295 | // loop through each value if empty |
296 | - if ( empty( $switch[ $key ] ) ) { |
|
297 | - $switch[ $key ] = array_keys( $val ); |
|
296 | + if ( empty( $switch[$key] ) ) { |
|
297 | + $switch[$key] = array_keys( $val ); |
|
298 | 298 | } |
299 | 299 | |
300 | - foreach ( $switch[ $key ] as $subkey ) { |
|
301 | - $action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val ); |
|
300 | + foreach ( $switch[$key] as $subkey ) { |
|
301 | + $action->post_content[$key] = $this->duplicate_array_walk( $action->post_content[$key], $subkey, $val ); |
|
302 | 302 | } |
303 | 303 | } |
304 | 304 | |
@@ -316,20 +316,20 @@ discard block |
||
316 | 316 | foreach ( $subkey as $subkey2 ) { |
317 | 317 | foreach ( (array) $val as $ck => $cv ) { |
318 | 318 | if ( is_array( $cv ) ) { |
319 | - $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv ); |
|
320 | - } elseif ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) { |
|
321 | - $action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ]; |
|
319 | + $action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey2, $cv ); |
|
320 | + } elseif ( isset( $cv[$subkey] ) && is_numeric( $cv[$subkey] ) && isset( $frm_duplicate_ids[$cv[$subkey]] ) ) { |
|
321 | + $action[$ck][$subkey] = $frm_duplicate_ids[$cv[$subkey]]; |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | } |
325 | 325 | } else { |
326 | 326 | foreach ( (array) $val as $ck => $cv ) { |
327 | 327 | if ( is_array( $cv ) ) { |
328 | - $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv ); |
|
329 | - } elseif ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) { |
|
330 | - $action[ $ck ] = $frm_duplicate_ids[ $cv ]; |
|
328 | + $action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey, $cv ); |
|
329 | + } elseif ( $ck == $subkey && isset( $frm_duplicate_ids[$cv] ) ) { |
|
330 | + $action[$ck] = $frm_duplicate_ids[$cv]; |
|
331 | 331 | } elseif ( $ck == $subkey ) { |
332 | - $action[ $ck ] = $this->maybe_switch_field_ids( $action[ $ck ] ); |
|
332 | + $action[$ck] = $this->maybe_switch_field_ids( $action[$ck] ); |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | } |
@@ -353,10 +353,10 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | // phpcs:ignore WordPress.Security.NonceVerification.Missing |
356 | - if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) { |
|
356 | + if ( isset( $_POST[$this->option_name] ) && is_array( $_POST[$this->option_name] ) ) { |
|
357 | 357 | // Sanitizing removes scripts and <email> type of values. |
358 | 358 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing |
359 | - $settings = wp_unslash( $_POST[ $this->option_name ] ); |
|
359 | + $settings = wp_unslash( $_POST[$this->option_name] ); |
|
360 | 360 | } else { |
361 | 361 | return; |
362 | 362 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | foreach ( $settings as $number => $new_instance ) { |
367 | 367 | $this->_set( $number ); |
368 | 368 | |
369 | - $old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array(); |
|
369 | + $old_instance = isset( $all_instances[$number] ) ? $all_instances[$number] : array(); |
|
370 | 370 | |
371 | 371 | if ( ! isset( $new_instance['post_status'] ) ) { |
372 | 372 | $new_instance['post_status'] = 'draft'; |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | $instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this ); |
407 | 407 | |
408 | 408 | if ( false !== $instance ) { |
409 | - $all_instances[ $number ] = $instance; |
|
409 | + $all_instances[$number] = $instance; |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | $action_ids[] = $this->save_settings( $instance ); |
@@ -482,12 +482,12 @@ discard block |
||
482 | 482 | // some plugins/themes are formatting the post_excerpt |
483 | 483 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
484 | 484 | |
485 | - if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) { |
|
485 | + if ( ! isset( $action_controls[$action->post_excerpt] ) ) { |
|
486 | 486 | continue; |
487 | 487 | } |
488 | 488 | |
489 | - $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action ); |
|
490 | - $settings[ $action->ID ] = $action; |
|
489 | + $action = $action_controls[$action->post_excerpt]->prepare_action( $action ); |
|
490 | + $settings[$action->ID] = $action; |
|
491 | 491 | |
492 | 492 | if ( count( $settings ) >= $limit ) { |
493 | 493 | break; |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | 'limit' => 99, |
518 | 518 | 'post_status' => $default_status, |
519 | 519 | ); |
520 | - $args = wp_parse_args( $args, $defaults ); |
|
520 | + $args = wp_parse_args( $args, $defaults ); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | |
579 | 579 | $action = $this->prepare_action( $action ); |
580 | 580 | |
581 | - $settings[ $action->ID ] = $action; |
|
581 | + $settings[$action->ID] = $action; |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | if ( 1 === $limit ) { |
@@ -615,10 +615,10 @@ discard block |
||
615 | 615 | |
616 | 616 | foreach ( $default_values as $k => $vals ) { |
617 | 617 | if ( is_array( $vals ) && ! empty( $vals ) ) { |
618 | - if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) { |
|
618 | + if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[$k] ) ) { |
|
619 | 619 | continue; |
620 | 620 | } |
621 | - $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals ); |
|
621 | + $action->post_content[$k] = wp_parse_args( $action->post_content[$k], $vals ); |
|
622 | 622 | } |
623 | 623 | } |
624 | 624 | |
@@ -693,14 +693,14 @@ discard block |
||
693 | 693 | * Migrate settings from form->options into new action. |
694 | 694 | */ |
695 | 695 | public function migrate_to_2( $form, $update = 'update' ) { |
696 | - $action = $this->prepare_new( $form->id ); |
|
696 | + $action = $this->prepare_new( $form->id ); |
|
697 | 697 | FrmAppHelper::unserialize_or_decode( $form->options ); |
698 | 698 | |
699 | 699 | // fill with existing options |
700 | 700 | foreach ( $action->post_content as $name => $val ) { |
701 | - if ( isset( $form->options[ $name ] ) ) { |
|
702 | - $action->post_content[ $name ] = $form->options[ $name ]; |
|
703 | - unset( $form->options[ $name ] ); |
|
701 | + if ( isset( $form->options[$name] ) ) { |
|
702 | + $action->post_content[$name] = $form->options[$name]; |
|
703 | + unset( $form->options[$name] ); |
|
704 | 704 | } |
705 | 705 | } |
706 | 706 | |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | $stop = $stop ? false : true; |
767 | 767 | } |
768 | 768 | |
769 | - $met[ $stop ] = $stop; |
|
769 | + $met[$stop] = $stop; |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) { |
@@ -817,8 +817,8 @@ discard block |
||
817 | 817 | private static function get_value_from_entry( $entry, $field_id ) { |
818 | 818 | $observed_value = ''; |
819 | 819 | |
820 | - if ( isset( $entry->metas[ $field_id ] ) ) { |
|
821 | - $observed_value = $entry->metas[ $field_id ]; |
|
820 | + if ( isset( $entry->metas[$field_id] ) ) { |
|
821 | + $observed_value = $entry->metas[$field_id]; |
|
822 | 822 | } elseif ( $entry->post_id && FrmAppHelper::pro_is_installed() ) { |
823 | 823 | $field = FrmField::getOne( $field_id ); |
824 | 824 | $observed_value = FrmProEntryMetaHelper::get_post_or_meta_value( |