C:\xampp\htdocs\landing\wp-content\plugins\wpforms-lite\includes\class-conditional-logic-core.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
<?php

/**
 * Conditional logic core.
 *
 * Contains functionality for using conditional logic in the form builder as
 * well as a global processing method that can be leveraged by all types of
 * conditional logic.
 *
 * This was contained in an addon until version 1.3.8 when it was rolled into
 * core.
 *
 * @since 1.3.8
 */
class WPForms_Conditional_Logic_Core {

    
/**
     * One is the loneliest number that you'll ever do.
     *
     * @since 1.1.0
     * @var WPForms_Conditional_Logic_Core
     */
    
private static $instance;

    
/**
     * Main Instance.
     *
     * @since 1.1.0
     * @return WPForms_Conditional_Logic_Core
     */
    
public static function instance() {

        if ( ! isset( 
self::$instance ) && ! ( self::$instance instanceof WPForms_Conditional_Logic_Core ) ) {
            
self::$instance = new WPForms_Conditional_Logic_Core;
            
add_action'wpforms_loaded', array( self::$instance'init' ), 10 );
        }

        return 
self::$instance;
    }

    
/**
     * Initialize.
     *
     * @since 1.0.0
     */
    
public function init() {

        
// Form builder.
        
add_action'wpforms_builder_enqueues', array( $this'builder_assets' ) );
        
add_action'wpforms_builder_print_footer_scripts', array( $this'builder_footer_scripts' ) );
    }

    
/**
     * Enqueue assets for the builder.
     *
     * @since 1.0.0
     */
    
public function builder_assets() {

        
// CSS.
        
wp_enqueue_style(
            
'wpforms-builder-conditionals',
            
WPFORMS_PLUGIN_URL 'assets/css/admin-builder-conditional-logic-core.css',
            array(),
            
WPFORMS_VERSION
        
);

        
// JavaScript.
        
wp_enqueue_script(
            
'wpforms-builder-conditionals',
            
WPFORMS_PLUGIN_URL 'assets/js/admin-builder-conditional-logic-core.js',
            array( 
'jquery''wpforms-utils''wpforms-builder' ),
            
WPFORMS_VERSION,
            
false
        
);
    }

    
/**
     * Output footer scripts inside the form builder.
     *
     * @since 1.3.8
     */
    
public function builder_footer_scripts() {

        
?>
        <script type="text/html" id="tmpl-wpforms-conditional-block">
            <# var containerID = data.fieldName.replace(/]/g, '').replace(/\[/g, '-'); #>
            <div class="wpforms-conditional-groups" id="wpforms-conditional-groups-{{ containerID }}">
                <h4>
                    <select name="{{ data.fieldName }}[conditional_type]">
                        <# _.each(data.actions, function(key, val) { #>
                        <option value="{{ val }}">{{ key }}</option>
                        <# }) #>
                    </select>
                    {{ data.actionDesc }}
                </h4>
                <div class="wpforms-conditional-group" data-reference="{{ data.fieldID }}">
                    <table><tbody>
                    <tr class="wpforms-conditional-row" data-field-id="{{ data.fieldID }}" data-input-name="{{ data.fieldName }}">
                        <td class="field">
                            <select name="{{ data.fieldName }}[conditionals][0][0][field]" class="wpforms-conditional-field" data-groupid="0" data-ruleid="0">
                                <option value="">{{ wpforms_builder.select_field }}</option>
                            </select>
                        </td>
                        <td class="operator">
                            <select name="{{ data.fieldName }}[conditionals][0][0][operator]" class="wpforms-conditional-operator">
                                <option value="==">{{ wpforms_builder.operator_is }}</option>
                                <option value="!=">{{ wpforms_builder.operator_is_not }}</option>
                                <option value="e">{{ wpforms_builder.operator_empty }}</option>
                                <option value="!e">{{ wpforms_builder.operator_not_empty }}</option>
                                <option value="c">{{ wpforms_builder.operator_contains }}</option>
                                <option value="!c">{{ wpforms_builder.operator_not_contains }}</option>
                                <option value="^">{{ wpforms_builder.operator_starts }}</option>
                                <option value="~">{{ wpforms_builder.operator_ends }}</option>
                                <option value=">">{{ wpforms_builder.operator_greater_than }}</option>
                                <option value="<">{{ wpforms_builder.operator_less_than }}</option>
                            </select>
                        </td>
                        <td class="value">
                            <select name="{{ data.fieldName }}[conditionals][0][0][value]" class="wpforms-conditional-value">
                                <option value="">{{ wpforms_builder.select_choice }}</option>
                            </select>
                        </td>
                            <td class="actions">
                                <button class="wpforms-conditional-rule-add" title="{{ wpforms_builder.rule_create }}">{{ wpforms_builder.and }}</button><button class="wpforms-conditional-rule-delete" title="{{ wpforms_builder.rule_delete }}"><i class="fa fa-times-circle" aria-hidden="true"></i></button>
                            </td>
                        </tr>
                    </tbody></table>
                    <h5>{{ wpforms_builder.or }}</h5>
                </div>
                <button class="wpforms-conditional-groups-add">{{ wpforms_builder.rule_create_group }}</button>
            </div>
        </script>
        <?php
    
}

    
/**
     * Build the conditional logic settings to display in the form builder.
     *
     * @since 1.3.8
     *
     * @param array $args Data needed for a block to be generated properly.
     * @param bool  $echo Whether to return or print. Default: print.
     *
     * @return string
     */
    
public function builder_block$args = array(), $echo true ) {

        if ( ! empty( 
$args['form'] ) ) {
            
$form_fields wpforms_get_form_fields$args['form'], wpforms_get_conditional_logic_form_fields_supported() );
        } else {
            
$form_fields = array();
        }

        
// Define data.
        
$type       = ! empty( $args['type'] ) ? $args['type'] : 'field';
        
$panel      = ! empty( $args['panel'] ) ? $args['panel'] : false// notifications/connections.
        
$parent     = ! empty( $args['parent'] ) ? $args['parent'] : false// settings.
        
$subsection = ! empty( $args['subsection'] ) ? $args['subsection'] : false;
        
$field      = ! empty( $args['field'] ) ? $args['field'] : false;
        
$reference  = ! empty( $args['reference'] ) ? $args['reference'] : '';
        
$data_attrs '';

        
ob_start();

        
// Block open markup.
        
printf(
            
'<div class="wpforms-conditional-block wpforms-conditional-block-%s" data-type="%s">',
            
esc_attr$type ),
            
esc_attr$type )
        );

            switch ( 
$type ) {
                case 
'field':
                    
/*
                     * This settings block is for a field.
                     */

                    // Define more data for this field.
                    
$fields_instance $args['instance'];
                    
$field_id        absint$field['id'] );
                    
$field_name      "fields[{$field_id}]";
                    
$groups_id       "wpforms-conditional-groups-fields-{$field_id}";
                    
$action_selected = ! empty( $field['conditional_type'] ) ? $field['conditional_type'] : '';
                    
$conditionals    = ! empty( $field['conditionals'] ) ? $field['conditionals'] : array( array( array() ) );
                    
$data_attrs      'data-field-id="' $field_id '" ';
                    
$reference       $field_id;
                    
$enabled         = isset( $field['conditional_logic'] ) ? $field['conditional_logic'] : false;
                    
$action_desc     = ! empty( $args['action_desc'] ) ? $args['action_desc'] : esc_html__'this field if''wpforms-lite' );

                    if ( empty( 
$args['actions'] ) ) {
                        
$actions = array(
                            
'show' => esc_attr__'Show''wpforms-lite' ),
                            
'hide' => esc_attr__'Hide''wpforms-lite' ),
                        );
                    } else {
                        
$actions array_map'esc_attr'$args['actions'] );
                    }

                    
// Output Conditional Logic toggle checkbox field option.
                    
$fld $fields_instance->field_element(
                        
'checkbox',
                        
$field,
                        array(
                            
'slug'    => 'conditional_logic',
                            
'value'   => $enabled,
                            
'desc'    => esc_html__'Enable conditional logic''wpforms-lite' ),
                            
'tooltip' => '<a href="https://wpforms.com/docs/how-to-use-conditional-logic-with-wpforms/" target="_blank" rel="noopener noreferrer">' esc_html__'How to use Conditional Logic''wpforms-lite' ) . '</a>',
                            
'data'    => array(
                                
'name'        => $field_name,
                                
'actions'     => $actions,
                                
'action-desc' => esc_attr$action_desc ),
                            ),
                        ),
                        
false
                    
);
                    
$fields_instance->field_element(
                        
'row',
                        
$field,
                        array(
                            
'slug'    => 'conditional_logic',
                            
'content' => $fld,
                            
'class'   => 'wpforms-conditionals-enable-toggle',
                        )
                    );

                    
// Prevent conditional logic from being applied to itself.
                    
if ( ! empty( $form_fields$field['id'] ] ) ) {
                        unset( 
$form_fields$field['id'] ] );
                    }
                    break;

                case 
'panel':
                    
/*
                     * This settings block is for something else - connections / notifications etc.
                     */

                    
$form_data $args['form'];

                    
$action_desc = ! empty( $args['action_desc'] ) ? $args['action_desc'] : esc_html__'this connection if''wpforms-lite' );

                    if ( empty( 
$args['actions'] ) ) {
                        
$actions = array(
                            
'go'   => esc_attr__'Process''wpforms-lite' ),
                            
'stop' => esc_attr__'Don\'t process''wpforms-lite' ),
                        );
                    } else {
                        
$actions array_map'esc_attr'$args['actions'] );
                    }

                    
// Below we do a bunch of voodoo to determine where this block
                    // is located in the form builder - eg is it in a top level
                    // setting or in a subsection, etc.
                    
if ( ! empty( $parent ) ) {
                        if ( ! empty( 
$subsection ) ) {
                            
$field_name      sprintf'%s[%s][%s]'$parent$panel$subsection );
                            
$groups_id       sprintf'wpforms-conditional-groups-%s-%s-%s'$parent$panel$subsection );
                            
$enabled         = ! empty( $form_data$parent ][ $panel ][ $subsection ]['conditional_logic'] ) ? true false;
                            
$action_selected = ! empty( $form_data$parent ][ $panel ][ $subsection ]['conditional_type'] ) ? $form_data$parent ][ $panel ][ $subsection ]['conditional_type'] : '';
                            
$conditionals    = ! empty( $form_data$parent ][ $panel ][ $subsection ]['conditionals'] ) ? $form_data$parent ][ $panel ][ $subsection ]['conditionals'] : array( array( array() ) );
                        } else {
                            
$field_name      sprintf'%s[%s]'$parent$panel );
                            
$groups_id       sprintf'wpforms-conditional-groups-%s-%s'$parent$panel );
                            
$enabled         = ! empty( $form_data$parent ][ $panel ]['conditional_logic'] ) ? true false;
                            
$action_selected = ! empty( $form_data$parent ][ $panel ]['conditional_type'] ) ? $form_data$parent ][ $panel ]['conditional_type'] : '';
                            
$conditionals    = ! empty( $form_data$parent ][ $panel ]['conditionals'] ) ? $form_data$parent ][ $panel ]['conditionals'] : array( array( array() ) );
                        }
                    } else {
                        
$field_name      sprintf'%s'$panel );
                        
$groups_id       sprintf'wpforms-conditional-groups-%s'$panel );
                        
$enabled         = ! empty( $form_data$panel ]['conditional_logic'] ) ? true false;
                        
$action_selected = ! empty( $form_data$panel ]['conditional_type'] ) ? $form_data$panel ]['conditional_type'] : '';
                        
$conditionals    = ! empty( $form_data$panel ]['conditionals'] ) ? $form_data$panel ]['conditionals'] : array( array( array() ) );
                    }

                    
// Output Conditional Logic toggle checkbox panel setting.
                    
wpforms_panel_field(
                        
'checkbox',
                        
$panel,
                        
'conditional_logic',
                        
$args['form'],
                        
esc_html__'Enable conditional logic''wpforms-lite' ),
                        array(
                            
'tooltip'     => '<a href="https://wpforms.com/docs/how-to-use-conditional-logic-with-wpforms/" target="_blank" rel="noopener noreferrer">' esc_html__'How to use Conditional Logic''wpforms-lite' ) . '</a>',
                            
'parent'      => $parent,
                            
'subsection'  => $subsection,
                            
'input_id'    => 'wpforms-panel-field-' implode'-'array_filter( array( $parent$panel$subsection'conditional_logic''checkbox' ) ) ),
                            
'input_class' => 'wpforms-panel-field-conditional_logic-checkbox',
                            
'class'       => 'wpforms-conditionals-enable-toggle',
                            
'data'        => array(
                                
'name'        => $field_name,
                                
'actions'     => $actions,
                                
'action-desc' => esc_attr$action_desc ),
                            ),
                        )
                    );
                    break;

                default:
                    
$enabled         false;
                    
$field_name      '';
                    
$reference       '';
                    
$action_selected '';
                    
$action_desc     '';
                    
$groups_id       '';
                    
$actions         = array();
                    
$conditionals    = array();
            }

            
// Only display the block details if conditional logic is enabled.
            
if ( $enabled ) :

                
$data_attrs .= 'data-input-name="' esc_attr$field_name ) . '"';
                
$style       $enabled '' 'display:none;';

                
// Groups wrap open markup.
                
printf(
                    
'<div class="wpforms-conditional-groups" id="%s" style="%s">',
                    
sanitize_html_class$groups_id ),
                    
esc_attr$style )
                );

                    
// This is the "[Show] this field if" type text and setting.
                    
echo '<h4>';
                        echo 
'<select name="' esc_attr$field_name ) . '[conditional_type]">';
                        foreach ( 
$actions as $key => $label ) {
                            
printf(
                                
'<option value="%s" %s>%s</option>',
                                
esc_attrtrim$key ) ),
                                
selected$key$action_selectedfalse ),
                                
esc_html$label )
                            );
                        }
                        echo 
'</select>';
                        echo 
esc_html$action_desc ); // Eg "this field if".
                    
echo '</h4>';

                    
// Go through each conditional logic group.
                    
foreach ( $conditionals as $group_id => $group ) :

                        
// Individual group open markup.
                        
echo '<div class="wpforms-conditional-group" data-reference="' $reference '">';

                            echo 
'<table><tbody>';

                                foreach ( 
$group as $rule_id => $rule ) :

                                    
$selected_current false;

                                    
// Individual rule table row.
                                    
echo '<tr class="wpforms-conditional-row" ' $data_attrs '>';

                                        
// Rule field - allows the user to select
                                        // which field the conditional logic rule is
                                        // anchored to.
                                        
echo '<td class="field">';

                                            
printf(
                                                
'<select name="%s[conditionals][%d][%d][field]" class="wpforms-conditional-field" data-groupid="%d" data-ruleid="%d">',
                                                
esc_attr$field_name ),
                                                (int) 
$group_id,
                                                (int) 
$rule_id,
                                                (int) 
$group_id,
                                                (int) 
$rule_id
                                            
);

                                                echo 
'<option value="">' esc_html__'--- Select Field ---''wpforms-lite' ) . '</option>';

                                                if ( ! empty( 
$form_fields ) ) {

                                                    foreach ( 
$form_fields as $form_field ) {

                                                        
// Exclude fields that are
                                                        // leveraging dynamic choices.
                                                        
if ( ! empty( $form_field['dynamic_choices'] ) ) {
                                                            continue;
                                                        }

                                                        if ( isset( 
$rule['field'] ) ) {
                                                            
$selected         $rule['field'];
                                                            
$selected_current $rule['field'];
                                                        } else {
                                                            
$selected false;
                                                        }

                                                        
$field_label = isset( $form_field['label'] ) && ! wpforms_is_empty_stringtrim$form_field['label'] ) ) ? $form_field['label'] : sprintf/* translators: %d - field ID. */ __'Field #%d''wpforms-lite' ), absint$form_field['id'] ) );

                                                        
$selected selected$selected$form_field['id'], false );
                                                        
printf'<option value="%s" %s>%s</option>'absint$form_field['id'] ), esc_attr$selected ), esc_html$field_label ) );
                                                    }
                                                }

                                            echo 
'</select>';

                                        echo 
'</td>';

                                        
// Rule operator - allows the user to
                                        // determine the comparison operator used
                                        // for processing.
                                        
echo '<td class="operator">';

                                            
printf(
                                                
'<select name="%s[conditionals][%s][%s][operator]" class="wpforms-conditional-operator">',
                                                
$field_name,
                                                
$group_id,
                                                
$rule_id
                                            
);

                                                
$operator = ! empty( $rule['operator'] ) ? $rule['operator'] : false;
                                                
printf'<option value="==" %s>%s</option>'selected$operator'=='false ), esc_html__'is''wpforms-lite' ) );
                                                
printf'<option value="!=" %s>%s</option>'selected$operator'!='false ), esc_html__'is not''wpforms-lite' ) );
                                                
printf'<option value="e" %s>%s</option>'selected$operator'e'false ), esc_html__'empty''wpforms-lite' ) );
                                                
printf'<option value="!e" %s>%s</option>'selected$operator'!e'false ), esc_html__'not empty''wpforms-lite' ) );

                                                
// Only text based fields support
                                                // these additional operators.
                                                
$disabled '';
                                                if ( ! empty( 
$rule['field'] ) && ! empty( $form_fields$rule['field'] ]['type'] ) ) {
                                                    
$disabled in_array$form_fields$rule['field'] ]['type'], array( 'text''textarea''email''url''number''hidden''rating''number-slider''net_promoter_score' ), true ) ? '' ' disabled';
                                                }

                                                
printf'<option value="c" %s%s>%s</option>'selected$operator'c'false ), $disabledesc_html__'contains''wpforms-lite' ) );
                                                
printf'<option value="!c" %s%s>%s</option>'selected$operator'!c'false ), $disabledesc_html__'does not contain''wpforms-lite' ) );
                                                
printf'<option value="^" %s%s>%s</option>'selected$operator'^'false ), $disabledesc_html__'starts with''wpforms-lite' ) );
                                                
printf'<option value="~" %s%s>%s</option>'selected$operator'~'false ), $disabledesc_html__'ends with''wpforms-lite' ) );
                                                
printf'<option value=">" %s%s>%s</option>'selected$operator'>'false ), $disabledesc_html__'greater than''wpforms-lite' ) );
                                                
printf'<option value="<" %s%s>%s</option>'selected$operator'<'false ), $disabledesc_html__'less than''wpforms-lite' ) );

                                            echo 
'</select>';

                                        echo 
'</td>';

                                        
// Rule value - allows the user to
                                        // determine the value we are using for
                                        // comparison.
                                        
echo '<td class="value">';

                                            if ( isset( 
$rule['field'] ) ) {

                                                
// For empty/not empty fields the field value input is not needed so we disable it.
                                                
if ( ! empty( $rule['operator'] ) && in_array$rule['operator'], array( 'e''!e' ), true ) ) {
                                                    
$disabled      'disabled';
                                                    
$rule['value'] = '';
                                                } else {
                                                    
$disabled '';
                                                }

                                                if ( isset( 
$form_fields$rule['field'] ]['type'] ) && in_array$form_fields$rule['field'] ]['type'], array( 'text''textarea''email''url''number''hidden''rating''number-slider''net_promoter_score' ), true ) ) {

                                                    
$type in_array$form_fields$rule['field'] ]['type'], array( 'rating''net_promoter_score''number-slider' ), true ) ? 'number' 'text';

                                                    
printf(
                                                        
'<input type="%s" name="%s[conditionals][%s][%s][value]" value="%s" class="wpforms-conditional-value" %s>',
                                                        
$type,
                                                        
$field_name,
                                                        
$group_id,
                                                        
$rule_id,
                                                        
esc_attr$rule['value'] ),
                                                        
$disabled
                                                    
);

                                                } else {

                                                    
printf(
                                                        
'<select name="%1$s[conditionals][%2$s][%3$s][value]" class="wpforms-conditional-value" %4$d>',
                                                        
$field_name,
                                                        
$group_id,
                                                        
$rule_id,
                                                        
$disabled
                                                    
);

                                                        echo 
'<option value="">' esc_html__'--- Select Choice ---''wpforms-lite' ) . '</option>';

                                                        if ( ! empty( 
$form_fields$rule['field'] ]['choices'] ) ) {

                                                            foreach ( 
$form_fields$rule['field'] ]['choices'] as $option_id => $option ) {
                                                                
$value = isset( $rule['value'] ) ? $rule['value'] : '';
                                                                
$label = ! isset( $option['label'] ) || '' === trim$option['label'] )
                                                                    ? 
sprintf/* translators: %d - choice number. */
                                                                        
esc_html__'Choice %d''wpforms-lite' ),
                                                                        (int) 
$option_id
                                                                    
)
                                                                    : 
$option['label'];
                                                                
printf(
                                                                    
'<option value="%1$s" %2$s>%3$s</option>',
                                                                    
esc_attr$option_id ),
                                                                    
selected$option_id$valuefalse ),
                                                                    
esc_htmltrim$label ) )
                                                                );
                                                            }
                                                        }

                                                    echo 
'</select>';
                                                }
                                            } else {
                                                echo 
'<select></select>';
                                            } 
// End if().
                                        
echo '</td>';

                                        
// Rule actions.
                                        
echo '<td class="actions">';
                                            echo 
'<button class="wpforms-conditional-rule-add" title="' esc_attr__'Create new rule''wpforms-lite' ) . '">' esc_html_x'AND''Conditional Logic: new rule logic.''wpforms-lite' ) . '</button>';
                                            echo 
'<button class="wpforms-conditional-rule-delete" title="' esc_attr__'Delete rule''wpforms-lite' ) . '"><i class="fa fa-times-circle" aria-hidden="true"></i></button>';
                                        echo 
'</td>';

                                    echo 
'</tr>'// Close individual rule table row.

                                
endforeach; // End foreach() for individual rules.

                            
echo '</tbody></table>';

                            echo 
'<h5>' esc_html_x'or''Conditional Logic: new rule logic.''wpforms-lite' ) . '</h5>';

                        echo 
'</div>'// Close individual group markup.

                    
endforeach; // End foreach() for conditional logic groups.

                    
echo '<button class="wpforms-conditional-groups-add">' esc_html__'Add rule group''wpforms-lite' ) . '</button>';

                echo 
'</div>'// Close Groups wrap markup.

            
endif; // End $enabled.

        
echo '</div>'// Close block markup.

        
$output ob_get_clean();

        if ( 
$echo ) {
            echo 
$output//phpcs:ignore
        
} else {
            return 
$output;
        }
    }

    
/**
     * Alias method for backwards compatibility.
     *
     * @since 1.1.0
     * @deprecated 1.3.8 Use wpforms_conditional_logic()->builder_block() instead.
     *
     * @param array $args Data needed for a block to be generated properly.
     * @param bool  $echo Whether to return or print. Default: print.
     *
     * @return string
     */
    
public function conditionals_block$args = array(), $echo true ) {

        if ( 
$echo ) {
            echo 
$this->builder_block$args$echo ); //phpcs:ignore
        
} else {
            return 
$this->builder_block$args$echo );
        }
    }

    
/**
     * Process conditional rules.
     *
     * Check if a form passes the conditional logic rules that are provided.
     *
     * @since 1.3.8
     * @since 1.6.1 Added multiple select support.
     *
     * @param array $fields       List of fields with data and settings.
     * @param array $form_data    Form data and settings.
     * @param array $conditionals List of conditionals.
     *
     * @return bool
     */
    
public function process$fields$form_data$conditionals ) {

        if ( empty( 
$conditionals ) ) {
            return 
true;
        }

        
$pass false;

        foreach ( 
$conditionals as $group_id => $group ) {

            
$pass_group true;

            if ( ! empty( 
$group ) ) {

                foreach ( 
$group as $rule_id => $rule ) {

                    if ( ! isset( 
$rule['field'] ) || '' == $rule['field'] || ! isset( $rule['operator'] ) ) {
                        continue;
                    }

                    if ( ! isset( 
$rule['value'] ) && ! in_array$rule['operator'], array( 'e''!e' ), true ) ) {
                        continue;
                    }

                    
$rule_field    $rule['field'];
                    
$rule_operator $rule['operator'];
                    
$rule_value    = isset( $rule['value'] ) ? $rule['value'] : '';

                    if ( 
in_array$fields$rule_field ]['type'], array( 'text''textarea''email''url''number''hidden''rating''number-slider''net_promoter_score' ), true ) ) {

                        
// Text based fields.
                        
$left  strtolowertrimwpforms_decode_string$fields$rule_field ]['value'] ) ) );
                        
$right strtolowertrim$rule_value ) );

                        switch ( 
$rule_operator ) {
                            case 
'==':
                                
$pass_rule = ( $left == $right );
                                break;
                            case 
'!=':
                                
$pass_rule = ( $left != $right );
                                break;
                            case 
'c':
                                
$pass_rule = ( strpos$left$right ) !== false );
                                break;
                            case 
'!c':
                                
$pass_rule = ( strpos$left$right ) === false );
                                break;
                            case 
'^':
                                
$pass_rule = ( strrpos$left$right, -strlen$left ) ) !== false );
                                break;
                            case 
'~':
                                
$pass_rule = ( ( $temp strlen$left ) - strlen$right ) ) >= && strpos$left$right$temp ) !== false );
                                break;
                            case 
'e':
                                
$pass_rule = ( '' == $left );
                                break;
                            case 
'!e':
                                
$pass_rule = ( '' != $left );
                                break;
                            case 
'>':
                                
$left      preg_replace'/[^-0-9.]/'''$left );
                                
$pass_rule = ( '' !== $left ) && ( floatval$left ) > floatval$right ) );
                                break;
                            case 
'<':
                                
$left      preg_replace'/[^-0-9.]/'''$left );
                                
$pass_rule = ( '' !== $left ) && ( floatval$left ) < floatval$right ) );
                                break;
                            default:
                                
$pass_rule apply_filters'wpforms_process_conditional_logic'false$rule_operator$left$right );
                                break;
                        }
                    } else {

                        
// Selector based fields.
                        
$provided_id false;

                        if (
                            
in_array$fields$rule_field ]['type'], array( 'payment-multiple''payment-checkbox''payment-select' ), true ) &&
                            isset( 
$fields$rule_field ]['value_raw'] ) &&
                            
'' != $fields$rule_field ]['value_raw']
                        ) {

                            
// Payment Multiple/Checkbox fields store the option key,
                            // so we can reference that easily.
                            
$provided_id explode',', (string) $fields$rule_field ]['value_raw'] );

                        } elseif ( isset( 
$fields$rule_field ]['value'] ) && '' != $fields$rule_field ]['value'] ) {

                            
// Other select type fields we don't store the
                            // option key so we have to do the logic to locate
                            // it ourselves.
                            
$provided_id = array();

                            if ( 
in_array$fields$rule_field ]['type'], array( 'checkbox''select' ), true ) ) {
                                
$values explode"\n"$fields$rule_field ]['value'] );
                            } else {
                                
$values = (array) $fields$rule_field ]['value'];
                            }

                            foreach ( 
$form_data['fields'][ $rule_field ]['choices'] as $key => $choice ) {

                                
$choice array_map'wpforms_decode_string'$choice );

                                if ( 
in_array$fields$rule_field ]['type'], [ 'radio''checkbox''select' ], true ) ) {
                                    
// Remove newlines from the choice (label or value) before comparing.
                                    // Newlines can be pasted with a long text to the choice label (or value) in the form builder.
                                    
$choice array_map'sanitize_text_field'$choice );
                                }

                                foreach ( 
$values as $value ) {
                                    
$value wpforms_decode_string$value );

                                    if ( 
in_array$value$choicetrue ) ) {
                                        
$provided_id[] = $key;
                                    }
                                }
                            }
                        }

                        
$left  = (array) $provided_id;
                        
$right strtolowertrim( (int) $rule_value ) );

                        switch ( 
$rule_operator ) {
                            case 
'==':
                            case 
'c'// BC, no longer available.
                            
case '^'// BC, no longer available.
                            
case '~'// BC, no longer available.
                                
$pass_rule in_array$right$left );
                                break;
                            case 
'!=':
                            case 
'!c'// BC, no longer available.
                                
$pass_rule = ! in_array$right$left );
                                break;
                            case 
'e':
                                
$pass_rule = empty( $left[0] );
                                break;
                            case 
'!e':
                                
$pass_rule = ! empty( $left[0] );
                                break;
                            default:
                                
$pass_rule apply_filters'wpforms_process_conditional_logic'false$rule_operator$left$right );
                                break;
                        }
                    } 
// End if().

                    
if ( ! $pass_rule ) {
                        
$pass_group false;
                        break;
                    }
                } 
// End foreach().
            
// End if().

            
if ( $pass_group ) {
                
$pass true;
            }
        } 
// End foreach().

        
return $pass;
    }

    
/**
     * Alias function for backwards compatibility.
     *
     * @since 1.0.0
     *
     * @param array $fields       List of fields with data and settings.
     * @param array $form_data    Form data and settings.
     * @param array $conditionals List of conditionals.
     *
     * @return bool
     */
    
public function conditionals_process$fields$form_data$conditionals ) {
        return 
$this->process$fields$form_data$conditionals );
    }
}

/**
 * The function which returns the one WPForms_Conditional_Logic_Core instance.
 *
 * Use this function like you would a global variable, except without needing
 * to declare the global.
 *
 * @since 1.1.0
 *
 * @return WPForms_Conditional_Logic_Core
 */
function wpforms_conditional_logic() {
    return 
WPForms_Conditional_Logic_Core::instance();
}

wpforms_conditional_logic();
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586