PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmFormAction.php +115 -261 6.266.7 View file →
@@ -4,71 +4,19 @@
4 4 }
5 5
6 6 class FrmFormAction {
7 7
8 - /**
9 - * Root id for all actions of this type.
10 - *
11 - * @var string
12 - */
13 - public $id_base;
14 -
15 - /**
16 - * Name for this action type.
17 - *
18 - * @var string
19 - */
20 - public $name;
21 -
22 - /**
23 - * Name of the option used to store the settings for this action type.
24 - *
25 - * @var string
26 - */
8 + public $id_base; // Root id for all actions of this type.
9 + public $name; // Name for this action type.
27 10 public $option_name;
11 + public $action_options; // Option array passed to wp_register_sidebar_widget()
12 + public $control_options; // Option array passed to wp_register_widget_control()
28 13
29 - /**
30 - * Option array passed to wp_register_sidebar_widget().
31 - *
32 - * @var array
33 - */
34 - public $action_options;
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 + public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice.
35 18
36 - /**
37 - * Option array passed to wp_register_widget_control().
38 - *
39 - * @var array
40 - */
41 - public $control_options;
42 -
43 - /**
44 - * The ID of the form to evaluate.
45 - *
46 - * @var int
47 - */
48 - public $form_id;
49 -
50 - /**
51 - * Unique ID number of the current instance.
52 - *
53 - * @var int
54 - */
55 - public $number = false;
56 -
57 - /**
58 - * Unique ID string of the current instance (id_base-number).
59 - *
60 - * @var string
61 - */
62 - public $id = '';
63 -
64 - /**
65 - * Set true when we update the data after a POST submit - makes sure we don't do it twice.
66 - *
67 - * @var bool
68 - */
69 - public $updated = false;
70 -
71 19 // Member functions that you must over-ride.
72 20
73 21 /**
74 22 * This function should check that $new_instance is set correctly.
@@ -74,10 +22,10 @@
74 22 * This function should check that $new_instance is set correctly.
75 23 * The newly calculated value of $instance should be returned.
76 24 * If "false" is returned, the instance won't be saved/updated.
77 25 *
78 - * @param array $new_instance New settings for this instance as input by the user via form().
79 - * @param array $old_instance Old settings for this instance.
26 + * @param array $new_instance New settings for this instance as input by the user via form()
27 + * @param array $old_instance Old settings for this instance
80 28 *
81 29 * @return array Settings to save or bool false to cancel saving
82 30 */
83 31 public function update( $new_instance, $old_instance ) {
@@ -86,12 +34,10 @@
86 34
87 35 /**
88 36 * Echo the settings update form
89 37 *
90 - * @param WP_Post $instance Current settings.
38 + * @param WP_Post $instance Current settings
91 39 * @param array $args
92 - *
93 - * @return string
94 40 */
95 41 public function form( $instance, $args = array() ) {
96 42 echo '<p class="no-options-widget">' . esc_html__( 'There are no options for this action.', 'formidable' ) . '</p>';
97 43
@@ -111,14 +57,8 @@
111 57 public function get_switch_fields() {
112 58 return array();
113 59 }
114 60
115 - /**
116 - * @param object $action
117 - * @param object $form
118 - *
119 - * @return object
120 - */
121 61 public function migrate_values( $action, $form ) {
122 62 return $action;
123 63 }
124 64
@@ -129,14 +69,14 @@
129 69 *
130 70 * @param string $id_base Optional Base ID for the widget, lower case,
131 71 * if left empty a portion of the widget's class name will be used. Has to be unique.
132 72 * @param string $name Name for the widget displayed on the configuration page.
133 - * @param array $action_options Optional Passed to wp_register_sidebar_widget().
134 - * - description: shown on the configuration page.
135 - * - classname.
136 - * @param array $control_options Optional Passed to wp_register_widget_control().
137 - * - width: required if more than 250px.
138 - * - height: currently not used but may be needed in the future.
73 + * @param array $action_options Optional Passed to wp_register_sidebar_widget()
74 + * - description: shown on the configuration page
75 + * - classname
76 + * @param array $control_options Optional Passed to wp_register_widget_control()
77 + * - width: required if more than 250px
78 + * - height: currently not used but may be needed in the future
139 79 */
140 80 public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) {
141 81 if ( ! defined( 'ABSPATH' ) ) {
142 82 die( 'You are not allowed to call this page directly.' );
@@ -171,13 +111,12 @@
171 111 $action_options['color'] = 'var(--' . reset( $colors ) . ')';
172 112 }
173 113
174 114 $upgrade_class = isset( $action_options['classes'] ) && $action_options['classes'] === 'frm_show_upgrade';
175 -
176 115 if ( $action_options['group'] === $id_base ) {
177 - $upgrade_class = strpos( $action_options['classes'], 'frm_show_upgrade' ) !== false;
116 + $upgrade_class = strpos( $action_options['classes'], 'frm_show_upgrade' ) !== false;
178 117 $action_options['classes'] = $group['icon'];
179 - } elseif ( empty( $action_options['classes'] ) || $upgrade_class ) {
118 + } elseif ( ! isset( $action_options['classes'] ) || empty( $action_options['classes'] ) || $upgrade_class ) {
180 119 $action_options['classes'] = $group['icon'];
181 120 }
182 121
183 122 if ( $upgrade_class ) {
@@ -189,13 +128,8 @@
189 128 }
190 129
191 130 /**
192 131 * @param string $id_base
193 - * @param string $name
194 - * @param array $action_options
195 - * @param array $control_options
196 - *
197 - * @return void
198 132 */
199 133 public function FrmFormAction( $id_base, $name, $action_options = array(), $control_options = array() ) {
200 134 self::__construct( $id_base, $name, $action_options, $control_options );
201 135 }
@@ -202,15 +136,14 @@
202 136
203 137 /**
204 138 * Help to switch old field id by new field id for duplicate form
205 139 *
206 - * @param string $action id of the field that needs to be switched.
140 + * @param string $action id of the field that needs to be switched
207 141 *
208 142 * @return string
209 143 */
210 144 public function maybe_switch_field_ids( $action ) {
211 145 $updated_action = apply_filters( 'frm_maybe_switch_field_ids', $action );
212 -
213 146 if ( $updated_action === $action ) {
214 147 $updated_action = FrmFieldsHelper::switch_field_ids( $action );
215 148 }
216 149 return $updated_action;
@@ -217,12 +150,8 @@
217 150 }
218 151
219 152 /**
220 153 * @since 4.0
221 - *
222 - * @param array $action_options
223 - *
224 - * @return array
225 154 */
226 155 protected function get_group( $action_options ) {
227 156 $groups = FrmFormActionsController::form_action_groups();
228 157 $group = 'misc';
@@ -248,15 +177,14 @@
248 177 * Constructs name attributes for use in form() fields
249 178 *
250 179 * This function should be used in form() methods to create name attributes for fields to be saved by update()
251 180 *
252 - * @param string $field_name Field name.
253 - * @param string $post_field
181 + * @param string $field_name Field name
254 182 *
255 183 * @return string Name attribute for $field_name
256 184 */
257 185 public function get_field_name( $field_name, $post_field = 'post_content' ) {
258 - $name = $this->option_name . '[' . $this->number . ']';
186 + $name = $this->option_name . '[' . $this->number . ']';
259 187 $name .= ( empty( $post_field ) ? '' : '[' . $post_field . ']' );
260 188 $name .= '[' . $field_name . ']';
261 189
262 190 return $name;
@@ -266,9 +194,9 @@
266 194 * Constructs id attributes for use in form() fields
267 195 *
268 196 * This function should be used in form() methods to create id attributes for fields to be saved by update()
269 197 *
270 - * @param string $field_name Field name.
198 + * @param string $field_name Field name
271 199 *
272 200 * @return string ID attribute for $field_name
273 201 */
274 202 public function get_field_id( $field_name ) {
@@ -276,9 +204,8 @@
276 204 }
277 205
278 206 /**
279 207 * @param int|string $number
280 - *
281 208 * @return void
282 209 */
283 210 public function _set( $number ) {
284 211 $this->number = $number;
@@ -285,10 +212,8 @@
285 212 $this->id = $this->id_base . '-' . $number;
286 213 }
287 214
288 215 /**
289 - * @param false|int|string $form_id
290 - *
291 216 * @return object
292 217 */
293 218 public function prepare_new( $form_id = false ) {
294 219 if ( $form_id ) {
@@ -319,13 +244,8 @@
319 244
320 245 return (object) $form_action;
321 246 }
322 247
323 - /**
324 - * @param int|string $form_id
325 - *
326 - * @return int|WP_Error
327 - */
328 248 public function create( $form_id ) {
329 249 $this->form_id = $form_id;
330 250
331 251 $action = $this->prepare_new();
@@ -333,11 +253,8 @@
333 253 return $this->save_settings( $action );
334 254 }
335 255
336 256 /**
337 - * @param int|string $form_id
338 - * @param int|string $old_id
339 - *
340 257 * @return void
341 258 */
342 259 public function duplicate_form_actions( $form_id, $old_id ) {
343 260 if ( $form_id == $old_id ) {
@@ -348,9 +265,8 @@
348 265 $this->form_id = $old_id;
349 266 $actions = $this->get_all( $old_id );
350 267
351 268 $this->form_id = $form_id;
352 -
353 269 foreach ( $actions as $action ) {
354 270 $this->duplicate_one( $action, $form_id );
355 271 unset( $action );
356 272 }
@@ -355,20 +271,17 @@
355 271 unset( $action );
356 272 }
357 273 }
358 274
359 - /**
360 - * Check if imported action should be created or updated.
275 + /* Check if imported action should be created or updated
361 276 *
362 277 * @since 2.0
363 278 *
364 279 * @param array $action
365 - * @param array $forms
366 - *
367 - * @return int $post_id
280 + * @return integer $post_id
368 281 */
369 282 public function maybe_create_action( $action, $forms ) {
370 - if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[ $action['menu_order'] ] ) && $forms[ $action['menu_order'] ] === 'updated' ) {
283 + if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[ $action['menu_order'] ] ) && $forms[ $action['menu_order'] ] == 'updated' ) {
371 284 // Update action only
372 285 $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
373 286 $post_id = $this->save_settings( $action );
374 287 } else {
@@ -380,12 +293,9 @@
380 293 return $post_id;
381 294 }
382 295
383 296 /**
384 - * @param object $action
385 - * @param int|string $form_id
386 - *
387 - * @return int|WP_Error
297 + * @param object $action
388 298 */
389 299 public function duplicate_one( $action, $form_id ) {
390 300 global $frm_duplicate_ids;
391 301
@@ -414,15 +324,8 @@
414 324
415 325 return $this->save_settings( $action );
416 326 }
417 327
418 - /**
419 - * @param array $action
420 - * @param array|string $subkey
421 - * @param mixed $val
422 - *
423 - * @return array
424 - */
425 328 private function duplicate_array_walk( $action, $subkey, $val ) {
426 329 global $frm_duplicate_ids;
427 330
428 331 if ( is_array( $subkey ) ) {
@@ -444,9 +347,9 @@
444 347 } elseif ( $ck == $subkey ) {
445 348 $action[ $ck ] = $this->maybe_switch_field_ids( $action[ $ck ] );
446 349 }
447 350 }
448 - }//end if
351 + }
449 352
450 353 return $action;
451 354 }
452 355
@@ -453,12 +356,8 @@
453 356 /**
454 357 * Deal with changed settings.
455 358 *
456 359 * Do NOT over-ride this function
457 - *
458 - * @param int|string $form_id
459 - *
460 - * @return array|null
461 360 */
462 361 public function update_callback( $form_id ) {
463 362 $this->form_id = $form_id;
464 363
@@ -482,9 +381,9 @@
482 381
483 382 foreach ( $settings as $number => $new_instance ) {
484 383 $this->_set( $number );
485 384
486 - $old_instance = $all_instances[ $number ] ?? array();
385 + $old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array();
487 386
488 387 if ( ! isset( $new_instance['post_status'] ) ) {
489 388 $new_instance['post_status'] = 'draft';
490 389 }
@@ -499,10 +398,10 @@
499 398
500 399 $new_instance['post_type'] = FrmFormActionsController::$action_post_type;
501 400 $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number;
502 401 $new_instance['menu_order'] = $this->form_id;
503 - $new_instance['post_date'] = $old_instance->post_date ?? '';
504 - $instance = $this->update( $new_instance, $old_instance );
402 + $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
403 + $instance = $this->update( $new_instance, $old_instance );
505 404
506 405 /**
507 406 * Filter an action's settings before saving.
508 407 *
@@ -510,12 +409,12 @@
510 409 * to update settings.
511 410 *
512 411 * @since 2.0
513 412 *
514 - * @param array $instance The current widget instance's settings.
515 - * @param array $new_instance Array of new widget settings.
516 - * @param array $old_instance Array of old widget settings.
517 - * @param FrmFormAction $form_action FrmFormAction instance.
413 + * @param array $instance The current widget instance's settings.
414 + * @param array $new_instance Array of new widget settings.
415 + * @param array $old_instance Array of old widget settings.
416 + * @param WP_Widget $this The current widget instance.
518 417 */
519 418 $instance = apply_filters( 'frm_action_update_callback', $instance, $new_instance, $old_instance, $this );
520 419
521 420 $instance['post_content'] = apply_filters( 'frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this );
@@ -527,9 +426,9 @@
527 426
528 427 $action_ids[] = $this->save_settings( $instance );
529 428
530 429 $this->updated = true;
531 - }//end foreach
430 + }
532 431
533 432 return $action_ids;
534 433 }
535 434
@@ -538,10 +437,9 @@
538 437 *
539 438 * @since 3.04
540 439 *
541 440 * @param array $new_instance
542 - * @param array|stdClass $old_instance
543 - *
441 + * @param stdClass|array $old_instance
544 442 * @return void
545 443 */
546 444 protected function maybe_update_status( $new_instance, $old_instance ) {
547 445 if ( ! is_object( $old_instance ) || $new_instance['post_status'] === $old_instance->post_status ) {
@@ -556,13 +454,8 @@
556 454 )
557 455 );
558 456 }
559 457
560 - /**
561 - * @param array $settings
562 - *
563 - * @return int|WP_Error
564 - */
565 458 public function save_settings( $settings ) {
566 459 self::clear_cache();
567 460
568 461 return FrmDb::save_settings( $settings, 'frm_actions' );
@@ -567,16 +460,10 @@
567 460
568 461 return FrmDb::save_settings( $settings, 'frm_actions' );
569 462 }
570 463
571 - /**
572 - * @param int $id
573 - *
574 - * @return object|null
575 - */
576 464 public function get_single_action( $id ) {
577 465 $action = get_post( $id );
578 -
579 466 if ( $action ) {
580 467 $action = $this->prepare_action( $action );
581 468 $this->_set( $id );
582 469 }
@@ -583,42 +470,26 @@
583 470
584 471 return $action;
585 472 }
586 473
587 - /**
588 - * @param int|string $form_id
589 - *
590 - * @return array
591 - */
592 474 public function get_one( $form_id ) {
593 475 return $this->get_all( $form_id, 1 );
594 476 }
595 477
596 - /**
597 - * @param int|string $form_id
598 - * @param string $type
599 - * @param array $atts
600 - *
601 - * @return array
602 - */
603 478 public static function get_action_for_form( $form_id, $type = 'all', $atts = array() ) {
604 479 $action_controls = FrmFormActionsController::get_form_actions( $type );
605 -
606 480 if ( empty( $action_controls ) ) {
607 481 // don't continue if there are no available actions
608 482 return array();
609 483 }
610 484
611 - if ( 'all' !== $type ) {
612 - if ( is_array( $action_controls ) ) {
613 - return array();
614 - }
485 + if ( 'all' != $type ) {
615 486 return $action_controls->get_all( $form_id, $atts );
616 487 }
617 488
618 489 self::prepare_get_action( $atts );
619 490
620 - $limit = self::get_action_limit( $form_id, $atts['limit'] );
491 + $limit = apply_filters( 'frm_form_action_limit', $atts['limit'], compact( 'type', 'form_id' ) );
621 492
622 493 $args = self::action_args( $form_id, $limit );
623 494 $args['post_status'] = $atts['post_status'];
624 495 $actions = FrmDb::check_cache( json_encode( $args ), 'frm_actions', $args, 'get_posts' );
@@ -627,9 +498,8 @@
627 498 return array();
628 499 }
629 500
630 501 $settings = array();
631 -
632 502 foreach ( $actions as $action ) {
633 503 // some plugins/themes are formatting the post_excerpt
634 504 $action->post_excerpt = sanitize_title( $action->post_excerpt );
635 505
@@ -652,24 +522,8 @@
652 522 return $settings;
653 523 }
654 524
655 525 /**
656 - * Get the limit for the number of actions for a single form. By default, this is 99, but
657 - * it can be modified with a code snippet.
658 - *
659 - * @since 6.17 This logic from moved from FrmFormAction::get_action_for_form.
660 - *
661 - * @param int|string $form_id
662 - * @param int|string $limit The unfiltered limit value.
663 - *
664 - * @return int The filtered limit value.
665 - */
666 - public static function get_action_limit( $form_id, $limit = 99 ) {
667 - $type = 'all';
668 - return (int) apply_filters( 'frm_form_action_limit', (int) $limit, compact( 'type', 'form_id' ) );
669 - }
670 -
671 - /**
672 526 * @since 3.04
673 527 *
674 528 * @param array $args
675 529 * @param string $default_status
@@ -682,9 +536,8 @@
682 536 $args = array(
683 537 'limit' => $args,
684 538 );
685 539 }
686 -
687 540 $defaults = array(
688 541 'limit' => 99,
689 542 'post_status' => $default_status,
690 543 );
@@ -691,21 +544,14 @@
691 544 $args = wp_parse_args( $args, $defaults );
692 545 }
693 546
694 547 /**
695 - * @param int $action_id
696 - * @param string $type
697 - *
698 - * @return bool|object
548 + * @param int $action_id
699 549 */
700 550 public static function get_single_action_type( $action_id, $type ) {
701 551 if ( ! $type ) {
702 552 return false;
703 553 }
704 -
705 - /**
706 - * @var FrmFormAction
707 - */
708 554 $action_control = FrmFormActionsController::get_form_actions( $type );
709 555
710 556 return $action_control->get_single_action( $action_id );
711 557 }
@@ -710,24 +556,18 @@
710 556 return $action_control->get_single_action( $action_id );
711 557 }
712 558
713 559 /**
714 - * @param int $form_id
715 - * @param string $type
560 + * @param int $form_id
716 561 *
717 562 * @return bool
718 563 */
719 564 public static function form_has_action_type( $form_id, $type ) {
720 - $actions = self::get_action_for_form( $form_id, $type );
721 - return ! empty( $actions );
565 + $payment_actions = self::get_action_for_form( $form_id, $type );
566 +
567 + return ! empty( $payment_actions );
722 568 }
723 569
724 - /**
725 - * @param false|int|string $form_id
726 - * @param array $atts
727 - *
728 - * @return array
729 - */
730 570 public function get_all( $form_id = false, $atts = array() ) {
731 571 if ( is_array( $atts ) && ! isset( $atts['limit'] ) && $this->action_options['limit'] > 99 ) {
732 572 $atts['limit'] = $this->action_options['limit'];
733 573 }
@@ -745,10 +585,10 @@
745 585 global $frm_vars;
746 586 $frm_vars['action_type'] = $type;
747 587
748 588 add_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' );
749 - $query = self::action_args( $form_id, $limit );
750 - $query['post_status'] = $atts['post_status'];
589 + $query = self::action_args( $form_id, $limit );
590 + $query['post_status'] = $atts['post_status'];
751 591 $query['suppress_filters'] = false;
752 592
753 593 $actions = FrmDb::check_cache( json_encode( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' );
754 594 unset( $query );
@@ -759,9 +599,8 @@
759 599 return array();
760 600 }
761 601
762 602 $settings = array();
763 -
764 603 foreach ( $actions as $action ) {
765 604 if ( count( $settings ) >= $limit ) {
766 605 continue;
767 606 }
@@ -778,11 +617,8 @@
778 617 return $settings;
779 618 }
780 619
781 620 /**
782 - * @param int $form_id
783 - * @param int $limit
784 - *
785 621 * @return array
786 622 */
787 623 public static function action_args( $form_id = 0, $limit = 99 ) {
788 624 $args = array(
@@ -800,11 +636,9 @@
800 636 return $args;
801 637 }
802 638
803 639 /**
804 - * @param WP_Post $action
805 - *
806 - * @return WP_Post
640 + * @param WP_Post|array $action
807 641 */
808 642 public function prepare_action( $action ) {
809 643 $action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content );
810 644 $action->post_excerpt = sanitize_title( $action->post_excerpt );
@@ -830,11 +664,8 @@
830 664 return $action;
831 665 }
832 666
833 667 /**
834 - * @param false|int|string $form_id
835 - * @param string $type
836 - *
837 668 * @return void
838 669 */
839 670 public function destroy( $form_id = false, $type = 'default' ) {
840 671 global $wpdb;
@@ -841,13 +672,11 @@
841 672
842 673 $this->form_id = $form_id;
843 674
844 675 $query = array( 'post_type' => FrmFormActionsController::$action_post_type );
845 -
846 676 if ( $form_id ) {
847 677 $query['menu_order'] = $form_id;
848 678 }
849 -
850 679 if ( 'all' != $type ) {
851 680 $query['post_excerpt'] = $this->id_base;
852 681 }
853 682
@@ -869,11 +698,8 @@
869 698 public static function clear_cache() {
870 699 FrmDb::cache_delete_group( 'frm_actions' );
871 700 }
872 701
873 - /**
874 - * @return array
875 - */
876 702 public function get_settings() {
877 703 return self::get_action_for_form( $this->form_id, $this->id_base );
878 704 }
879 705
@@ -896,11 +722,8 @@
896 722
897 723 return $defaults;
898 724 }
899 725
900 - /**
901 - * @return array
902 - */
903 726 public function get_global_switch_fields() {
904 727 $switch = $this->get_switch_fields();
905 728 $switch['conditions'] = array( 'hide_field' );
906 729
@@ -910,16 +733,11 @@
910 733 }
911 734
912 735 /**
913 736 * Migrate settings from form->options into new action.
914 - *
915 - * @param object $form
916 - * @param string $update
917 - *
918 - * @return int|WP_Error
919 737 */
920 738 public function migrate_to_2( $form, $update = 'update' ) {
921 - $action = $this->prepare_new( $form->id );
739 + $action = $this->prepare_new( $form->id );
922 740 FrmAppHelper::unserialize_or_decode( $form->options );
923 741
924 742 // fill with existing options
925 743 foreach ( $action->post_content as $name => $val ) {
@@ -957,30 +775,89 @@
957 775
958 776 return $post_id;
959 777 }
960 778
961 - /**
962 - * @param WP_Post $action
963 - * @param stdClass $entry
964 - *
965 - * @return bool
966 - */
967 779 public static function action_conditions_met( $action, $entry ) {
968 780 if ( is_callable( 'FrmProFormActionsController::action_conditions_met' ) ) {
969 781 return FrmProFormActionsController::action_conditions_met( $action, $entry );
970 782 }
971 783
972 - $stop = false;
784 + // This is here for reverse compatibility.
785 + $notification = $action->post_content;
786 + $stop = false;
787 + $met = array();
788 +
789 + if ( ! isset( $notification['conditions'] ) || empty( $notification['conditions'] ) ) {
790 + return $stop;
791 + }
792 +
793 + foreach ( $notification['conditions'] as $k => $condition ) {
794 + if ( ! is_numeric( $k ) ) {
795 + continue;
796 + }
797 +
798 + if ( $stop && 'any' == $notification['conditions']['any_all'] && 'stop' == $notification['conditions']['send_stop'] ) {
799 + continue;
800 + }
801 +
802 + self::prepare_logic_value( $condition['hide_opt'], $action, $entry );
803 +
804 + $observed_value = self::get_value_from_entry( $entry, $condition['hide_field'] );
805 +
806 + $stop = FrmFieldsHelper::value_meets_condition( $observed_value, $condition['hide_field_cond'], $condition['hide_opt'] );
807 +
808 + if ( $notification['conditions']['send_stop'] == 'send' ) {
809 + $stop = $stop ? false : true;
810 + }
811 +
812 + $met[ $stop ] = $stop;
813 + }
814 +
815 + if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) {
816 + $stop = ( $notification['conditions']['send_stop'] == 'send' );
817 + } elseif ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset( $met[0] ) ) {
818 + $stop = false;
819 + }
820 +
973 821 return $stop;
974 822 }
975 823
976 824 /**
825 + * Prepare the logic value for comparison against the entered value
826 + *
827 + * @since 2.01.02
828 + *
829 + * @deprecated 4.06.02
830 + *
831 + * @param array|string $logic_value
832 + *
833 + * @return void
834 + */
835 + private static function prepare_logic_value( &$logic_value, $action, $entry ) {
836 + if ( is_array( $logic_value ) ) {
837 + $logic_value = reset( $logic_value );
838 + }
839 +
840 + if ( $logic_value == 'current_user' ) {
841 + $logic_value = get_current_user_id();
842 + }
843 +
844 + $logic_value = apply_filters( 'frm_content', $logic_value, $action->menu_order, $entry );
845 +
846 + /**
847 + * @since 4.04.05
848 + */
849 + $logic_value = apply_filters( 'frm_action_logic_value', $logic_value );
850 + }
851 +
852 + /**
977 853 * Get the value from a specific field and entry
978 854 *
979 855 * @since 2.01.02
856 + * @deprecated 4.06.02
980 857 *
981 858 * @param object $entry
982 - * @param int $field_id
859 + * @param int $field_id
983 860 *
984 861 * @return array|bool|mixed|string
985 862 */
986 863 private static function get_value_from_entry( $entry, $field_id ) {
@@ -1015,11 +892,8 @@
1015 892 'limit' => 0,
1016 893 );
1017 894 }
1018 895
1019 - /**
1020 - * @return array
1021 - */
1022 896 public static function trigger_labels() {
1023 897 $triggers = array(
1024 898 'draft' => __( 'Draft is saved', 'formidable' ),
1025 899 'create' => __( 'Entry is created', 'formidable' ),
@@ -1048,26 +922,6 @@
1048 922 * @return string
1049 923 */
1050 924 protected function get_upgrade_text() {
1051 925 return __( 'Conditional form actions', 'formidable' );
1052 - }
1053 -
1054 - /**
1055 - * Gets form fields for form action settings.
1056 - *
1057 - * @since 6.10
1058 - *
1059 - * @param int $form_id Form ID.
1060 - *
1061 - * @return object[]
1062 - */
1063 - protected function get_form_fields( $form_id ) {
1064 - // Get form fields, include embedded and repeater child fields.
1065 - $form_fields = FrmField::get_all_for_form( $form_id, '', 'include' );
1066 - return array_filter(
1067 - $form_fields,
1068 - function ( $form_field ) {
1069 - return ! FrmField::is_no_save_field( $form_field->type );
1070 - }
1071 - );
1072 926 }
1073 927 }