@@ -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. |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | $groups = FrmFormActionsController::form_action_groups(); |
142 | 142 | $group = 'misc'; |
143 | 143 | |
144 | - if ( isset( $action_options['group'] ) && isset( $groups[ $action_options['group'] ] ) ) { |
|
144 | + if ( isset( $action_options['group'] ) && isset( $groups[$action_options['group']] ) ) { |
|
145 | 145 | $group = $action_options['group']; |
146 | - } elseif ( isset( $groups[ $this->id_base ] ) ) { |
|
146 | + } elseif ( isset( $groups[$this->id_base] ) ) { |
|
147 | 147 | $group = $this->id_base; |
148 | 148 | } else { |
149 | 149 | foreach ( $groups as $name => $check_group ) { |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | - $groups[ $group ]['id'] = $group; |
|
158 | - return $groups[ $group ]; |
|
157 | + $groups[$group]['id'] = $group; |
|
158 | + return $groups[$group]; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @return integer $post_id |
258 | 258 | */ |
259 | 259 | public function maybe_create_action( $action, $forms ) { |
260 | - if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[ $action['menu_order'] ] ) && $forms[ $action['menu_order'] ] == 'updated' ) { |
|
260 | + if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[$action['menu_order']] ) && $forms[$action['menu_order']] == 'updated' ) { |
|
261 | 261 | // Update action only |
262 | 262 | $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
263 | 263 | $post_id = $this->save_settings( $action ); |
@@ -277,18 +277,18 @@ discard block |
||
277 | 277 | $switch = $this->get_global_switch_fields(); |
278 | 278 | |
279 | 279 | foreach ( (array) $action->post_content as $key => $val ) { |
280 | - if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) { |
|
281 | - $action->post_content[ $key ] = $frm_duplicate_ids[ $val ]; |
|
280 | + if ( is_numeric( $val ) && isset( $frm_duplicate_ids[$val] ) ) { |
|
281 | + $action->post_content[$key] = $frm_duplicate_ids[$val]; |
|
282 | 282 | } elseif ( ! is_array( $val ) ) { |
283 | - $action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val ); |
|
284 | - } elseif ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) { |
|
283 | + $action->post_content[$key] = FrmFieldsHelper::switch_field_ids( $val ); |
|
284 | + } elseif ( isset( $switch[$key] ) && is_array( $switch[$key] ) ) { |
|
285 | 285 | // loop through each value if empty |
286 | - if ( empty( $switch[ $key ] ) ) { |
|
287 | - $switch[ $key ] = array_keys( $val ); |
|
286 | + if ( empty( $switch[$key] ) ) { |
|
287 | + $switch[$key] = array_keys( $val ); |
|
288 | 288 | } |
289 | 289 | |
290 | - foreach ( $switch[ $key ] as $subkey ) { |
|
291 | - $action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val ); |
|
290 | + foreach ( $switch[$key] as $subkey ) { |
|
291 | + $action->post_content[$key] = $this->duplicate_array_walk( $action->post_content[$key], $subkey, $val ); |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
@@ -306,20 +306,20 @@ discard block |
||
306 | 306 | foreach ( $subkey as $subkey2 ) { |
307 | 307 | foreach ( (array) $val as $ck => $cv ) { |
308 | 308 | if ( is_array( $cv ) ) { |
309 | - $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv ); |
|
310 | - } elseif ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) { |
|
311 | - $action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ]; |
|
309 | + $action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey2, $cv ); |
|
310 | + } elseif ( isset( $cv[$subkey] ) && is_numeric( $cv[$subkey] ) && isset( $frm_duplicate_ids[$cv[$subkey]] ) ) { |
|
311 | + $action[$ck][$subkey] = $frm_duplicate_ids[$cv[$subkey]]; |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | } |
315 | 315 | } else { |
316 | 316 | foreach ( (array) $val as $ck => $cv ) { |
317 | 317 | if ( is_array( $cv ) ) { |
318 | - $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv ); |
|
319 | - } elseif ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) { |
|
320 | - $action[ $ck ] = $frm_duplicate_ids[ $cv ]; |
|
318 | + $action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey, $cv ); |
|
319 | + } elseif ( $ck == $subkey && isset( $frm_duplicate_ids[$cv] ) ) { |
|
320 | + $action[$ck] = $frm_duplicate_ids[$cv]; |
|
321 | 321 | } elseif ( $ck == $subkey ) { |
322 | - $action[ $ck ] = $this->maybe_switch_field_ids( $action[ $ck ] ); |
|
322 | + $action[$ck] = $this->maybe_switch_field_ids( $action[$ck] ); |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | } |
@@ -342,10 +342,10 @@ discard block |
||
342 | 342 | return; |
343 | 343 | } |
344 | 344 | |
345 | - if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) { |
|
345 | + if ( isset( $_POST[$this->option_name] ) && is_array( $_POST[$this->option_name] ) ) { |
|
346 | 346 | // Sanitizing removes scripts and <email> type of values. |
347 | 347 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
348 | - $settings = wp_unslash( $_POST[ $this->option_name ] ); |
|
348 | + $settings = wp_unslash( $_POST[$this->option_name] ); |
|
349 | 349 | } else { |
350 | 350 | return; |
351 | 351 | } |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | foreach ( $settings as $number => $new_instance ) { |
356 | 356 | $this->_set( $number ); |
357 | 357 | |
358 | - $old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array(); |
|
358 | + $old_instance = isset( $all_instances[$number] ) ? $all_instances[$number] : array(); |
|
359 | 359 | |
360 | 360 | if ( ! isset( $new_instance['post_status'] ) ) { |
361 | 361 | $new_instance['post_status'] = 'draft'; |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | $instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this ); |
396 | 396 | |
397 | 397 | if ( false !== $instance ) { |
398 | - $all_instances[ $number ] = $instance; |
|
398 | + $all_instances[$number] = $instance; |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | $action_ids[] = $this->save_settings( $instance ); |
@@ -471,12 +471,12 @@ discard block |
||
471 | 471 | // some plugins/themes are formatting the post_excerpt |
472 | 472 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
473 | 473 | |
474 | - if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) { |
|
474 | + if ( ! isset( $action_controls[$action->post_excerpt] ) ) { |
|
475 | 475 | continue; |
476 | 476 | } |
477 | 477 | |
478 | - $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action ); |
|
479 | - $settings[ $action->ID ] = $action; |
|
478 | + $action = $action_controls[$action->post_excerpt]->prepare_action( $action ); |
|
479 | + $settings[$action->ID] = $action; |
|
480 | 480 | |
481 | 481 | if ( count( $settings ) >= $limit ) { |
482 | 482 | break; |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | 'limit' => 99, |
507 | 507 | 'post_status' => $default_status, |
508 | 508 | ); |
509 | - $args = wp_parse_args( $args, $defaults ); |
|
509 | + $args = wp_parse_args( $args, $defaults ); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | |
568 | 568 | $action = $this->prepare_action( $action ); |
569 | 569 | |
570 | - $settings[ $action->ID ] = $action; |
|
570 | + $settings[$action->ID] = $action; |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | if ( 1 === $limit ) { |
@@ -604,10 +604,10 @@ discard block |
||
604 | 604 | |
605 | 605 | foreach ( $default_values as $k => $vals ) { |
606 | 606 | if ( is_array( $vals ) && ! empty( $vals ) ) { |
607 | - if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) { |
|
607 | + if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[$k] ) ) { |
|
608 | 608 | continue; |
609 | 609 | } |
610 | - $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals ); |
|
610 | + $action->post_content[$k] = wp_parse_args( $action->post_content[$k], $vals ); |
|
611 | 611 | } |
612 | 612 | } |
613 | 613 | |
@@ -682,14 +682,14 @@ discard block |
||
682 | 682 | * Migrate settings from form->options into new action. |
683 | 683 | */ |
684 | 684 | public function migrate_to_2( $form, $update = 'update' ) { |
685 | - $action = $this->prepare_new( $form->id ); |
|
685 | + $action = $this->prepare_new( $form->id ); |
|
686 | 686 | FrmAppHelper::unserialize_or_decode( $form->options ); |
687 | 687 | |
688 | 688 | // fill with existing options |
689 | 689 | foreach ( $action->post_content as $name => $val ) { |
690 | - if ( isset( $form->options[ $name ] ) ) { |
|
691 | - $action->post_content[ $name ] = $form->options[ $name ]; |
|
692 | - unset( $form->options[ $name ] ); |
|
690 | + if ( isset( $form->options[$name] ) ) { |
|
691 | + $action->post_content[$name] = $form->options[$name]; |
|
692 | + unset( $form->options[$name] ); |
|
693 | 693 | } |
694 | 694 | } |
695 | 695 | |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | $stop = $stop ? false : true; |
756 | 756 | } |
757 | 757 | |
758 | - $met[ $stop ] = $stop; |
|
758 | + $met[$stop] = $stop; |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) { |
@@ -806,8 +806,8 @@ discard block |
||
806 | 806 | private static function get_value_from_entry( $entry, $field_id ) { |
807 | 807 | $observed_value = ''; |
808 | 808 | |
809 | - if ( isset( $entry->metas[ $field_id ] ) ) { |
|
810 | - $observed_value = $entry->metas[ $field_id ]; |
|
809 | + if ( isset( $entry->metas[$field_id] ) ) { |
|
810 | + $observed_value = $entry->metas[$field_id]; |
|
811 | 811 | } elseif ( $entry->post_id && FrmAppHelper::pro_is_installed() ) { |
812 | 812 | $field = FrmField::getOne( $field_id ); |
813 | 813 | $observed_value = FrmProEntryMetaHelper::get_post_or_meta_value( |