| @@ -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,11 +539,8 @@ | ||
| 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 ); |
| @@ -855,20 +852,77 @@ | ||
| 855 | 852 | |
| 856 | 853 | return $post_id; |
| 857 | 854 | } |
| 858 | 855 | |
| 859 | - /** | |
| 860 | - * @param WP_Post $action | |
| 861 | - * @param stdClass $entry | |
| 862 | - * @return bool | |
| 863 | - */ | |
| 864 | 856 | public static function action_conditions_met( $action, $entry ) { |
| 865 | 857 | if ( is_callable( 'FrmProFormActionsController::action_conditions_met' ) ) { |
| 866 | 858 | return FrmProFormActionsController::action_conditions_met( $action, $entry ); |
| 867 | 859 | } |
| 868 | 860 | |
| 869 | - $stop = false; | |
| 861 | + // This is here for reverse compatibility. | |
| 862 | + $notification = $action->post_content; | |
| 863 | + $stop = false; | |
| 864 | + $met = array(); | |
| 865 | + | |
| 866 | + if ( empty( $notification['conditions'] ) ) { | |
| 867 | + return $stop; | |
| 868 | + } | |
| 869 | + | |
| 870 | + foreach ( $notification['conditions'] as $k => $condition ) { | |
| 871 | + if ( ! is_numeric( $k ) ) { | |
| 872 | + continue; | |
| 873 | + } | |
| 874 | + | |
| 875 | + if ( $stop && 'any' == $notification['conditions']['any_all'] && 'stop' == $notification['conditions']['send_stop'] ) { | |
| 876 | + continue; | |
| 877 | + } | |
| 878 | + | |
| 879 | + self::prepare_logic_value( $condition['hide_opt'], $action, $entry ); | |
| 880 | + | |
| 881 | + $observed_value = self::get_value_from_entry( $entry, $condition['hide_field'] ); | |
| 882 | + | |
| 883 | + $stop = FrmFieldsHelper::value_meets_condition( $observed_value, $condition['hide_field_cond'], $condition['hide_opt'] ); | |
| 884 | + | |
| 885 | + if ( $notification['conditions']['send_stop'] === 'send' ) { | |
| 886 | + $stop = $stop ? false : true; | |
| 887 | + } | |
| 888 | + | |
| 889 | + $met[ $stop ] = $stop; | |
| 890 | + }//end foreach | |
| 891 | + | |
| 892 | + if ( $notification['conditions']['any_all'] === 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) { | |
| 893 | + $stop = ( $notification['conditions']['send_stop'] === 'send' ); | |
| 894 | + } elseif ( $notification['conditions']['any_all'] === 'any' && $notification['conditions']['send_stop'] === 'send' && isset( $met[0] ) ) { | |
| 895 | + $stop = false; | |
| 896 | + } | |
| 897 | + | |
| 870 | 898 | return $stop; |
| 899 | + } | |
| 900 | + | |
| 901 | + /** | |
| 902 | + * Prepare the logic value for comparison against the entered value | |
| 903 | + * | |
| 904 | + * @since 2.01.02 | |
| 905 | + * | |
| 906 | + * @param array|string $logic_value | |
| 907 | + * | |
| 908 | + * @return void | |
| 909 | + */ | |
| 910 | + private static function prepare_logic_value( &$logic_value, $action, $entry ) { | |
| 911 | + if ( is_array( $logic_value ) ) { | |
| 912 | + $logic_value = reset( $logic_value ); | |
| 913 | + } | |
| 914 | + | |
| 915 | + if ( $logic_value === 'current_user' ) { | |
| 916 | + $logic_value = get_current_user_id(); | |
| 917 | + } | |
| 918 | + | |
| 919 | + $logic_value = apply_filters( 'frm_content', $logic_value, $action->menu_order, $entry ); | |
| 920 | + | |
| 921 | + /** | |
| 922 | + * @since 4.04.05 | |
| 923 | + */ | |
| 924 | + $logic_value = apply_filters( 'frm_action_logic_value', $logic_value ); | |
| 871 | 925 | } |
| 872 | 926 | |
| 873 | 927 | /** |
| 874 | 928 | * Get the value from a specific field and entry |