PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16
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 +66 -28 6.256.16 View file →
@@ -434,9 +434,9 @@
434 434
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 = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array();
439 439
440 440 if ( ! isset( $new_instance['post_status'] ) ) {
441 441 $new_instance['post_status'] = 'draft';
442 442 }
@@ -451,9 +451,9 @@
451 451
452 452 $new_instance['post_type'] = FrmFormActionsController::$action_post_type;
453 453 $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number;
454 454 $new_instance['menu_order'] = $this->form_id;
455 - $new_instance['post_date'] = $old_instance->post_date ?? '';
455 + $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
456 456 $instance = $this->update( $new_instance, $old_instance );
457 457
458 458 /**
459 459 * Filter an action's settings before saving.
@@ -539,17 +539,14 @@
539 539 return array();
540 540 }
541 541
542 542 if ( 'all' !== $type ) {
543 - if ( is_array( $action_controls ) ) {
544 - return array();
545 - }
546 543 return $action_controls->get_all( $form_id, $atts );
547 544 }
548 545
549 546 self::prepare_get_action( $atts );
550 547
551 - $limit = self::get_action_limit( $form_id, $atts['limit'] );
548 + $limit = apply_filters( 'frm_form_action_limit', $atts['limit'], compact( 'type', 'form_id' ) );
552 549
553 550 $args = self::action_args( $form_id, $limit );
554 551 $args['post_status'] = $atts['post_status'];
555 552 $actions = FrmDb::check_cache( json_encode( $args ), 'frm_actions', $args, 'get_posts' );
@@ -582,24 +579,8 @@
582 579 return $settings;
583 580 }
584 581
585 582 /**
586 - * Get the limit for the number of actions for a single form. By default, this is 99, but
587 - * it can be modified with a code snippet.
588 - *
589 - * @since 6.17 This logic from moved from FrmFormAction::get_action_for_form.
590 - *
591 - * @param int|string $form_id
592 - * @param int|string $limit The unfiltered limit value.
593 - *
594 - * @return int The filtered limit value.
595 - */
596 - public static function get_action_limit( $form_id, $limit = 99 ) {
597 - $type = 'all';
598 - return (int) apply_filters( 'frm_form_action_limit', (int) $limit, compact( 'type', 'form_id' ) );
599 - }
600 -
601 - /**
602 583 * @since 3.04
603 584 *
604 585 * @param array $args
605 586 * @param string $default_status
@@ -855,20 +836,77 @@
855 836
856 837 return $post_id;
857 838 }
858 839
859 - /**
860 - * @param WP_Post $action
861 - * @param stdClass $entry
862 - * @return bool
863 - */
864 840 public static function action_conditions_met( $action, $entry ) {
865 841 if ( is_callable( 'FrmProFormActionsController::action_conditions_met' ) ) {
866 842 return FrmProFormActionsController::action_conditions_met( $action, $entry );
867 843 }
868 844
869 - $stop = false;
845 + // This is here for reverse compatibility.
846 + $notification = $action->post_content;
847 + $stop = false;
848 + $met = array();
849 +
850 + if ( empty( $notification['conditions'] ) ) {
851 + return $stop;
852 + }
853 +
854 + foreach ( $notification['conditions'] as $k => $condition ) {
855 + if ( ! is_numeric( $k ) ) {
856 + continue;
857 + }
858 +
859 + if ( $stop && 'any' == $notification['conditions']['any_all'] && 'stop' == $notification['conditions']['send_stop'] ) {
860 + continue;
861 + }
862 +
863 + self::prepare_logic_value( $condition['hide_opt'], $action, $entry );
864 +
865 + $observed_value = self::get_value_from_entry( $entry, $condition['hide_field'] );
866 +
867 + $stop = FrmFieldsHelper::value_meets_condition( $observed_value, $condition['hide_field_cond'], $condition['hide_opt'] );
868 +
869 + if ( $notification['conditions']['send_stop'] === 'send' ) {
870 + $stop = $stop ? false : true;
871 + }
872 +
873 + $met[ $stop ] = $stop;
874 + }//end foreach
875 +
876 + if ( $notification['conditions']['any_all'] === 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) {
877 + $stop = ( $notification['conditions']['send_stop'] === 'send' );
878 + } elseif ( $notification['conditions']['any_all'] === 'any' && $notification['conditions']['send_stop'] === 'send' && isset( $met[0] ) ) {
879 + $stop = false;
880 + }
881 +
870 882 return $stop;
883 + }
884 +
885 + /**
886 + * Prepare the logic value for comparison against the entered value
887 + *
888 + * @since 2.01.02
889 + *
890 + * @param array|string $logic_value
891 + *
892 + * @return void
893 + */
894 + private static function prepare_logic_value( &$logic_value, $action, $entry ) {
895 + if ( is_array( $logic_value ) ) {
896 + $logic_value = reset( $logic_value );
897 + }
898 +
899 + if ( $logic_value === 'current_user' ) {
900 + $logic_value = get_current_user_id();
901 + }
902 +
903 + $logic_value = apply_filters( 'frm_content', $logic_value, $action->menu_order, $entry );
904 +
905 + /**
906 + * @since 4.04.05
907 + */
908 + $logic_value = apply_filters( 'frm_action_logic_value', $logic_value );
871 909 }
872 910
873 911 /**
874 912 * Get the value from a specific field and entry