Completed
Branch master (5979d3)
by
unknown
26:18 queued 23:58
created
admin_pages/transactions/templates/txn_admin_details_header.template.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@
 block discarded – undo
17 17
 
18 18
 <h3 class="txn-navigation-strip">
19 19
     <?php
20
-    echo wp_kses($previous_transaction, AllowedTags::getAllowedTags());
21
-    echo '&nbsp;' . sprintf(
22
-        /* translators: %s: transaction number */
23
-        esc_html__('Transaction # %1$s', 'event_espresso'),
24
-        esc_html($txn_nmbr['value'])
25
-    ) . '&nbsp;';
26
-    echo wp_kses($next_transaction, AllowedTags::getAllowedTags());
27
-    ?>
20
+	echo wp_kses($previous_transaction, AllowedTags::getAllowedTags());
21
+	echo '&nbsp;' . sprintf(
22
+		/* translators: %s: transaction number */
23
+		esc_html__('Transaction # %1$s', 'event_espresso'),
24
+		esc_html($txn_nmbr['value'])
25
+	) . '&nbsp;';
26
+	echo wp_kses($next_transaction, AllowedTags::getAllowedTags());
27
+	?>
28 28
 </h3>
29 29
 
30 30
 <h2 id="txn-date-h2" class="txn-date-h2">
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@
 block discarded – undo
18 18
 <h3 class="txn-navigation-strip">
19 19
     <?php
20 20
     echo wp_kses($previous_transaction, AllowedTags::getAllowedTags());
21
-    echo '&nbsp;' . sprintf(
21
+    echo '&nbsp;'.sprintf(
22 22
         /* translators: %s: transaction number */
23 23
         esc_html__('Transaction # %1$s', 'event_espresso'),
24 24
         esc_html($txn_nmbr['value'])
25
-    ) . '&nbsp;';
25
+    ).'&nbsp;';
26 26
     echo wp_kses($next_transaction, AllowedTags::getAllowedTags());
27 27
     ?>
28 28
 </h3>
Please login to merge, or discard this patch.
templates/txn_admin_details_main_meta_box_txn_details.template.php 2 patches
Indentation   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -83,25 +83,25 @@  discard block
 block discarded – undo
83 83
     </div>
84 84
     <br class="clear" />
85 85
     <?php
86
-    $no_payments = $grand_raw_total > 0
87
-                   || $TXN_status !== EEM_Transaction::complete_status_code
88
-                   || ! empty($payments);
89
-    ?>
86
+	$no_payments = $grand_raw_total > 0
87
+				   || $TXN_status !== EEM_Transaction::complete_status_code
88
+				   || ! empty($payments);
89
+	?>
90 90
     <?php if ($attendee instanceof EE_Attendee && $no_payments) : ?>
91 91
         <?php $no_payment_text = $can_edit_payments
92
-            ? esc_html__(
93
-                'No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.',
94
-                'event_espresso'
95
-            )
96
-            : esc_html__(
97
-                'No payments have been applied to this transaction yet.',
98
-                'event_espresso'
99
-            );
100
-        ?>
92
+			? esc_html__(
93
+				'No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.',
94
+				'event_espresso'
95
+			)
96
+			: esc_html__(
97
+				'No payments have been applied to this transaction yet.',
98
+				'event_espresso'
99
+			);
100
+		?>
101 101
 
102 102
         <h3 class="admin-primary-mbox-h4 hdr-has-icon">
103 103
             <span class="ee-icon ee-icon-cash"></span><?php
104
-            esc_html_e('Payment Details', 'event_espresso'); ?>
104
+			esc_html_e('Payment Details', 'event_espresso'); ?>
105 105
         </h3>
106 106
 
107 107
         <div class="admin-primary-mbox-tbl-wrap">
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
                         <th class="jst-left"><?php esc_html_e('TXN&nbsp;ID / CHQ&nbsp;#', 'event_espresso'); ?></th>
118 118
                         <th class="jst-left"><?php esc_html_e('P.O. / S.O.&nbsp;#', 'event_espresso'); ?></th>
119 119
                         <th class="jst-left"><?php esc_html_e(
120
-                            'Notes / Extra&nbsp;Accounting',
121
-                            'event_espresso'
122
-                        ); ?></th>
120
+							'Notes / Extra&nbsp;Accounting',
121
+							'event_espresso'
122
+						); ?></th>
123 123
                         <!--<th class="jst-left"><?php esc_html_e('Details', 'event_espresso'); ?></th>-->
124 124
                         <th class="jst-cntr"><?php esc_html_e('Amount', 'event_espresso'); ?></th>
125 125
                     </tr>
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
                     <?php if ($payments) : ?>
129 129
                         <?php $payment_total = 0; ?>
130 130
                         <?php foreach ($payments as $PAY_ID => $payment) :
131
-                            if (! $payment instanceof EE_Payment) {
132
-                                continue;
133
-                            }
134
-                            $PAY_ID = absint($PAY_ID);
135
-                            $existing_reg_payment_json = isset($existing_reg_payments[ $PAY_ID ])
136
-                                ? wp_json_encode($existing_reg_payments[ $PAY_ID ])
137
-                                : '{}';
138
-                            ?>
131
+							if (! $payment instanceof EE_Payment) {
132
+								continue;
133
+							}
134
+							$PAY_ID = absint($PAY_ID);
135
+							$existing_reg_payment_json = isset($existing_reg_payments[ $PAY_ID ])
136
+								? wp_json_encode($existing_reg_payments[ $PAY_ID ])
137
+								: '{}';
138
+							?>
139 139
                             <tr id="txn-admin-payment-tr-<?php echo absint($PAY_ID); ?>">
140 140
                                 <td>
141 141
                 <span id="payment-status-<?php echo absint($PAY_ID); ?>"
@@ -189,15 +189,15 @@  discard block
 block discarded – undo
189 189
                                     </div>
190 190
                                     <div id="payment-gateway-<?php echo absint($PAY_ID); ?>">
191 191
                                         <?php echo ($payment->payment_method() instanceof EE_Payment_Method
192
-                                            ? esc_html($payment->payment_method()->admin_name())
193
-                                            : esc_html__("Unknown", 'event_espresso')); ?>
192
+											? esc_html($payment->payment_method()->admin_name())
193
+											: esc_html__("Unknown", 'event_espresso')); ?>
194 194
                                     </div>
195 195
                                     <div id="payment-gateway-id-<?php echo absint($PAY_ID); ?>"
196 196
                                          class="hidden"
197 197
                                     >
198 198
                                         <?php echo ($payment->payment_method() instanceof EE_Payment_Method
199
-                                            ? esc_html($payment->payment_method()->ID())
200
-                                            : 0); ?>
199
+											? esc_html($payment->payment_method()->ID())
200
+											: 0); ?>
201 201
                                     </div>
202 202
                                 </td>
203 203
                                 <td class=" jst-left">
@@ -222,18 +222,18 @@  discard block
 block discarded – undo
222 222
                                 </td>
223 223
                                 <td class=" jst-rght">
224 224
                                     <?php
225
-                                    $payment_class = $payment->amount() > 0
226
-                                        ? 'txn-admin-payment-status-' . $payment->STS_ID()
227
-                                        : 'txn-admin-payment-status-PDC';
228
-                                    ?>
225
+									$payment_class = $payment->amount() > 0
226
+										? 'txn-admin-payment-status-' . $payment->STS_ID()
227
+										: 'txn-admin-payment-status-PDC';
228
+									?>
229 229
                                     <span class="<?php echo esc_attr($payment_class); ?>">
230 230
                                         <span id="payment-amount-<?php echo absint($PAY_ID); ?>" style="display:inline;">
231 231
                                         <?php echo EEH_Template::format_currency(
232
-                                            $payment->amount(),
233
-                                            false,
234
-                                            false
235
-                                        ); // already escaped
236
-                                        ?>
232
+											$payment->amount(),
233
+											false,
234
+											false
235
+										); // already escaped
236
+										?>
237 237
                                         </span>
238 238
                                     </span>
239 239
                                 </td>
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
                             <?php $payment_total += $payment->STS_ID() == 'PAP' ? $payment->amount() : 0; ?>
242 242
                         <?php endforeach; ?>
243 243
                         <?php $pay_totals_class = $payment_total > $grand_raw_total
244
-                            ? ' important-notice'
245
-                            : '';
246
-                        ?>
244
+							? ' important-notice'
245
+							: '';
246
+						?>
247 247
                         <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr hidden">
248 248
                             <td class=" jst-rght" colspan="10">
249 249
                                 <span class="important-notice"><?php echo wp_kses($no_payment_text, AllowedTags::getAllowedTags()); ?></span>
@@ -255,28 +255,28 @@  discard block
 block discarded – undo
255 255
                             <th class=" jst-rght" colspan="9">
256 256
                         <span id="payments-total-spn">
257 257
                         <?php
258
-                        $overpaid = $payment_total > $grand_raw_total
259
-                            ? '<span id="overpaid">'
260
-                              . __('This transaction has been overpaid ! ', 'event_espresso')
261
-                              . '</span>'
262
-                            : '';
263
-                        echo esc_html(
264
-                            $overpaid
265
-                            . sprintf(
266
-                                __('Payments Total %s', 'event_espresso'),
267
-                                '(' . EE_Registry::instance()->CFG->currency->code . ')'
268
-                            )
269
-                        ); ?>
258
+						$overpaid = $payment_total > $grand_raw_total
259
+							? '<span id="overpaid">'
260
+							  . __('This transaction has been overpaid ! ', 'event_espresso')
261
+							  . '</span>'
262
+							: '';
263
+						echo esc_html(
264
+							$overpaid
265
+							. sprintf(
266
+								__('Payments Total %s', 'event_espresso'),
267
+								'(' . EE_Registry::instance()->CFG->currency->code . ')'
268
+							)
269
+						); ?>
270 270
                         </span>
271 271
                             </th>
272 272
                             <th class=" jst-rght">
273 273
                         <span id="txn-admin-payment-total">
274 274
                         <?php
275
-                        echo EEH_Template::format_currency(
276
-                            $payment_total,
277
-                            false,
278
-                            false
279
-                        ); // already escaped ?>
275
+						echo EEH_Template::format_currency(
276
+							$payment_total,
277
+							false,
278
+							false
279
+						); // already escaped ?>
280 280
                         </span>
281 281
                             </th>
282 282
                         </tr>
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 
360 360
         <ul id="txn-admin-payment-options-ul">
361 361
             <?php if ($can_edit_payments) :
362
-                ?>
362
+				?>
363 363
                 <li>
364 364
                     <a id="display-txn-admin-apply-payment"
365 365
                        class="button-primary no-icon no-hide"
@@ -384,12 +384,12 @@  discard block
 block discarded – undo
384 384
                 </li>
385 385
             <?php endif; ?>
386 386
             <?php
387
-            // Allows extend the fields at actions area.
388
-            do_action(
389
-                'AHEE__txn_admin_details_main_meta_box_txn_details__after_actions_buttons',
390
-                $can_edit_payments
391
-            );
392
-            ?>
387
+			// Allows extend the fields at actions area.
388
+			do_action(
389
+				'AHEE__txn_admin_details_main_meta_box_txn_details__after_actions_buttons',
390
+				$can_edit_payments
391
+			);
392
+			?>
393 393
         </ul>
394 394
         <br class="clear" />
395 395
 
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
             >
401 401
                 <div class="ee-icon ee-icon-cash-add float-left"></div>
402 402
                 <?php
403
-                echo esc_html__('Apply a Payment to Transaction #', 'event_espresso') . esc_html($txn_nmbr['value']); ?>
403
+				echo esc_html__('Apply a Payment to Transaction #', 'event_espresso') . esc_html($txn_nmbr['value']); ?>
404 404
             </h2>
405 405
 
406 406
             <h2 id="admin-modal-dialog-edit-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon"
@@ -408,23 +408,23 @@  discard block
 block discarded – undo
408 408
             >
409 409
                 <div class="ee-icon ee-icon-cash-edit float-left"></div>
410 410
                 <?php
411
-                printf(
412
-                    esc_html__('Edit Payment #%s for Transaction #%s', 'event_espresso'),
413
-                    '<span></span>',
414
-                    $txn_nmbr['value']
415
-                );
416
-                ?>
411
+				printf(
412
+					esc_html__('Edit Payment #%s for Transaction #%s', 'event_espresso'),
413
+					'<span></span>',
414
+					$txn_nmbr['value']
415
+				);
416
+				?>
417 417
             </h2>
418 418
 
419 419
             <h2 id="admin-modal-dialog-edit-refund-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;">
420 420
                 <div class="ee-icon ee-icon-cash-edit float-left"></div>
421 421
                 <?php
422
-                printf(
423
-                    esc_html__('Edit Refund #%s for Transaction #%s', 'event_espresso'),
424
-                    '<span></span>',
425
-                    $txn_nmbr['value']
426
-                );
427
-                ?>
422
+				printf(
423
+					esc_html__('Edit Refund #%s for Transaction #%s', 'event_espresso'),
424
+					'<span></span>',
425
+					$txn_nmbr['value']
426
+				);
427
+				?>
428 428
             </h2>
429 429
 
430 430
             <h2 id="admin-modal-dialog-apply-refund-h2" class="admin-modal-dialog-h2 hdr-has-icon"
@@ -432,9 +432,9 @@  discard block
 block discarded – undo
432 432
             >
433 433
                 <div class="ee-icon ee-icon-cash-remove float-left"></div>
434 434
                 <?php
435
-                echo esc_html__('Apply a Refund to Transaction #', 'event_espresso');
436
-                echo esc_html($txn_nmbr['value']);
437
-                ?>
435
+				echo esc_html__('Apply a Refund to Transaction #', 'event_espresso');
436
+				echo esc_html($txn_nmbr['value']);
437
+				?>
438 438
             </h2>
439 439
 
440 440
             <form name="txn-admin-apply-payment-frm"
@@ -533,29 +533,29 @@  discard block
 block discarded – undo
533 533
                             >
534 534
                                 <?php foreach ($payment_methods as $method) : ?>
535 535
                                     <?php
536
-                                    $selected = $method->slug() == 'cash'
537
-                                        ? ' selected'
538
-                                        : '';
539
-                                    ?>
536
+									$selected = $method->slug() == 'cash'
537
+										? ' selected'
538
+										: '';
539
+									?>
540 540
                                     <option id="payment-method-opt-<?php echo esc_attr($method->slug()); ?>"
541 541
                                             value="<?php echo esc_attr($method->ID()); ?>"
542 542
                                         <?php echo esc_attr($selected); ?>
543 543
                                     >
544 544
                                         <?php
545
-                                        echo esc_html(
546
-                                            sanitize_key($method->admin_desc())
547
-                                                ? substr($method->admin_desc(), 0, 128)
548
-                                                : $method->admin_name()
549
-                                        );
550
-                                        ?>&nbsp;&nbsp;
545
+										echo esc_html(
546
+											sanitize_key($method->admin_desc())
547
+												? substr($method->admin_desc(), 0, 128)
548
+												: $method->admin_name()
549
+										);
550
+										?>&nbsp;&nbsp;
551 551
                                     </option>
552 552
                                 <?php endforeach; ?>
553 553
                             </select>
554 554
                             <p class="description">
555 555
                                 <?php esc_html_e(
556
-                                    'Whether the payment was made via PayPal, Credit Card, Cheque, or Cash',
557
-                                    'event_espresso'
558
-                                ); ?>
556
+									'Whether the payment was made via PayPal, Credit Card, Cheque, or Cash',
557
+									'event_espresso'
558
+								); ?>
559 559
                             </p>
560 560
                         </div>
561 561
 
@@ -563,9 +563,9 @@  discard block
 block discarded – undo
563 563
                             <div class="txn-admin-apply-payment-gw-txn-id-dv admin-modal-dialog-row">
564 564
                                 <label for="txn-admin-payment-txn-id-chq-nmbr-inp" class="">
565 565
                                     <?php esc_html_e(
566
-                                        'TXN ID / CHQ #',
567
-                                        'event_espresso'
568
-                                    ); ?>
566
+										'TXN ID / CHQ #',
567
+										'event_espresso'
568
+									); ?>
569 569
                                 </label>
570 570
                                 <input name="txn_admin_payment[txn_id_chq_nmbr]"
571 571
                                        id="txn-admin-payment-txn-id-chq-nmbr-inp"
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
                                 />
575 575
                                 <p class="description">
576 576
                                     <?php esc_html_e(
577
-                                        'The Transaction ID sent back from the payment gateway, or the Cheque #',
578
-                                        'event_espresso'
579
-                                    ); ?>
577
+										'The Transaction ID sent back from the payment gateway, or the Cheque #',
578
+										'event_espresso'
579
+									); ?>
580 580
                                 </p>
581 581
                             </div>
582 582
                         </div>
@@ -593,9 +593,9 @@  discard block
 block discarded – undo
593 593
                                 />
594 594
                                 <p class="description">
595 595
                                     <?php esc_html_e(
596
-                                        'The gateway response string (optional)',
597
-                                        'event_espresso'
598
-                                    ); ?>
596
+										'The gateway response string (optional)',
597
+										'event_espresso'
598
+									); ?>
599 599
                                 </p>
600 600
                             </div>
601 601
                         </div>
@@ -604,9 +604,9 @@  discard block
 block discarded – undo
604 604
                             <div class="txn-admin-apply-payment-status-dv admin-modal-dialog-row">
605 605
                                 <label for="txn-admin-payment-status-slct" class="">
606 606
                                     <?php esc_html_e(
607
-                                        'Payment Status',
608
-                                        'event_espresso'
609
-                                    ); ?>
607
+										'Payment Status',
608
+										'event_espresso'
609
+									); ?>
610 610
                                 </label>
611 611
                                 <select name="txn_admin_payment[status]"
612 612
                                         id="txn-admin-payment-status-slct"
@@ -615,10 +615,10 @@  discard block
 block discarded – undo
615 615
                                 >
616 616
                                     <?php foreach ($payment_status as $STS_ID => $STS_code) : ?>
617 617
                                         <?php
618
-                                        $selected = $STS_ID == 'PAP'
619
-                                            ? 'selected'
620
-                                            : '';
621
-                                        ?>
618
+										$selected = $STS_ID == 'PAP'
619
+											? 'selected'
620
+											: '';
621
+										?>
622 622
                                         <option id="payment-status-opt-<?php echo esc_attr($STS_ID); ?>"
623 623
                                                 value="<?php echo esc_attr($STS_ID); ?>"
624 624
                                             <?php echo esc_attr($selected); ?>
@@ -629,10 +629,10 @@  discard block
 block discarded – undo
629 629
                                 </select>
630 630
                                 <p class="description">
631 631
                                     <?php
632
-                                    esc_html_e(
633
-                                        'Whether the payment was approved, cancelled, declined or failed after submission to the gateway',
634
-                                        'event_espresso'
635
-                                    ); ?>
632
+									esc_html_e(
633
+										'Whether the payment was approved, cancelled, declined or failed after submission to the gateway',
634
+										'event_espresso'
635
+									); ?>
636 636
                                 </p>
637 637
                             </div>
638 638
                         </div>
@@ -649,9 +649,9 @@  discard block
 block discarded – undo
649 649
                             />
650 650
                             <p class="description">
651 651
                                 <?php esc_html_e(
652
-                                    'The Purchase or Sales Order Number if any (optional)',
653
-                                    'event_espresso'
654
-                                ); ?>
652
+									'The Purchase or Sales Order Number if any (optional)',
653
+									'event_espresso'
654
+								); ?>
655 655
                             </p>
656 656
                         </div>
657 657
 
@@ -672,9 +672,9 @@  discard block
 block discarded – undo
672 672
                             />
673 673
                             <p class="description">
674 674
                                 <?php esc_html_e(
675
-                                    'An extra field you may use for accounting purposes or simple notes. Defaults to the primary registrant\'s registration code.',
676
-                                    'event_espresso'
677
-                                ); ?>
675
+									'An extra field you may use for accounting purposes or simple notes. Defaults to the primary registrant\'s registration code.',
676
+									'event_espresso'
677
+								); ?>
678 678
                             </p>
679 679
                         </div>
680 680
 
@@ -709,9 +709,9 @@  discard block
 block discarded – undo
709 709
                             <?php echo wp_kses($status_change_select, AllowedTags::getWithFormTags()); ?>
710 710
                             <p class="description">
711 711
                                 <?php esc_html_e(
712
-                                    'If you wish to change the status for the registrations selected above, then select which status from this dropdown.',
713
-                                    'event_espresso'
714
-                                ); ?>
712
+									'If you wish to change the status for the registrations selected above, then select which status from this dropdown.',
713
+									'event_espresso'
714
+								); ?>
715 715
                             </p>
716 716
                             <br />
717 717
                         </div>
@@ -742,14 +742,14 @@  discard block
 block discarded – undo
742 742
                             <br class="clear-float" />
743 743
                             <p class="description">
744 744
                                 <?php printf(
745
-                                    esc_html__(
746
-                                        'By default %1$sa payment message is sent to the primary registrant%2$s after submitting this form.%3$sHowever, if you check the "Registration Messages" box, the system will also send any related messages matching the status of the registrations to %1$seach registration for this transaction%2$s.',
747
-                                        'event_espresso'
748
-                                    ),
749
-                                    '<strong>',
750
-                                    '</strong>',
751
-                                    '<br />'
752
-                                ); ?>
745
+									esc_html__(
746
+										'By default %1$sa payment message is sent to the primary registrant%2$s after submitting this form.%3$sHowever, if you check the "Registration Messages" box, the system will also send any related messages matching the status of the registrations to %1$seach registration for this transaction%2$s.',
747
+										'event_espresso'
748
+									),
749
+									'<strong>',
750
+									'</strong>',
751
+									'<br />'
752
+								); ?>
753 753
                             </p>
754 754
                         </div>
755 755
                         <div class="clear"></div>
@@ -814,10 +814,10 @@  discard block
 block discarded – undo
814 814
             >
815 815
                 <span class="ee-icon ee-icon-cash-add"></span>
816 816
                 <?php printf(
817
-                    esc_html__('Delete Payment/Refund for Transaction #', 'event_espresso'),
818
-                    $txn_nmbr['value']
819
-                );
820
-                ?>
817
+					esc_html__('Delete Payment/Refund for Transaction #', 'event_espresso'),
818
+					$txn_nmbr['value']
819
+				);
820
+				?>
821 821
             </h2>
822 822
 
823 823
             <form name="txn-admin-delete-payment-frm"
@@ -853,13 +853,13 @@  discard block
 block discarded – undo
853 853
                             <?php echo wp_kses($delete_status_change_select, AllowedTags::getWithFormTags()); ?>
854 854
                             <p class="description">
855 855
                                 <?php printf(
856
-                                    esc_html__(
857
-                                        'If you wish to change the status of all the registrations associated with this transaction after deleting this payment/refund, then select which status from this dropdown. %sNote: ALL registrations associated with this transaction will be updated to this new status.%s',
858
-                                        'event_espresso'
859
-                                    ),
860
-                                    '<strong>',
861
-                                    '</strong>'
862
-                                ); ?>
856
+									esc_html__(
857
+										'If you wish to change the status of all the registrations associated with this transaction after deleting this payment/refund, then select which status from this dropdown. %sNote: ALL registrations associated with this transaction will be updated to this new status.%s',
858
+										'event_espresso'
859
+									),
860
+									'<strong>',
861
+									'</strong>'
862
+								); ?>
863 863
                             </p>
864 864
                         </div>
865 865
 
@@ -874,10 +874,10 @@  discard block
 block discarded – undo
874 874
                             />
875 875
                             <p class="description">
876 876
                                 <?php
877
-                                esc_html_e(
878
-                                    'If you check this box, the system will send any related registration messages matching the status of the registrations to each registration for this transaction. No Payment notifications are sent when deleting a payment.',
879
-                                    'event_espresso'
880
-                                ); ?>
877
+								esc_html_e(
878
+									'If you check this box, the system will send any related registration messages matching the status of the registrations to each registration for this transaction. No Payment notifications are sent when deleting a payment.',
879
+									'event_espresso'
880
+								); ?>
881 881
                             </p>
882 882
                         </div>
883 883
                         <div class="clear"></div>
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
     <?php endif; // $grand_raw_total > 0?>
911 911
 
912 912
     <?php if (WP_DEBUG) {
913
-        $delivered_messages = get_option('EED_Messages__payment', []);
914
-        if (isset($delivered_messages[ $TXN_ID ])) { ?>
913
+		$delivered_messages = get_option('EED_Messages__payment', []);
914
+		if (isset($delivered_messages[ $TXN_ID ])) { ?>
915 915
             <h4 class="admin-primary-mbox-h4 hdr-has-icon">
916 916
                 <span class="dashicons dashicons-email-alt"></span>
917 917
                 <?php esc_html_e('Messages Sent to Primary Registrant', 'event_espresso'); ?>
@@ -923,39 +923,39 @@  discard block
 block discarded – undo
923 923
                             <th class="jst-left"><?php esc_html_e('Date & Time', 'event_espresso'); ?></th>
924 924
                             <th class="jst-left"><?php esc_html_e('Message Type', 'event_espresso'); ?></th>
925 925
                             <th class="jst-left"><?php esc_html_e(
926
-                                'Payment Status Upon Sending',
927
-                                'event_espresso'
928
-                            ); ?></th>
926
+								'Payment Status Upon Sending',
927
+								'event_espresso'
928
+							); ?></th>
929 929
                             <th class="jst-left"><?php esc_html_e('TXN Status Upon Sending', 'event_espresso'); ?></th>
930 930
                         </tr>
931 931
                     </thead>
932 932
                     <tbody>
933 933
                         <?php
934
-                        foreach ($delivered_messages[ $TXN_ID ] as $timestamp => $delivered_message) :
935
-                            ?>
934
+						foreach ($delivered_messages[ $TXN_ID ] as $timestamp => $delivered_message) :
935
+							?>
936 936
                             <tr>
937 937
                                 <td class="jst-left">
938 938
                                     <?php echo esc_html(
939
-                                        date(
940
-                                            get_option('date_format') . ' ' . get_option('time_format'),
941
-                                            ($timestamp + (get_option('gmt_offset') * HOUR_IN_SECONDS))
942
-                                        )
943
-                                    ); ?>
939
+										date(
940
+											get_option('date_format') . ' ' . get_option('time_format'),
941
+											($timestamp + (get_option('gmt_offset') * HOUR_IN_SECONDS))
942
+										)
943
+									); ?>
944 944
                                 </td>
945 945
                                 <td class="jst-left"><?php
946
-                                    echo isset($delivered_message['message_type'])
947
-                                        ? esc_html($delivered_message['message_type'])
948
-                                        : ''; ?>
946
+									echo isset($delivered_message['message_type'])
947
+										? esc_html($delivered_message['message_type'])
948
+										: ''; ?>
949 949
                                 </td>
950 950
                                 <td class="jst-left"><?php
951
-                                    echo isset($delivered_message['pay_status'])
952
-                                        ? esc_html($delivered_message['pay_status'])
953
-                                        : ''; ?>
951
+									echo isset($delivered_message['pay_status'])
952
+										? esc_html($delivered_message['pay_status'])
953
+										: ''; ?>
954 954
                                 </td>
955 955
                                 <td class="jst-left"><?php
956
-                                    echo isset($delivered_message['txn_status'])
957
-                                        ? esc_html($delivered_message['txn_status'])
958
-                                        : ''; ?>
956
+									echo isset($delivered_message['txn_status'])
957
+										? esc_html($delivered_message['txn_status'])
958
+										: ''; ?>
959 959
                                 </td>
960 960
                             </tr>
961 961
                         <?php endforeach; // $delivered_messages?>
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
                 </table>
964 964
             </div>
965 965
             <?php
966
-        }
967
-    }
968
-    ?>
966
+		}
967
+	}
968
+	?>
969 969
 </div>
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -280,10 +280,13 @@  discard block
 block discarded – undo
280 280
                         </span>
281 281
                             </th>
282 282
                         </tr>
283
-                    <?php else : ?>
283
+                    <?php else {
284
+	: ?>
284 285
                         <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr">
285 286
                             <td class=" jst-rght" colspan="10">
286
-                                <span class="important-notice"><?php echo wp_kses($no_payment_text, AllowedTags::getAllowedTags()); ?></span>
287
+                                <span class="important-notice"><?php echo wp_kses($no_payment_text, AllowedTags::getAllowedTags());
288
+}
289
+?></span>
287 290
                             </td>
288 291
                         </tr>
289 292
                         <tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr hidden">
@@ -376,10 +379,13 @@  discard block
 block discarded – undo
376 379
                         <?php esc_html_e('Apply Refund', 'event_espresso'); ?>
377 380
                     </a>
378 381
                 </li>
379
-            <?php else : ?>
382
+            <?php else {
383
+	: ?>
380 384
                 <li>
381 385
                     <p>
382
-                        <?php esc_html__('You do not have access to apply payments or refunds.', 'event_espresso'); ?>
386
+                        <?php esc_html__('You do not have access to apply payments or refunds.', 'event_espresso');
387
+}
388
+?>
383 389
                     </p>
384 390
                 </li>
385 391
             <?php endif; ?>
Please login to merge, or discard this patch.
templates/txn_admin_details_side_meta_box_billing_info.template.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -10,30 +10,30 @@  discard block
 block discarded – undo
10 10
  */
11 11
 function ee_show_billing_info_cleaned(EE_Form_Section_Proper $form_section, $found_cc_data = false)
12 12
 {
13
-    foreach ($form_section->subsections() as $subsection) {
14
-        if ($subsection instanceof EE_Form_Input_Base) {
15
-            if (
16
-                $subsection->get_sensitive_data_removal_strategy() instanceof EE_All_Sensitive_Data_Removal
17
-                || $subsection->get_sensitive_data_removal_strategy() instanceof EE_CCV_Sensitive_Data_Removal
18
-                || $subsection->get_display_strategy() instanceof EE_Hidden_Display_Strategy
19
-            ) {
20
-                continue;
21
-            }
22
-            if ($subsection->get_sensitive_data_removal_strategy() instanceof EE_Credit_Card_Sensitive_Data_Removal) {
23
-                $found_cc_data = true;
24
-            }
25
-            ?>
13
+	foreach ($form_section->subsections() as $subsection) {
14
+		if ($subsection instanceof EE_Form_Input_Base) {
15
+			if (
16
+				$subsection->get_sensitive_data_removal_strategy() instanceof EE_All_Sensitive_Data_Removal
17
+				|| $subsection->get_sensitive_data_removal_strategy() instanceof EE_CCV_Sensitive_Data_Removal
18
+				|| $subsection->get_display_strategy() instanceof EE_Hidden_Display_Strategy
19
+			) {
20
+				continue;
21
+			}
22
+			if ($subsection->get_sensitive_data_removal_strategy() instanceof EE_Credit_Card_Sensitive_Data_Removal) {
23
+				$found_cc_data = true;
24
+			}
25
+			?>
26 26
             <div class="clearfix">
27 27
             <span class="admin-side-mbox-label-spn lt-grey-txt float-left">
28 28
                 <?php echo wp_kses($subsection->get_html_for_label(), AllowedTags::getWithFormTags()); ?>
29 29
             </span>
30 30
             <?php echo wp_kses($subsection->pretty_value(), AllowedTags::getWithFormTags()); ?>
31 31
             </div><?php
32
-        } elseif ($subsection instanceof EE_Form_Section_Proper) {
33
-            $found_cc_data = ee_show_billing_info_cleaned($subsection, $found_cc_data);
34
-        }
35
-    }
36
-    return $found_cc_data;
32
+		} elseif ($subsection instanceof EE_Form_Section_Proper) {
33
+			$found_cc_data = ee_show_billing_info_cleaned($subsection, $found_cc_data);
34
+		}
35
+	}
36
+	return $found_cc_data;
37 37
 }
38 38
 ?>
39 39
 
@@ -43,24 +43,24 @@  discard block
 block discarded – undo
43 43
             <?php esc_html_e('There is no billing info for this transaction.', 'event_espresso'); ?><br/>
44 44
         </div>
45 45
     <?php else :
46
-        $found_cc_data = ee_show_billing_info_cleaned($billing_form);
47
-        if (
48
-            apply_filters(
49
-                'FHEE__txn_admin_details_side_meta_box_billing_info__show_default_note',
50
-                $found_cc_data,
51
-                $billing_form
52
-            )
53
-        ) { ?>
46
+		$found_cc_data = ee_show_billing_info_cleaned($billing_form);
47
+		if (
48
+			apply_filters(
49
+				'FHEE__txn_admin_details_side_meta_box_billing_info__show_default_note',
50
+				$found_cc_data,
51
+				$billing_form
52
+			)
53
+		) { ?>
54 54
             <p class="help">
55 55
                 <?php esc_html_e(
56
-                    'Note: Card expiry dates and CCV are not stored. Only the last 4 digits of card numbers are stored.',
57
-                    'event_espresso'
58
-                ); ?>
56
+					'Note: Card expiry dates and CCV are not stored. Only the last 4 digits of card numbers are stored.',
57
+					'event_espresso'
58
+				); ?>
59 59
             </p>
60 60
             <?php
61
-        }
62
-        do_action('AHEE__txn_admin_details_side_meta_box_billing_info__billing_form_footer', $billing_form);
63
-    endif; ?>
61
+		}
62
+		do_action('AHEE__txn_admin_details_side_meta_box_billing_info__billing_form_footer', $billing_form);
63
+	endif; ?>
64 64
 
65 65
 </div>
66 66
 
Please login to merge, or discard this patch.
core/helpers/EEH_Form_Fields.helper.php 2 patches
Indentation   +1971 added lines, -1971 removed lines patch added patch discarded remove patch
@@ -29,1997 +29,1997 @@
 block discarded – undo
29 29
 {
30 30
 
31 31
 
32
-    /**
33
-     *  Generates HTML for the forms used on admin pages
34
-     *
35
-     *
36
-     * @static
37
-     * @access public
38
-     * @param array $input_vars - array of input field details
39
-     *                          format:
40
-     *                          $template_form_fields['field-id'] = array(
41
-     *                          'name' => 'name_attribute',
42
-     *                          'label' => esc_html__('Field Label', 'event_espresso'), //or false
43
-     *                          'input' => 'hidden', //field input type can be 'text', 'select', 'textarea', 'hidden',
44
-     *                          'checkbox', 'wp_editor'
45
-     *                          'type' => 'int', //what "type" the value is (i.e. string, int etc)
46
-     *                          'required' => false, //boolean for whether the field is required
47
-     *                          'validation' => true, //boolean, whether to validate the field (todo)
48
-     *                          'value' => 'some_value_for_field', //what value is used for field
49
-     *                          'format' => '%d', //what format the value is (%d, %f, or %s)
50
-     *                          'db-col' => 'column_in_db' //used to indicate which column the field corresponds with
51
-     *                          in the db
52
-     *                          'options' => optiona, optionb || array('value' => 'label', '') //if the input type is
53
-     *                          "select", this allows you to set the args for the different <option> tags.
54
-     *                          'tabindex' => 1 //this allows you to set the tabindex for the field.
55
-     *                          'append_content' => '' //this allows you to send in html content to append to the
56
-     *                          field.
57
-     *                          )
58
-     * @param array $form_id    - used for defining unique identifiers for the form.
59
-     * @return string
60
-     * @todo   : at some point we can break this down into other static methods to abstract it a bit better.
61
-     */
62
-    public static function get_form_fields($input_vars = [], $form_id = false)
63
-    {
64
-
65
-        if (empty($input_vars)) {
66
-            EE_Error::add_error(
67
-                esc_html__('missing required variables for the form field generator', 'event_espresso'),
68
-                __FILE__,
69
-                __FUNCTION__,
70
-                __LINE__
71
-            );
72
-            return false;
73
-        }
74
-
75
-        $output        = "";
76
-        $inputs        = [];
77
-        $hidden_inputs = [];
78
-
79
-        // cycle thru inputs
80
-        foreach ($input_vars as $input_key => $input_value) {
81
-            $defaults = [
82
-                'append_content' => '',
83
-                'css_class'      => '',
84
-                'cols'           => 80,
85
-                'db-col'         => 'column_in_db',
86
-                'format'         => '%d',
87
-                'input'          => 'hidden',
88
-                'label'          => esc_html__('No label', 'event_espresso'),
89
-                'name'           => $input_key,
90
-                'options'        => [],
91
-                'required'       => false,
92
-                'tabindex'       => 0,
93
-                'rows'           => 10,
94
-                'type'           => 'int',
95
-                'validation'     => true,
96
-                'value'          => 'some_value_for_field',
97
-            ];
98
-
99
-            $input_value = wp_parse_args($input_value, $defaults);
100
-
101
-            $append_content = $input_value['append_content'];
102
-            $css_class      = $input_value['css_class'];
103
-            $cols           = $input_value['cols'];
104
-            $label          = $input_value['label'];
105
-            $name           = $input_value['name'];
106
-            $options        = $input_value['options'];
107
-            $required       = $input_value['required'];
108
-            $tab_index      = $input_value['tabindex'];
109
-            $rows           = $input_value['rows'];
110
-            $type           = $input_value['input'];
111
-            $value          = $input_value['value'];
112
-
113
-            $id    = $form_id ? $form_id . '-' . $input_key : $input_key;
114
-            $class = $required ? 'required ' . $css_class : $css_class;
115
-
116
-            // what type of input are we dealing with ?
117
-            switch ($type) {
118
-                case 'checkbox':
119
-                case 'radio':
120
-                    $field = self::adminMulti($value, $class, $id, $name, $required, $tab_index, $type, 1, $label);
121
-                    $field .= $append_content ?: '';
122
-                    break;
123
-
124
-                case 'hidden':
125
-                    $field           = null;
126
-                    $hidden_inputs[] = self::adminHidden($css_class, $id, $name, $value);
127
-                    break;
128
-
129
-                case 'select':
130
-                    $options = is_array($options) ? $options : explode(',', $options);
131
-                    $field   = self::adminLabel($id, $label, $required);
132
-                    $field   .= self::adminSelect($value, $class, $id, $name, $required, $tab_index, $options);
133
-                    $field   .= $append_content ?: '';
134
-                    break;
135
-
136
-                case 'textarea':
137
-                    $field = self::adminLabel($id, $label, $required);
138
-                    $field .= self::adminTextarea($class, $cols, $id, $name, $required, $rows, $tab_index, $value);
139
-                    $field .= $append_content ?: '';
140
-                    break;
141
-
142
-                case 'wp_editor':
143
-                    $label = esc_html($label);
144
-                    $field = "<h4>{$label}</h4>";
145
-                    $field .= $append_content ?: '';
146
-                    $field .= self::adminWpEditor(
147
-                        $class,
148
-                        $id,
149
-                        $name,
150
-                        $rows,
151
-                        $tab_index,
152
-                        $value
153
-                    );
154
-                    break;
155
-
156
-                default:
157
-                    $field = self::adminLabel($id, $label, $required);
158
-                    $field .= self::adminText($class, $id, $name, $required, $tab_index, $value);
159
-                    $field .= $append_content ?: '';
160
-            }
161
-            if ($field) {
162
-                $inputs[] = $field;
163
-            }
164
-        } // end foreach( $input_vars as $input_key => $input_value )
165
-
166
-        if (! empty($inputs)) {
167
-            $glue   = "
32
+	/**
33
+	 *  Generates HTML for the forms used on admin pages
34
+	 *
35
+	 *
36
+	 * @static
37
+	 * @access public
38
+	 * @param array $input_vars - array of input field details
39
+	 *                          format:
40
+	 *                          $template_form_fields['field-id'] = array(
41
+	 *                          'name' => 'name_attribute',
42
+	 *                          'label' => esc_html__('Field Label', 'event_espresso'), //or false
43
+	 *                          'input' => 'hidden', //field input type can be 'text', 'select', 'textarea', 'hidden',
44
+	 *                          'checkbox', 'wp_editor'
45
+	 *                          'type' => 'int', //what "type" the value is (i.e. string, int etc)
46
+	 *                          'required' => false, //boolean for whether the field is required
47
+	 *                          'validation' => true, //boolean, whether to validate the field (todo)
48
+	 *                          'value' => 'some_value_for_field', //what value is used for field
49
+	 *                          'format' => '%d', //what format the value is (%d, %f, or %s)
50
+	 *                          'db-col' => 'column_in_db' //used to indicate which column the field corresponds with
51
+	 *                          in the db
52
+	 *                          'options' => optiona, optionb || array('value' => 'label', '') //if the input type is
53
+	 *                          "select", this allows you to set the args for the different <option> tags.
54
+	 *                          'tabindex' => 1 //this allows you to set the tabindex for the field.
55
+	 *                          'append_content' => '' //this allows you to send in html content to append to the
56
+	 *                          field.
57
+	 *                          )
58
+	 * @param array $form_id    - used for defining unique identifiers for the form.
59
+	 * @return string
60
+	 * @todo   : at some point we can break this down into other static methods to abstract it a bit better.
61
+	 */
62
+	public static function get_form_fields($input_vars = [], $form_id = false)
63
+	{
64
+
65
+		if (empty($input_vars)) {
66
+			EE_Error::add_error(
67
+				esc_html__('missing required variables for the form field generator', 'event_espresso'),
68
+				__FILE__,
69
+				__FUNCTION__,
70
+				__LINE__
71
+			);
72
+			return false;
73
+		}
74
+
75
+		$output        = "";
76
+		$inputs        = [];
77
+		$hidden_inputs = [];
78
+
79
+		// cycle thru inputs
80
+		foreach ($input_vars as $input_key => $input_value) {
81
+			$defaults = [
82
+				'append_content' => '',
83
+				'css_class'      => '',
84
+				'cols'           => 80,
85
+				'db-col'         => 'column_in_db',
86
+				'format'         => '%d',
87
+				'input'          => 'hidden',
88
+				'label'          => esc_html__('No label', 'event_espresso'),
89
+				'name'           => $input_key,
90
+				'options'        => [],
91
+				'required'       => false,
92
+				'tabindex'       => 0,
93
+				'rows'           => 10,
94
+				'type'           => 'int',
95
+				'validation'     => true,
96
+				'value'          => 'some_value_for_field',
97
+			];
98
+
99
+			$input_value = wp_parse_args($input_value, $defaults);
100
+
101
+			$append_content = $input_value['append_content'];
102
+			$css_class      = $input_value['css_class'];
103
+			$cols           = $input_value['cols'];
104
+			$label          = $input_value['label'];
105
+			$name           = $input_value['name'];
106
+			$options        = $input_value['options'];
107
+			$required       = $input_value['required'];
108
+			$tab_index      = $input_value['tabindex'];
109
+			$rows           = $input_value['rows'];
110
+			$type           = $input_value['input'];
111
+			$value          = $input_value['value'];
112
+
113
+			$id    = $form_id ? $form_id . '-' . $input_key : $input_key;
114
+			$class = $required ? 'required ' . $css_class : $css_class;
115
+
116
+			// what type of input are we dealing with ?
117
+			switch ($type) {
118
+				case 'checkbox':
119
+				case 'radio':
120
+					$field = self::adminMulti($value, $class, $id, $name, $required, $tab_index, $type, 1, $label);
121
+					$field .= $append_content ?: '';
122
+					break;
123
+
124
+				case 'hidden':
125
+					$field           = null;
126
+					$hidden_inputs[] = self::adminHidden($css_class, $id, $name, $value);
127
+					break;
128
+
129
+				case 'select':
130
+					$options = is_array($options) ? $options : explode(',', $options);
131
+					$field   = self::adminLabel($id, $label, $required);
132
+					$field   .= self::adminSelect($value, $class, $id, $name, $required, $tab_index, $options);
133
+					$field   .= $append_content ?: '';
134
+					break;
135
+
136
+				case 'textarea':
137
+					$field = self::adminLabel($id, $label, $required);
138
+					$field .= self::adminTextarea($class, $cols, $id, $name, $required, $rows, $tab_index, $value);
139
+					$field .= $append_content ?: '';
140
+					break;
141
+
142
+				case 'wp_editor':
143
+					$label = esc_html($label);
144
+					$field = "<h4>{$label}</h4>";
145
+					$field .= $append_content ?: '';
146
+					$field .= self::adminWpEditor(
147
+						$class,
148
+						$id,
149
+						$name,
150
+						$rows,
151
+						$tab_index,
152
+						$value
153
+					);
154
+					break;
155
+
156
+				default:
157
+					$field = self::adminLabel($id, $label, $required);
158
+					$field .= self::adminText($class, $id, $name, $required, $tab_index, $value);
159
+					$field .= $append_content ?: '';
160
+			}
161
+			if ($field) {
162
+				$inputs[] = $field;
163
+			}
164
+		} // end foreach( $input_vars as $input_key => $input_value )
165
+
166
+		if (! empty($inputs)) {
167
+			$glue   = "
168 168
                 </li>
169 169
                 <li>
170 170
                     ";
171
-            $inputs = implode($glue, $inputs);
172
-            $output = "
171
+			$inputs = implode($glue, $inputs);
172
+			$output = "
173 173
             <ul>
174 174
                 <li>
175 175
                 {$inputs} 
176 176
                 </li>
177 177
             </ul>
178 178
             ";
179
-        }
180
-        return $output . implode("\n", $hidden_inputs);
181
-    }
182
-
183
-
184
-    /**
185
-     * form_fields_array
186
-     * This utility function assembles form fields from a given structured array with field information.
187
-     * //TODO: This is an alternate generator that we may want to use instead.
188
-     *
189
-     * @param array $fields structured array of fields to assemble in the following format:
190
-     *                      [field_name] => array(
191
-     *                      ['label'] => 'label for field',
192
-     *                      ['labels'] => array('label_1', 'label_2'); //optional - if the field type is a multi select
193
-     *                      type of field you can indicated the labels for each option via this index
194
-     *                      ['extra_desc'] => 'extra description for the field', //optional
195
-     *                      ['type'] => 'textarea'|'text'|'wp_editor'|'checkbox'|'radio'|'hidden'|'select', //defaults
196
-     *                      to text
197
-     *                      ['value'] => 'value that goes in the field', //(if multi then this is an array of values
198
-     *                      and the 'default' paramater will be used for what is selected)
199
-     *                      ['default'] => 'default if the field type is multi (i.e. select or radios or checkboxes)',
200
-     *                      ['class'] => 'name-of-class(es)-for-input',
201
-     *                      ['classes'] => array('class_1', 'class_2'); //optional - if the field type is a multi
202
-     *                      select type of field you can indicate the css class for each option via this index.
203
-     *                      ['id'] => 'css-id-for-input') //defaults to 'field_name'
204
-     *                      ['unique_id'] => 1 //defaults to empty string.  This is useful for when the fields
205
-     *                      generated are going to be used in a loop and you want to make sure that the field
206
-     *                      identifiers are unique from each other.
207
-     *                      ['dimensions'] => array(100,300), //defaults to empty array.  This is used by field types
208
-     *                      such as textarea to indicate cols/rows.
209
-     *                      ['tabindex'] => '' //this allows you to set the tabindex for the field.
210
-     *                      ['wpeditor_args'] => array() //if the type of field is wpeditor then this can optionally
211
-     *                      contain an array of arguments for the editor setup.
212
-     *
213
-     * @return array         an array of inputs for form indexed by field name, and in the following structure:
214
-     *     [field_name] => array( 'label' => '{label_html}', 'field' => '{input_html}'
215
-     */
216
-    public static function get_form_fields_array($fields)
217
-    {
218
-
219
-        $form_fields = [];
220
-        $fields      = (array) $fields;
221
-
222
-        foreach ($fields as $field_name => $field_atts) {
223
-            // defaults:
224
-            $defaults = [
225
-                'class'         => '',
226
-                'classes'       => '',
227
-                'default'       => '',
228
-                'dimensions'    => ['10', '5'],
229
-                'extra_desc'    => '',
230
-                'id'            => $field_name,
231
-                'label'         => '',
232
-                'labels'        => '',
233
-                'required'      => false,
234
-                'tabindex'      => 0,
235
-                'type'          => 'text',
236
-                'unique_id'     => '',
237
-                'value'         => '',
238
-                'wpeditor_args' => [],
239
-            ];
240
-            // merge defaults with passed arguments
241
-            $_fields = wp_parse_args($field_atts, $defaults);
242
-
243
-            $class          = $_fields['class'];
244
-            $classes        = $_fields['classes'];
245
-            $default        = $_fields['default'];
246
-            $dims           = $_fields['dimensions'];
247
-            $extra_desc     = $_fields['extra_desc'];
248
-            $id             = $_fields['id'];
249
-            $label          = $_fields['label'];
250
-            $labels         = $_fields['labels'];
251
-            $required       = $_fields['required'];
252
-            $tab_index      = $_fields['tabindex'];
253
-            $type           = $_fields['type'];
254
-            $unique_id      = $_fields['unique_id'];
255
-            $value          = $_fields['value'];
256
-            $wp_editor_args = $_fields['wpeditor_args'];
257
-
258
-            // generate label
259
-            $label = ! empty($label) ? self::adminLabel($id, $label, $required) : '';
260
-            // generate field name
261
-            $name = ! empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name;
262
-
263
-            // we determine what we're building based on the type
264
-            switch ($type) {
265
-                case 'checkbox':
266
-                case 'radio':
267
-                    if (is_array($value)) {
268
-                        $c_input = '';
269
-                        foreach ($value as $key => $val) {
270
-                            $c_input .= self::adminMulti(
271
-                                $default,
272
-                                isset($classes[ $key ]) ? $classes[ $key ] : '',
273
-                                $field_name . '_' . $value,
274
-                                $name,
275
-                                $required,
276
-                                $tab_index,
277
-                                $type,
278
-                                $val,
279
-                                isset($labels[ $key ]) ? $labels[ $key ] : ''
280
-                            );
281
-                        }
282
-                        $field = $c_input;
283
-                    } else {
284
-                        $field = self::adminMulti(
285
-                            $default,
286
-                            $class,
287
-                            $id,
288
-                            $name,
289
-                            $required,
290
-                            $tab_index,
291
-                            $type,
292
-                            $value,
293
-                            $_fields['label']
294
-                        );
295
-                    }
296
-                    break;
297
-
298
-                case 'hidden':
299
-                    $field = self::adminHidden($class, $id, $name, $value);
300
-                    break;
301
-
302
-                case 'select':
303
-                    $options = [];
304
-                    foreach ($value as $key => $val) {
305
-                        $options[ $val ] = isset($labels[ $key ]) ? $labels[ $key ] : '';
306
-                    }
307
-                    $field = self::adminSelect($default, $class, $id, $name, $required, $tab_index, $options);
308
-                    break;
309
-
310
-                case 'textarea':
311
-                    $field =
312
-                        self::adminTextarea($class, $dims[0], $id, $name, $required, $dims[1], $tab_index, $value);
313
-                    break;
314
-
315
-                case 'wp_editor':
316
-                    $field = self::adminWpEditor(
317
-                        $class,
318
-                        $_fields['id'],
319
-                        $name,
320
-                        $dims[1],
321
-                        $tab_index,
322
-                        $value,
323
-                        $wp_editor_args
324
-                    );
325
-                    break;
326
-
327
-                default:
328
-                    $field = self::adminText($class, $id, $name, $required, $tab_index, $value);
329
-            }
330
-
331
-            $form_fields[ $field_name ] = ['label' => $label, 'field' => $field . $extra_desc];
332
-        }
333
-
334
-        return $form_fields;
335
-    }
336
-
337
-
338
-    /**
339
-     * @param string $class
340
-     * @param string $id
341
-     * @param string $name
342
-     * @param string $value
343
-     * @return string
344
-     * @since   4.10.14.p
345
-     */
346
-    private static function adminHidden($class, $id, $name, $value)
347
-    {
348
-        $id    = esc_attr($id);
349
-        $name  = esc_attr($name);
350
-        $class = esc_attr($class);
351
-        return "
179
+		}
180
+		return $output . implode("\n", $hidden_inputs);
181
+	}
182
+
183
+
184
+	/**
185
+	 * form_fields_array
186
+	 * This utility function assembles form fields from a given structured array with field information.
187
+	 * //TODO: This is an alternate generator that we may want to use instead.
188
+	 *
189
+	 * @param array $fields structured array of fields to assemble in the following format:
190
+	 *                      [field_name] => array(
191
+	 *                      ['label'] => 'label for field',
192
+	 *                      ['labels'] => array('label_1', 'label_2'); //optional - if the field type is a multi select
193
+	 *                      type of field you can indicated the labels for each option via this index
194
+	 *                      ['extra_desc'] => 'extra description for the field', //optional
195
+	 *                      ['type'] => 'textarea'|'text'|'wp_editor'|'checkbox'|'radio'|'hidden'|'select', //defaults
196
+	 *                      to text
197
+	 *                      ['value'] => 'value that goes in the field', //(if multi then this is an array of values
198
+	 *                      and the 'default' paramater will be used for what is selected)
199
+	 *                      ['default'] => 'default if the field type is multi (i.e. select or radios or checkboxes)',
200
+	 *                      ['class'] => 'name-of-class(es)-for-input',
201
+	 *                      ['classes'] => array('class_1', 'class_2'); //optional - if the field type is a multi
202
+	 *                      select type of field you can indicate the css class for each option via this index.
203
+	 *                      ['id'] => 'css-id-for-input') //defaults to 'field_name'
204
+	 *                      ['unique_id'] => 1 //defaults to empty string.  This is useful for when the fields
205
+	 *                      generated are going to be used in a loop and you want to make sure that the field
206
+	 *                      identifiers are unique from each other.
207
+	 *                      ['dimensions'] => array(100,300), //defaults to empty array.  This is used by field types
208
+	 *                      such as textarea to indicate cols/rows.
209
+	 *                      ['tabindex'] => '' //this allows you to set the tabindex for the field.
210
+	 *                      ['wpeditor_args'] => array() //if the type of field is wpeditor then this can optionally
211
+	 *                      contain an array of arguments for the editor setup.
212
+	 *
213
+	 * @return array         an array of inputs for form indexed by field name, and in the following structure:
214
+	 *     [field_name] => array( 'label' => '{label_html}', 'field' => '{input_html}'
215
+	 */
216
+	public static function get_form_fields_array($fields)
217
+	{
218
+
219
+		$form_fields = [];
220
+		$fields      = (array) $fields;
221
+
222
+		foreach ($fields as $field_name => $field_atts) {
223
+			// defaults:
224
+			$defaults = [
225
+				'class'         => '',
226
+				'classes'       => '',
227
+				'default'       => '',
228
+				'dimensions'    => ['10', '5'],
229
+				'extra_desc'    => '',
230
+				'id'            => $field_name,
231
+				'label'         => '',
232
+				'labels'        => '',
233
+				'required'      => false,
234
+				'tabindex'      => 0,
235
+				'type'          => 'text',
236
+				'unique_id'     => '',
237
+				'value'         => '',
238
+				'wpeditor_args' => [],
239
+			];
240
+			// merge defaults with passed arguments
241
+			$_fields = wp_parse_args($field_atts, $defaults);
242
+
243
+			$class          = $_fields['class'];
244
+			$classes        = $_fields['classes'];
245
+			$default        = $_fields['default'];
246
+			$dims           = $_fields['dimensions'];
247
+			$extra_desc     = $_fields['extra_desc'];
248
+			$id             = $_fields['id'];
249
+			$label          = $_fields['label'];
250
+			$labels         = $_fields['labels'];
251
+			$required       = $_fields['required'];
252
+			$tab_index      = $_fields['tabindex'];
253
+			$type           = $_fields['type'];
254
+			$unique_id      = $_fields['unique_id'];
255
+			$value          = $_fields['value'];
256
+			$wp_editor_args = $_fields['wpeditor_args'];
257
+
258
+			// generate label
259
+			$label = ! empty($label) ? self::adminLabel($id, $label, $required) : '';
260
+			// generate field name
261
+			$name = ! empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name;
262
+
263
+			// we determine what we're building based on the type
264
+			switch ($type) {
265
+				case 'checkbox':
266
+				case 'radio':
267
+					if (is_array($value)) {
268
+						$c_input = '';
269
+						foreach ($value as $key => $val) {
270
+							$c_input .= self::adminMulti(
271
+								$default,
272
+								isset($classes[ $key ]) ? $classes[ $key ] : '',
273
+								$field_name . '_' . $value,
274
+								$name,
275
+								$required,
276
+								$tab_index,
277
+								$type,
278
+								$val,
279
+								isset($labels[ $key ]) ? $labels[ $key ] : ''
280
+							);
281
+						}
282
+						$field = $c_input;
283
+					} else {
284
+						$field = self::adminMulti(
285
+							$default,
286
+							$class,
287
+							$id,
288
+							$name,
289
+							$required,
290
+							$tab_index,
291
+							$type,
292
+							$value,
293
+							$_fields['label']
294
+						);
295
+					}
296
+					break;
297
+
298
+				case 'hidden':
299
+					$field = self::adminHidden($class, $id, $name, $value);
300
+					break;
301
+
302
+				case 'select':
303
+					$options = [];
304
+					foreach ($value as $key => $val) {
305
+						$options[ $val ] = isset($labels[ $key ]) ? $labels[ $key ] : '';
306
+					}
307
+					$field = self::adminSelect($default, $class, $id, $name, $required, $tab_index, $options);
308
+					break;
309
+
310
+				case 'textarea':
311
+					$field =
312
+						self::adminTextarea($class, $dims[0], $id, $name, $required, $dims[1], $tab_index, $value);
313
+					break;
314
+
315
+				case 'wp_editor':
316
+					$field = self::adminWpEditor(
317
+						$class,
318
+						$_fields['id'],
319
+						$name,
320
+						$dims[1],
321
+						$tab_index,
322
+						$value,
323
+						$wp_editor_args
324
+					);
325
+					break;
326
+
327
+				default:
328
+					$field = self::adminText($class, $id, $name, $required, $tab_index, $value);
329
+			}
330
+
331
+			$form_fields[ $field_name ] = ['label' => $label, 'field' => $field . $extra_desc];
332
+		}
333
+
334
+		return $form_fields;
335
+	}
336
+
337
+
338
+	/**
339
+	 * @param string $class
340
+	 * @param string $id
341
+	 * @param string $name
342
+	 * @param string $value
343
+	 * @return string
344
+	 * @since   4.10.14.p
345
+	 */
346
+	private static function adminHidden($class, $id, $name, $value)
347
+	{
348
+		$id    = esc_attr($id);
349
+		$name  = esc_attr($name);
350
+		$class = esc_attr($class);
351
+		return "
352 352
         <input name='{$name}' type='hidden' id='{$id}' class='{$class}' value='{$value}' />";
353
-    }
354
-
355
-
356
-    /**
357
-     * @param string $id
358
-     * @param string $label
359
-     * @param string $required
360
-     * @return string
361
-     * @since   4.10.14.p
362
-     */
363
-    private static function adminLabel($id, $label, $required)
364
-    {
365
-        $id       = esc_attr($id);
366
-        $label    = esc_html($label);
367
-        $required = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? " <span>*</span>" : '';
368
-        return "<label for='{$id}'>{$label}{$required}</label>";
369
-    }
370
-
371
-
372
-    /**
373
-     * @param string $default
374
-     * @param string $class
375
-     * @param string $id
376
-     * @param string $name
377
-     * @param string $required
378
-     * @param int    $tab_index
379
-     * @param string $type
380
-     * @param string $value
381
-     * @param string $label
382
-     * @return string
383
-     * @since   4.10.14.p
384
-     */
385
-    private static function adminMulti($default, $class, $id, $name, $required, $tab_index, $type, $value, $label = '')
386
-    {
387
-        $id        = esc_attr($id);
388
-        $name      = esc_attr($name);
389
-        $class     = esc_attr($class);
390
-        $tab_index = absint($tab_index);
391
-        $checked   = ! empty($default) && $default == $value ? 'checked ' : '';
392
-        $required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
393
-        $input     = "
353
+	}
354
+
355
+
356
+	/**
357
+	 * @param string $id
358
+	 * @param string $label
359
+	 * @param string $required
360
+	 * @return string
361
+	 * @since   4.10.14.p
362
+	 */
363
+	private static function adminLabel($id, $label, $required)
364
+	{
365
+		$id       = esc_attr($id);
366
+		$label    = esc_html($label);
367
+		$required = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? " <span>*</span>" : '';
368
+		return "<label for='{$id}'>{$label}{$required}</label>";
369
+	}
370
+
371
+
372
+	/**
373
+	 * @param string $default
374
+	 * @param string $class
375
+	 * @param string $id
376
+	 * @param string $name
377
+	 * @param string $required
378
+	 * @param int    $tab_index
379
+	 * @param string $type
380
+	 * @param string $value
381
+	 * @param string $label
382
+	 * @return string
383
+	 * @since   4.10.14.p
384
+	 */
385
+	private static function adminMulti($default, $class, $id, $name, $required, $tab_index, $type, $value, $label = '')
386
+	{
387
+		$id        = esc_attr($id);
388
+		$name      = esc_attr($name);
389
+		$class     = esc_attr($class);
390
+		$tab_index = absint($tab_index);
391
+		$checked   = ! empty($default) && $default == $value ? 'checked ' : '';
392
+		$required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
393
+		$input     = "
394 394
         <input name='{$name}[]' type='{$type}' id='{$id}' class='{$class}' value='{$value}' {$checked} {$required} tabindex='{$tab_index}'/>";
395
-        if ($label === '') {
396
-            return $input;
397
-        }
398
-        $label = esc_html($label);
399
-        return "
395
+		if ($label === '') {
396
+			return $input;
397
+		}
398
+		$label = esc_html($label);
399
+		return "
400 400
         <label for='$id'>
401 401
             {$input}
402 402
             {$label}
403 403
         </label>";
404
-    }
405
-
406
-
407
-    /**
408
-     * @param string $default
409
-     * @param string $class
410
-     * @param string $id
411
-     * @param string $name
412
-     * @param string $required
413
-     * @param int    $tab_index
414
-     * @param array  $options
415
-     * @return string
416
-     * @since   4.10.14.p
417
-     */
418
-    private static function adminSelect($default, $class, $id, $name, $required, $tab_index, $options = [])
419
-    {
420
-        $options_array = [];
421
-        foreach ($options as $value => $label) {
422
-            $selected        = ! empty($default) && $default == $value ? 'selected' : '';
423
-            $value           = esc_attr($value);
424
-            $label           = wp_strip_all_tags($label);
425
-            $options_array[] = "<option value='{$value}' {$selected}>{$label}</option>";
426
-        }
427
-        $options_html = implode($options_array, "\n");
428
-        $id           = esc_attr($id);
429
-        $name         = esc_attr($name);
430
-        $class        = esc_attr($class);
431
-        $tab_index    = absint($tab_index);
432
-        $required     = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
433
-        return "
404
+	}
405
+
406
+
407
+	/**
408
+	 * @param string $default
409
+	 * @param string $class
410
+	 * @param string $id
411
+	 * @param string $name
412
+	 * @param string $required
413
+	 * @param int    $tab_index
414
+	 * @param array  $options
415
+	 * @return string
416
+	 * @since   4.10.14.p
417
+	 */
418
+	private static function adminSelect($default, $class, $id, $name, $required, $tab_index, $options = [])
419
+	{
420
+		$options_array = [];
421
+		foreach ($options as $value => $label) {
422
+			$selected        = ! empty($default) && $default == $value ? 'selected' : '';
423
+			$value           = esc_attr($value);
424
+			$label           = wp_strip_all_tags($label);
425
+			$options_array[] = "<option value='{$value}' {$selected}>{$label}</option>";
426
+		}
427
+		$options_html = implode($options_array, "\n");
428
+		$id           = esc_attr($id);
429
+		$name         = esc_attr($name);
430
+		$class        = esc_attr($class);
431
+		$tab_index    = absint($tab_index);
432
+		$required     = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
433
+		return "
434 434
         <select name='{$name}' id='{$id}' class='{$class}' {$required} tabindex='{$tab_index}'>
435 435
             {$options_html}
436 436
         </select>";
437
-    }
438
-
439
-
440
-    /**
441
-     * @param string $class
442
-     * @param string $id
443
-     * @param string $name
444
-     * @param string $required
445
-     * @param int    $tab_index
446
-     * @param string $value
447
-     * @return string
448
-     * @since   4.10.14.p
449
-     */
450
-    private static function adminText($class, $id, $name, $required, $tab_index, $value)
451
-    {
452
-        $id        = esc_attr($id);
453
-        $name      = esc_attr($name);
454
-        $class     = esc_attr($class);
455
-        $tab_index = absint($tab_index);
456
-        $required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
457
-        return "
437
+	}
438
+
439
+
440
+	/**
441
+	 * @param string $class
442
+	 * @param string $id
443
+	 * @param string $name
444
+	 * @param string $required
445
+	 * @param int    $tab_index
446
+	 * @param string $value
447
+	 * @return string
448
+	 * @since   4.10.14.p
449
+	 */
450
+	private static function adminText($class, $id, $name, $required, $tab_index, $value)
451
+	{
452
+		$id        = esc_attr($id);
453
+		$name      = esc_attr($name);
454
+		$class     = esc_attr($class);
455
+		$tab_index = absint($tab_index);
456
+		$required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
457
+		return "
458 458
         <input name='{$name}' type='text' id='{$id}' class='{$class}' value='{$value}' {$required} tabindex='{$tab_index}'/>";
459
-    }
460
-
461
-
462
-    /**
463
-     * @param string $class
464
-     * @param int    $cols
465
-     * @param string $id
466
-     * @param string $name
467
-     * @param string $required
468
-     * @param int    $rows
469
-     * @param int    $tab_index
470
-     * @param string $value
471
-     * @return string
472
-     * @since   4.10.14.p
473
-     */
474
-    private static function adminTextarea($class, $cols, $id, $name, $required, $rows, $tab_index, $value)
475
-    {
476
-        $id        = esc_attr($id);
477
-        $name      = esc_attr($name);
478
-        $class     = esc_attr($class);
479
-        $cols      = absint($cols);
480
-        $rows      = absint($rows);
481
-        $value     = esc_textarea($value);
482
-        $tab_index = absint($tab_index);
483
-        $required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
484
-        return "
459
+	}
460
+
461
+
462
+	/**
463
+	 * @param string $class
464
+	 * @param int    $cols
465
+	 * @param string $id
466
+	 * @param string $name
467
+	 * @param string $required
468
+	 * @param int    $rows
469
+	 * @param int    $tab_index
470
+	 * @param string $value
471
+	 * @return string
472
+	 * @since   4.10.14.p
473
+	 */
474
+	private static function adminTextarea($class, $cols, $id, $name, $required, $rows, $tab_index, $value)
475
+	{
476
+		$id        = esc_attr($id);
477
+		$name      = esc_attr($name);
478
+		$class     = esc_attr($class);
479
+		$cols      = absint($cols);
480
+		$rows      = absint($rows);
481
+		$value     = esc_textarea($value);
482
+		$tab_index = absint($tab_index);
483
+		$required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
484
+		return "
485 485
         <textarea name='{$name}' id='{$id}' class='{$class}' rows='{$rows}' cols='{$cols}' {$required} tabindex='{$tab_index}'>
486 486
             {$value}
487 487
         </textarea>";
488
-    }
489
-
490
-
491
-    /**
492
-     * @param string $class
493
-     * @param string $id
494
-     * @param string $name
495
-     * @param int    $rows
496
-     * @param int    $tab_index
497
-     * @param string $value
498
-     * @param array  $wp_editor_args
499
-     * @return false|string
500
-     * @since   4.10.14.p
501
-     */
502
-    private static function adminWpEditor($class, $id, $name, $rows, $tab_index, $value, $wp_editor_args = [])
503
-    {
504
-        $editor_settings = $wp_editor_args + [
505
-                'textarea_name' => esc_attr($name),
506
-                'textarea_rows' => absint($rows),
507
-                'editor_class'  => esc_attr($class),
508
-                'tabindex'      => absint($tab_index),
509
-            ];
510
-        ob_start();
511
-        wp_editor($value, esc_attr($id), $editor_settings);
512
-        return ob_get_clean();
513
-    }
514
-
515
-
516
-    /**
517
-     * espresso admin page select_input
518
-     * Turns an array into a select fields
519
-     *
520
-     * @static
521
-     * @access public
522
-     * @param string  $name       field name
523
-     * @param array   $values     option values, numbered array starting at 0, where each value is an array with a key
524
-     *                            'text' (meaning text to display' and 'id' (meaning the internal value) eg:
525
-     *                            array(1=>array('text'=>'Monday','id'=>1),2=>array('text'=>'Tuesday','id'=>2)...). or
526
-     *                            as an array of key-value pairs, where the key is to be used for the select input's
527
-     *                            name, and the value will be the text shown to the user.  Optionally you can also
528
-     *                            include an additional key of "class" which will add a specific class to the option
529
-     *                            for that value.
530
-     * @param string  $default    default value
531
-     * @param string  $parameters extra parameters
532
-     * @param string  $class      css class
533
-     * @param boolean $autosize   whether to autosize the select or not
534
-     * @return string              html string for the select input
535
-     */
536
-    public static function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true)
537
-    {
538
-        // if $values was submitted in the wrong format, convert it over
539
-        if (! empty($values) && (! array_key_exists(0, $values) || ! is_array($values[0]))) {
540
-            $converted_values = [];
541
-            foreach ($values as $id => $text) {
542
-                $converted_values[] = ['id' => $id, 'text' => $text];
543
-            }
544
-            $values = $converted_values;
545
-        }
546
-
547
-        $field =
548
-            '<select id="' . EEH_Formatter::ee_tep_output_string($name)
549
-            . '" name="' . EEH_Formatter::ee_tep_output_string($name)
550
-            . '"';
551
-
552
-        if (EEH_Formatter::ee_tep_not_null($parameters)) {
553
-            $field .= ' ' . $parameters;
554
-        }
555
-        if ($autosize) {
556
-            $size = 'med';
557
-            for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) {
558
-                if ($values[ $ii ]['text']) {
559
-                    if (strlen($values[ $ii ]['text']) > 5) {
560
-                        $size = 'wide';
561
-                    }
562
-                }
563
-            }
564
-        } else {
565
-            $size = '';
566
-        }
567
-
568
-        $field .= ' class="' . $class . ' ' . $size . '">';
569
-
570
-        if (empty($default) && isset($GLOBALS[ $name ])) {
571
-            $default = stripslashes($GLOBALS[ $name ]);
572
-        }
573
-
574
-
575
-        for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
576
-            $field .= '<option value="' . $values[ $i ]['id'] . '"';
577
-            if ($default == $values[ $i ]['id']) {
578
-                $field .= ' selected = "selected"';
579
-            }
580
-            if (isset($values[ $i ]['class'])) {
581
-                $field .= ' class="' . $values[ $i ]['class'] . '"';
582
-            }
583
-            $field .= '>' . $values[ $i ]['text'] . '</option>';
584
-        }
585
-        $field .= '</select>';
586
-
587
-        return $field;
588
-    }
589
-
590
-
591
-    /**
592
-     * generate_question_groups_html
593
-     *
594
-     * @param array  $question_groups
595
-     * @param string $group_wrapper
596
-     * @return string HTML
597
-     * @throws EE_Error
598
-     * @throws ReflectionException
599
-     */
600
-    public static function generate_question_groups_html($question_groups = [], $group_wrapper = 'fieldset')
601
-    {
602
-
603
-        $html                            = '';
604
-        $before_question_group_questions =
605
-            apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
606
-        $after_question_group_questions  =
607
-            apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
608
-
609
-        if (! empty($question_groups)) {
610
-            // loop thru question groups
611
-            foreach ($question_groups as $QSG) {
612
-                // check that questions exist
613
-                if (! empty($QSG['QSG_questions'])) {
614
-                    // use fieldsets
615
-                    $html .= "\n\t"
616
-                             . '<'
617
-                             . $group_wrapper
618
-                             . ' class="espresso-question-group-wrap" id="'
619
-                             . $QSG['QSG_identifier']
620
-                             . '">';
621
-                    // group_name
622
-                    $html .= $QSG['QSG_show_group_name']
623
-                        ? "\n\t\t"
624
-                          . '<h5 class="espresso-question-group-title-h5 section-title">'
625
-                          . self::prep_answer($QSG['QSG_name'])
626
-                          . '</h5>'
627
-                        : '';
628
-                    // group_desc
629
-                    $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc'])
630
-                        ? '<div class="espresso-question-group-desc-pg">'
631
-                          . self::prep_answer($QSG['QSG_desc'])
632
-                          . '</div>'
633
-                        : '';
634
-
635
-                    $html .= $before_question_group_questions;
636
-                    // loop thru questions
637
-                    foreach ($QSG['QSG_questions'] as $question) {
638
-                        $QFI  = new EE_Question_Form_Input(
639
-                            $question['qst_obj'],
640
-                            $question['ans_obj'],
641
-                            $question
642
-                        );
643
-                        $html .= self::generate_form_input($QFI);
644
-                    }
645
-                    $html .= $after_question_group_questions;
646
-                    $html .= "\n\t" . '</' . $group_wrapper . '>';
647
-                }
648
-            }
649
-        }
650
-
651
-        return $html;
652
-    }
653
-
654
-
655
-    /**
656
-     * generate_question_groups_html
657
-     *
658
-     * @param array  $question_groups
659
-     * @param array  $q_meta
660
-     * @param bool   $from_admin
661
-     * @param string $group_wrapper
662
-     * @return string HTML
663
-     * @throws EE_Error
664
-     * @throws ReflectionException
665
-     */
666
-    public static function generate_question_groups_html2(
667
-        $question_groups = [],
668
-        $q_meta = [],
669
-        $from_admin = false,
670
-        $group_wrapper = 'fieldset'
671
-    ) {
672
-
673
-        $html                            = '';
674
-        $before_question_group_questions =
675
-            apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
676
-        $after_question_group_questions  =
677
-            apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
678
-
679
-        $default_q_meta = [
680
-            'att_nmbr'    => 1,
681
-            'ticket_id'   => '',
682
-            'input_name'  => '',
683
-            'input_id'    => '',
684
-            'input_class' => '',
685
-        ];
686
-        $q_meta         = array_merge($default_q_meta, $q_meta);
687
-
688
-        if (! empty($question_groups)) {
689
-            // loop thru question groups
690
-            foreach ($question_groups as $QSG) {
691
-                if ($QSG instanceof EE_Question_Group) {
692
-                    // check that questions exist
693
-
694
-                    $where = ['QST_deleted' => 0];
695
-                    if (! $from_admin) {
696
-                        $where['QST_admin_only'] = 0;
697
-                    }
698
-                    $questions =
699
-                        $QSG->questions([$where, 'order_by' => ['Question_Group_Question.QGQ_order' => 'ASC']]);
700
-                    if (! empty($questions)) {
701
-                        // use fieldsets
702
-                        $html .= "\n\t"
703
-                                 . '<' . $group_wrapper . ' class="espresso-question-group-wrap" '
704
-                                 . 'id="' . $QSG->get('QSG_identifier') . '">';
705
-                        // group_name
706
-                        if ($QSG->show_group_name()) {
707
-                            $html .= "\n\t\t"
708
-                                     . '<h5 class="espresso-question-group-title-h5 section-title">'
709
-                                     . $QSG->get_pretty('QSG_name')
710
-                                     . '</h5>';
711
-                        }
712
-                        // group_desc
713
-                        if ($QSG->show_group_desc()) {
714
-                            $html .= '<div class="espresso-question-group-desc-pg">'
715
-                                     . $QSG->get_pretty('QSG_desc')
716
-                                     . '</div>';
717
-                        }
718
-
719
-                        $html .= $before_question_group_questions;
720
-                        // loop thru questions
721
-                        foreach ($questions as $QST) {
722
-                            $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID();
723
-
724
-                            $answer = null;
725
-
726
-                            /** @var RequestInterface $request */
727
-                            $request      = LoaderFactory::getLoader()->getShared(RequestInterface::class);
728
-                            $request_qstn = $request->getRequestParam('qstn', [], 'string', true);
729
-                            if (! empty($request_qstn) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) {
730
-                                // check for answer in $request_qstn in case we are reprocessing a form after an error
731
-                                if (isset($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])) {
732
-                                    $answer = is_array($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])
733
-                                        ? $request_qstn[ $q_meta['input_id'] ][ $qstn_id ]
734
-                                        : sanitize_text_field($request_qstn[ $q_meta['input_id'] ][ $qstn_id ]);
735
-                                }
736
-                            } elseif (isset($q_meta['attendee']) && $q_meta['attendee']) {
737
-                                // attendee data from the session
738
-                                $answer =
739
-                                    isset($q_meta['attendee'][ $qstn_id ]) ? $q_meta['attendee'][ $qstn_id ] : null;
740
-                            }
741
-
742
-
743
-                            $QFI  = new EE_Question_Form_Input(
744
-                                $QST,
745
-                                EE_Answer::new_instance(
746
-                                    [
747
-                                        'ANS_ID'    => 0,
748
-                                        'QST_ID'    => 0,
749
-                                        'REG_ID'    => 0,
750
-                                        'ANS_value' => $answer,
751
-                                    ]
752
-                                ),
753
-                                $q_meta
754
-                            );
755
-                            $html .= self::generate_form_input($QFI);
756
-                        }
757
-                        $html .= $after_question_group_questions;
758
-                        $html .= "\n\t" . '</' . $group_wrapper . '>';
759
-                    }
760
-                }
761
-            }
762
-        }
763
-        return $html;
764
-    }
765
-
766
-
767
-    /**
768
-     * generate_form_input
769
-     *
770
-     * @param EE_Question_Form_Input $QFI
771
-     * @return string HTML
772
-     * @throws EE_Error
773
-     * @throws ReflectionException
774
-     */
775
-    public static function generate_form_input(EE_Question_Form_Input $QFI)
776
-    {
777
-        if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) {
778
-            return '';
779
-        }
780
-        /** @var RequestInterface $request */
781
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
782
-
783
-        $QFI = self::_load_system_dropdowns($QFI);
784
-        $QFI = self::_load_specialized_dropdowns($QFI);
785
-
786
-        // we also need to verify
787
-
788
-        $display_text = $QFI->get('QST_display_text');
789
-        $input_name   = $QFI->get('QST_input_name');
790
-        $answer       = $request->getRequestParam($input_name, $QFI->get('ANS_value'));
791
-        $input_id     = $QFI->get('QST_input_id');
792
-        $input_class  = $QFI->get('QST_input_class');
793
-        //      $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : '';
794
-        $disabled          = $QFI->get('QST_disabled');
795
-        $required_label    = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>');
796
-        $QST_required      = $QFI->get('QST_required');
797
-        $required          =
798
-            $QST_required
799
-                ? ['label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required]
800
-                : [];
801
-        $use_html_entities = $QFI->get_meta('htmlentities');
802
-        $required_text     =
803
-            $QFI->get('QST_required_text') != ''
804
-                ? $QFI->get('QST_required_text')
805
-                : esc_html__('This field is required', 'event_espresso');
806
-        $required_text     = $QST_required
807
-            ? "\n\t\t\t"
808
-              . '<div class="required-text hidden">'
809
-              . self::prep_answer($required_text, $use_html_entities)
810
-              . '</div>'
811
-            : '';
812
-        $label_class       = 'espresso-form-input-lbl';
813
-        $QST_options       = $QFI->options(true, $answer);
814
-        $options           = is_array($QST_options) ? self::prep_answer_options($QST_options) : [];
815
-        $system_ID         = $QFI->get('QST_system');
816
-        $label_b4          = $QFI->get_meta('label_b4');
817
-        $use_desc_4_label  = $QFI->get_meta('use_desc_4_label');
818
-
819
-
820
-        switch ($QFI->get('QST_type')) {
821
-            case 'TEXTAREA':
822
-                return EEH_Form_Fields::textarea(
823
-                    $display_text,
824
-                    $answer,
825
-                    $input_name,
826
-                    $input_id,
827
-                    $input_class,
828
-                    [],
829
-                    $required,
830
-                    $required_text,
831
-                    $label_class,
832
-                    $disabled,
833
-                    $system_ID,
834
-                    $use_html_entities
835
-                );
836
-
837
-            case 'DROPDOWN':
838
-                return EEH_Form_Fields::select(
839
-                    $display_text,
840
-                    $answer,
841
-                    $options,
842
-                    $input_name,
843
-                    $input_id,
844
-                    $input_class,
845
-                    $required,
846
-                    $required_text,
847
-                    $label_class,
848
-                    $disabled,
849
-                    $system_ID,
850
-                    $use_html_entities,
851
-                    true
852
-                );
853
-
854
-
855
-            case 'RADIO_BTN':
856
-                return EEH_Form_Fields::radio(
857
-                    $display_text,
858
-                    $answer,
859
-                    $options,
860
-                    $input_name,
861
-                    $input_id,
862
-                    $input_class,
863
-                    $required,
864
-                    $required_text,
865
-                    $label_class,
866
-                    $disabled,
867
-                    $system_ID,
868
-                    $use_html_entities,
869
-                    $label_b4,
870
-                    $use_desc_4_label
871
-                );
872
-
873
-            case 'CHECKBOX':
874
-                return EEH_Form_Fields::checkbox(
875
-                    $display_text,
876
-                    $answer,
877
-                    $options,
878
-                    $input_name,
879
-                    $input_id,
880
-                    $input_class,
881
-                    $required,
882
-                    $required_text,
883
-                    $label_class,
884
-                    $disabled,
885
-                    $label_b4,
886
-                    $system_ID,
887
-                    $use_html_entities
888
-                );
889
-
890
-            case 'DATE':
891
-                return EEH_Form_Fields::datepicker(
892
-                    $display_text,
893
-                    $answer,
894
-                    $input_name,
895
-                    $input_id,
896
-                    $input_class,
897
-                    $required,
898
-                    $required_text,
899
-                    $label_class,
900
-                    $disabled,
901
-                    $system_ID,
902
-                    $use_html_entities
903
-                );
904
-
905
-            case 'TEXT':
906
-            default:
907
-                return EEH_Form_Fields::text(
908
-                    $display_text,
909
-                    $answer,
910
-                    $input_name,
911
-                    $input_id,
912
-                    $input_class,
913
-                    $required,
914
-                    $required_text,
915
-                    $label_class,
916
-                    $disabled,
917
-                    $system_ID,
918
-                    $use_html_entities
919
-                );
920
-        }
921
-    }
922
-
923
-
924
-    /**
925
-     * generates HTML for a form text input
926
-     *
927
-     * @param string $question    label content
928
-     * @param string $answer      form input value attribute
929
-     * @param string $name        form input name attribute
930
-     * @param string $id          form input css id attribute
931
-     * @param string $class       form input css class attribute
932
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
933
-     *                            required 'class', and required 'msg' attribute
934
-     * @param string $label_class css class attribute for the label
935
-     * @param string $disabled    disabled="disabled" or null
936
-     * @return string HTML
937
-     */
938
-    public static function text(
939
-        $question = false,
940
-        $answer = null,
941
-        $name = false,
942
-        $id = '',
943
-        $class = '',
944
-        $required = false,
945
-        $required_text = '',
946
-        $label_class = '',
947
-        $disabled = false,
948
-        $system_ID = false,
949
-        $use_html_entities = true
950
-    ) {
951
-        // need these
952
-        if (! $question || ! $name) {
953
-            return null;
954
-        }
955
-        // prep the answer
956
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
957
-        // prep the required array
958
-        $required = self::prep_required($required);
959
-        // set disabled tag
960
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
961
-        // ya gots ta have style man!!!
962
-        $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp';
963
-        $class     = empty($class) ? $txt_class : $class;
964
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
965
-        $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
966
-
967
-        $label_html =
968
-            $required_text
969
-            . "\n\t\t\t"
970
-            . '<label for="' . $name . '" class="' . $label_class . '">'
971
-            . self::prep_question($question)
972
-            . $required['label']
973
-            . '</label><br/>';
974
-        // filter label but ensure required text comes before it
975
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
976
-
977
-        $input_html =
978
-            "\n\t\t\t"
979
-            . '<input type="text" name="' . $name . '" id="' . $id . '" '
980
-            . 'class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr($answer) . '"  '
981
-            . 'title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
982
-
983
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
984
-        return $label_html . $input_html;
985
-    }
986
-
987
-
988
-    /**
989
-     * generates HTML for a form textarea
990
-     *
991
-     * @param string $question    label content
992
-     * @param string $answer      form input value attribute
993
-     * @param string $name        form input name attribute
994
-     * @param string $id          form input css id attribute
995
-     * @param string $class       form input css class attribute
996
-     * @param array  $dimensions  array of form input rows and cols attributes : array( 'rows' => 3, 'cols' => 40 )
997
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
998
-     *                            required 'class', and required 'msg' attribute
999
-     * @param string $label_class css class attribute for the label
1000
-     * @param string $disabled    disabled="disabled" or null
1001
-     * @return string HTML
1002
-     */
1003
-    public static function textarea(
1004
-        $question = false,
1005
-        $answer = null,
1006
-        $name = false,
1007
-        $id = '',
1008
-        $class = '',
1009
-        $dimensions = false,
1010
-        $required = false,
1011
-        $required_text = '',
1012
-        $label_class = '',
1013
-        $disabled = false,
1014
-        $system_ID = false,
1015
-        $use_html_entities = true
1016
-    ) {
1017
-        // need these
1018
-        if (! $question || ! $name) {
1019
-            return null;
1020
-        }
1021
-        // prep the answer
1022
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1023
-        // prep the required array
1024
-        $required = self::prep_required($required);
1025
-        // make sure $dimensions is an array
1026
-        $dimensions = is_array($dimensions) ? $dimensions : [];
1027
-        // and set some defaults
1028
-        $dimensions = array_merge(['rows' => 3, 'cols' => 40], $dimensions);
1029
-        // set disabled tag
1030
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1031
-        // ya gots ta have style man!!!
1032
-        $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp';
1033
-        $class     = empty($class) ? $txt_class : $class;
1034
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1035
-        $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1036
-
1037
-        $label_html =
1038
-            $required_text
1039
-            . "\n\t\t\t"
1040
-            . '<label for="' . $name . '" class="' . $label_class . '">'
1041
-            . self::prep_question($question)
1042
-            . $required['label']
1043
-            . '</label><br/>';
1044
-        // filter label but ensure required text comes before it
1045
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1046
-
1047
-        $input_html =
1048
-            "\n\t\t\t"
1049
-            . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" '
1050
-            . 'rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '"  '
1051
-            . 'title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>'
1052
-            . esc_textarea($answer)
1053
-            . '</textarea>';
1054
-
1055
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1056
-        return $label_html . $input_html;
1057
-    }
1058
-
1059
-
1060
-    /**
1061
-     * generates HTML for a form select input
1062
-     *
1063
-     * @param string $question    label content
1064
-     * @param string $answer      form input value attribute
1065
-     * @param array  $options     array of answer options where array key = option value and array value = option
1066
-     *                            display text
1067
-     * @param string $name        form input name attribute
1068
-     * @param string $id          form input css id attribute
1069
-     * @param string $class       form input css class attribute
1070
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1071
-     *                            required 'class', and required 'msg' attribute
1072
-     * @param string $label_class css class attribute for the label
1073
-     * @param string $disabled    disabled="disabled" or null
1074
-     * @return string HTML
1075
-     */
1076
-    public static function select(
1077
-        $question = false,
1078
-        $answer = null,
1079
-        $options = false,
1080
-        $name = false,
1081
-        $id = '',
1082
-        $class = '',
1083
-        $required = false,
1084
-        $required_text = '',
1085
-        $label_class = '',
1086
-        $disabled = false,
1087
-        $system_ID = false,
1088
-        $use_html_entities = true,
1089
-        $add_please_select_option = false
1090
-    ) {
1091
-
1092
-        // need these
1093
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1094
-            return null;
1095
-        }
1096
-        // prep the answer
1097
-        $answer =
1098
-            is_array($answer)
1099
-                ? self::prep_answer(array_shift($answer), $use_html_entities)
1100
-                : self::prep_answer(
1101
-                    $answer,
1102
-                    $use_html_entities
1103
-                );
1104
-        // prep the required array
1105
-        $required = self::prep_required($required);
1106
-        // set disabled tag
1107
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1108
-        // ya gots ta have style man!!!
1109
-        $txt_class = is_admin() ? 'wide' : 'espresso-select-inp';
1110
-        $class     = empty($class) ? $txt_class : $class;
1111
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1112
-        $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1113
-
1114
-        $label_html =
1115
-            $required_text
1116
-            . "\n\t\t\t"
1117
-            . '<label for="' . $name . '" class="' . $label_class . '">'
1118
-            . self::prep_question($question)
1119
-            . $required['label']
1120
-            . '</label><br/>';
1121
-        // filter label but ensure required text comes before it
1122
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1123
-
1124
-        $input_html =
1125
-            "\n\t\t\t"
1126
-            . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" '
1127
-            . 'title="' . esc_attr($required['msg']) . '"' . $disabled . ' ' . $extra . '>';
1128
-        // recursively count array elements, to determine total number of options
1129
-        $only_option = count($options, 1) == 1;
1130
-        if (! $only_option) {
1131
-            // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected
1132
-            $selected   = $answer === null ? ' selected' : '';
1133
-            $input_html .= $add_please_select_option
1134
-                ? "\n\t\t\t\t"
1135
-                  . '<option value=""' . $selected . '>'
1136
-                  . esc_html__(' - please select - ', 'event_espresso')
1137
-                  . '</option>'
1138
-                : '';
1139
-        }
1140
-        foreach ($options as $key => $value) {
1141
-            // if value is an array, then create option groups, else create regular ol' options
1142
-            $input_html .= is_array($value)
1143
-                ? self::_generate_select_option_group(
1144
-                    $key,
1145
-                    $value,
1146
-                    $answer,
1147
-                    $use_html_entities
1148
-                )
1149
-                : self::_generate_select_option(
1150
-                    $value->value(),
1151
-                    $value->desc(),
1152
-                    $answer,
1153
-                    $only_option,
1154
-                    $use_html_entities
1155
-                );
1156
-        }
1157
-
1158
-        $input_html .= "\n\t\t\t" . '</select>';
1159
-
1160
-        $input_html =
1161
-            apply_filters(
1162
-                'FHEE__EEH_Form_Fields__select__before_end_wrapper',
1163
-                $input_html,
1164
-                $question,
1165
-                $answer,
1166
-                $name,
1167
-                $id,
1168
-                $class,
1169
-                $system_ID
1170
-            );
1171
-
1172
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1173
-        return $label_html . $input_html;
1174
-    }
1175
-
1176
-
1177
-    /**
1178
-     *  _generate_select_option_group
1179
-     *
1180
-     *  if  $value for a select box is an array, then the key will be used as the optgroup label
1181
-     *  and the value array will be looped thru and the elements sent to _generate_select_option
1182
-     *
1183
-     * @param mixed   $opt_group
1184
-     * @param mixed   $QSOs
1185
-     * @param mixed   $answer
1186
-     * @param boolean $use_html_entities
1187
-     * @return string
1188
-     */
1189
-    private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true)
1190
-    {
1191
-        $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value($opt_group) . '">';
1192
-        foreach ($QSOs as $QSO) {
1193
-            $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities);
1194
-        }
1195
-        $html .= "\n\t\t\t\t" . '</optgroup>';
1196
-        return $html;
1197
-    }
1198
-
1199
-
1200
-    /**
1201
-     *  _generate_select_option
1202
-     *
1203
-     * @param mixed   $key
1204
-     * @param mixed   $value
1205
-     * @param mixed   $answer
1206
-     * @param int     $only_option
1207
-     * @param boolean $use_html_entities
1208
-     * @return string
1209
-     */
1210
-    private static function _generate_select_option(
1211
-        $key,
1212
-        $value,
1213
-        $answer,
1214
-        $only_option = false,
1215
-        $use_html_entities = true
1216
-    ) {
1217
-        $key      = self::prep_answer($key, $use_html_entities);
1218
-        $value    = self::prep_answer($value, $use_html_entities);
1219
-        $value    = ! empty($value) ? $value : $key;
1220
-        $selected = ($answer == $key || $only_option) ? 'selected' : '';
1221
-        return "\n\t\t\t\t"
1222
-               . '<option value="' . self::prep_option_value($key) . '" ' . $selected . '> '
1223
-               . $value
1224
-               . '&nbsp;&nbsp;&nbsp;</option>';
1225
-    }
1226
-
1227
-
1228
-    /**
1229
-     * generates HTML for form radio button inputs
1230
-     *
1231
-     * @param bool|string $question    label content
1232
-     * @param string      $answer      form input value attribute
1233
-     * @param array|bool  $options     array of answer options where array key = option value and array value = option
1234
-     *                                 display text
1235
-     * @param bool|string $name        form input name attribute
1236
-     * @param string      $id          form input css id attribute
1237
-     * @param string      $class       form input css class attribute
1238
-     * @param array|bool  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1239
-     *                                 required 'class', and required 'msg' attribute
1240
-     * @param string      $required_text
1241
-     * @param string      $label_class css class attribute for the label
1242
-     * @param bool|string $disabled    disabled="disabled" or null
1243
-     * @param bool        $system_ID
1244
-     * @param bool        $use_html_entities
1245
-     * @param bool        $label_b4
1246
-     * @param bool        $use_desc_4_label
1247
-     * @return string HTML
1248
-     */
1249
-    public static function radio(
1250
-        $question = false,
1251
-        $answer = null,
1252
-        $options = false,
1253
-        $name = false,
1254
-        $id = '',
1255
-        $class = '',
1256
-        $required = false,
1257
-        $required_text = '',
1258
-        $label_class = '',
1259
-        $disabled = false,
1260
-        $system_ID = false,
1261
-        $use_html_entities = true,
1262
-        $label_b4 = false,
1263
-        $use_desc_4_label = false
1264
-    ) {
1265
-        // need these
1266
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1267
-            return null;
1268
-        }
1269
-        // prep the answer
1270
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1271
-        // prep the required array
1272
-        $required = self::prep_required($required);
1273
-        // set disabled tag
1274
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1275
-        // ya gots ta have style man!!!
1276
-        $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
1277
-        $class       = ! empty($class) ? $class : 'espresso-radio-btn-inp';
1278
-        $extra       = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1279
-
1280
-        $label_html =
1281
-            $required_text
1282
-            . "\n\t\t\t"
1283
-            . '<label class="' . $label_class . '">'
1284
-            . self::prep_question($question)
1285
-            . $required['label']
1286
-            . '</label> ';
1287
-        // filter label but ensure required text comes before it
1288
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1289
-
1290
-        $input_html =
1291
-            "\n\t\t\t"
1292
-            . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">';
1293
-
1294
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1295
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1296
-
1297
-        foreach ($options as $OPT) {
1298
-            if ($OPT instanceof EE_Question_Option) {
1299
-                $value   = self::prep_option_value($OPT->value());
1300
-                $label   = $use_desc_4_label ? $OPT->desc() : $OPT->value();
1301
-                $size    = $use_desc_4_label
1302
-                    ? self::get_label_size_class($OPT->value() . ' ' . $OPT->desc())
1303
-                    : self::get_label_size_class($OPT->value());
1304
-                $desc    = $OPT->desc();// no self::prep_answer
1305
-                $answer  = is_numeric($value) && empty($answer) ? 0 : $answer;
1306
-                $checked = (string) $value == (string) $answer ? ' checked' : '';
1307
-                $opt     = '-' . sanitize_key($value);
1308
-
1309
-                $input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1310
-                $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">';
1311
-                $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : '';
1312
-                $input_html .= "\n\t\t\t\t\t\t"
1313
-                               . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" '
1314
-                               . 'class="' . $class . '" value="' . $value . '" '
1315
-                               . 'title="' . esc_attr($required['msg']) . '" ' . $disabled
1316
-                               . $checked . ' ' . $extra . '/>';
1317
-                $input_html .= ! $label_b4
1318
-                    ? "\n\t\t\t\t\t\t"
1319
-                      . '<span class="espresso-radio-btn-desc">'
1320
-                      . $label
1321
-                      . '</span>'
1322
-                    : '';
1323
-                $input_html .= "\n\t\t\t\t\t" . '</label>';
1324
-                $input_html .= $use_desc_4_label
1325
-                    ? ''
1326
-                    : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>';
1327
-                $input_html .= "\n\t\t\t\t" . '</li>';
1328
-            }
1329
-        }
1330
-
1331
-        $input_html .= "\n\t\t\t" . '</ul>';
1332
-
1333
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1334
-        return $label_html . $input_html;
1335
-    }
1336
-
1337
-
1338
-    /**
1339
-     * generates HTML for form checkbox inputs
1340
-     *
1341
-     * @param string $question    label content
1342
-     * @param string $answer      form input value attribute
1343
-     * @param array  $options     array of options where array key = option value and array value = option display text
1344
-     * @param string $name        form input name attribute
1345
-     * @param string $id          form input css id attribute
1346
-     * @param string $class       form input css class attribute
1347
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1348
-     *                            required 'class', and required 'msg' attribute
1349
-     * @param string $label_class css class attribute for the label
1350
-     * @param string $disabled    disabled="disabled" or null
1351
-     * @return string HTML
1352
-     */
1353
-    public static function checkbox(
1354
-        $question = false,
1355
-        $answer = null,
1356
-        $options = false,
1357
-        $name = false,
1358
-        $id = '',
1359
-        $class = '',
1360
-        $required = false,
1361
-        $required_text = '',
1362
-        $label_class = '',
1363
-        $disabled = false,
1364
-        $label_b4 = false,
1365
-        $system_ID = false,
1366
-        $use_html_entities = true
1367
-    ) {
1368
-        // need these
1369
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1370
-            return null;
1371
-        }
1372
-        $answer = maybe_unserialize($answer);
1373
-
1374
-        // prep the answer(s)
1375
-        $answer = is_array($answer) ? $answer : [sanitize_key($answer) => $answer];
1376
-
1377
-        foreach ($answer as $key => $value) {
1378
-            $key            = self::prep_option_value($key);
1379
-            $answer[ $key ] = self::prep_answer($value, $use_html_entities);
1380
-        }
1381
-
1382
-        // prep the required array
1383
-        $required = self::prep_required($required);
1384
-        // set disabled tag
1385
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1386
-        // ya gots ta have style man!!!
1387
-        $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
1388
-        $class       = empty($class) ? 'espresso-radio-btn-inp' : $class;
1389
-        $extra       = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1390
-
1391
-        $label_html =
1392
-            $required_text
1393
-            . "\n\t\t\t"
1394
-            . '<label class="' . $label_class . '">'
1395
-            . self::prep_question($question)
1396
-            . $required['label']
1397
-            . '</label> ';
1398
-        // filter label but ensure required text comes before it
1399
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1400
-
1401
-        $input_html =
1402
-            "\n\t\t\t"
1403
-            . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">';
1404
-
1405
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1406
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1407
-
1408
-        foreach ($options as $OPT) {
1409
-            $value = $OPT->value();// self::prep_option_value( $OPT->value() );
1410
-            $size  = self::get_label_size_class($OPT->value() . ' ' . $OPT->desc());
1411
-            $text  = self::prep_answer($OPT->value());
1412
-            $desc  = $OPT->desc();
1413
-            $opt   = '-' . sanitize_key($value);
1414
-
1415
-            $checked = is_array($answer) && in_array($text, $answer) ? ' checked' : '';
1416
-
1417
-            $input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1418
-            $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">';
1419
-            $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
1420
-            $input_html .= "\n\t\t\t\t\t\t"
1421
-                           . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" '
1422
-                           . 'id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" '
1423
-                           . 'title="' . esc_attr($required['msg']) . '" ' . $disabled . $checked . ' ' . $extra . '/>';
1424
-            $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
1425
-            $input_html .= "\n\t\t\t\t\t" . '</label>';
1426
-            if (! empty($desc) && $desc != $text) {
1427
-                $input_html .= "\n\t\t\t\t\t"
1428
-                               . ' &nbsp; <br/><div class="espresso-checkbox-option-desc small-text grey-text">'
1429
-                               . $desc
1430
-                               . '</div>';
1431
-            }
1432
-            $input_html .= "\n\t\t\t\t" . '</li>';
1433
-        }
1434
-
1435
-        $input_html .= "\n\t\t\t" . '</ul>';
1436
-
1437
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1438
-        return $label_html . $input_html;
1439
-    }
1440
-
1441
-
1442
-    /**
1443
-     * generates HTML for a form datepicker input
1444
-     *
1445
-     * @param string $question    label content
1446
-     * @param string $answer      form input value attribute
1447
-     * @param string $name        form input name attribute
1448
-     * @param string $id          form input css id attribute
1449
-     * @param string $class       form input css class attribute
1450
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1451
-     *                            required 'class', and required 'msg' attribute
1452
-     * @param string $label_class css class attribute for the label
1453
-     * @param string $disabled    disabled="disabled" or null
1454
-     * @return string HTML
1455
-     */
1456
-    public static function datepicker(
1457
-        $question = false,
1458
-        $answer = null,
1459
-        $name = false,
1460
-        $id = '',
1461
-        $class = '',
1462
-        $required = false,
1463
-        $required_text = '',
1464
-        $label_class = '',
1465
-        $disabled = false,
1466
-        $system_ID = false,
1467
-        $use_html_entities = true
1468
-    ) {
1469
-        // need these
1470
-        if (! $question || ! $name) {
1471
-            return null;
1472
-        }
1473
-        // prep the answer
1474
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1475
-        // prep the required array
1476
-        $required = self::prep_required($required);
1477
-        // set disabled tag
1478
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1479
-        // ya gots ta have style man!!!
1480
-        $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp';
1481
-        $class     = empty($class) ? $txt_class : $class;
1482
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1483
-        $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1484
-
1485
-        $label_html =
1486
-            $required_text
1487
-            . "\n\t\t\t"
1488
-            . '<label for="' . $name . '" class="' . $label_class . '">'
1489
-            . self::prep_question($question)
1490
-            . $required['label']
1491
-            . '</label><br/>';
1492
-        // filter label but ensure required text comes before it
1493
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1494
-
1495
-        $input_html =
1496
-            "\n\t\t\t"
1497
-            . '<input type="text" name="' . $name . '" id="' . $id . '" '
1498
-            . 'class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '"  '
1499
-            . 'title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
1500
-
1501
-        // enqueue scripts
1502
-        wp_register_style(
1503
-            'espresso-ui-theme',
1504
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1505
-            [],
1506
-            EVENT_ESPRESSO_VERSION
1507
-        );
1508
-        wp_enqueue_style('espresso-ui-theme');
1509
-        wp_enqueue_script('jquery-ui-datepicker');
1510
-
1511
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1512
-        return $label_html . $input_html;
1513
-    }
1514
-
1515
-
1516
-    /**
1517
-     *  remove_label_keep_required_msg
1518
-     *  this will strip out a form input's label HTML while keeping the required text HTML that MUST be before the label
1519
-     *
1520
-     * @access public
1521
-     * @return     string
1522
-     */
1523
-    public static function remove_label_keep_required_msg($label_html, $required_text)
1524
-    {
1525
-        return $required_text;
1526
-    }
1527
-
1528
-
1529
-    /**
1530
-     * Simply returns the HTML for a hidden input of the given name and value.
1531
-     *
1532
-     * @param string $name
1533
-     * @param string $value
1534
-     * @return string HTML
1535
-     */
1536
-    public static function hidden_input($name, $value, $id = '')
1537
-    {
1538
-        $id = ! empty($id) ? $id : $name;
1539
-        return '<input id="' . $id . '" type="hidden" name="' . $name . '" value="' . $value . '"/>';
1540
-    }
1541
-
1542
-
1543
-    /**
1544
-     * prep_question
1545
-     *
1546
-     * @param string $question
1547
-     * @return string
1548
-     */
1549
-    public static function prep_question($question)
1550
-    {
1551
-        return $question;
1552
-    }
1553
-
1554
-
1555
-    /**
1556
-     *  prep_answer
1557
-     *
1558
-     * @param mixed $answer
1559
-     * @return string
1560
-     */
1561
-    public static function prep_answer($answer, $use_html_entities = true)
1562
-    {
1563
-        // make sure we convert bools first.  Otherwise (bool) false becomes an empty string which is NOT desired,
1564
-        // we want "0".
1565
-        if (is_bool($answer)) {
1566
-            $answer = $answer ? 1 : 0;
1567
-        }
1568
-        $answer = trim(stripslashes(str_replace('&#039;', "'", $answer)));
1569
-        return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer;
1570
-    }
1571
-
1572
-
1573
-    /**
1574
-     *  prep_answer_options
1575
-     *
1576
-     * @param array $QSOs array of EE_Question_Option objects
1577
-     * @return array
1578
-     */
1579
-    public static function prep_answer_options($QSOs = [])
1580
-    {
1581
-        $prepped_answer_options = [];
1582
-        if (is_array($QSOs) && ! empty($QSOs)) {
1583
-            foreach ($QSOs as $key => $QSO) {
1584
-                if (! $QSO instanceof EE_Question_Option) {
1585
-                    $QSO = EE_Question_Option::new_instance(
1586
-                        [
1587
-                            'QSO_value' => is_array($QSO) && isset($QSO['id'])
1588
-                                ? (string) $QSO['id']
1589
-                                : (string) $key,
1590
-                            'QSO_desc'  => is_array($QSO) && isset($QSO['text'])
1591
-                                ? (string) $QSO['text']
1592
-                                : (string) $QSO,
1593
-                        ]
1594
-                    );
1595
-                }
1596
-                if ($QSO->opt_group()) {
1597
-                    $prepped_answer_options[ $QSO->opt_group() ][] = $QSO;
1598
-                } else {
1599
-                    $prepped_answer_options[] = $QSO;
1600
-                }
1601
-            }
1602
-        }
1603
-        //      d( $prepped_answer_options );
1604
-        return $prepped_answer_options;
1605
-    }
1606
-
1607
-
1608
-    /**
1609
-     *  prep_option_value
1610
-     *
1611
-     * @param string $option_value
1612
-     * @return string
1613
-     */
1614
-    public static function prep_option_value($option_value)
1615
-    {
1616
-        return esc_attr(trim(stripslashes($option_value)));
1617
-    }
1618
-
1619
-
1620
-    /**
1621
-     *  prep_required
1622
-     *
1623
-     * @param string|array $required
1624
-     * @return array
1625
-     */
1626
-    public static function prep_required($required = [])
1627
-    {
1628
-        // make sure required is an array
1629
-        $required = is_array($required) ? $required : [];
1630
-        // and set some defaults
1631
-        return array_merge(['label' => '', 'class' => '', 'msg' => ''], $required);
1632
-    }
1633
-
1634
-
1635
-    /**
1636
-     *  get_label_size_class
1637
-     *
1638
-     * @param string $value
1639
-     * @return string
1640
-     */
1641
-    public static function get_label_size_class($value = false)
1642
-    {
1643
-        if ($value === false || $value === '') {
1644
-            return ' class="medium-lbl"';
1645
-        }
1646
-        // determine length of option value
1647
-        $val_size = strlen($value);
1648
-        switch ($val_size) {
1649
-            case $val_size < 3:
1650
-                $size = ' class="nano-lbl"';
1651
-                break;
1652
-            case $val_size < 6:
1653
-                $size = ' class="micro-lbl"';
1654
-                break;
1655
-            case $val_size < 12:
1656
-                $size = ' class="tiny-lbl"';
1657
-                break;
1658
-            case $val_size < 25:
1659
-                $size = ' class="small-lbl"';
1660
-                break;
1661
-            case $val_size > 100:
1662
-                $size = ' class="big-lbl"';
1663
-                break;
1664
-            default:
1665
-                $size = ' class="medium-lbl"';
1666
-                break;
1667
-        }
1668
-        return $size;
1669
-    }
1670
-
1671
-
1672
-    /**
1673
-     *  _load_system_dropdowns
1674
-     *
1675
-     * @param EE_Question_Form_Input $QFI
1676
-     * @return array
1677
-     * @throws EE_Error
1678
-     * @throws ReflectionException
1679
-     */
1680
-    private static function _load_system_dropdowns($QFI)
1681
-    {
1682
-        $QST_system = $QFI->get('QST_system');
1683
-        switch ($QST_system) {
1684
-            case 'state':
1685
-                $QFI = self::generate_state_dropdown($QFI);
1686
-                break;
1687
-            case 'country':
1688
-                $QFI = self::generate_country_dropdown($QFI);
1689
-                break;
1690
-            case 'admin-state':
1691
-                $QFI = self::generate_state_dropdown($QFI, true);
1692
-                break;
1693
-            case 'admin-country':
1694
-                $QFI = self::generate_country_dropdown($QFI, true);
1695
-                break;
1696
-        }
1697
-        return $QFI;
1698
-    }
1699
-
1700
-
1701
-    /**
1702
-     * This preps dropdowns that are specialized.
1703
-     *
1704
-     * @param EE_Question_Form_Input $QFI
1705
-     *
1706
-     * @return EE_Question_Form_Input
1707
-     * @throws EE_Error
1708
-     * @throws ReflectionException
1709
-     * @since  4.6.0
1710
-     */
1711
-    protected static function _load_specialized_dropdowns($QFI)
1712
-    {
1713
-        switch ($QFI->get('QST_type')) {
1714
-            case 'STATE':
1715
-                $QFI = self::generate_state_dropdown($QFI);
1716
-                break;
1717
-            case 'COUNTRY':
1718
-                $QFI = self::generate_country_dropdown($QFI);
1719
-                break;
1720
-        }
1721
-        return $QFI;
1722
-    }
1723
-
1724
-
1725
-    /**
1726
-     *    generate_state_dropdown
1727
-     *
1728
-     * @param EE_Question_Form_Input $QST
1729
-     * @param bool                   $get_all
1730
-     * @return EE_Question_Form_Input
1731
-     * @throws EE_Error
1732
-     * @throws ReflectionException
1733
-     */
1734
-    public static function generate_state_dropdown($QST, $get_all = false)
1735
-    {
1736
-        $states = $get_all
1737
-            ? EEM_State::instance()->get_all_states()
1738
-            : EEM_State::instance()->get_all_states_of_active_countries();
1739
-        if ($states && count($states) != count($QST->options())) {
1740
-            $QST->set('QST_type', 'DROPDOWN');
1741
-            // if multiple countries, we'll create option groups within the dropdown
1742
-            foreach ($states as $state) {
1743
-                if ($state instanceof EE_State) {
1744
-                    $QSO = EE_Question_Option::new_instance(
1745
-                        [
1746
-                            'QSO_value'   => $state->ID(),
1747
-                            'QSO_desc'    => $state->name(),
1748
-                            'QST_ID'      => $QST->get('QST_ID'),
1749
-                            'QSO_deleted' => false,
1750
-                        ]
1751
-                    );
1752
-                    // set option group
1753
-                    $QSO->set_opt_group($state->country()->name());
1754
-                    // add option to question
1755
-                    $QST->add_temp_option($QSO);
1756
-                }
1757
-            }
1758
-        }
1759
-        return $QST;
1760
-    }
1761
-
1762
-
1763
-    /**
1764
-     *    generate_country_dropdown
1765
-     *
1766
-     * @param      $QST
1767
-     * @param bool $get_all
1768
-     * @return array
1769
-     * @throws EE_Error
1770
-     * @throws ReflectionException
1771
-     * @internal param array $question
1772
-     */
1773
-    public static function generate_country_dropdown($QST, $get_all = false)
1774
-    {
1775
-        $countries = $get_all
1776
-            ? EEM_Country::instance()->get_all_countries()
1777
-            : EEM_Country::instance()->get_all_active_countries();
1778
-        if ($countries && count($countries) != count($QST->options())) {
1779
-            $QST->set('QST_type', 'DROPDOWN');
1780
-            // now add countries
1781
-            foreach ($countries as $country) {
1782
-                if ($country instanceof EE_Country) {
1783
-                    $QSO = EE_Question_Option::new_instance(
1784
-                        [
1785
-                            'QSO_value'   => $country->ID(),
1786
-                            'QSO_desc'    => $country->name(),
1787
-                            'QST_ID'      => $QST->get('QST_ID'),
1788
-                            'QSO_deleted' => false,
1789
-                        ]
1790
-                    );
1791
-                    $QST->add_temp_option($QSO);
1792
-                }
1793
-            }
1794
-        }
1795
-        return $QST;
1796
-    }
1797
-
1798
-
1799
-    /**
1800
-     *  generates options for a month dropdown selector with numbers from 01 to 12
1801
-     *
1802
-     * @return array()
1803
-     */
1804
-    public static function two_digit_months_dropdown_options()
1805
-    {
1806
-        $options = [];
1807
-        for ($x = 1; $x <= 12; $x++) {
1808
-            $mm             = str_pad($x, 2, '0', STR_PAD_LEFT);
1809
-            $options[ $mm ] = $mm;
1810
-        }
1811
-        return EEH_Form_Fields::prep_answer_options($options);
1812
-    }
1813
-
1814
-
1815
-    /**
1816
-     *  generates a year dropdown selector with numbers for the next ten years
1817
-     *
1818
-     * @return array
1819
-     */
1820
-    public static function next_decade_two_digit_year_dropdown_options()
1821
-    {
1822
-        $options      = [];
1823
-        $current_year = date('y');
1824
-        $next_decade  = $current_year + 10;
1825
-        for ($x = $current_year; $x <= $next_decade; $x++) {
1826
-            $yy             = str_pad($x, 2, '0', STR_PAD_LEFT);
1827
-            $options[ $yy ] = $yy;
1828
-        }
1829
-        return EEH_Form_Fields::prep_answer_options($options);
1830
-    }
1831
-
1832
-
1833
-    /**
1834
-     * generates a month/year dropdown selector for all registrations matching the given criteria.  Typically used for
1835
-     * list table filter.
1836
-     *
1837
-     * @param string  $cur_date     any currently selected date can be entered here.
1838
-     * @param string  $status       Registration status
1839
-     * @param integer $evt_category Event Category ID if the Event Category filter is selected
1840
-     * @return string                html
1841
-     * @throws EE_Error
1842
-     */
1843
-    public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0)
1844
-    {
1845
-        $_where = [];
1846
-        if (! empty($status)) {
1847
-            $_where['STS_ID'] = $status;
1848
-        }
1849
-
1850
-        if ($evt_category > 0) {
1851
-            $_where['Event.Term_Taxonomy.term_id'] = $evt_category;
1852
-        }
1853
-
1854
-        $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where);
1855
-
1856
-        // setup vals for select input helper
1857
-        $options = [
1858
-            0 => [
1859
-                'text' => esc_html__('Select a Month/Year', 'event_espresso'),
1860
-                'id'   => '',
1861
-            ],
1862
-        ];
1863
-
1864
-        foreach ($regdtts as $regdtt) {
1865
-            $date      = $regdtt->reg_month . ' ' . $regdtt->reg_year;
1866
-            $options[] = [
1867
-                'text' => $date,
1868
-                'id'   => $date,
1869
-            ];
1870
-        }
1871
-
1872
-        return self::select_input('month_range', $options, $cur_date, '', 'wide');
1873
-    }
1874
-
1875
-
1876
-    /**
1877
-     * generates a month/year dropdown selector for all events matching the given criteria
1878
-     * Typically used for list table filter
1879
-     *
1880
-     * @param string $cur_date          any currently selected date can be entered here.
1881
-     * @param string $status            "view" (i.e. all, today, month, draft)
1882
-     * @param int    $evt_category      category event belongs to
1883
-     * @param string $evt_active_status "upcoming", "expired", "active", or "inactive"
1884
-     * @return string                    html
1885
-     * @throws EE_Error
1886
-     */
1887
-    public static function generate_event_months_dropdown(
1888
-        $cur_date = '',
1889
-        $status = null,
1890
-        $evt_category = null,
1891
-        $evt_active_status = null
1892
-    ) {
1893
-        // determine what post_status our condition will have for the query.
1894
-        // phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
1895
-        switch ($status) {
1896
-            case 'month':
1897
-            case 'today':
1898
-            case null:
1899
-            case 'all':
1900
-                $where['Event.status'] = ['NOT IN', ['trash']];
1901
-                break;
1902
-            case 'draft':
1903
-                $where['Event.status'] = ['IN', ['draft', 'auto-draft']];
1904
-                break;
1905
-            default:
1906
-                $where['Event.status'] = $status;
1907
-        }
1908
-
1909
-        // phpcs:enable
1910
-
1911
-        // categories?
1912
-
1913
-
1914
-        if (! empty($evt_category)) {
1915
-            $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1916
-            $where['Event.Term_Taxonomy.term_id']  = $evt_category;
1917
-        }
1918
-
1919
-
1920
-        //      $where['DTT_is_primary'] = 1;
1921
-
1922
-        $DTTS = EEM_Datetime::instance()->get_dtt_months_and_years($where, $evt_active_status);
1923
-
1924
-        // let's setup vals for select input helper
1925
-        $options = [
1926
-            0 => [
1927
-                'text' => esc_html__('Select a Month/Year', 'event_espresso'),
1928
-                'id'   => "",
1929
-            ],
1930
-        ];
1931
-
1932
-
1933
-        // translate month and date
1934
-        global $wp_locale;
1935
-
1936
-        foreach ($DTTS as $DTT) {
1937
-            $localized_date = $wp_locale->get_month($DTT->dtt_month_num) . ' ' . $DTT->dtt_year;
1938
-            $id             = $DTT->dtt_month . ' ' . $DTT->dtt_year;
1939
-            $options[]      = [
1940
-                'text' => $localized_date,
1941
-                'id'   => $id,
1942
-            ];
1943
-        }
1944
-
1945
-
1946
-        return self::select_input('month_range', $options, $cur_date, '', 'wide');
1947
-    }
1948
-
1949
-
1950
-    /**
1951
-     * generates the dropdown selector for event categories
1952
-     * typically used as a filter on list tables.
1953
-     *
1954
-     * @param integer $current_cat currently selected category
1955
-     * @return string               html for dropdown
1956
-     * @throws EE_Error
1957
-     * @throws ReflectionException
1958
-     */
1959
-    public static function generate_event_category_dropdown($current_cat = -1)
1960
-    {
1961
-        $categories = EEM_Term::instance()->get_all_ee_categories(true);
1962
-        $options    = [
1963
-            '0' => [
1964
-                'text' => esc_html__('All Categories', 'event_espresso'),
1965
-                'id'   => -1,
1966
-            ],
1967
-        ];
1968
-
1969
-        // setup categories for dropdown
1970
-        foreach ($categories as $category) {
1971
-            $options[] = [
1972
-                'text' => $category->get('name'),
1973
-                'id'   => $category->ID(),
1974
-            ];
1975
-        }
1976
-
1977
-        return self::select_input('EVT_CAT', $options, $current_cat);
1978
-    }
1979
-
1980
-
1981
-    /**
1982
-     *    generate a submit button with or without it's own microform
1983
-     *    this is the only way to create buttons that are compatible across all themes
1984
-     *
1985
-     * @access    public
1986
-     * @param string      $url              - the form action
1987
-     * @param string      $ID               - some kind of unique ID, appended with "-sbmt" for the input and "-frm"
1988
-     *                                      for the form
1989
-     * @param string      $class            - css classes (separated by spaces if more than one)
1990
-     * @param string      $text             - what appears on the button
1991
-     * @param string      $nonce_action     - if using nonces
1992
-     * @param bool|string $input_only       - whether to print form header and footer. TRUE returns the input without
1993
-     *                                      the form
1994
-     * @param string      $extra_attributes - any extra attributes that need to be attached to the form input
1995
-     * @return    string
1996
-     */
1997
-    public static function submit_button(
1998
-        $url = '',
1999
-        $ID = '',
2000
-        $class = '',
2001
-        $text = '',
2002
-        $nonce_action = '',
2003
-        $input_only = false,
2004
-        $extra_attributes = ''
2005
-    ) {
2006
-        $btn = '';
2007
-        if (empty($url) || empty($ID)) {
2008
-            return $btn;
2009
-        }
2010
-        $text = ! empty($text) ? $text : esc_html__('Submit', 'event_espresso');
2011
-        $btn  .= '<input id="' . $ID . '-btn" class="' . $class . '" '
2012
-                 . 'type="submit" value="' . $text . '" ' . $extra_attributes . '/>';
2013
-        if (! $input_only) {
2014
-            $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">';
2015
-            $btn_frm .= ! empty($nonce_action)
2016
-                ? wp_nonce_field($nonce_action, $nonce_action . '_nonce', true, false)
2017
-                : '';
2018
-            $btn_frm .= $btn;
2019
-            $btn_frm .= '</form>';
2020
-            $btn     = $btn_frm;
2021
-            unset($btn_frm);
2022
-        }
2023
-        return $btn;
2024
-    }
488
+	}
489
+
490
+
491
+	/**
492
+	 * @param string $class
493
+	 * @param string $id
494
+	 * @param string $name
495
+	 * @param int    $rows
496
+	 * @param int    $tab_index
497
+	 * @param string $value
498
+	 * @param array  $wp_editor_args
499
+	 * @return false|string
500
+	 * @since   4.10.14.p
501
+	 */
502
+	private static function adminWpEditor($class, $id, $name, $rows, $tab_index, $value, $wp_editor_args = [])
503
+	{
504
+		$editor_settings = $wp_editor_args + [
505
+				'textarea_name' => esc_attr($name),
506
+				'textarea_rows' => absint($rows),
507
+				'editor_class'  => esc_attr($class),
508
+				'tabindex'      => absint($tab_index),
509
+			];
510
+		ob_start();
511
+		wp_editor($value, esc_attr($id), $editor_settings);
512
+		return ob_get_clean();
513
+	}
514
+
515
+
516
+	/**
517
+	 * espresso admin page select_input
518
+	 * Turns an array into a select fields
519
+	 *
520
+	 * @static
521
+	 * @access public
522
+	 * @param string  $name       field name
523
+	 * @param array   $values     option values, numbered array starting at 0, where each value is an array with a key
524
+	 *                            'text' (meaning text to display' and 'id' (meaning the internal value) eg:
525
+	 *                            array(1=>array('text'=>'Monday','id'=>1),2=>array('text'=>'Tuesday','id'=>2)...). or
526
+	 *                            as an array of key-value pairs, where the key is to be used for the select input's
527
+	 *                            name, and the value will be the text shown to the user.  Optionally you can also
528
+	 *                            include an additional key of "class" which will add a specific class to the option
529
+	 *                            for that value.
530
+	 * @param string  $default    default value
531
+	 * @param string  $parameters extra parameters
532
+	 * @param string  $class      css class
533
+	 * @param boolean $autosize   whether to autosize the select or not
534
+	 * @return string              html string for the select input
535
+	 */
536
+	public static function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true)
537
+	{
538
+		// if $values was submitted in the wrong format, convert it over
539
+		if (! empty($values) && (! array_key_exists(0, $values) || ! is_array($values[0]))) {
540
+			$converted_values = [];
541
+			foreach ($values as $id => $text) {
542
+				$converted_values[] = ['id' => $id, 'text' => $text];
543
+			}
544
+			$values = $converted_values;
545
+		}
546
+
547
+		$field =
548
+			'<select id="' . EEH_Formatter::ee_tep_output_string($name)
549
+			. '" name="' . EEH_Formatter::ee_tep_output_string($name)
550
+			. '"';
551
+
552
+		if (EEH_Formatter::ee_tep_not_null($parameters)) {
553
+			$field .= ' ' . $parameters;
554
+		}
555
+		if ($autosize) {
556
+			$size = 'med';
557
+			for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) {
558
+				if ($values[ $ii ]['text']) {
559
+					if (strlen($values[ $ii ]['text']) > 5) {
560
+						$size = 'wide';
561
+					}
562
+				}
563
+			}
564
+		} else {
565
+			$size = '';
566
+		}
567
+
568
+		$field .= ' class="' . $class . ' ' . $size . '">';
569
+
570
+		if (empty($default) && isset($GLOBALS[ $name ])) {
571
+			$default = stripslashes($GLOBALS[ $name ]);
572
+		}
573
+
574
+
575
+		for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
576
+			$field .= '<option value="' . $values[ $i ]['id'] . '"';
577
+			if ($default == $values[ $i ]['id']) {
578
+				$field .= ' selected = "selected"';
579
+			}
580
+			if (isset($values[ $i ]['class'])) {
581
+				$field .= ' class="' . $values[ $i ]['class'] . '"';
582
+			}
583
+			$field .= '>' . $values[ $i ]['text'] . '</option>';
584
+		}
585
+		$field .= '</select>';
586
+
587
+		return $field;
588
+	}
589
+
590
+
591
+	/**
592
+	 * generate_question_groups_html
593
+	 *
594
+	 * @param array  $question_groups
595
+	 * @param string $group_wrapper
596
+	 * @return string HTML
597
+	 * @throws EE_Error
598
+	 * @throws ReflectionException
599
+	 */
600
+	public static function generate_question_groups_html($question_groups = [], $group_wrapper = 'fieldset')
601
+	{
602
+
603
+		$html                            = '';
604
+		$before_question_group_questions =
605
+			apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
606
+		$after_question_group_questions  =
607
+			apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
608
+
609
+		if (! empty($question_groups)) {
610
+			// loop thru question groups
611
+			foreach ($question_groups as $QSG) {
612
+				// check that questions exist
613
+				if (! empty($QSG['QSG_questions'])) {
614
+					// use fieldsets
615
+					$html .= "\n\t"
616
+							 . '<'
617
+							 . $group_wrapper
618
+							 . ' class="espresso-question-group-wrap" id="'
619
+							 . $QSG['QSG_identifier']
620
+							 . '">';
621
+					// group_name
622
+					$html .= $QSG['QSG_show_group_name']
623
+						? "\n\t\t"
624
+						  . '<h5 class="espresso-question-group-title-h5 section-title">'
625
+						  . self::prep_answer($QSG['QSG_name'])
626
+						  . '</h5>'
627
+						: '';
628
+					// group_desc
629
+					$html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc'])
630
+						? '<div class="espresso-question-group-desc-pg">'
631
+						  . self::prep_answer($QSG['QSG_desc'])
632
+						  . '</div>'
633
+						: '';
634
+
635
+					$html .= $before_question_group_questions;
636
+					// loop thru questions
637
+					foreach ($QSG['QSG_questions'] as $question) {
638
+						$QFI  = new EE_Question_Form_Input(
639
+							$question['qst_obj'],
640
+							$question['ans_obj'],
641
+							$question
642
+						);
643
+						$html .= self::generate_form_input($QFI);
644
+					}
645
+					$html .= $after_question_group_questions;
646
+					$html .= "\n\t" . '</' . $group_wrapper . '>';
647
+				}
648
+			}
649
+		}
650
+
651
+		return $html;
652
+	}
653
+
654
+
655
+	/**
656
+	 * generate_question_groups_html
657
+	 *
658
+	 * @param array  $question_groups
659
+	 * @param array  $q_meta
660
+	 * @param bool   $from_admin
661
+	 * @param string $group_wrapper
662
+	 * @return string HTML
663
+	 * @throws EE_Error
664
+	 * @throws ReflectionException
665
+	 */
666
+	public static function generate_question_groups_html2(
667
+		$question_groups = [],
668
+		$q_meta = [],
669
+		$from_admin = false,
670
+		$group_wrapper = 'fieldset'
671
+	) {
672
+
673
+		$html                            = '';
674
+		$before_question_group_questions =
675
+			apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
676
+		$after_question_group_questions  =
677
+			apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
678
+
679
+		$default_q_meta = [
680
+			'att_nmbr'    => 1,
681
+			'ticket_id'   => '',
682
+			'input_name'  => '',
683
+			'input_id'    => '',
684
+			'input_class' => '',
685
+		];
686
+		$q_meta         = array_merge($default_q_meta, $q_meta);
687
+
688
+		if (! empty($question_groups)) {
689
+			// loop thru question groups
690
+			foreach ($question_groups as $QSG) {
691
+				if ($QSG instanceof EE_Question_Group) {
692
+					// check that questions exist
693
+
694
+					$where = ['QST_deleted' => 0];
695
+					if (! $from_admin) {
696
+						$where['QST_admin_only'] = 0;
697
+					}
698
+					$questions =
699
+						$QSG->questions([$where, 'order_by' => ['Question_Group_Question.QGQ_order' => 'ASC']]);
700
+					if (! empty($questions)) {
701
+						// use fieldsets
702
+						$html .= "\n\t"
703
+								 . '<' . $group_wrapper . ' class="espresso-question-group-wrap" '
704
+								 . 'id="' . $QSG->get('QSG_identifier') . '">';
705
+						// group_name
706
+						if ($QSG->show_group_name()) {
707
+							$html .= "\n\t\t"
708
+									 . '<h5 class="espresso-question-group-title-h5 section-title">'
709
+									 . $QSG->get_pretty('QSG_name')
710
+									 . '</h5>';
711
+						}
712
+						// group_desc
713
+						if ($QSG->show_group_desc()) {
714
+							$html .= '<div class="espresso-question-group-desc-pg">'
715
+									 . $QSG->get_pretty('QSG_desc')
716
+									 . '</div>';
717
+						}
718
+
719
+						$html .= $before_question_group_questions;
720
+						// loop thru questions
721
+						foreach ($questions as $QST) {
722
+							$qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID();
723
+
724
+							$answer = null;
725
+
726
+							/** @var RequestInterface $request */
727
+							$request      = LoaderFactory::getLoader()->getShared(RequestInterface::class);
728
+							$request_qstn = $request->getRequestParam('qstn', [], 'string', true);
729
+							if (! empty($request_qstn) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) {
730
+								// check for answer in $request_qstn in case we are reprocessing a form after an error
731
+								if (isset($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])) {
732
+									$answer = is_array($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])
733
+										? $request_qstn[ $q_meta['input_id'] ][ $qstn_id ]
734
+										: sanitize_text_field($request_qstn[ $q_meta['input_id'] ][ $qstn_id ]);
735
+								}
736
+							} elseif (isset($q_meta['attendee']) && $q_meta['attendee']) {
737
+								// attendee data from the session
738
+								$answer =
739
+									isset($q_meta['attendee'][ $qstn_id ]) ? $q_meta['attendee'][ $qstn_id ] : null;
740
+							}
741
+
742
+
743
+							$QFI  = new EE_Question_Form_Input(
744
+								$QST,
745
+								EE_Answer::new_instance(
746
+									[
747
+										'ANS_ID'    => 0,
748
+										'QST_ID'    => 0,
749
+										'REG_ID'    => 0,
750
+										'ANS_value' => $answer,
751
+									]
752
+								),
753
+								$q_meta
754
+							);
755
+							$html .= self::generate_form_input($QFI);
756
+						}
757
+						$html .= $after_question_group_questions;
758
+						$html .= "\n\t" . '</' . $group_wrapper . '>';
759
+					}
760
+				}
761
+			}
762
+		}
763
+		return $html;
764
+	}
765
+
766
+
767
+	/**
768
+	 * generate_form_input
769
+	 *
770
+	 * @param EE_Question_Form_Input $QFI
771
+	 * @return string HTML
772
+	 * @throws EE_Error
773
+	 * @throws ReflectionException
774
+	 */
775
+	public static function generate_form_input(EE_Question_Form_Input $QFI)
776
+	{
777
+		if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) {
778
+			return '';
779
+		}
780
+		/** @var RequestInterface $request */
781
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
782
+
783
+		$QFI = self::_load_system_dropdowns($QFI);
784
+		$QFI = self::_load_specialized_dropdowns($QFI);
785
+
786
+		// we also need to verify
787
+
788
+		$display_text = $QFI->get('QST_display_text');
789
+		$input_name   = $QFI->get('QST_input_name');
790
+		$answer       = $request->getRequestParam($input_name, $QFI->get('ANS_value'));
791
+		$input_id     = $QFI->get('QST_input_id');
792
+		$input_class  = $QFI->get('QST_input_class');
793
+		//      $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : '';
794
+		$disabled          = $QFI->get('QST_disabled');
795
+		$required_label    = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>');
796
+		$QST_required      = $QFI->get('QST_required');
797
+		$required          =
798
+			$QST_required
799
+				? ['label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required]
800
+				: [];
801
+		$use_html_entities = $QFI->get_meta('htmlentities');
802
+		$required_text     =
803
+			$QFI->get('QST_required_text') != ''
804
+				? $QFI->get('QST_required_text')
805
+				: esc_html__('This field is required', 'event_espresso');
806
+		$required_text     = $QST_required
807
+			? "\n\t\t\t"
808
+			  . '<div class="required-text hidden">'
809
+			  . self::prep_answer($required_text, $use_html_entities)
810
+			  . '</div>'
811
+			: '';
812
+		$label_class       = 'espresso-form-input-lbl';
813
+		$QST_options       = $QFI->options(true, $answer);
814
+		$options           = is_array($QST_options) ? self::prep_answer_options($QST_options) : [];
815
+		$system_ID         = $QFI->get('QST_system');
816
+		$label_b4          = $QFI->get_meta('label_b4');
817
+		$use_desc_4_label  = $QFI->get_meta('use_desc_4_label');
818
+
819
+
820
+		switch ($QFI->get('QST_type')) {
821
+			case 'TEXTAREA':
822
+				return EEH_Form_Fields::textarea(
823
+					$display_text,
824
+					$answer,
825
+					$input_name,
826
+					$input_id,
827
+					$input_class,
828
+					[],
829
+					$required,
830
+					$required_text,
831
+					$label_class,
832
+					$disabled,
833
+					$system_ID,
834
+					$use_html_entities
835
+				);
836
+
837
+			case 'DROPDOWN':
838
+				return EEH_Form_Fields::select(
839
+					$display_text,
840
+					$answer,
841
+					$options,
842
+					$input_name,
843
+					$input_id,
844
+					$input_class,
845
+					$required,
846
+					$required_text,
847
+					$label_class,
848
+					$disabled,
849
+					$system_ID,
850
+					$use_html_entities,
851
+					true
852
+				);
853
+
854
+
855
+			case 'RADIO_BTN':
856
+				return EEH_Form_Fields::radio(
857
+					$display_text,
858
+					$answer,
859
+					$options,
860
+					$input_name,
861
+					$input_id,
862
+					$input_class,
863
+					$required,
864
+					$required_text,
865
+					$label_class,
866
+					$disabled,
867
+					$system_ID,
868
+					$use_html_entities,
869
+					$label_b4,
870
+					$use_desc_4_label
871
+				);
872
+
873
+			case 'CHECKBOX':
874
+				return EEH_Form_Fields::checkbox(
875
+					$display_text,
876
+					$answer,
877
+					$options,
878
+					$input_name,
879
+					$input_id,
880
+					$input_class,
881
+					$required,
882
+					$required_text,
883
+					$label_class,
884
+					$disabled,
885
+					$label_b4,
886
+					$system_ID,
887
+					$use_html_entities
888
+				);
889
+
890
+			case 'DATE':
891
+				return EEH_Form_Fields::datepicker(
892
+					$display_text,
893
+					$answer,
894
+					$input_name,
895
+					$input_id,
896
+					$input_class,
897
+					$required,
898
+					$required_text,
899
+					$label_class,
900
+					$disabled,
901
+					$system_ID,
902
+					$use_html_entities
903
+				);
904
+
905
+			case 'TEXT':
906
+			default:
907
+				return EEH_Form_Fields::text(
908
+					$display_text,
909
+					$answer,
910
+					$input_name,
911
+					$input_id,
912
+					$input_class,
913
+					$required,
914
+					$required_text,
915
+					$label_class,
916
+					$disabled,
917
+					$system_ID,
918
+					$use_html_entities
919
+				);
920
+		}
921
+	}
922
+
923
+
924
+	/**
925
+	 * generates HTML for a form text input
926
+	 *
927
+	 * @param string $question    label content
928
+	 * @param string $answer      form input value attribute
929
+	 * @param string $name        form input name attribute
930
+	 * @param string $id          form input css id attribute
931
+	 * @param string $class       form input css class attribute
932
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
933
+	 *                            required 'class', and required 'msg' attribute
934
+	 * @param string $label_class css class attribute for the label
935
+	 * @param string $disabled    disabled="disabled" or null
936
+	 * @return string HTML
937
+	 */
938
+	public static function text(
939
+		$question = false,
940
+		$answer = null,
941
+		$name = false,
942
+		$id = '',
943
+		$class = '',
944
+		$required = false,
945
+		$required_text = '',
946
+		$label_class = '',
947
+		$disabled = false,
948
+		$system_ID = false,
949
+		$use_html_entities = true
950
+	) {
951
+		// need these
952
+		if (! $question || ! $name) {
953
+			return null;
954
+		}
955
+		// prep the answer
956
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
957
+		// prep the required array
958
+		$required = self::prep_required($required);
959
+		// set disabled tag
960
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
961
+		// ya gots ta have style man!!!
962
+		$txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp';
963
+		$class     = empty($class) ? $txt_class : $class;
964
+		$class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
965
+		$extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
966
+
967
+		$label_html =
968
+			$required_text
969
+			. "\n\t\t\t"
970
+			. '<label for="' . $name . '" class="' . $label_class . '">'
971
+			. self::prep_question($question)
972
+			. $required['label']
973
+			. '</label><br/>';
974
+		// filter label but ensure required text comes before it
975
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
976
+
977
+		$input_html =
978
+			"\n\t\t\t"
979
+			. '<input type="text" name="' . $name . '" id="' . $id . '" '
980
+			. 'class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr($answer) . '"  '
981
+			. 'title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
982
+
983
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
984
+		return $label_html . $input_html;
985
+	}
986
+
987
+
988
+	/**
989
+	 * generates HTML for a form textarea
990
+	 *
991
+	 * @param string $question    label content
992
+	 * @param string $answer      form input value attribute
993
+	 * @param string $name        form input name attribute
994
+	 * @param string $id          form input css id attribute
995
+	 * @param string $class       form input css class attribute
996
+	 * @param array  $dimensions  array of form input rows and cols attributes : array( 'rows' => 3, 'cols' => 40 )
997
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
998
+	 *                            required 'class', and required 'msg' attribute
999
+	 * @param string $label_class css class attribute for the label
1000
+	 * @param string $disabled    disabled="disabled" or null
1001
+	 * @return string HTML
1002
+	 */
1003
+	public static function textarea(
1004
+		$question = false,
1005
+		$answer = null,
1006
+		$name = false,
1007
+		$id = '',
1008
+		$class = '',
1009
+		$dimensions = false,
1010
+		$required = false,
1011
+		$required_text = '',
1012
+		$label_class = '',
1013
+		$disabled = false,
1014
+		$system_ID = false,
1015
+		$use_html_entities = true
1016
+	) {
1017
+		// need these
1018
+		if (! $question || ! $name) {
1019
+			return null;
1020
+		}
1021
+		// prep the answer
1022
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1023
+		// prep the required array
1024
+		$required = self::prep_required($required);
1025
+		// make sure $dimensions is an array
1026
+		$dimensions = is_array($dimensions) ? $dimensions : [];
1027
+		// and set some defaults
1028
+		$dimensions = array_merge(['rows' => 3, 'cols' => 40], $dimensions);
1029
+		// set disabled tag
1030
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1031
+		// ya gots ta have style man!!!
1032
+		$txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp';
1033
+		$class     = empty($class) ? $txt_class : $class;
1034
+		$class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1035
+		$extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1036
+
1037
+		$label_html =
1038
+			$required_text
1039
+			. "\n\t\t\t"
1040
+			. '<label for="' . $name . '" class="' . $label_class . '">'
1041
+			. self::prep_question($question)
1042
+			. $required['label']
1043
+			. '</label><br/>';
1044
+		// filter label but ensure required text comes before it
1045
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1046
+
1047
+		$input_html =
1048
+			"\n\t\t\t"
1049
+			. '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" '
1050
+			. 'rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '"  '
1051
+			. 'title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>'
1052
+			. esc_textarea($answer)
1053
+			. '</textarea>';
1054
+
1055
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1056
+		return $label_html . $input_html;
1057
+	}
1058
+
1059
+
1060
+	/**
1061
+	 * generates HTML for a form select input
1062
+	 *
1063
+	 * @param string $question    label content
1064
+	 * @param string $answer      form input value attribute
1065
+	 * @param array  $options     array of answer options where array key = option value and array value = option
1066
+	 *                            display text
1067
+	 * @param string $name        form input name attribute
1068
+	 * @param string $id          form input css id attribute
1069
+	 * @param string $class       form input css class attribute
1070
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1071
+	 *                            required 'class', and required 'msg' attribute
1072
+	 * @param string $label_class css class attribute for the label
1073
+	 * @param string $disabled    disabled="disabled" or null
1074
+	 * @return string HTML
1075
+	 */
1076
+	public static function select(
1077
+		$question = false,
1078
+		$answer = null,
1079
+		$options = false,
1080
+		$name = false,
1081
+		$id = '',
1082
+		$class = '',
1083
+		$required = false,
1084
+		$required_text = '',
1085
+		$label_class = '',
1086
+		$disabled = false,
1087
+		$system_ID = false,
1088
+		$use_html_entities = true,
1089
+		$add_please_select_option = false
1090
+	) {
1091
+
1092
+		// need these
1093
+		if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1094
+			return null;
1095
+		}
1096
+		// prep the answer
1097
+		$answer =
1098
+			is_array($answer)
1099
+				? self::prep_answer(array_shift($answer), $use_html_entities)
1100
+				: self::prep_answer(
1101
+					$answer,
1102
+					$use_html_entities
1103
+				);
1104
+		// prep the required array
1105
+		$required = self::prep_required($required);
1106
+		// set disabled tag
1107
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1108
+		// ya gots ta have style man!!!
1109
+		$txt_class = is_admin() ? 'wide' : 'espresso-select-inp';
1110
+		$class     = empty($class) ? $txt_class : $class;
1111
+		$class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1112
+		$extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1113
+
1114
+		$label_html =
1115
+			$required_text
1116
+			. "\n\t\t\t"
1117
+			. '<label for="' . $name . '" class="' . $label_class . '">'
1118
+			. self::prep_question($question)
1119
+			. $required['label']
1120
+			. '</label><br/>';
1121
+		// filter label but ensure required text comes before it
1122
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1123
+
1124
+		$input_html =
1125
+			"\n\t\t\t"
1126
+			. '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" '
1127
+			. 'title="' . esc_attr($required['msg']) . '"' . $disabled . ' ' . $extra . '>';
1128
+		// recursively count array elements, to determine total number of options
1129
+		$only_option = count($options, 1) == 1;
1130
+		if (! $only_option) {
1131
+			// if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected
1132
+			$selected   = $answer === null ? ' selected' : '';
1133
+			$input_html .= $add_please_select_option
1134
+				? "\n\t\t\t\t"
1135
+				  . '<option value=""' . $selected . '>'
1136
+				  . esc_html__(' - please select - ', 'event_espresso')
1137
+				  . '</option>'
1138
+				: '';
1139
+		}
1140
+		foreach ($options as $key => $value) {
1141
+			// if value is an array, then create option groups, else create regular ol' options
1142
+			$input_html .= is_array($value)
1143
+				? self::_generate_select_option_group(
1144
+					$key,
1145
+					$value,
1146
+					$answer,
1147
+					$use_html_entities
1148
+				)
1149
+				: self::_generate_select_option(
1150
+					$value->value(),
1151
+					$value->desc(),
1152
+					$answer,
1153
+					$only_option,
1154
+					$use_html_entities
1155
+				);
1156
+		}
1157
+
1158
+		$input_html .= "\n\t\t\t" . '</select>';
1159
+
1160
+		$input_html =
1161
+			apply_filters(
1162
+				'FHEE__EEH_Form_Fields__select__before_end_wrapper',
1163
+				$input_html,
1164
+				$question,
1165
+				$answer,
1166
+				$name,
1167
+				$id,
1168
+				$class,
1169
+				$system_ID
1170
+			);
1171
+
1172
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1173
+		return $label_html . $input_html;
1174
+	}
1175
+
1176
+
1177
+	/**
1178
+	 *  _generate_select_option_group
1179
+	 *
1180
+	 *  if  $value for a select box is an array, then the key will be used as the optgroup label
1181
+	 *  and the value array will be looped thru and the elements sent to _generate_select_option
1182
+	 *
1183
+	 * @param mixed   $opt_group
1184
+	 * @param mixed   $QSOs
1185
+	 * @param mixed   $answer
1186
+	 * @param boolean $use_html_entities
1187
+	 * @return string
1188
+	 */
1189
+	private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true)
1190
+	{
1191
+		$html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value($opt_group) . '">';
1192
+		foreach ($QSOs as $QSO) {
1193
+			$html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities);
1194
+		}
1195
+		$html .= "\n\t\t\t\t" . '</optgroup>';
1196
+		return $html;
1197
+	}
1198
+
1199
+
1200
+	/**
1201
+	 *  _generate_select_option
1202
+	 *
1203
+	 * @param mixed   $key
1204
+	 * @param mixed   $value
1205
+	 * @param mixed   $answer
1206
+	 * @param int     $only_option
1207
+	 * @param boolean $use_html_entities
1208
+	 * @return string
1209
+	 */
1210
+	private static function _generate_select_option(
1211
+		$key,
1212
+		$value,
1213
+		$answer,
1214
+		$only_option = false,
1215
+		$use_html_entities = true
1216
+	) {
1217
+		$key      = self::prep_answer($key, $use_html_entities);
1218
+		$value    = self::prep_answer($value, $use_html_entities);
1219
+		$value    = ! empty($value) ? $value : $key;
1220
+		$selected = ($answer == $key || $only_option) ? 'selected' : '';
1221
+		return "\n\t\t\t\t"
1222
+			   . '<option value="' . self::prep_option_value($key) . '" ' . $selected . '> '
1223
+			   . $value
1224
+			   . '&nbsp;&nbsp;&nbsp;</option>';
1225
+	}
1226
+
1227
+
1228
+	/**
1229
+	 * generates HTML for form radio button inputs
1230
+	 *
1231
+	 * @param bool|string $question    label content
1232
+	 * @param string      $answer      form input value attribute
1233
+	 * @param array|bool  $options     array of answer options where array key = option value and array value = option
1234
+	 *                                 display text
1235
+	 * @param bool|string $name        form input name attribute
1236
+	 * @param string      $id          form input css id attribute
1237
+	 * @param string      $class       form input css class attribute
1238
+	 * @param array|bool  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1239
+	 *                                 required 'class', and required 'msg' attribute
1240
+	 * @param string      $required_text
1241
+	 * @param string      $label_class css class attribute for the label
1242
+	 * @param bool|string $disabled    disabled="disabled" or null
1243
+	 * @param bool        $system_ID
1244
+	 * @param bool        $use_html_entities
1245
+	 * @param bool        $label_b4
1246
+	 * @param bool        $use_desc_4_label
1247
+	 * @return string HTML
1248
+	 */
1249
+	public static function radio(
1250
+		$question = false,
1251
+		$answer = null,
1252
+		$options = false,
1253
+		$name = false,
1254
+		$id = '',
1255
+		$class = '',
1256
+		$required = false,
1257
+		$required_text = '',
1258
+		$label_class = '',
1259
+		$disabled = false,
1260
+		$system_ID = false,
1261
+		$use_html_entities = true,
1262
+		$label_b4 = false,
1263
+		$use_desc_4_label = false
1264
+	) {
1265
+		// need these
1266
+		if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1267
+			return null;
1268
+		}
1269
+		// prep the answer
1270
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1271
+		// prep the required array
1272
+		$required = self::prep_required($required);
1273
+		// set disabled tag
1274
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1275
+		// ya gots ta have style man!!!
1276
+		$radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
1277
+		$class       = ! empty($class) ? $class : 'espresso-radio-btn-inp';
1278
+		$extra       = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1279
+
1280
+		$label_html =
1281
+			$required_text
1282
+			. "\n\t\t\t"
1283
+			. '<label class="' . $label_class . '">'
1284
+			. self::prep_question($question)
1285
+			. $required['label']
1286
+			. '</label> ';
1287
+		// filter label but ensure required text comes before it
1288
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1289
+
1290
+		$input_html =
1291
+			"\n\t\t\t"
1292
+			. '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">';
1293
+
1294
+		$class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1295
+		$class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1296
+
1297
+		foreach ($options as $OPT) {
1298
+			if ($OPT instanceof EE_Question_Option) {
1299
+				$value   = self::prep_option_value($OPT->value());
1300
+				$label   = $use_desc_4_label ? $OPT->desc() : $OPT->value();
1301
+				$size    = $use_desc_4_label
1302
+					? self::get_label_size_class($OPT->value() . ' ' . $OPT->desc())
1303
+					: self::get_label_size_class($OPT->value());
1304
+				$desc    = $OPT->desc();// no self::prep_answer
1305
+				$answer  = is_numeric($value) && empty($answer) ? 0 : $answer;
1306
+				$checked = (string) $value == (string) $answer ? ' checked' : '';
1307
+				$opt     = '-' . sanitize_key($value);
1308
+
1309
+				$input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1310
+				$input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">';
1311
+				$input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : '';
1312
+				$input_html .= "\n\t\t\t\t\t\t"
1313
+							   . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" '
1314
+							   . 'class="' . $class . '" value="' . $value . '" '
1315
+							   . 'title="' . esc_attr($required['msg']) . '" ' . $disabled
1316
+							   . $checked . ' ' . $extra . '/>';
1317
+				$input_html .= ! $label_b4
1318
+					? "\n\t\t\t\t\t\t"
1319
+					  . '<span class="espresso-radio-btn-desc">'
1320
+					  . $label
1321
+					  . '</span>'
1322
+					: '';
1323
+				$input_html .= "\n\t\t\t\t\t" . '</label>';
1324
+				$input_html .= $use_desc_4_label
1325
+					? ''
1326
+					: '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>';
1327
+				$input_html .= "\n\t\t\t\t" . '</li>';
1328
+			}
1329
+		}
1330
+
1331
+		$input_html .= "\n\t\t\t" . '</ul>';
1332
+
1333
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1334
+		return $label_html . $input_html;
1335
+	}
1336
+
1337
+
1338
+	/**
1339
+	 * generates HTML for form checkbox inputs
1340
+	 *
1341
+	 * @param string $question    label content
1342
+	 * @param string $answer      form input value attribute
1343
+	 * @param array  $options     array of options where array key = option value and array value = option display text
1344
+	 * @param string $name        form input name attribute
1345
+	 * @param string $id          form input css id attribute
1346
+	 * @param string $class       form input css class attribute
1347
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1348
+	 *                            required 'class', and required 'msg' attribute
1349
+	 * @param string $label_class css class attribute for the label
1350
+	 * @param string $disabled    disabled="disabled" or null
1351
+	 * @return string HTML
1352
+	 */
1353
+	public static function checkbox(
1354
+		$question = false,
1355
+		$answer = null,
1356
+		$options = false,
1357
+		$name = false,
1358
+		$id = '',
1359
+		$class = '',
1360
+		$required = false,
1361
+		$required_text = '',
1362
+		$label_class = '',
1363
+		$disabled = false,
1364
+		$label_b4 = false,
1365
+		$system_ID = false,
1366
+		$use_html_entities = true
1367
+	) {
1368
+		// need these
1369
+		if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1370
+			return null;
1371
+		}
1372
+		$answer = maybe_unserialize($answer);
1373
+
1374
+		// prep the answer(s)
1375
+		$answer = is_array($answer) ? $answer : [sanitize_key($answer) => $answer];
1376
+
1377
+		foreach ($answer as $key => $value) {
1378
+			$key            = self::prep_option_value($key);
1379
+			$answer[ $key ] = self::prep_answer($value, $use_html_entities);
1380
+		}
1381
+
1382
+		// prep the required array
1383
+		$required = self::prep_required($required);
1384
+		// set disabled tag
1385
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1386
+		// ya gots ta have style man!!!
1387
+		$radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
1388
+		$class       = empty($class) ? 'espresso-radio-btn-inp' : $class;
1389
+		$extra       = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1390
+
1391
+		$label_html =
1392
+			$required_text
1393
+			. "\n\t\t\t"
1394
+			. '<label class="' . $label_class . '">'
1395
+			. self::prep_question($question)
1396
+			. $required['label']
1397
+			. '</label> ';
1398
+		// filter label but ensure required text comes before it
1399
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1400
+
1401
+		$input_html =
1402
+			"\n\t\t\t"
1403
+			. '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">';
1404
+
1405
+		$class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1406
+		$class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1407
+
1408
+		foreach ($options as $OPT) {
1409
+			$value = $OPT->value();// self::prep_option_value( $OPT->value() );
1410
+			$size  = self::get_label_size_class($OPT->value() . ' ' . $OPT->desc());
1411
+			$text  = self::prep_answer($OPT->value());
1412
+			$desc  = $OPT->desc();
1413
+			$opt   = '-' . sanitize_key($value);
1414
+
1415
+			$checked = is_array($answer) && in_array($text, $answer) ? ' checked' : '';
1416
+
1417
+			$input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1418
+			$input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">';
1419
+			$input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
1420
+			$input_html .= "\n\t\t\t\t\t\t"
1421
+						   . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" '
1422
+						   . 'id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" '
1423
+						   . 'title="' . esc_attr($required['msg']) . '" ' . $disabled . $checked . ' ' . $extra . '/>';
1424
+			$input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
1425
+			$input_html .= "\n\t\t\t\t\t" . '</label>';
1426
+			if (! empty($desc) && $desc != $text) {
1427
+				$input_html .= "\n\t\t\t\t\t"
1428
+							   . ' &nbsp; <br/><div class="espresso-checkbox-option-desc small-text grey-text">'
1429
+							   . $desc
1430
+							   . '</div>';
1431
+			}
1432
+			$input_html .= "\n\t\t\t\t" . '</li>';
1433
+		}
1434
+
1435
+		$input_html .= "\n\t\t\t" . '</ul>';
1436
+
1437
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1438
+		return $label_html . $input_html;
1439
+	}
1440
+
1441
+
1442
+	/**
1443
+	 * generates HTML for a form datepicker input
1444
+	 *
1445
+	 * @param string $question    label content
1446
+	 * @param string $answer      form input value attribute
1447
+	 * @param string $name        form input name attribute
1448
+	 * @param string $id          form input css id attribute
1449
+	 * @param string $class       form input css class attribute
1450
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1451
+	 *                            required 'class', and required 'msg' attribute
1452
+	 * @param string $label_class css class attribute for the label
1453
+	 * @param string $disabled    disabled="disabled" or null
1454
+	 * @return string HTML
1455
+	 */
1456
+	public static function datepicker(
1457
+		$question = false,
1458
+		$answer = null,
1459
+		$name = false,
1460
+		$id = '',
1461
+		$class = '',
1462
+		$required = false,
1463
+		$required_text = '',
1464
+		$label_class = '',
1465
+		$disabled = false,
1466
+		$system_ID = false,
1467
+		$use_html_entities = true
1468
+	) {
1469
+		// need these
1470
+		if (! $question || ! $name) {
1471
+			return null;
1472
+		}
1473
+		// prep the answer
1474
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1475
+		// prep the required array
1476
+		$required = self::prep_required($required);
1477
+		// set disabled tag
1478
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1479
+		// ya gots ta have style man!!!
1480
+		$txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp';
1481
+		$class     = empty($class) ? $txt_class : $class;
1482
+		$class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1483
+		$extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1484
+
1485
+		$label_html =
1486
+			$required_text
1487
+			. "\n\t\t\t"
1488
+			. '<label for="' . $name . '" class="' . $label_class . '">'
1489
+			. self::prep_question($question)
1490
+			. $required['label']
1491
+			. '</label><br/>';
1492
+		// filter label but ensure required text comes before it
1493
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1494
+
1495
+		$input_html =
1496
+			"\n\t\t\t"
1497
+			. '<input type="text" name="' . $name . '" id="' . $id . '" '
1498
+			. 'class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '"  '
1499
+			. 'title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
1500
+
1501
+		// enqueue scripts
1502
+		wp_register_style(
1503
+			'espresso-ui-theme',
1504
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1505
+			[],
1506
+			EVENT_ESPRESSO_VERSION
1507
+		);
1508
+		wp_enqueue_style('espresso-ui-theme');
1509
+		wp_enqueue_script('jquery-ui-datepicker');
1510
+
1511
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1512
+		return $label_html . $input_html;
1513
+	}
1514
+
1515
+
1516
+	/**
1517
+	 *  remove_label_keep_required_msg
1518
+	 *  this will strip out a form input's label HTML while keeping the required text HTML that MUST be before the label
1519
+	 *
1520
+	 * @access public
1521
+	 * @return     string
1522
+	 */
1523
+	public static function remove_label_keep_required_msg($label_html, $required_text)
1524
+	{
1525
+		return $required_text;
1526
+	}
1527
+
1528
+
1529
+	/**
1530
+	 * Simply returns the HTML for a hidden input of the given name and value.
1531
+	 *
1532
+	 * @param string $name
1533
+	 * @param string $value
1534
+	 * @return string HTML
1535
+	 */
1536
+	public static function hidden_input($name, $value, $id = '')
1537
+	{
1538
+		$id = ! empty($id) ? $id : $name;
1539
+		return '<input id="' . $id . '" type="hidden" name="' . $name . '" value="' . $value . '"/>';
1540
+	}
1541
+
1542
+
1543
+	/**
1544
+	 * prep_question
1545
+	 *
1546
+	 * @param string $question
1547
+	 * @return string
1548
+	 */
1549
+	public static function prep_question($question)
1550
+	{
1551
+		return $question;
1552
+	}
1553
+
1554
+
1555
+	/**
1556
+	 *  prep_answer
1557
+	 *
1558
+	 * @param mixed $answer
1559
+	 * @return string
1560
+	 */
1561
+	public static function prep_answer($answer, $use_html_entities = true)
1562
+	{
1563
+		// make sure we convert bools first.  Otherwise (bool) false becomes an empty string which is NOT desired,
1564
+		// we want "0".
1565
+		if (is_bool($answer)) {
1566
+			$answer = $answer ? 1 : 0;
1567
+		}
1568
+		$answer = trim(stripslashes(str_replace('&#039;', "'", $answer)));
1569
+		return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer;
1570
+	}
1571
+
1572
+
1573
+	/**
1574
+	 *  prep_answer_options
1575
+	 *
1576
+	 * @param array $QSOs array of EE_Question_Option objects
1577
+	 * @return array
1578
+	 */
1579
+	public static function prep_answer_options($QSOs = [])
1580
+	{
1581
+		$prepped_answer_options = [];
1582
+		if (is_array($QSOs) && ! empty($QSOs)) {
1583
+			foreach ($QSOs as $key => $QSO) {
1584
+				if (! $QSO instanceof EE_Question_Option) {
1585
+					$QSO = EE_Question_Option::new_instance(
1586
+						[
1587
+							'QSO_value' => is_array($QSO) && isset($QSO['id'])
1588
+								? (string) $QSO['id']
1589
+								: (string) $key,
1590
+							'QSO_desc'  => is_array($QSO) && isset($QSO['text'])
1591
+								? (string) $QSO['text']
1592
+								: (string) $QSO,
1593
+						]
1594
+					);
1595
+				}
1596
+				if ($QSO->opt_group()) {
1597
+					$prepped_answer_options[ $QSO->opt_group() ][] = $QSO;
1598
+				} else {
1599
+					$prepped_answer_options[] = $QSO;
1600
+				}
1601
+			}
1602
+		}
1603
+		//      d( $prepped_answer_options );
1604
+		return $prepped_answer_options;
1605
+	}
1606
+
1607
+
1608
+	/**
1609
+	 *  prep_option_value
1610
+	 *
1611
+	 * @param string $option_value
1612
+	 * @return string
1613
+	 */
1614
+	public static function prep_option_value($option_value)
1615
+	{
1616
+		return esc_attr(trim(stripslashes($option_value)));
1617
+	}
1618
+
1619
+
1620
+	/**
1621
+	 *  prep_required
1622
+	 *
1623
+	 * @param string|array $required
1624
+	 * @return array
1625
+	 */
1626
+	public static function prep_required($required = [])
1627
+	{
1628
+		// make sure required is an array
1629
+		$required = is_array($required) ? $required : [];
1630
+		// and set some defaults
1631
+		return array_merge(['label' => '', 'class' => '', 'msg' => ''], $required);
1632
+	}
1633
+
1634
+
1635
+	/**
1636
+	 *  get_label_size_class
1637
+	 *
1638
+	 * @param string $value
1639
+	 * @return string
1640
+	 */
1641
+	public static function get_label_size_class($value = false)
1642
+	{
1643
+		if ($value === false || $value === '') {
1644
+			return ' class="medium-lbl"';
1645
+		}
1646
+		// determine length of option value
1647
+		$val_size = strlen($value);
1648
+		switch ($val_size) {
1649
+			case $val_size < 3:
1650
+				$size = ' class="nano-lbl"';
1651
+				break;
1652
+			case $val_size < 6:
1653
+				$size = ' class="micro-lbl"';
1654
+				break;
1655
+			case $val_size < 12:
1656
+				$size = ' class="tiny-lbl"';
1657
+				break;
1658
+			case $val_size < 25:
1659
+				$size = ' class="small-lbl"';
1660
+				break;
1661
+			case $val_size > 100:
1662
+				$size = ' class="big-lbl"';
1663
+				break;
1664
+			default:
1665
+				$size = ' class="medium-lbl"';
1666
+				break;
1667
+		}
1668
+		return $size;
1669
+	}
1670
+
1671
+
1672
+	/**
1673
+	 *  _load_system_dropdowns
1674
+	 *
1675
+	 * @param EE_Question_Form_Input $QFI
1676
+	 * @return array
1677
+	 * @throws EE_Error
1678
+	 * @throws ReflectionException
1679
+	 */
1680
+	private static function _load_system_dropdowns($QFI)
1681
+	{
1682
+		$QST_system = $QFI->get('QST_system');
1683
+		switch ($QST_system) {
1684
+			case 'state':
1685
+				$QFI = self::generate_state_dropdown($QFI);
1686
+				break;
1687
+			case 'country':
1688
+				$QFI = self::generate_country_dropdown($QFI);
1689
+				break;
1690
+			case 'admin-state':
1691
+				$QFI = self::generate_state_dropdown($QFI, true);
1692
+				break;
1693
+			case 'admin-country':
1694
+				$QFI = self::generate_country_dropdown($QFI, true);
1695
+				break;
1696
+		}
1697
+		return $QFI;
1698
+	}
1699
+
1700
+
1701
+	/**
1702
+	 * This preps dropdowns that are specialized.
1703
+	 *
1704
+	 * @param EE_Question_Form_Input $QFI
1705
+	 *
1706
+	 * @return EE_Question_Form_Input
1707
+	 * @throws EE_Error
1708
+	 * @throws ReflectionException
1709
+	 * @since  4.6.0
1710
+	 */
1711
+	protected static function _load_specialized_dropdowns($QFI)
1712
+	{
1713
+		switch ($QFI->get('QST_type')) {
1714
+			case 'STATE':
1715
+				$QFI = self::generate_state_dropdown($QFI);
1716
+				break;
1717
+			case 'COUNTRY':
1718
+				$QFI = self::generate_country_dropdown($QFI);
1719
+				break;
1720
+		}
1721
+		return $QFI;
1722
+	}
1723
+
1724
+
1725
+	/**
1726
+	 *    generate_state_dropdown
1727
+	 *
1728
+	 * @param EE_Question_Form_Input $QST
1729
+	 * @param bool                   $get_all
1730
+	 * @return EE_Question_Form_Input
1731
+	 * @throws EE_Error
1732
+	 * @throws ReflectionException
1733
+	 */
1734
+	public static function generate_state_dropdown($QST, $get_all = false)
1735
+	{
1736
+		$states = $get_all
1737
+			? EEM_State::instance()->get_all_states()
1738
+			: EEM_State::instance()->get_all_states_of_active_countries();
1739
+		if ($states && count($states) != count($QST->options())) {
1740
+			$QST->set('QST_type', 'DROPDOWN');
1741
+			// if multiple countries, we'll create option groups within the dropdown
1742
+			foreach ($states as $state) {
1743
+				if ($state instanceof EE_State) {
1744
+					$QSO = EE_Question_Option::new_instance(
1745
+						[
1746
+							'QSO_value'   => $state->ID(),
1747
+							'QSO_desc'    => $state->name(),
1748
+							'QST_ID'      => $QST->get('QST_ID'),
1749
+							'QSO_deleted' => false,
1750
+						]
1751
+					);
1752
+					// set option group
1753
+					$QSO->set_opt_group($state->country()->name());
1754
+					// add option to question
1755
+					$QST->add_temp_option($QSO);
1756
+				}
1757
+			}
1758
+		}
1759
+		return $QST;
1760
+	}
1761
+
1762
+
1763
+	/**
1764
+	 *    generate_country_dropdown
1765
+	 *
1766
+	 * @param      $QST
1767
+	 * @param bool $get_all
1768
+	 * @return array
1769
+	 * @throws EE_Error
1770
+	 * @throws ReflectionException
1771
+	 * @internal param array $question
1772
+	 */
1773
+	public static function generate_country_dropdown($QST, $get_all = false)
1774
+	{
1775
+		$countries = $get_all
1776
+			? EEM_Country::instance()->get_all_countries()
1777
+			: EEM_Country::instance()->get_all_active_countries();
1778
+		if ($countries && count($countries) != count($QST->options())) {
1779
+			$QST->set('QST_type', 'DROPDOWN');
1780
+			// now add countries
1781
+			foreach ($countries as $country) {
1782
+				if ($country instanceof EE_Country) {
1783
+					$QSO = EE_Question_Option::new_instance(
1784
+						[
1785
+							'QSO_value'   => $country->ID(),
1786
+							'QSO_desc'    => $country->name(),
1787
+							'QST_ID'      => $QST->get('QST_ID'),
1788
+							'QSO_deleted' => false,
1789
+						]
1790
+					);
1791
+					$QST->add_temp_option($QSO);
1792
+				}
1793
+			}
1794
+		}
1795
+		return $QST;
1796
+	}
1797
+
1798
+
1799
+	/**
1800
+	 *  generates options for a month dropdown selector with numbers from 01 to 12
1801
+	 *
1802
+	 * @return array()
1803
+	 */
1804
+	public static function two_digit_months_dropdown_options()
1805
+	{
1806
+		$options = [];
1807
+		for ($x = 1; $x <= 12; $x++) {
1808
+			$mm             = str_pad($x, 2, '0', STR_PAD_LEFT);
1809
+			$options[ $mm ] = $mm;
1810
+		}
1811
+		return EEH_Form_Fields::prep_answer_options($options);
1812
+	}
1813
+
1814
+
1815
+	/**
1816
+	 *  generates a year dropdown selector with numbers for the next ten years
1817
+	 *
1818
+	 * @return array
1819
+	 */
1820
+	public static function next_decade_two_digit_year_dropdown_options()
1821
+	{
1822
+		$options      = [];
1823
+		$current_year = date('y');
1824
+		$next_decade  = $current_year + 10;
1825
+		for ($x = $current_year; $x <= $next_decade; $x++) {
1826
+			$yy             = str_pad($x, 2, '0', STR_PAD_LEFT);
1827
+			$options[ $yy ] = $yy;
1828
+		}
1829
+		return EEH_Form_Fields::prep_answer_options($options);
1830
+	}
1831
+
1832
+
1833
+	/**
1834
+	 * generates a month/year dropdown selector for all registrations matching the given criteria.  Typically used for
1835
+	 * list table filter.
1836
+	 *
1837
+	 * @param string  $cur_date     any currently selected date can be entered here.
1838
+	 * @param string  $status       Registration status
1839
+	 * @param integer $evt_category Event Category ID if the Event Category filter is selected
1840
+	 * @return string                html
1841
+	 * @throws EE_Error
1842
+	 */
1843
+	public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0)
1844
+	{
1845
+		$_where = [];
1846
+		if (! empty($status)) {
1847
+			$_where['STS_ID'] = $status;
1848
+		}
1849
+
1850
+		if ($evt_category > 0) {
1851
+			$_where['Event.Term_Taxonomy.term_id'] = $evt_category;
1852
+		}
1853
+
1854
+		$regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where);
1855
+
1856
+		// setup vals for select input helper
1857
+		$options = [
1858
+			0 => [
1859
+				'text' => esc_html__('Select a Month/Year', 'event_espresso'),
1860
+				'id'   => '',
1861
+			],
1862
+		];
1863
+
1864
+		foreach ($regdtts as $regdtt) {
1865
+			$date      = $regdtt->reg_month . ' ' . $regdtt->reg_year;
1866
+			$options[] = [
1867
+				'text' => $date,
1868
+				'id'   => $date,
1869
+			];
1870
+		}
1871
+
1872
+		return self::select_input('month_range', $options, $cur_date, '', 'wide');
1873
+	}
1874
+
1875
+
1876
+	/**
1877
+	 * generates a month/year dropdown selector for all events matching the given criteria
1878
+	 * Typically used for list table filter
1879
+	 *
1880
+	 * @param string $cur_date          any currently selected date can be entered here.
1881
+	 * @param string $status            "view" (i.e. all, today, month, draft)
1882
+	 * @param int    $evt_category      category event belongs to
1883
+	 * @param string $evt_active_status "upcoming", "expired", "active", or "inactive"
1884
+	 * @return string                    html
1885
+	 * @throws EE_Error
1886
+	 */
1887
+	public static function generate_event_months_dropdown(
1888
+		$cur_date = '',
1889
+		$status = null,
1890
+		$evt_category = null,
1891
+		$evt_active_status = null
1892
+	) {
1893
+		// determine what post_status our condition will have for the query.
1894
+		// phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
1895
+		switch ($status) {
1896
+			case 'month':
1897
+			case 'today':
1898
+			case null:
1899
+			case 'all':
1900
+				$where['Event.status'] = ['NOT IN', ['trash']];
1901
+				break;
1902
+			case 'draft':
1903
+				$where['Event.status'] = ['IN', ['draft', 'auto-draft']];
1904
+				break;
1905
+			default:
1906
+				$where['Event.status'] = $status;
1907
+		}
1908
+
1909
+		// phpcs:enable
1910
+
1911
+		// categories?
1912
+
1913
+
1914
+		if (! empty($evt_category)) {
1915
+			$where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1916
+			$where['Event.Term_Taxonomy.term_id']  = $evt_category;
1917
+		}
1918
+
1919
+
1920
+		//      $where['DTT_is_primary'] = 1;
1921
+
1922
+		$DTTS = EEM_Datetime::instance()->get_dtt_months_and_years($where, $evt_active_status);
1923
+
1924
+		// let's setup vals for select input helper
1925
+		$options = [
1926
+			0 => [
1927
+				'text' => esc_html__('Select a Month/Year', 'event_espresso'),
1928
+				'id'   => "",
1929
+			],
1930
+		];
1931
+
1932
+
1933
+		// translate month and date
1934
+		global $wp_locale;
1935
+
1936
+		foreach ($DTTS as $DTT) {
1937
+			$localized_date = $wp_locale->get_month($DTT->dtt_month_num) . ' ' . $DTT->dtt_year;
1938
+			$id             = $DTT->dtt_month . ' ' . $DTT->dtt_year;
1939
+			$options[]      = [
1940
+				'text' => $localized_date,
1941
+				'id'   => $id,
1942
+			];
1943
+		}
1944
+
1945
+
1946
+		return self::select_input('month_range', $options, $cur_date, '', 'wide');
1947
+	}
1948
+
1949
+
1950
+	/**
1951
+	 * generates the dropdown selector for event categories
1952
+	 * typically used as a filter on list tables.
1953
+	 *
1954
+	 * @param integer $current_cat currently selected category
1955
+	 * @return string               html for dropdown
1956
+	 * @throws EE_Error
1957
+	 * @throws ReflectionException
1958
+	 */
1959
+	public static function generate_event_category_dropdown($current_cat = -1)
1960
+	{
1961
+		$categories = EEM_Term::instance()->get_all_ee_categories(true);
1962
+		$options    = [
1963
+			'0' => [
1964
+				'text' => esc_html__('All Categories', 'event_espresso'),
1965
+				'id'   => -1,
1966
+			],
1967
+		];
1968
+
1969
+		// setup categories for dropdown
1970
+		foreach ($categories as $category) {
1971
+			$options[] = [
1972
+				'text' => $category->get('name'),
1973
+				'id'   => $category->ID(),
1974
+			];
1975
+		}
1976
+
1977
+		return self::select_input('EVT_CAT', $options, $current_cat);
1978
+	}
1979
+
1980
+
1981
+	/**
1982
+	 *    generate a submit button with or without it's own microform
1983
+	 *    this is the only way to create buttons that are compatible across all themes
1984
+	 *
1985
+	 * @access    public
1986
+	 * @param string      $url              - the form action
1987
+	 * @param string      $ID               - some kind of unique ID, appended with "-sbmt" for the input and "-frm"
1988
+	 *                                      for the form
1989
+	 * @param string      $class            - css classes (separated by spaces if more than one)
1990
+	 * @param string      $text             - what appears on the button
1991
+	 * @param string      $nonce_action     - if using nonces
1992
+	 * @param bool|string $input_only       - whether to print form header and footer. TRUE returns the input without
1993
+	 *                                      the form
1994
+	 * @param string      $extra_attributes - any extra attributes that need to be attached to the form input
1995
+	 * @return    string
1996
+	 */
1997
+	public static function submit_button(
1998
+		$url = '',
1999
+		$ID = '',
2000
+		$class = '',
2001
+		$text = '',
2002
+		$nonce_action = '',
2003
+		$input_only = false,
2004
+		$extra_attributes = ''
2005
+	) {
2006
+		$btn = '';
2007
+		if (empty($url) || empty($ID)) {
2008
+			return $btn;
2009
+		}
2010
+		$text = ! empty($text) ? $text : esc_html__('Submit', 'event_espresso');
2011
+		$btn  .= '<input id="' . $ID . '-btn" class="' . $class . '" '
2012
+				 . 'type="submit" value="' . $text . '" ' . $extra_attributes . '/>';
2013
+		if (! $input_only) {
2014
+			$btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">';
2015
+			$btn_frm .= ! empty($nonce_action)
2016
+				? wp_nonce_field($nonce_action, $nonce_action . '_nonce', true, false)
2017
+				: '';
2018
+			$btn_frm .= $btn;
2019
+			$btn_frm .= '</form>';
2020
+			$btn     = $btn_frm;
2021
+			unset($btn_frm);
2022
+		}
2023
+		return $btn;
2024
+	}
2025 2025
 }
Please login to merge, or discard this patch.
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
             $type           = $input_value['input'];
111 111
             $value          = $input_value['value'];
112 112
 
113
-            $id    = $form_id ? $form_id . '-' . $input_key : $input_key;
114
-            $class = $required ? 'required ' . $css_class : $css_class;
113
+            $id    = $form_id ? $form_id.'-'.$input_key : $input_key;
114
+            $class = $required ? 'required '.$css_class : $css_class;
115 115
 
116 116
             // what type of input are we dealing with ?
117 117
             switch ($type) {
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
             }
164 164
         } // end foreach( $input_vars as $input_key => $input_value )
165 165
 
166
-        if (! empty($inputs)) {
167
-            $glue   = "
166
+        if ( ! empty($inputs)) {
167
+            $glue = "
168 168
                 </li>
169 169
                 <li>
170 170
                     ";
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             </ul>
178 178
             ";
179 179
         }
180
-        return $output . implode("\n", $hidden_inputs);
180
+        return $output.implode("\n", $hidden_inputs);
181 181
     }
182 182
 
183 183
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
             // generate label
259 259
             $label = ! empty($label) ? self::adminLabel($id, $label, $required) : '';
260 260
             // generate field name
261
-            $name = ! empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name;
261
+            $name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name;
262 262
 
263 263
             // we determine what we're building based on the type
264 264
             switch ($type) {
@@ -269,14 +269,14 @@  discard block
 block discarded – undo
269 269
                         foreach ($value as $key => $val) {
270 270
                             $c_input .= self::adminMulti(
271 271
                                 $default,
272
-                                isset($classes[ $key ]) ? $classes[ $key ] : '',
273
-                                $field_name . '_' . $value,
272
+                                isset($classes[$key]) ? $classes[$key] : '',
273
+                                $field_name.'_'.$value,
274 274
                                 $name,
275 275
                                 $required,
276 276
                                 $tab_index,
277 277
                                 $type,
278 278
                                 $val,
279
-                                isset($labels[ $key ]) ? $labels[ $key ] : ''
279
+                                isset($labels[$key]) ? $labels[$key] : ''
280 280
                             );
281 281
                         }
282 282
                         $field = $c_input;
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
                 case 'select':
303 303
                     $options = [];
304 304
                     foreach ($value as $key => $val) {
305
-                        $options[ $val ] = isset($labels[ $key ]) ? $labels[ $key ] : '';
305
+                        $options[$val] = isset($labels[$key]) ? $labels[$key] : '';
306 306
                     }
307 307
                     $field = self::adminSelect($default, $class, $id, $name, $required, $tab_index, $options);
308 308
                     break;
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
                     $field = self::adminText($class, $id, $name, $required, $tab_index, $value);
329 329
             }
330 330
 
331
-            $form_fields[ $field_name ] = ['label' => $label, 'field' => $field . $extra_desc];
331
+            $form_fields[$field_name] = ['label' => $label, 'field' => $field.$extra_desc];
332 332
         }
333 333
 
334 334
         return $form_fields;
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
     public static function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true)
537 537
     {
538 538
         // if $values was submitted in the wrong format, convert it over
539
-        if (! empty($values) && (! array_key_exists(0, $values) || ! is_array($values[0]))) {
539
+        if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) {
540 540
             $converted_values = [];
541 541
             foreach ($values as $id => $text) {
542 542
                 $converted_values[] = ['id' => $id, 'text' => $text];
@@ -545,18 +545,18 @@  discard block
 block discarded – undo
545 545
         }
546 546
 
547 547
         $field =
548
-            '<select id="' . EEH_Formatter::ee_tep_output_string($name)
549
-            . '" name="' . EEH_Formatter::ee_tep_output_string($name)
548
+            '<select id="'.EEH_Formatter::ee_tep_output_string($name)
549
+            . '" name="'.EEH_Formatter::ee_tep_output_string($name)
550 550
             . '"';
551 551
 
552 552
         if (EEH_Formatter::ee_tep_not_null($parameters)) {
553
-            $field .= ' ' . $parameters;
553
+            $field .= ' '.$parameters;
554 554
         }
555 555
         if ($autosize) {
556 556
             $size = 'med';
557 557
             for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) {
558
-                if ($values[ $ii ]['text']) {
559
-                    if (strlen($values[ $ii ]['text']) > 5) {
558
+                if ($values[$ii]['text']) {
559
+                    if (strlen($values[$ii]['text']) > 5) {
560 560
                         $size = 'wide';
561 561
                     }
562 562
                 }
@@ -565,22 +565,22 @@  discard block
 block discarded – undo
565 565
             $size = '';
566 566
         }
567 567
 
568
-        $field .= ' class="' . $class . ' ' . $size . '">';
568
+        $field .= ' class="'.$class.' '.$size.'">';
569 569
 
570
-        if (empty($default) && isset($GLOBALS[ $name ])) {
571
-            $default = stripslashes($GLOBALS[ $name ]);
570
+        if (empty($default) && isset($GLOBALS[$name])) {
571
+            $default = stripslashes($GLOBALS[$name]);
572 572
         }
573 573
 
574 574
 
575 575
         for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
576
-            $field .= '<option value="' . $values[ $i ]['id'] . '"';
577
-            if ($default == $values[ $i ]['id']) {
576
+            $field .= '<option value="'.$values[$i]['id'].'"';
577
+            if ($default == $values[$i]['id']) {
578 578
                 $field .= ' selected = "selected"';
579 579
             }
580
-            if (isset($values[ $i ]['class'])) {
581
-                $field .= ' class="' . $values[ $i ]['class'] . '"';
580
+            if (isset($values[$i]['class'])) {
581
+                $field .= ' class="'.$values[$i]['class'].'"';
582 582
             }
583
-            $field .= '>' . $values[ $i ]['text'] . '</option>';
583
+            $field .= '>'.$values[$i]['text'].'</option>';
584 584
         }
585 585
         $field .= '</select>';
586 586
 
@@ -606,11 +606,11 @@  discard block
 block discarded – undo
606 606
         $after_question_group_questions  =
607 607
             apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
608 608
 
609
-        if (! empty($question_groups)) {
609
+        if ( ! empty($question_groups)) {
610 610
             // loop thru question groups
611 611
             foreach ($question_groups as $QSG) {
612 612
                 // check that questions exist
613
-                if (! empty($QSG['QSG_questions'])) {
613
+                if ( ! empty($QSG['QSG_questions'])) {
614 614
                     // use fieldsets
615 615
                     $html .= "\n\t"
616 616
                              . '<'
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
                     $html .= $before_question_group_questions;
636 636
                     // loop thru questions
637 637
                     foreach ($QSG['QSG_questions'] as $question) {
638
-                        $QFI  = new EE_Question_Form_Input(
638
+                        $QFI = new EE_Question_Form_Input(
639 639
                             $question['qst_obj'],
640 640
                             $question['ans_obj'],
641 641
                             $question
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
                         $html .= self::generate_form_input($QFI);
644 644
                     }
645 645
                     $html .= $after_question_group_questions;
646
-                    $html .= "\n\t" . '</' . $group_wrapper . '>';
646
+                    $html .= "\n\t".'</'.$group_wrapper.'>';
647 647
                 }
648 648
             }
649 649
         }
@@ -683,25 +683,25 @@  discard block
 block discarded – undo
683 683
             'input_id'    => '',
684 684
             'input_class' => '',
685 685
         ];
686
-        $q_meta         = array_merge($default_q_meta, $q_meta);
686
+        $q_meta = array_merge($default_q_meta, $q_meta);
687 687
 
688
-        if (! empty($question_groups)) {
688
+        if ( ! empty($question_groups)) {
689 689
             // loop thru question groups
690 690
             foreach ($question_groups as $QSG) {
691 691
                 if ($QSG instanceof EE_Question_Group) {
692 692
                     // check that questions exist
693 693
 
694 694
                     $where = ['QST_deleted' => 0];
695
-                    if (! $from_admin) {
695
+                    if ( ! $from_admin) {
696 696
                         $where['QST_admin_only'] = 0;
697 697
                     }
698 698
                     $questions =
699 699
                         $QSG->questions([$where, 'order_by' => ['Question_Group_Question.QGQ_order' => 'ASC']]);
700
-                    if (! empty($questions)) {
700
+                    if ( ! empty($questions)) {
701 701
                         // use fieldsets
702 702
                         $html .= "\n\t"
703
-                                 . '<' . $group_wrapper . ' class="espresso-question-group-wrap" '
704
-                                 . 'id="' . $QSG->get('QSG_identifier') . '">';
703
+                                 . '<'.$group_wrapper.' class="espresso-question-group-wrap" '
704
+                                 . 'id="'.$QSG->get('QSG_identifier').'">';
705 705
                         // group_name
706 706
                         if ($QSG->show_group_name()) {
707 707
                             $html .= "\n\t\t"
@@ -726,21 +726,21 @@  discard block
 block discarded – undo
726 726
                             /** @var RequestInterface $request */
727 727
                             $request      = LoaderFactory::getLoader()->getShared(RequestInterface::class);
728 728
                             $request_qstn = $request->getRequestParam('qstn', [], 'string', true);
729
-                            if (! empty($request_qstn) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) {
729
+                            if ( ! empty($request_qstn) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) {
730 730
                                 // check for answer in $request_qstn in case we are reprocessing a form after an error
731
-                                if (isset($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])) {
732
-                                    $answer = is_array($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])
733
-                                        ? $request_qstn[ $q_meta['input_id'] ][ $qstn_id ]
734
-                                        : sanitize_text_field($request_qstn[ $q_meta['input_id'] ][ $qstn_id ]);
731
+                                if (isset($request_qstn[$q_meta['input_id']][$qstn_id])) {
732
+                                    $answer = is_array($request_qstn[$q_meta['input_id']][$qstn_id])
733
+                                        ? $request_qstn[$q_meta['input_id']][$qstn_id]
734
+                                        : sanitize_text_field($request_qstn[$q_meta['input_id']][$qstn_id]);
735 735
                                 }
736 736
                             } elseif (isset($q_meta['attendee']) && $q_meta['attendee']) {
737 737
                                 // attendee data from the session
738 738
                                 $answer =
739
-                                    isset($q_meta['attendee'][ $qstn_id ]) ? $q_meta['attendee'][ $qstn_id ] : null;
739
+                                    isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : null;
740 740
                             }
741 741
 
742 742
 
743
-                            $QFI  = new EE_Question_Form_Input(
743
+                            $QFI = new EE_Question_Form_Input(
744 744
                                 $QST,
745 745
                                 EE_Answer::new_instance(
746 746
                                     [
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
                             $html .= self::generate_form_input($QFI);
756 756
                         }
757 757
                         $html .= $after_question_group_questions;
758
-                        $html .= "\n\t" . '</' . $group_wrapper . '>';
758
+                        $html .= "\n\t".'</'.$group_wrapper.'>';
759 759
                     }
760 760
                 }
761 761
             }
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
             $QFI->get('QST_required_text') != ''
804 804
                 ? $QFI->get('QST_required_text')
805 805
                 : esc_html__('This field is required', 'event_espresso');
806
-        $required_text     = $QST_required
806
+        $required_text = $QST_required
807 807
             ? "\n\t\t\t"
808 808
               . '<div class="required-text hidden">'
809 809
               . self::prep_answer($required_text, $use_html_entities)
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
         $use_html_entities = true
950 950
     ) {
951 951
         // need these
952
-        if (! $question || ! $name) {
952
+        if ( ! $question || ! $name) {
953 953
             return null;
954 954
         }
955 955
         // prep the answer
@@ -961,13 +961,13 @@  discard block
 block discarded – undo
961 961
         // ya gots ta have style man!!!
962 962
         $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp';
963 963
         $class     = empty($class) ? $txt_class : $class;
964
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
964
+        $class     .= ! empty($system_ID) ? ' '.$system_ID : '';
965 965
         $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
966 966
 
967 967
         $label_html =
968 968
             $required_text
969 969
             . "\n\t\t\t"
970
-            . '<label for="' . $name . '" class="' . $label_class . '">'
970
+            . '<label for="'.$name.'" class="'.$label_class.'">'
971 971
             . self::prep_question($question)
972 972
             . $required['label']
973 973
             . '</label><br/>';
@@ -976,12 +976,12 @@  discard block
 block discarded – undo
976 976
 
977 977
         $input_html =
978 978
             "\n\t\t\t"
979
-            . '<input type="text" name="' . $name . '" id="' . $id . '" '
980
-            . 'class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr($answer) . '"  '
981
-            . 'title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
979
+            . '<input type="text" name="'.$name.'" id="'.$id.'" '
980
+            . 'class="'.$class.' '.$required['class'].'" value="'.esc_attr($answer).'"  '
981
+            . 'title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>';
982 982
 
983 983
         $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
984
-        return $label_html . $input_html;
984
+        return $label_html.$input_html;
985 985
     }
986 986
 
987 987
 
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
         $use_html_entities = true
1016 1016
     ) {
1017 1017
         // need these
1018
-        if (! $question || ! $name) {
1018
+        if ( ! $question || ! $name) {
1019 1019
             return null;
1020 1020
         }
1021 1021
         // prep the answer
@@ -1031,13 +1031,13 @@  discard block
 block discarded – undo
1031 1031
         // ya gots ta have style man!!!
1032 1032
         $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp';
1033 1033
         $class     = empty($class) ? $txt_class : $class;
1034
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1034
+        $class     .= ! empty($system_ID) ? ' '.$system_ID : '';
1035 1035
         $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1036 1036
 
1037 1037
         $label_html =
1038 1038
             $required_text
1039 1039
             . "\n\t\t\t"
1040
-            . '<label for="' . $name . '" class="' . $label_class . '">'
1040
+            . '<label for="'.$name.'" class="'.$label_class.'">'
1041 1041
             . self::prep_question($question)
1042 1042
             . $required['label']
1043 1043
             . '</label><br/>';
@@ -1046,14 +1046,14 @@  discard block
 block discarded – undo
1046 1046
 
1047 1047
         $input_html =
1048 1048
             "\n\t\t\t"
1049
-            . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" '
1050
-            . 'rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '"  '
1051
-            . 'title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>'
1049
+            . '<textarea name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" '
1050
+            . 'rows="'.$dimensions['rows'].'" cols="'.$dimensions['cols'].'"  '
1051
+            . 'title="'.$required['msg'].'" '.$disabled.' '.$extra.'>'
1052 1052
             . esc_textarea($answer)
1053 1053
             . '</textarea>';
1054 1054
 
1055 1055
         $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1056
-        return $label_html . $input_html;
1056
+        return $label_html.$input_html;
1057 1057
     }
1058 1058
 
1059 1059
 
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
     ) {
1091 1091
 
1092 1092
         // need these
1093
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1093
+        if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1094 1094
             return null;
1095 1095
         }
1096 1096
         // prep the answer
@@ -1108,13 +1108,13 @@  discard block
 block discarded – undo
1108 1108
         // ya gots ta have style man!!!
1109 1109
         $txt_class = is_admin() ? 'wide' : 'espresso-select-inp';
1110 1110
         $class     = empty($class) ? $txt_class : $class;
1111
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1111
+        $class     .= ! empty($system_ID) ? ' '.$system_ID : '';
1112 1112
         $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1113 1113
 
1114 1114
         $label_html =
1115 1115
             $required_text
1116 1116
             . "\n\t\t\t"
1117
-            . '<label for="' . $name . '" class="' . $label_class . '">'
1117
+            . '<label for="'.$name.'" class="'.$label_class.'">'
1118 1118
             . self::prep_question($question)
1119 1119
             . $required['label']
1120 1120
             . '</label><br/>';
@@ -1123,16 +1123,16 @@  discard block
 block discarded – undo
1123 1123
 
1124 1124
         $input_html =
1125 1125
             "\n\t\t\t"
1126
-            . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" '
1127
-            . 'title="' . esc_attr($required['msg']) . '"' . $disabled . ' ' . $extra . '>';
1126
+            . '<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" '
1127
+            . 'title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>';
1128 1128
         // recursively count array elements, to determine total number of options
1129 1129
         $only_option = count($options, 1) == 1;
1130
-        if (! $only_option) {
1130
+        if ( ! $only_option) {
1131 1131
             // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected
1132
-            $selected   = $answer === null ? ' selected' : '';
1132
+            $selected = $answer === null ? ' selected' : '';
1133 1133
             $input_html .= $add_please_select_option
1134 1134
                 ? "\n\t\t\t\t"
1135
-                  . '<option value=""' . $selected . '>'
1135
+                  . '<option value=""'.$selected.'>'
1136 1136
                   . esc_html__(' - please select - ', 'event_espresso')
1137 1137
                   . '</option>'
1138 1138
                 : '';
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
                 );
1156 1156
         }
1157 1157
 
1158
-        $input_html .= "\n\t\t\t" . '</select>';
1158
+        $input_html .= "\n\t\t\t".'</select>';
1159 1159
 
1160 1160
         $input_html =
1161 1161
             apply_filters(
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
             );
1171 1171
 
1172 1172
         $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1173
-        return $label_html . $input_html;
1173
+        return $label_html.$input_html;
1174 1174
     }
1175 1175
 
1176 1176
 
@@ -1188,11 +1188,11 @@  discard block
 block discarded – undo
1188 1188
      */
1189 1189
     private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true)
1190 1190
     {
1191
-        $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value($opt_group) . '">';
1191
+        $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">';
1192 1192
         foreach ($QSOs as $QSO) {
1193 1193
             $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities);
1194 1194
         }
1195
-        $html .= "\n\t\t\t\t" . '</optgroup>';
1195
+        $html .= "\n\t\t\t\t".'</optgroup>';
1196 1196
         return $html;
1197 1197
     }
1198 1198
 
@@ -1219,7 +1219,7 @@  discard block
 block discarded – undo
1219 1219
         $value    = ! empty($value) ? $value : $key;
1220 1220
         $selected = ($answer == $key || $only_option) ? 'selected' : '';
1221 1221
         return "\n\t\t\t\t"
1222
-               . '<option value="' . self::prep_option_value($key) . '" ' . $selected . '> '
1222
+               . '<option value="'.self::prep_option_value($key).'" '.$selected.'> '
1223 1223
                . $value
1224 1224
                . '&nbsp;&nbsp;&nbsp;</option>';
1225 1225
     }
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
         $use_desc_4_label = false
1264 1264
     ) {
1265 1265
         // need these
1266
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1266
+        if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1267 1267
             return null;
1268 1268
         }
1269 1269
         // prep the answer
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
         $label_html =
1281 1281
             $required_text
1282 1282
             . "\n\t\t\t"
1283
-            . '<label class="' . $label_class . '">'
1283
+            . '<label class="'.$label_class.'">'
1284 1284
             . self::prep_question($question)
1285 1285
             . $required['label']
1286 1286
             . '</label> ';
@@ -1289,49 +1289,49 @@  discard block
 block discarded – undo
1289 1289
 
1290 1290
         $input_html =
1291 1291
             "\n\t\t\t"
1292
-            . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">';
1292
+            . '<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">';
1293 1293
 
1294
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1295
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1294
+        $class .= ! empty($system_ID) ? ' '.$system_ID : '';
1295
+        $class .= ! empty($required['class']) ? ' '.$required['class'] : '';
1296 1296
 
1297 1297
         foreach ($options as $OPT) {
1298 1298
             if ($OPT instanceof EE_Question_Option) {
1299 1299
                 $value   = self::prep_option_value($OPT->value());
1300 1300
                 $label   = $use_desc_4_label ? $OPT->desc() : $OPT->value();
1301 1301
                 $size    = $use_desc_4_label
1302
-                    ? self::get_label_size_class($OPT->value() . ' ' . $OPT->desc())
1302
+                    ? self::get_label_size_class($OPT->value().' '.$OPT->desc())
1303 1303
                     : self::get_label_size_class($OPT->value());
1304
-                $desc    = $OPT->desc();// no self::prep_answer
1304
+                $desc    = $OPT->desc(); // no self::prep_answer
1305 1305
                 $answer  = is_numeric($value) && empty($answer) ? 0 : $answer;
1306 1306
                 $checked = (string) $value == (string) $answer ? ' checked' : '';
1307
-                $opt     = '-' . sanitize_key($value);
1307
+                $opt     = '-'.sanitize_key($value);
1308 1308
 
1309
-                $input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1310
-                $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">';
1311
-                $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : '';
1309
+                $input_html .= "\n\t\t\t\t".'<li'.$size.'>';
1310
+                $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">';
1311
+                $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : '';
1312 1312
                 $input_html .= "\n\t\t\t\t\t\t"
1313
-                               . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" '
1314
-                               . 'class="' . $class . '" value="' . $value . '" '
1315
-                               . 'title="' . esc_attr($required['msg']) . '" ' . $disabled
1316
-                               . $checked . ' ' . $extra . '/>';
1313
+                               . '<input type="radio" name="'.$name.'" id="'.$id.$opt.'" '
1314
+                               . 'class="'.$class.'" value="'.$value.'" '
1315
+                               . 'title="'.esc_attr($required['msg']).'" '.$disabled
1316
+                               . $checked.' '.$extra.'/>';
1317 1317
                 $input_html .= ! $label_b4
1318 1318
                     ? "\n\t\t\t\t\t\t"
1319 1319
                       . '<span class="espresso-radio-btn-desc">'
1320 1320
                       . $label
1321 1321
                       . '</span>'
1322 1322
                     : '';
1323
-                $input_html .= "\n\t\t\t\t\t" . '</label>';
1323
+                $input_html .= "\n\t\t\t\t\t".'</label>';
1324 1324
                 $input_html .= $use_desc_4_label
1325 1325
                     ? ''
1326
-                    : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>';
1327
-                $input_html .= "\n\t\t\t\t" . '</li>';
1326
+                    : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>';
1327
+                $input_html .= "\n\t\t\t\t".'</li>';
1328 1328
             }
1329 1329
         }
1330 1330
 
1331
-        $input_html .= "\n\t\t\t" . '</ul>';
1331
+        $input_html .= "\n\t\t\t".'</ul>';
1332 1332
 
1333 1333
         $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1334
-        return $label_html . $input_html;
1334
+        return $label_html.$input_html;
1335 1335
     }
1336 1336
 
1337 1337
 
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
         $use_html_entities = true
1367 1367
     ) {
1368 1368
         // need these
1369
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1369
+        if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1370 1370
             return null;
1371 1371
         }
1372 1372
         $answer = maybe_unserialize($answer);
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 
1377 1377
         foreach ($answer as $key => $value) {
1378 1378
             $key            = self::prep_option_value($key);
1379
-            $answer[ $key ] = self::prep_answer($value, $use_html_entities);
1379
+            $answer[$key] = self::prep_answer($value, $use_html_entities);
1380 1380
         }
1381 1381
 
1382 1382
         // prep the required array
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
         $label_html =
1392 1392
             $required_text
1393 1393
             . "\n\t\t\t"
1394
-            . '<label class="' . $label_class . '">'
1394
+            . '<label class="'.$label_class.'">'
1395 1395
             . self::prep_question($question)
1396 1396
             . $required['label']
1397 1397
             . '</label> ';
@@ -1400,42 +1400,42 @@  discard block
 block discarded – undo
1400 1400
 
1401 1401
         $input_html =
1402 1402
             "\n\t\t\t"
1403
-            . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">';
1403
+            . '<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">';
1404 1404
 
1405
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1406
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1405
+        $class .= ! empty($system_ID) ? ' '.$system_ID : '';
1406
+        $class .= ! empty($required['class']) ? ' '.$required['class'] : '';
1407 1407
 
1408 1408
         foreach ($options as $OPT) {
1409
-            $value = $OPT->value();// self::prep_option_value( $OPT->value() );
1410
-            $size  = self::get_label_size_class($OPT->value() . ' ' . $OPT->desc());
1409
+            $value = $OPT->value(); // self::prep_option_value( $OPT->value() );
1410
+            $size  = self::get_label_size_class($OPT->value().' '.$OPT->desc());
1411 1411
             $text  = self::prep_answer($OPT->value());
1412 1412
             $desc  = $OPT->desc();
1413
-            $opt   = '-' . sanitize_key($value);
1413
+            $opt   = '-'.sanitize_key($value);
1414 1414
 
1415 1415
             $checked = is_array($answer) && in_array($text, $answer) ? ' checked' : '';
1416 1416
 
1417
-            $input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1418
-            $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">';
1419
-            $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
1417
+            $input_html .= "\n\t\t\t\t".'<li'.$size.'>';
1418
+            $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">';
1419
+            $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : '';
1420 1420
             $input_html .= "\n\t\t\t\t\t\t"
1421
-                           . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" '
1422
-                           . 'id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" '
1423
-                           . 'title="' . esc_attr($required['msg']) . '" ' . $disabled . $checked . ' ' . $extra . '/>';
1424
-            $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
1425
-            $input_html .= "\n\t\t\t\t\t" . '</label>';
1426
-            if (! empty($desc) && $desc != $text) {
1421
+                           . '<input type="checkbox" name="'.$name.'['.$OPT->ID().']" '
1422
+                           . 'id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" '
1423
+                           . 'title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>';
1424
+            $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : '';
1425
+            $input_html .= "\n\t\t\t\t\t".'</label>';
1426
+            if ( ! empty($desc) && $desc != $text) {
1427 1427
                 $input_html .= "\n\t\t\t\t\t"
1428 1428
                                . ' &nbsp; <br/><div class="espresso-checkbox-option-desc small-text grey-text">'
1429 1429
                                . $desc
1430 1430
                                . '</div>';
1431 1431
             }
1432
-            $input_html .= "\n\t\t\t\t" . '</li>';
1432
+            $input_html .= "\n\t\t\t\t".'</li>';
1433 1433
         }
1434 1434
 
1435
-        $input_html .= "\n\t\t\t" . '</ul>';
1435
+        $input_html .= "\n\t\t\t".'</ul>';
1436 1436
 
1437 1437
         $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1438
-        return $label_html . $input_html;
1438
+        return $label_html.$input_html;
1439 1439
     }
1440 1440
 
1441 1441
 
@@ -1467,7 +1467,7 @@  discard block
 block discarded – undo
1467 1467
         $use_html_entities = true
1468 1468
     ) {
1469 1469
         // need these
1470
-        if (! $question || ! $name) {
1470
+        if ( ! $question || ! $name) {
1471 1471
             return null;
1472 1472
         }
1473 1473
         // prep the answer
@@ -1479,13 +1479,13 @@  discard block
 block discarded – undo
1479 1479
         // ya gots ta have style man!!!
1480 1480
         $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp';
1481 1481
         $class     = empty($class) ? $txt_class : $class;
1482
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1482
+        $class     .= ! empty($system_ID) ? ' '.$system_ID : '';
1483 1483
         $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1484 1484
 
1485 1485
         $label_html =
1486 1486
             $required_text
1487 1487
             . "\n\t\t\t"
1488
-            . '<label for="' . $name . '" class="' . $label_class . '">'
1488
+            . '<label for="'.$name.'" class="'.$label_class.'">'
1489 1489
             . self::prep_question($question)
1490 1490
             . $required['label']
1491 1491
             . '</label><br/>';
@@ -1494,14 +1494,14 @@  discard block
 block discarded – undo
1494 1494
 
1495 1495
         $input_html =
1496 1496
             "\n\t\t\t"
1497
-            . '<input type="text" name="' . $name . '" id="' . $id . '" '
1498
-            . 'class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '"  '
1499
-            . 'title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
1497
+            . '<input type="text" name="'.$name.'" id="'.$id.'" '
1498
+            . 'class="'.$class.' '.$required['class'].' datepicker" value="'.$answer.'"  '
1499
+            . 'title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>';
1500 1500
 
1501 1501
         // enqueue scripts
1502 1502
         wp_register_style(
1503 1503
             'espresso-ui-theme',
1504
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1504
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1505 1505
             [],
1506 1506
             EVENT_ESPRESSO_VERSION
1507 1507
         );
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
         wp_enqueue_script('jquery-ui-datepicker');
1510 1510
 
1511 1511
         $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1512
-        return $label_html . $input_html;
1512
+        return $label_html.$input_html;
1513 1513
     }
1514 1514
 
1515 1515
 
@@ -1536,7 +1536,7 @@  discard block
 block discarded – undo
1536 1536
     public static function hidden_input($name, $value, $id = '')
1537 1537
     {
1538 1538
         $id = ! empty($id) ? $id : $name;
1539
-        return '<input id="' . $id . '" type="hidden" name="' . $name . '" value="' . $value . '"/>';
1539
+        return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>';
1540 1540
     }
1541 1541
 
1542 1542
 
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
         $prepped_answer_options = [];
1582 1582
         if (is_array($QSOs) && ! empty($QSOs)) {
1583 1583
             foreach ($QSOs as $key => $QSO) {
1584
-                if (! $QSO instanceof EE_Question_Option) {
1584
+                if ( ! $QSO instanceof EE_Question_Option) {
1585 1585
                     $QSO = EE_Question_Option::new_instance(
1586 1586
                         [
1587 1587
                             'QSO_value' => is_array($QSO) && isset($QSO['id'])
@@ -1594,7 +1594,7 @@  discard block
 block discarded – undo
1594 1594
                     );
1595 1595
                 }
1596 1596
                 if ($QSO->opt_group()) {
1597
-                    $prepped_answer_options[ $QSO->opt_group() ][] = $QSO;
1597
+                    $prepped_answer_options[$QSO->opt_group()][] = $QSO;
1598 1598
                 } else {
1599 1599
                     $prepped_answer_options[] = $QSO;
1600 1600
                 }
@@ -1806,7 +1806,7 @@  discard block
 block discarded – undo
1806 1806
         $options = [];
1807 1807
         for ($x = 1; $x <= 12; $x++) {
1808 1808
             $mm             = str_pad($x, 2, '0', STR_PAD_LEFT);
1809
-            $options[ $mm ] = $mm;
1809
+            $options[$mm] = $mm;
1810 1810
         }
1811 1811
         return EEH_Form_Fields::prep_answer_options($options);
1812 1812
     }
@@ -1824,7 +1824,7 @@  discard block
 block discarded – undo
1824 1824
         $next_decade  = $current_year + 10;
1825 1825
         for ($x = $current_year; $x <= $next_decade; $x++) {
1826 1826
             $yy             = str_pad($x, 2, '0', STR_PAD_LEFT);
1827
-            $options[ $yy ] = $yy;
1827
+            $options[$yy] = $yy;
1828 1828
         }
1829 1829
         return EEH_Form_Fields::prep_answer_options($options);
1830 1830
     }
@@ -1843,7 +1843,7 @@  discard block
 block discarded – undo
1843 1843
     public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0)
1844 1844
     {
1845 1845
         $_where = [];
1846
-        if (! empty($status)) {
1846
+        if ( ! empty($status)) {
1847 1847
             $_where['STS_ID'] = $status;
1848 1848
         }
1849 1849
 
@@ -1862,7 +1862,7 @@  discard block
 block discarded – undo
1862 1862
         ];
1863 1863
 
1864 1864
         foreach ($regdtts as $regdtt) {
1865
-            $date      = $regdtt->reg_month . ' ' . $regdtt->reg_year;
1865
+            $date      = $regdtt->reg_month.' '.$regdtt->reg_year;
1866 1866
             $options[] = [
1867 1867
                 'text' => $date,
1868 1868
                 'id'   => $date,
@@ -1911,7 +1911,7 @@  discard block
 block discarded – undo
1911 1911
         // categories?
1912 1912
 
1913 1913
 
1914
-        if (! empty($evt_category)) {
1914
+        if ( ! empty($evt_category)) {
1915 1915
             $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1916 1916
             $where['Event.Term_Taxonomy.term_id']  = $evt_category;
1917 1917
         }
@@ -1934,8 +1934,8 @@  discard block
 block discarded – undo
1934 1934
         global $wp_locale;
1935 1935
 
1936 1936
         foreach ($DTTS as $DTT) {
1937
-            $localized_date = $wp_locale->get_month($DTT->dtt_month_num) . ' ' . $DTT->dtt_year;
1938
-            $id             = $DTT->dtt_month . ' ' . $DTT->dtt_year;
1937
+            $localized_date = $wp_locale->get_month($DTT->dtt_month_num).' '.$DTT->dtt_year;
1938
+            $id             = $DTT->dtt_month.' '.$DTT->dtt_year;
1939 1939
             $options[]      = [
1940 1940
                 'text' => $localized_date,
1941 1941
                 'id'   => $id,
@@ -2008,16 +2008,16 @@  discard block
 block discarded – undo
2008 2008
             return $btn;
2009 2009
         }
2010 2010
         $text = ! empty($text) ? $text : esc_html__('Submit', 'event_espresso');
2011
-        $btn  .= '<input id="' . $ID . '-btn" class="' . $class . '" '
2012
-                 . 'type="submit" value="' . $text . '" ' . $extra_attributes . '/>';
2013
-        if (! $input_only) {
2014
-            $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">';
2011
+        $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" '
2012
+                 . 'type="submit" value="'.$text.'" '.$extra_attributes.'/>';
2013
+        if ( ! $input_only) {
2014
+            $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">';
2015 2015
             $btn_frm .= ! empty($nonce_action)
2016
-                ? wp_nonce_field($nonce_action, $nonce_action . '_nonce', true, false)
2016
+                ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', true, false)
2017 2017
                 : '';
2018 2018
             $btn_frm .= $btn;
2019 2019
             $btn_frm .= '</form>';
2020
-            $btn     = $btn_frm;
2020
+            $btn = $btn_frm;
2021 2021
             unset($btn_frm);
2022 2022
         }
2023 2023
         return $btn;
Please login to merge, or discard this patch.
core/helpers/EEH_DTT_Helper.helper.php 2 patches
Indentation   +983 added lines, -983 removed lines patch added patch discarded remove patch
@@ -17,1045 +17,1045 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * return the timezone set for the WP install
22
-     *
23
-     * @return string valid timezone string for PHP DateTimeZone() class
24
-     * @throws InvalidArgumentException
25
-     * @throws InvalidDataTypeException
26
-     * @throws InvalidInterfaceException
27
-     */
28
-    public static function get_timezone()
29
-    {
30
-        return EEH_DTT_Helper::get_valid_timezone_string();
31
-    }
20
+	/**
21
+	 * return the timezone set for the WP install
22
+	 *
23
+	 * @return string valid timezone string for PHP DateTimeZone() class
24
+	 * @throws InvalidArgumentException
25
+	 * @throws InvalidDataTypeException
26
+	 * @throws InvalidInterfaceException
27
+	 */
28
+	public static function get_timezone()
29
+	{
30
+		return EEH_DTT_Helper::get_valid_timezone_string();
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * get_valid_timezone_string
36
-     *    ensures that a valid timezone string is returned
37
-     *
38
-     * @param string $timezone_string
39
-     * @return string
40
-     * @throws InvalidArgumentException
41
-     * @throws InvalidDataTypeException
42
-     * @throws InvalidInterfaceException
43
-     */
44
-    public static function get_valid_timezone_string($timezone_string = '')
45
-    {
46
-        return self::getHelperAdapter()->getValidTimezoneString($timezone_string);
47
-    }
34
+	/**
35
+	 * get_valid_timezone_string
36
+	 *    ensures that a valid timezone string is returned
37
+	 *
38
+	 * @param string $timezone_string
39
+	 * @return string
40
+	 * @throws InvalidArgumentException
41
+	 * @throws InvalidDataTypeException
42
+	 * @throws InvalidInterfaceException
43
+	 */
44
+	public static function get_valid_timezone_string($timezone_string = '')
45
+	{
46
+		return self::getHelperAdapter()->getValidTimezoneString($timezone_string);
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone.
52
-     *
53
-     * @static
54
-     * @param  string $timezone_string Timezone string to check
55
-     * @param bool    $throw_error
56
-     * @return bool
57
-     * @throws InvalidArgumentException
58
-     * @throws InvalidDataTypeException
59
-     * @throws InvalidInterfaceException
60
-     */
61
-    public static function validate_timezone($timezone_string, $throw_error = true)
62
-    {
63
-        return self::getHelperAdapter()->validateTimezone($timezone_string, $throw_error);
64
-    }
50
+	/**
51
+	 * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone.
52
+	 *
53
+	 * @static
54
+	 * @param  string $timezone_string Timezone string to check
55
+	 * @param bool    $throw_error
56
+	 * @return bool
57
+	 * @throws InvalidArgumentException
58
+	 * @throws InvalidDataTypeException
59
+	 * @throws InvalidInterfaceException
60
+	 */
61
+	public static function validate_timezone($timezone_string, $throw_error = true)
62
+	{
63
+		return self::getHelperAdapter()->validateTimezone($timezone_string, $throw_error);
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * This returns a string that can represent the provided gmt offset in format that can be passed into
69
-     * DateTimeZone.  This is NOT a string that can be passed as a value on the WordPress timezone_string option.
70
-     *
71
-     * @param float|string $gmt_offset
72
-     * @return string
73
-     * @throws InvalidArgumentException
74
-     * @throws InvalidDataTypeException
75
-     * @throws InvalidInterfaceException
76
-     */
77
-    public static function get_timezone_string_from_gmt_offset($gmt_offset = '')
78
-    {
79
-        return self::getHelperAdapter()->getTimezoneStringFromGmtOffset($gmt_offset);
80
-    }
67
+	/**
68
+	 * This returns a string that can represent the provided gmt offset in format that can be passed into
69
+	 * DateTimeZone.  This is NOT a string that can be passed as a value on the WordPress timezone_string option.
70
+	 *
71
+	 * @param float|string $gmt_offset
72
+	 * @return string
73
+	 * @throws InvalidArgumentException
74
+	 * @throws InvalidDataTypeException
75
+	 * @throws InvalidInterfaceException
76
+	 */
77
+	public static function get_timezone_string_from_gmt_offset($gmt_offset = '')
78
+	{
79
+		return self::getHelperAdapter()->getTimezoneStringFromGmtOffset($gmt_offset);
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * Gets the site's GMT offset based on either the timezone string
85
-     * (in which case teh gmt offset will vary depending on the location's
86
-     * observance of daylight savings time) or the gmt_offset wp option
87
-     *
88
-     * @return int seconds offset
89
-     * @throws InvalidArgumentException
90
-     * @throws InvalidDataTypeException
91
-     * @throws InvalidInterfaceException
92
-     */
93
-    public static function get_site_timezone_gmt_offset()
94
-    {
95
-        return self::getHelperAdapter()->getSiteTimezoneGmtOffset();
96
-    }
83
+	/**
84
+	 * Gets the site's GMT offset based on either the timezone string
85
+	 * (in which case teh gmt offset will vary depending on the location's
86
+	 * observance of daylight savings time) or the gmt_offset wp option
87
+	 *
88
+	 * @return int seconds offset
89
+	 * @throws InvalidArgumentException
90
+	 * @throws InvalidDataTypeException
91
+	 * @throws InvalidInterfaceException
92
+	 */
93
+	public static function get_site_timezone_gmt_offset()
94
+	{
95
+		return self::getHelperAdapter()->getSiteTimezoneGmtOffset();
96
+	}
97 97
 
98 98
 
99
-    /**
100
-     * Depending on PHP version,
101
-     * there might not be valid current timezone strings to match these gmt_offsets in its timezone tables.
102
-     * To get around that, for these fringe timezones we bump them to a known valid offset.
103
-     * This method should ONLY be called after first verifying an timezone_string cannot be retrieved for the offset.
104
-     *
105
-     * @deprecated 4.9.54.rc    Developers this was always meant to only be an internally used method.  This will be
106
-     *                          removed in a future version of EE.
107
-     * @param int $gmt_offset
108
-     * @return int
109
-     * @throws InvalidArgumentException
110
-     * @throws InvalidDataTypeException
111
-     * @throws InvalidInterfaceException
112
-     */
113
-    public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
114
-    {
115
-        return self::getHelperAdapter()->adjustInvalidGmtOffsets($gmt_offset);
116
-    }
99
+	/**
100
+	 * Depending on PHP version,
101
+	 * there might not be valid current timezone strings to match these gmt_offsets in its timezone tables.
102
+	 * To get around that, for these fringe timezones we bump them to a known valid offset.
103
+	 * This method should ONLY be called after first verifying an timezone_string cannot be retrieved for the offset.
104
+	 *
105
+	 * @deprecated 4.9.54.rc    Developers this was always meant to only be an internally used method.  This will be
106
+	 *                          removed in a future version of EE.
107
+	 * @param int $gmt_offset
108
+	 * @return int
109
+	 * @throws InvalidArgumentException
110
+	 * @throws InvalidDataTypeException
111
+	 * @throws InvalidInterfaceException
112
+	 */
113
+	public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
114
+	{
115
+		return self::getHelperAdapter()->adjustInvalidGmtOffsets($gmt_offset);
116
+	}
117 117
 
118 118
 
119
-    /**
120
-     * get_timezone_string_from_abbreviations_list
121
-     *
122
-     * @deprecated 4.9.54.rc  Developers, this was never intended to be public.  This is a soft deprecation for now.
123
-     *                        If you are using this, you'll want to work out an alternate way of getting the value.
124
-     * @param int  $gmt_offset
125
-     * @param bool $coerce If true, we attempt to coerce with our adjustment table @see self::adjust_invalid_gmt_offset.
126
-     * @return string
127
-     * @throws EE_Error
128
-     * @throws InvalidArgumentException
129
-     * @throws InvalidDataTypeException
130
-     * @throws InvalidInterfaceException
131
-     */
132
-    public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0, $coerce = true)
133
-    {
134
-        $gmt_offset =  (int) $gmt_offset;
135
-        /** @var array[] $abbreviations */
136
-        $abbreviations = DateTimeZone::listAbbreviations();
137
-        foreach ($abbreviations as $abbreviation) {
138
-            foreach ($abbreviation as $timezone) {
139
-                if ((int) $timezone['offset'] === $gmt_offset && (bool) $timezone['dst'] === false) {
140
-                    try {
141
-                        $offset = self::get_timezone_offset(new DateTimeZone($timezone['timezone_id']));
142
-                        if ($offset !== $gmt_offset) {
143
-                            continue;
144
-                        }
145
-                        return $timezone['timezone_id'];
146
-                    } catch (Exception $e) {
147
-                        continue;
148
-                    }
149
-                }
150
-            }
151
-        }
152
-        // if $coerce is true, let's see if we can get a timezone string after the offset is adjusted
153
-        if ($coerce === true) {
154
-            $timezone_string = self::get_timezone_string_from_abbreviations_list(
155
-                self::adjust_invalid_gmt_offsets($gmt_offset),
156
-                false
157
-            );
158
-            if ($timezone_string) {
159
-                return $timezone_string;
160
-            }
161
-        }
162
-        throw new EE_Error(
163
-            sprintf(
164
-                esc_html__(
165
-                    'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
166
-                    'event_espresso'
167
-                ),
168
-                $gmt_offset / HOUR_IN_SECONDS,
169
-                '<a href="http://www.php.net/manual/en/timezones.php">',
170
-                '</a>'
171
-            )
172
-        );
173
-    }
119
+	/**
120
+	 * get_timezone_string_from_abbreviations_list
121
+	 *
122
+	 * @deprecated 4.9.54.rc  Developers, this was never intended to be public.  This is a soft deprecation for now.
123
+	 *                        If you are using this, you'll want to work out an alternate way of getting the value.
124
+	 * @param int  $gmt_offset
125
+	 * @param bool $coerce If true, we attempt to coerce with our adjustment table @see self::adjust_invalid_gmt_offset.
126
+	 * @return string
127
+	 * @throws EE_Error
128
+	 * @throws InvalidArgumentException
129
+	 * @throws InvalidDataTypeException
130
+	 * @throws InvalidInterfaceException
131
+	 */
132
+	public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0, $coerce = true)
133
+	{
134
+		$gmt_offset =  (int) $gmt_offset;
135
+		/** @var array[] $abbreviations */
136
+		$abbreviations = DateTimeZone::listAbbreviations();
137
+		foreach ($abbreviations as $abbreviation) {
138
+			foreach ($abbreviation as $timezone) {
139
+				if ((int) $timezone['offset'] === $gmt_offset && (bool) $timezone['dst'] === false) {
140
+					try {
141
+						$offset = self::get_timezone_offset(new DateTimeZone($timezone['timezone_id']));
142
+						if ($offset !== $gmt_offset) {
143
+							continue;
144
+						}
145
+						return $timezone['timezone_id'];
146
+					} catch (Exception $e) {
147
+						continue;
148
+					}
149
+				}
150
+			}
151
+		}
152
+		// if $coerce is true, let's see if we can get a timezone string after the offset is adjusted
153
+		if ($coerce === true) {
154
+			$timezone_string = self::get_timezone_string_from_abbreviations_list(
155
+				self::adjust_invalid_gmt_offsets($gmt_offset),
156
+				false
157
+			);
158
+			if ($timezone_string) {
159
+				return $timezone_string;
160
+			}
161
+		}
162
+		throw new EE_Error(
163
+			sprintf(
164
+				esc_html__(
165
+					'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
166
+					'event_espresso'
167
+				),
168
+				$gmt_offset / HOUR_IN_SECONDS,
169
+				'<a href="http://www.php.net/manual/en/timezones.php">',
170
+				'</a>'
171
+			)
172
+		);
173
+	}
174 174
 
175 175
 
176
-    /**
177
-     * Get Timezone Transitions
178
-     *
179
-     * @param DateTimeZone $date_time_zone
180
-     * @param int|null     $time
181
-     * @param bool         $first_only
182
-     * @return array
183
-     * @throws InvalidArgumentException
184
-     * @throws InvalidDataTypeException
185
-     * @throws InvalidInterfaceException
186
-     */
187
-    public static function get_timezone_transitions(DateTimeZone $date_time_zone, $time = null, $first_only = true)
188
-    {
189
-        return self::getHelperAdapter()->getTimezoneTransitions($date_time_zone, $time, $first_only);
190
-    }
176
+	/**
177
+	 * Get Timezone Transitions
178
+	 *
179
+	 * @param DateTimeZone $date_time_zone
180
+	 * @param int|null     $time
181
+	 * @param bool         $first_only
182
+	 * @return array
183
+	 * @throws InvalidArgumentException
184
+	 * @throws InvalidDataTypeException
185
+	 * @throws InvalidInterfaceException
186
+	 */
187
+	public static function get_timezone_transitions(DateTimeZone $date_time_zone, $time = null, $first_only = true)
188
+	{
189
+		return self::getHelperAdapter()->getTimezoneTransitions($date_time_zone, $time, $first_only);
190
+	}
191 191
 
192 192
 
193
-    /**
194
-     * Get Timezone Offset for given timezone object.
195
-     *
196
-     * @param DateTimeZone $date_time_zone
197
-     * @param null         $time
198
-     * @return mixed
199
-     * @throws InvalidArgumentException
200
-     * @throws InvalidDataTypeException
201
-     * @throws InvalidInterfaceException
202
-     */
203
-    public static function get_timezone_offset(DateTimeZone $date_time_zone, $time = null)
204
-    {
205
-        return self::getHelperAdapter()->getTimezoneOffset($date_time_zone, $time);
206
-    }
193
+	/**
194
+	 * Get Timezone Offset for given timezone object.
195
+	 *
196
+	 * @param DateTimeZone $date_time_zone
197
+	 * @param null         $time
198
+	 * @return mixed
199
+	 * @throws InvalidArgumentException
200
+	 * @throws InvalidDataTypeException
201
+	 * @throws InvalidInterfaceException
202
+	 */
203
+	public static function get_timezone_offset(DateTimeZone $date_time_zone, $time = null)
204
+	{
205
+		return self::getHelperAdapter()->getTimezoneOffset($date_time_zone, $time);
206
+	}
207 207
 
208 208
 
209
-    /**
210
-     * Prints a select input for the given timezone string.
211
-     * @param string $timezone_string
212
-     * @deprecatd 4.9.54.rc   Soft deprecation.  Consider using \EEH_DTT_Helper::wp_timezone_choice instead.
213
-     * @throws InvalidArgumentException
214
-     * @throws InvalidDataTypeException
215
-     * @throws InvalidInterfaceException
216
-     */
217
-    public static function timezone_select_input($timezone_string = '')
218
-    {
219
-        self::getHelperAdapter()->timezoneSelectInput($timezone_string);
220
-    }
209
+	/**
210
+	 * Prints a select input for the given timezone string.
211
+	 * @param string $timezone_string
212
+	 * @deprecatd 4.9.54.rc   Soft deprecation.  Consider using \EEH_DTT_Helper::wp_timezone_choice instead.
213
+	 * @throws InvalidArgumentException
214
+	 * @throws InvalidDataTypeException
215
+	 * @throws InvalidInterfaceException
216
+	 */
217
+	public static function timezone_select_input($timezone_string = '')
218
+	{
219
+		self::getHelperAdapter()->timezoneSelectInput($timezone_string);
220
+	}
221 221
 
222 222
 
223
-    /**
224
-     * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string.
225
-     * If no unix timestamp is given then time() is used.  If no timezone is given then the set timezone string for
226
-     * the site is used.
227
-     * This is used typically when using a Unix timestamp any core WP functions that expect their specially
228
-     * computed timestamp (i.e. date_i18n() )
229
-     *
230
-     * @param int    $unix_timestamp                  if 0, then time() will be used.
231
-     * @param string $timezone_string                 timezone_string. If empty, then the current set timezone for the
232
-     *                                                site will be used.
233
-     * @return int $unix_timestamp with the offset applied for the given timezone.
234
-     * @throws InvalidArgumentException
235
-     * @throws InvalidDataTypeException
236
-     * @throws InvalidInterfaceException
237
-     */
238
-    public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
239
-    {
240
-        return self::getHelperAdapter()->getTimestampWithOffset($unix_timestamp, $timezone_string);
241
-    }
223
+	/**
224
+	 * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string.
225
+	 * If no unix timestamp is given then time() is used.  If no timezone is given then the set timezone string for
226
+	 * the site is used.
227
+	 * This is used typically when using a Unix timestamp any core WP functions that expect their specially
228
+	 * computed timestamp (i.e. date_i18n() )
229
+	 *
230
+	 * @param int    $unix_timestamp                  if 0, then time() will be used.
231
+	 * @param string $timezone_string                 timezone_string. If empty, then the current set timezone for the
232
+	 *                                                site will be used.
233
+	 * @return int $unix_timestamp with the offset applied for the given timezone.
234
+	 * @throws InvalidArgumentException
235
+	 * @throws InvalidDataTypeException
236
+	 * @throws InvalidInterfaceException
237
+	 */
238
+	public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
239
+	{
240
+		return self::getHelperAdapter()->getTimestampWithOffset($unix_timestamp, $timezone_string);
241
+	}
242 242
 
243 243
 
244
-    /**
245
-     *    _set_date_time_field
246
-     *    modifies EE_Base_Class EE_Datetime_Field objects
247
-     *
248
-     * @param  EE_Base_Class $obj                 EE_Base_Class object
249
-     * @param    DateTime    $DateTime            PHP DateTime object
250
-     * @param  string        $datetime_field_name the datetime fieldname to be manipulated
251
-     * @return EE_Base_Class
252
-     * @throws EE_Error
253
-     */
254
-    protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name)
255
-    {
256
-        // grab current datetime format
257
-        $current_format = $obj->get_format();
258
-        // set new full timestamp format
259
-        $obj->set_date_format(EE_Datetime_Field::mysql_date_format);
260
-        $obj->set_time_format(EE_Datetime_Field::mysql_time_format);
261
-        // set the new date value using a full timestamp format so that no data is lost
262
-        $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
263
-        // reset datetime formats
264
-        $obj->set_date_format($current_format[0]);
265
-        $obj->set_time_format($current_format[1]);
266
-        return $obj;
267
-    }
244
+	/**
245
+	 *    _set_date_time_field
246
+	 *    modifies EE_Base_Class EE_Datetime_Field objects
247
+	 *
248
+	 * @param  EE_Base_Class $obj                 EE_Base_Class object
249
+	 * @param    DateTime    $DateTime            PHP DateTime object
250
+	 * @param  string        $datetime_field_name the datetime fieldname to be manipulated
251
+	 * @return EE_Base_Class
252
+	 * @throws EE_Error
253
+	 */
254
+	protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name)
255
+	{
256
+		// grab current datetime format
257
+		$current_format = $obj->get_format();
258
+		// set new full timestamp format
259
+		$obj->set_date_format(EE_Datetime_Field::mysql_date_format);
260
+		$obj->set_time_format(EE_Datetime_Field::mysql_time_format);
261
+		// set the new date value using a full timestamp format so that no data is lost
262
+		$obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
263
+		// reset datetime formats
264
+		$obj->set_date_format($current_format[0]);
265
+		$obj->set_time_format($current_format[1]);
266
+		return $obj;
267
+	}
268 268
 
269 269
 
270
-    /**
271
-     *    date_time_add
272
-     *    helper for doing simple datetime calculations on a given datetime from EE_Base_Class
273
-     *    and modifying it IN the EE_Base_Class so you don't have to do anything else.
274
-     *
275
-     * @param  EE_Base_Class $obj                 EE_Base_Class object
276
-     * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
277
-     * @param  string        $period              what you are adding. The options are (years, months, days, hours,
278
-     *                                            minutes, seconds) defaults to years
279
-     * @param  integer       $value               what you want to increment the time by
280
-     * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it
281
-     *                                            (chaining)
282
-     * @throws EE_Error
283
-     * @throws Exception
284
-     */
285
-    public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
286
-    {
287
-        // get the raw UTC date.
288
-        $DateTime = $obj->get_DateTime_object($datetime_field_name);
289
-        $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
290
-        return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
291
-    }
270
+	/**
271
+	 *    date_time_add
272
+	 *    helper for doing simple datetime calculations on a given datetime from EE_Base_Class
273
+	 *    and modifying it IN the EE_Base_Class so you don't have to do anything else.
274
+	 *
275
+	 * @param  EE_Base_Class $obj                 EE_Base_Class object
276
+	 * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
277
+	 * @param  string        $period              what you are adding. The options are (years, months, days, hours,
278
+	 *                                            minutes, seconds) defaults to years
279
+	 * @param  integer       $value               what you want to increment the time by
280
+	 * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it
281
+	 *                                            (chaining)
282
+	 * @throws EE_Error
283
+	 * @throws Exception
284
+	 */
285
+	public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
286
+	{
287
+		// get the raw UTC date.
288
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
289
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
290
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
291
+	}
292 292
 
293 293
 
294
-    /**
295
-     *    date_time_subtract
296
-     *    same as date_time_add except subtracting value instead of adding.
297
-     *
298
-     * @param EE_Base_Class $obj
299
-     * @param  string       $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
300
-     * @param string        $period
301
-     * @param int           $value
302
-     * @return EE_Base_Class
303
-     * @throws EE_Error
304
-     * @throws Exception
305
-     */
306
-    public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
307
-    {
308
-        // get the raw UTC date
309
-        $DateTime = $obj->get_DateTime_object($datetime_field_name);
310
-        $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
311
-        return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
312
-    }
294
+	/**
295
+	 *    date_time_subtract
296
+	 *    same as date_time_add except subtracting value instead of adding.
297
+	 *
298
+	 * @param EE_Base_Class $obj
299
+	 * @param  string       $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
300
+	 * @param string        $period
301
+	 * @param int           $value
302
+	 * @return EE_Base_Class
303
+	 * @throws EE_Error
304
+	 * @throws Exception
305
+	 */
306
+	public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
307
+	{
308
+		// get the raw UTC date
309
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
310
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
311
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
312
+	}
313 313
 
314 314
 
315
-    /**
316
-     * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters
317
-     *
318
-     * @param  DateTime   $DateTime DateTime object
319
-     * @param  string     $period   a value to indicate what interval is being used in the calculation. The options are
320
-     *                              'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
321
-     * @param  int|string $value    What you want to increment the date by
322
-     * @param  string     $operand  What operand you wish to use for the calculation
323
-     * @return DateTime return whatever type came in.
324
-     * @throws Exception
325
-     * @throws EE_Error
326
-     */
327
-    protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
328
-    {
329
-        if (! $DateTime instanceof DateTime) {
330
-            throw new EE_Error(
331
-                sprintf(
332
-                    esc_html__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
333
-                    print_r($DateTime, true)
334
-                )
335
-            );
336
-        }
337
-        switch ($period) {
338
-            case 'years':
339
-                $value = 'P' . $value . 'Y';
340
-                break;
341
-            case 'months':
342
-                $value = 'P' . $value . 'M';
343
-                break;
344
-            case 'weeks':
345
-                $value = 'P' . $value . 'W';
346
-                break;
347
-            case 'days':
348
-                $value = 'P' . $value . 'D';
349
-                break;
350
-            case 'hours':
351
-                $value = 'PT' . $value . 'H';
352
-                break;
353
-            case 'minutes':
354
-                $value = 'PT' . $value . 'M';
355
-                break;
356
-            case 'seconds':
357
-                $value = 'PT' . $value . 'S';
358
-                break;
359
-        }
360
-        switch ($operand) {
361
-            case '+':
362
-                $DateTime->add(new DateInterval($value));
363
-                break;
364
-            case '-':
365
-                $DateTime->sub(new DateInterval($value));
366
-                break;
367
-        }
368
-        return $DateTime;
369
-    }
315
+	/**
316
+	 * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters
317
+	 *
318
+	 * @param  DateTime   $DateTime DateTime object
319
+	 * @param  string     $period   a value to indicate what interval is being used in the calculation. The options are
320
+	 *                              'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
321
+	 * @param  int|string $value    What you want to increment the date by
322
+	 * @param  string     $operand  What operand you wish to use for the calculation
323
+	 * @return DateTime return whatever type came in.
324
+	 * @throws Exception
325
+	 * @throws EE_Error
326
+	 */
327
+	protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
328
+	{
329
+		if (! $DateTime instanceof DateTime) {
330
+			throw new EE_Error(
331
+				sprintf(
332
+					esc_html__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
333
+					print_r($DateTime, true)
334
+				)
335
+			);
336
+		}
337
+		switch ($period) {
338
+			case 'years':
339
+				$value = 'P' . $value . 'Y';
340
+				break;
341
+			case 'months':
342
+				$value = 'P' . $value . 'M';
343
+				break;
344
+			case 'weeks':
345
+				$value = 'P' . $value . 'W';
346
+				break;
347
+			case 'days':
348
+				$value = 'P' . $value . 'D';
349
+				break;
350
+			case 'hours':
351
+				$value = 'PT' . $value . 'H';
352
+				break;
353
+			case 'minutes':
354
+				$value = 'PT' . $value . 'M';
355
+				break;
356
+			case 'seconds':
357
+				$value = 'PT' . $value . 'S';
358
+				break;
359
+		}
360
+		switch ($operand) {
361
+			case '+':
362
+				$DateTime->add(new DateInterval($value));
363
+				break;
364
+			case '-':
365
+				$DateTime->sub(new DateInterval($value));
366
+				break;
367
+		}
368
+		return $DateTime;
369
+	}
370 370
 
371 371
 
372
-    /**
373
-     * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters
374
-     *
375
-     * @param  int     $timestamp Unix timestamp
376
-     * @param  string  $period    a value to indicate what interval is being used in the calculation. The options are
377
-     *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
378
-     * @param  integer $value     What you want to increment the date by
379
-     * @param  string  $operand   What operand you wish to use for the calculation
380
-     * @return int
381
-     * @throws EE_Error
382
-     */
383
-    protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
384
-    {
385
-        if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
386
-            throw new EE_Error(
387
-                sprintf(
388
-                    esc_html__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
389
-                    print_r($timestamp, true)
390
-                )
391
-            );
392
-        }
393
-        switch ($period) {
394
-            case 'years':
395
-                $value = YEAR_IN_SECONDS * $value;
396
-                break;
397
-            case 'months':
398
-                $value = YEAR_IN_SECONDS / 12 * $value;
399
-                break;
400
-            case 'weeks':
401
-                $value = WEEK_IN_SECONDS * $value;
402
-                break;
403
-            case 'days':
404
-                $value = DAY_IN_SECONDS * $value;
405
-                break;
406
-            case 'hours':
407
-                $value = HOUR_IN_SECONDS * $value;
408
-                break;
409
-            case 'minutes':
410
-                $value = MINUTE_IN_SECONDS * $value;
411
-                break;
412
-        }
413
-        switch ($operand) {
414
-            case '+':
415
-                $timestamp += $value;
416
-                break;
417
-            case '-':
418
-                $timestamp -= $value;
419
-                break;
420
-        }
421
-        return $timestamp;
422
-    }
372
+	/**
373
+	 * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters
374
+	 *
375
+	 * @param  int     $timestamp Unix timestamp
376
+	 * @param  string  $period    a value to indicate what interval is being used in the calculation. The options are
377
+	 *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
378
+	 * @param  integer $value     What you want to increment the date by
379
+	 * @param  string  $operand   What operand you wish to use for the calculation
380
+	 * @return int
381
+	 * @throws EE_Error
382
+	 */
383
+	protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
384
+	{
385
+		if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
386
+			throw new EE_Error(
387
+				sprintf(
388
+					esc_html__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
389
+					print_r($timestamp, true)
390
+				)
391
+			);
392
+		}
393
+		switch ($period) {
394
+			case 'years':
395
+				$value = YEAR_IN_SECONDS * $value;
396
+				break;
397
+			case 'months':
398
+				$value = YEAR_IN_SECONDS / 12 * $value;
399
+				break;
400
+			case 'weeks':
401
+				$value = WEEK_IN_SECONDS * $value;
402
+				break;
403
+			case 'days':
404
+				$value = DAY_IN_SECONDS * $value;
405
+				break;
406
+			case 'hours':
407
+				$value = HOUR_IN_SECONDS * $value;
408
+				break;
409
+			case 'minutes':
410
+				$value = MINUTE_IN_SECONDS * $value;
411
+				break;
412
+		}
413
+		switch ($operand) {
414
+			case '+':
415
+				$timestamp += $value;
416
+				break;
417
+			case '-':
418
+				$timestamp -= $value;
419
+				break;
420
+		}
421
+		return $timestamp;
422
+	}
423 423
 
424 424
 
425
-    /**
426
-     * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming
427
-     * parameters and returns the new timestamp or DateTime.
428
-     *
429
-     * @param  int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp
430
-     * @param  string         $period                a value to indicate what interval is being used in the
431
-     *                                               calculation. The options are 'years', 'months', 'days', 'hours',
432
-     *                                               'minutes', 'seconds'. Defaults to years.
433
-     * @param  integer        $value                 What you want to increment the date by
434
-     * @param  string         $operand               What operand you wish to use for the calculation
435
-     * @return mixed string|DateTime          return whatever type came in.
436
-     * @throws Exception
437
-     * @throws EE_Error
438
-     */
439
-    public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+')
440
-    {
441
-        if ($DateTime_or_timestamp instanceof DateTime) {
442
-            return EEH_DTT_Helper::_modify_datetime_object(
443
-                $DateTime_or_timestamp,
444
-                $period,
445
-                $value,
446
-                $operand
447
-            );
448
-        }
449
-        if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
450
-            return EEH_DTT_Helper::_modify_timestamp(
451
-                $DateTime_or_timestamp,
452
-                $period,
453
-                $value,
454
-                $operand
455
-            );
456
-        }
457
-        // error
458
-        return $DateTime_or_timestamp;
459
-    }
425
+	/**
426
+	 * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming
427
+	 * parameters and returns the new timestamp or DateTime.
428
+	 *
429
+	 * @param  int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp
430
+	 * @param  string         $period                a value to indicate what interval is being used in the
431
+	 *                                               calculation. The options are 'years', 'months', 'days', 'hours',
432
+	 *                                               'minutes', 'seconds'. Defaults to years.
433
+	 * @param  integer        $value                 What you want to increment the date by
434
+	 * @param  string         $operand               What operand you wish to use for the calculation
435
+	 * @return mixed string|DateTime          return whatever type came in.
436
+	 * @throws Exception
437
+	 * @throws EE_Error
438
+	 */
439
+	public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+')
440
+	{
441
+		if ($DateTime_or_timestamp instanceof DateTime) {
442
+			return EEH_DTT_Helper::_modify_datetime_object(
443
+				$DateTime_or_timestamp,
444
+				$period,
445
+				$value,
446
+				$operand
447
+			);
448
+		}
449
+		if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
450
+			return EEH_DTT_Helper::_modify_timestamp(
451
+				$DateTime_or_timestamp,
452
+				$period,
453
+				$value,
454
+				$operand
455
+			);
456
+		}
457
+		// error
458
+		return $DateTime_or_timestamp;
459
+	}
460 460
 
461 461
 
462
-    /**
463
-     * The purpose of this helper method is to receive an incoming format string in php date/time format
464
-     * and spit out the js and moment.js equivalent formats.
465
-     * Note, if no format string is given, then it is assumed the user wants what is set for WP.
466
-     * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date-
467
-     * time picker.
468
-     *
469
-     * @see http://stackoverflow.com/posts/16725290/ for the code inspiration.
470
-     * @param string $date_format_string
471
-     * @param string $time_format_string
472
-     * @return array
473
-     *              array(
474
-     *              'js' => array (
475
-     *              'date' => //date format
476
-     *              'time' => //time format
477
-     *              ),
478
-     *              'moment' => //date and time format.
479
-     *              )
480
-     */
481
-    public static function convert_php_to_js_and_moment_date_formats(
482
-        $date_format_string = null,
483
-        $time_format_string = null
484
-    ) {
485
-        if ($date_format_string === null) {
486
-            $date_format_string = (string) get_option('date_format');
487
-        }
488
-        if ($time_format_string === null) {
489
-            $time_format_string = (string) get_option('time_format');
490
-        }
491
-        $date_format = self::_php_to_js_moment_converter($date_format_string);
492
-        $time_format = self::_php_to_js_moment_converter($time_format_string);
493
-        return array(
494
-            'js'     => array(
495
-                'date' => $date_format['js'],
496
-                'time' => $time_format['js'],
497
-            ),
498
-            'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
499
-            'moment_split' => array(
500
-                'date' => $date_format['moment'],
501
-                'time' => $time_format['moment']
502
-            )
503
-        );
504
-    }
462
+	/**
463
+	 * The purpose of this helper method is to receive an incoming format string in php date/time format
464
+	 * and spit out the js and moment.js equivalent formats.
465
+	 * Note, if no format string is given, then it is assumed the user wants what is set for WP.
466
+	 * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date-
467
+	 * time picker.
468
+	 *
469
+	 * @see http://stackoverflow.com/posts/16725290/ for the code inspiration.
470
+	 * @param string $date_format_string
471
+	 * @param string $time_format_string
472
+	 * @return array
473
+	 *              array(
474
+	 *              'js' => array (
475
+	 *              'date' => //date format
476
+	 *              'time' => //time format
477
+	 *              ),
478
+	 *              'moment' => //date and time format.
479
+	 *              )
480
+	 */
481
+	public static function convert_php_to_js_and_moment_date_formats(
482
+		$date_format_string = null,
483
+		$time_format_string = null
484
+	) {
485
+		if ($date_format_string === null) {
486
+			$date_format_string = (string) get_option('date_format');
487
+		}
488
+		if ($time_format_string === null) {
489
+			$time_format_string = (string) get_option('time_format');
490
+		}
491
+		$date_format = self::_php_to_js_moment_converter($date_format_string);
492
+		$time_format = self::_php_to_js_moment_converter($time_format_string);
493
+		return array(
494
+			'js'     => array(
495
+				'date' => $date_format['js'],
496
+				'time' => $time_format['js'],
497
+			),
498
+			'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
499
+			'moment_split' => array(
500
+				'date' => $date_format['moment'],
501
+				'time' => $time_format['moment']
502
+			)
503
+		);
504
+	}
505 505
 
506 506
 
507
-    /**
508
-     * This converts incoming format string into js and moment variations.
509
-     *
510
-     * @param string $format_string incoming php format string
511
-     * @return array js and moment formats.
512
-     */
513
-    protected static function _php_to_js_moment_converter($format_string)
514
-    {
515
-        /**
516
-         * This is a map of symbols for formats.
517
-         * The index is the php symbol, the equivalent values are in the array.
518
-         *
519
-         * @var array
520
-         */
521
-        $symbols_map          = array(
522
-            // Day
523
-            // 01
524
-            'd' => array(
525
-                'js'     => 'dd',
526
-                'moment' => 'DD',
527
-            ),
528
-            // Mon
529
-            'D' => array(
530
-                'js'     => 'D',
531
-                'moment' => 'ddd',
532
-            ),
533
-            // 1,2,...31
534
-            'j' => array(
535
-                'js'     => 'd',
536
-                'moment' => 'D',
537
-            ),
538
-            // Monday
539
-            'l' => array(
540
-                'js'     => 'DD',
541
-                'moment' => 'dddd',
542
-            ),
543
-            // ISO numeric representation of the day of the week (1-6)
544
-            'N' => array(
545
-                'js'     => '',
546
-                'moment' => 'E',
547
-            ),
548
-            // st,nd.rd
549
-            'S' => array(
550
-                'js'     => '',
551
-                'moment' => 'o',
552
-            ),
553
-            // numeric representation of day of week (0-6)
554
-            'w' => array(
555
-                'js'     => '',
556
-                'moment' => 'd',
557
-            ),
558
-            // day of year starting from 0 (0-365)
559
-            'z' => array(
560
-                'js'     => 'o',
561
-                'moment' => 'DDD' // note moment does not start with 0 so will need to modify by subtracting 1
562
-            ),
563
-            // Week
564
-            // ISO-8601 week number of year (weeks starting on monday)
565
-            'W' => array(
566
-                'js'     => '',
567
-                'moment' => 'w',
568
-            ),
569
-            // Month
570
-            // January...December
571
-            'F' => array(
572
-                'js'     => 'MM',
573
-                'moment' => 'MMMM',
574
-            ),
575
-            // 01...12
576
-            'm' => array(
577
-                'js'     => 'mm',
578
-                'moment' => 'MM',
579
-            ),
580
-            // Jan...Dec
581
-            'M' => array(
582
-                'js'     => 'M',
583
-                'moment' => 'MMM',
584
-            ),
585
-            // 1-12
586
-            'n' => array(
587
-                'js'     => 'm',
588
-                'moment' => 'M',
589
-            ),
590
-            // number of days in given month
591
-            't' => array(
592
-                'js'     => '',
593
-                'moment' => '',
594
-            ),
595
-            // Year
596
-            // whether leap year or not 1/0
597
-            'L' => array(
598
-                'js'     => '',
599
-                'moment' => '',
600
-            ),
601
-            // ISO-8601 year number
602
-            'o' => array(
603
-                'js'     => '',
604
-                'moment' => 'GGGG',
605
-            ),
606
-            // 1999...2003
607
-            'Y' => array(
608
-                'js'     => 'yy',
609
-                'moment' => 'YYYY',
610
-            ),
611
-            // 99...03
612
-            'y' => array(
613
-                'js'     => 'y',
614
-                'moment' => 'YY',
615
-            ),
616
-            // Time
617
-            // am/pm
618
-            'a' => array(
619
-                'js'     => 'tt',
620
-                'moment' => 'a',
621
-            ),
622
-            // AM/PM
623
-            'A' => array(
624
-                'js'     => 'TT',
625
-                'moment' => 'A',
626
-            ),
627
-            // Swatch Internet Time?!?
628
-            'B' => array(
629
-                'js'     => '',
630
-                'moment' => '',
631
-            ),
632
-            // 1...12
633
-            'g' => array(
634
-                'js'     => 'h',
635
-                'moment' => 'h',
636
-            ),
637
-            // 0...23
638
-            'G' => array(
639
-                'js'     => 'H',
640
-                'moment' => 'H',
641
-            ),
642
-            // 01...12
643
-            'h' => array(
644
-                'js'     => 'hh',
645
-                'moment' => 'hh',
646
-            ),
647
-            // 00...23
648
-            'H' => array(
649
-                'js'     => 'HH',
650
-                'moment' => 'HH',
651
-            ),
652
-            // 00..59
653
-            'i' => array(
654
-                'js'     => 'mm',
655
-                'moment' => 'mm',
656
-            ),
657
-            // seconds... 00...59
658
-            's' => array(
659
-                'js'     => 'ss',
660
-                'moment' => 'ss',
661
-            ),
662
-            // microseconds
663
-            'u' => array(
664
-                'js'     => '',
665
-                'moment' => '',
666
-            ),
667
-        );
668
-        $jquery_ui_format     = '';
669
-        $moment_format        = '';
670
-        $escaping             = false;
671
-        $format_string_length = strlen($format_string);
672
-        for ($i = 0; $i < $format_string_length; $i++) {
673
-            $char = $format_string[ $i ];
674
-            if ($char === '\\') { // PHP date format escaping character
675
-                $i++;
676
-                if ($escaping) {
677
-                    $jquery_ui_format .= $format_string[ $i ];
678
-                    $moment_format    .= $format_string[ $i ];
679
-                } else {
680
-                    $jquery_ui_format .= '\'' . $format_string[ $i ];
681
-                    $moment_format    .= $format_string[ $i ];
682
-                }
683
-                $escaping = true;
684
-            } else {
685
-                if ($escaping) {
686
-                    $jquery_ui_format .= "'";
687
-                    $moment_format    .= "'";
688
-                    $escaping         = false;
689
-                }
690
-                if (isset($symbols_map[ $char ])) {
691
-                    $jquery_ui_format .= $symbols_map[ $char ]['js'];
692
-                    $moment_format    .= $symbols_map[ $char ]['moment'];
693
-                } else {
694
-                    $jquery_ui_format .= $char;
695
-                    $moment_format    .= $char;
696
-                }
697
-            }
698
-        }
699
-        return array('js' => $jquery_ui_format, 'moment' => $moment_format);
700
-    }
507
+	/**
508
+	 * This converts incoming format string into js and moment variations.
509
+	 *
510
+	 * @param string $format_string incoming php format string
511
+	 * @return array js and moment formats.
512
+	 */
513
+	protected static function _php_to_js_moment_converter($format_string)
514
+	{
515
+		/**
516
+		 * This is a map of symbols for formats.
517
+		 * The index is the php symbol, the equivalent values are in the array.
518
+		 *
519
+		 * @var array
520
+		 */
521
+		$symbols_map          = array(
522
+			// Day
523
+			// 01
524
+			'd' => array(
525
+				'js'     => 'dd',
526
+				'moment' => 'DD',
527
+			),
528
+			// Mon
529
+			'D' => array(
530
+				'js'     => 'D',
531
+				'moment' => 'ddd',
532
+			),
533
+			// 1,2,...31
534
+			'j' => array(
535
+				'js'     => 'd',
536
+				'moment' => 'D',
537
+			),
538
+			// Monday
539
+			'l' => array(
540
+				'js'     => 'DD',
541
+				'moment' => 'dddd',
542
+			),
543
+			// ISO numeric representation of the day of the week (1-6)
544
+			'N' => array(
545
+				'js'     => '',
546
+				'moment' => 'E',
547
+			),
548
+			// st,nd.rd
549
+			'S' => array(
550
+				'js'     => '',
551
+				'moment' => 'o',
552
+			),
553
+			// numeric representation of day of week (0-6)
554
+			'w' => array(
555
+				'js'     => '',
556
+				'moment' => 'd',
557
+			),
558
+			// day of year starting from 0 (0-365)
559
+			'z' => array(
560
+				'js'     => 'o',
561
+				'moment' => 'DDD' // note moment does not start with 0 so will need to modify by subtracting 1
562
+			),
563
+			// Week
564
+			// ISO-8601 week number of year (weeks starting on monday)
565
+			'W' => array(
566
+				'js'     => '',
567
+				'moment' => 'w',
568
+			),
569
+			// Month
570
+			// January...December
571
+			'F' => array(
572
+				'js'     => 'MM',
573
+				'moment' => 'MMMM',
574
+			),
575
+			// 01...12
576
+			'm' => array(
577
+				'js'     => 'mm',
578
+				'moment' => 'MM',
579
+			),
580
+			// Jan...Dec
581
+			'M' => array(
582
+				'js'     => 'M',
583
+				'moment' => 'MMM',
584
+			),
585
+			// 1-12
586
+			'n' => array(
587
+				'js'     => 'm',
588
+				'moment' => 'M',
589
+			),
590
+			// number of days in given month
591
+			't' => array(
592
+				'js'     => '',
593
+				'moment' => '',
594
+			),
595
+			// Year
596
+			// whether leap year or not 1/0
597
+			'L' => array(
598
+				'js'     => '',
599
+				'moment' => '',
600
+			),
601
+			// ISO-8601 year number
602
+			'o' => array(
603
+				'js'     => '',
604
+				'moment' => 'GGGG',
605
+			),
606
+			// 1999...2003
607
+			'Y' => array(
608
+				'js'     => 'yy',
609
+				'moment' => 'YYYY',
610
+			),
611
+			// 99...03
612
+			'y' => array(
613
+				'js'     => 'y',
614
+				'moment' => 'YY',
615
+			),
616
+			// Time
617
+			// am/pm
618
+			'a' => array(
619
+				'js'     => 'tt',
620
+				'moment' => 'a',
621
+			),
622
+			// AM/PM
623
+			'A' => array(
624
+				'js'     => 'TT',
625
+				'moment' => 'A',
626
+			),
627
+			// Swatch Internet Time?!?
628
+			'B' => array(
629
+				'js'     => '',
630
+				'moment' => '',
631
+			),
632
+			// 1...12
633
+			'g' => array(
634
+				'js'     => 'h',
635
+				'moment' => 'h',
636
+			),
637
+			// 0...23
638
+			'G' => array(
639
+				'js'     => 'H',
640
+				'moment' => 'H',
641
+			),
642
+			// 01...12
643
+			'h' => array(
644
+				'js'     => 'hh',
645
+				'moment' => 'hh',
646
+			),
647
+			// 00...23
648
+			'H' => array(
649
+				'js'     => 'HH',
650
+				'moment' => 'HH',
651
+			),
652
+			// 00..59
653
+			'i' => array(
654
+				'js'     => 'mm',
655
+				'moment' => 'mm',
656
+			),
657
+			// seconds... 00...59
658
+			's' => array(
659
+				'js'     => 'ss',
660
+				'moment' => 'ss',
661
+			),
662
+			// microseconds
663
+			'u' => array(
664
+				'js'     => '',
665
+				'moment' => '',
666
+			),
667
+		);
668
+		$jquery_ui_format     = '';
669
+		$moment_format        = '';
670
+		$escaping             = false;
671
+		$format_string_length = strlen($format_string);
672
+		for ($i = 0; $i < $format_string_length; $i++) {
673
+			$char = $format_string[ $i ];
674
+			if ($char === '\\') { // PHP date format escaping character
675
+				$i++;
676
+				if ($escaping) {
677
+					$jquery_ui_format .= $format_string[ $i ];
678
+					$moment_format    .= $format_string[ $i ];
679
+				} else {
680
+					$jquery_ui_format .= '\'' . $format_string[ $i ];
681
+					$moment_format    .= $format_string[ $i ];
682
+				}
683
+				$escaping = true;
684
+			} else {
685
+				if ($escaping) {
686
+					$jquery_ui_format .= "'";
687
+					$moment_format    .= "'";
688
+					$escaping         = false;
689
+				}
690
+				if (isset($symbols_map[ $char ])) {
691
+					$jquery_ui_format .= $symbols_map[ $char ]['js'];
692
+					$moment_format    .= $symbols_map[ $char ]['moment'];
693
+				} else {
694
+					$jquery_ui_format .= $char;
695
+					$moment_format    .= $char;
696
+				}
697
+			}
698
+		}
699
+		return array('js' => $jquery_ui_format, 'moment' => $moment_format);
700
+	}
701 701
 
702 702
 
703
-    /**
704
-     * This takes an incoming format string and validates it to ensure it will work fine with PHP.
705
-     *
706
-     * @param string $format_string   Incoming format string for php date().
707
-     * @return mixed bool|array  If all is okay then TRUE is returned.  Otherwise an array of validation
708
-     *                                errors is returned.  So for client code calling, check for is_array() to
709
-     *                                indicate failed validations.
710
-     */
711
-    public static function validate_format_string($format_string)
712
-    {
713
-        $error_msg = array();
714
-        // time format checks
715
-        switch (true) {
716
-            case strpos($format_string, 'h') !== false:
717
-            case strpos($format_string, 'g') !== false:
718
-                /**
719
-                 * if the time string has a lowercase 'h' which == 12 hour time format and there
720
-                 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
721
-                 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
722
-                 */
723
-                if (stripos($format_string, 'A') === false) {
724
-                    $error_msg[] = esc_html__(
725
-                        'There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".',
726
-                        'event_espresso'
727
-                    );
728
-                }
729
-                break;
730
-        }
731
-        return empty($error_msg) ? true : $error_msg;
732
-    }
703
+	/**
704
+	 * This takes an incoming format string and validates it to ensure it will work fine with PHP.
705
+	 *
706
+	 * @param string $format_string   Incoming format string for php date().
707
+	 * @return mixed bool|array  If all is okay then TRUE is returned.  Otherwise an array of validation
708
+	 *                                errors is returned.  So for client code calling, check for is_array() to
709
+	 *                                indicate failed validations.
710
+	 */
711
+	public static function validate_format_string($format_string)
712
+	{
713
+		$error_msg = array();
714
+		// time format checks
715
+		switch (true) {
716
+			case strpos($format_string, 'h') !== false:
717
+			case strpos($format_string, 'g') !== false:
718
+				/**
719
+				 * if the time string has a lowercase 'h' which == 12 hour time format and there
720
+				 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
721
+				 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
722
+				 */
723
+				if (stripos($format_string, 'A') === false) {
724
+					$error_msg[] = esc_html__(
725
+						'There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".',
726
+						'event_espresso'
727
+					);
728
+				}
729
+				break;
730
+		}
731
+		return empty($error_msg) ? true : $error_msg;
732
+	}
733 733
 
734 734
 
735
-    /**
736
-     *     If the the first date starts at midnight on one day, and the next date ends at midnight on the
737
-     *     very next day then this method will return true.
738
-     *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true.
739
-     *    If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false.
740
-     *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true.
741
-     *
742
-     * @param mixed $date_1
743
-     * @param mixed $date_2
744
-     * @return bool
745
-     */
746
-    public static function dates_represent_one_24_hour_date($date_1, $date_2)
747
-    {
735
+	/**
736
+	 *     If the the first date starts at midnight on one day, and the next date ends at midnight on the
737
+	 *     very next day then this method will return true.
738
+	 *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true.
739
+	 *    If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false.
740
+	 *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true.
741
+	 *
742
+	 * @param mixed $date_1
743
+	 * @param mixed $date_2
744
+	 * @return bool
745
+	 */
746
+	public static function dates_represent_one_24_hour_date($date_1, $date_2)
747
+	{
748 748
 
749
-        if (
750
-            (! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
751
-            || ($date_1->format(EE_Datetime_Field::mysql_time_format) !== '00:00:00'
752
-                || $date_2->format(
753
-                    EE_Datetime_Field::mysql_time_format
754
-                ) !== '00:00:00')
755
-        ) {
756
-            return false;
757
-        }
758
-        return $date_2->format('U') - $date_1->format('U') === 86400;
759
-    }
749
+		if (
750
+			(! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
751
+			|| ($date_1->format(EE_Datetime_Field::mysql_time_format) !== '00:00:00'
752
+				|| $date_2->format(
753
+					EE_Datetime_Field::mysql_time_format
754
+				) !== '00:00:00')
755
+		) {
756
+			return false;
757
+		}
758
+		return $date_2->format('U') - $date_1->format('U') === 86400;
759
+	}
760 760
 
761 761
 
762
-    /**
763
-     * This returns the appropriate query interval string that can be used in sql queries involving mysql Date
764
-     * Functions.
765
-     *
766
-     * @param string $timezone_string    A timezone string in a valid format to instantiate a DateTimeZone object.
767
-     * @param string $field_for_interval The Database field that is the interval is applied to in the query.
768
-     * @return string
769
-     */
770
-    public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval)
771
-    {
772
-        try {
773
-            /** need to account for timezone offset on the selects */
774
-            $DateTimeZone = new DateTimeZone($timezone_string);
775
-        } catch (Exception $e) {
776
-            $DateTimeZone = null;
777
-        }
778
-        /**
779
-         * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds.
780
-         * Hence we do the calc for DateTimeZone::getOffset.
781
-         */
782
-        $offset         = $DateTimeZone instanceof DateTimeZone
783
-            ? $DateTimeZone->getOffset(new DateTime('now')) / HOUR_IN_SECONDS
784
-            : (float) get_option('gmt_offset');
785
-        $query_interval = $offset < 0
786
-            ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
787
-            : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
788
-        return $query_interval;
789
-    }
762
+	/**
763
+	 * This returns the appropriate query interval string that can be used in sql queries involving mysql Date
764
+	 * Functions.
765
+	 *
766
+	 * @param string $timezone_string    A timezone string in a valid format to instantiate a DateTimeZone object.
767
+	 * @param string $field_for_interval The Database field that is the interval is applied to in the query.
768
+	 * @return string
769
+	 */
770
+	public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval)
771
+	{
772
+		try {
773
+			/** need to account for timezone offset on the selects */
774
+			$DateTimeZone = new DateTimeZone($timezone_string);
775
+		} catch (Exception $e) {
776
+			$DateTimeZone = null;
777
+		}
778
+		/**
779
+		 * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds.
780
+		 * Hence we do the calc for DateTimeZone::getOffset.
781
+		 */
782
+		$offset         = $DateTimeZone instanceof DateTimeZone
783
+			? $DateTimeZone->getOffset(new DateTime('now')) / HOUR_IN_SECONDS
784
+			: (float) get_option('gmt_offset');
785
+		$query_interval = $offset < 0
786
+			? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
787
+			: 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
788
+		return $query_interval;
789
+	}
790 790
 
791 791
 
792
-    /**
793
-     * Retrieves the site's default timezone and returns it formatted so it's ready for display
794
-     * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string'
795
-     * and 'gmt_offset' WordPress options directly; or use the filter
796
-     * FHEE__EEH_DTT_Helper__get_timezone_string_for_display
797
-     * (although note that we remove any HTML that may be added)
798
-     *
799
-     * @return string
800
-     */
801
-    public static function get_timezone_string_for_display()
802
-    {
803
-        $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
804
-        if (! empty($pretty_timezone)) {
805
-            return esc_html($pretty_timezone);
806
-        }
807
-        $timezone_string = get_option('timezone_string');
808
-        if ($timezone_string) {
809
-            static $mo_loaded = false;
810
-            // Load translations for continents and cities just like wp_timezone_choice does
811
-            if (! $mo_loaded) {
812
-                $locale = get_locale();
813
-                $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
814
-                load_textdomain('continents-cities', $mofile);
815
-                $mo_loaded = true;
816
-            }
817
-            // well that was easy.
818
-            $parts = explode('/', $timezone_string);
819
-            // remove the continent
820
-            unset($parts[0]);
821
-            $t_parts = array();
822
-            // phpcs:disable WordPress.WP.I18n.NonSingularStringLiteralText
823
-            // phpcs:disable WordPress.WP.I18n.TextDomainMismatch
824
-            // disabled because this code is copied from WordPress and is a WordPress domain
825
-            foreach ($parts as $part) {
826
-                $t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities');
827
-            }
828
-            return implode(' - ', $t_parts);
829
-            // phpcs:enable
830
-        }
831
-        // they haven't set the timezone string, so let's return a string like "UTC+1"
832
-        $gmt_offset = get_option('gmt_offset');
833
-        $prefix     = (int) $gmt_offset >= 0 ? '+' : '';
834
-        $parts      = explode('.', (string) $gmt_offset);
835
-        if (count($parts) === 1) {
836
-            $parts[1] = '00';
837
-        } else {
838
-            // convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
839
-            // to minutes, eg 30 or 15, respectively
840
-            $hour_fraction = (float) ('0.' . $parts[1]);
841
-            $parts[1]      = (string) $hour_fraction * 60;
842
-        }
843
-        return sprintf(esc_html__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
844
-    }
792
+	/**
793
+	 * Retrieves the site's default timezone and returns it formatted so it's ready for display
794
+	 * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string'
795
+	 * and 'gmt_offset' WordPress options directly; or use the filter
796
+	 * FHEE__EEH_DTT_Helper__get_timezone_string_for_display
797
+	 * (although note that we remove any HTML that may be added)
798
+	 *
799
+	 * @return string
800
+	 */
801
+	public static function get_timezone_string_for_display()
802
+	{
803
+		$pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
804
+		if (! empty($pretty_timezone)) {
805
+			return esc_html($pretty_timezone);
806
+		}
807
+		$timezone_string = get_option('timezone_string');
808
+		if ($timezone_string) {
809
+			static $mo_loaded = false;
810
+			// Load translations for continents and cities just like wp_timezone_choice does
811
+			if (! $mo_loaded) {
812
+				$locale = get_locale();
813
+				$mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
814
+				load_textdomain('continents-cities', $mofile);
815
+				$mo_loaded = true;
816
+			}
817
+			// well that was easy.
818
+			$parts = explode('/', $timezone_string);
819
+			// remove the continent
820
+			unset($parts[0]);
821
+			$t_parts = array();
822
+			// phpcs:disable WordPress.WP.I18n.NonSingularStringLiteralText
823
+			// phpcs:disable WordPress.WP.I18n.TextDomainMismatch
824
+			// disabled because this code is copied from WordPress and is a WordPress domain
825
+			foreach ($parts as $part) {
826
+				$t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities');
827
+			}
828
+			return implode(' - ', $t_parts);
829
+			// phpcs:enable
830
+		}
831
+		// they haven't set the timezone string, so let's return a string like "UTC+1"
832
+		$gmt_offset = get_option('gmt_offset');
833
+		$prefix     = (int) $gmt_offset >= 0 ? '+' : '';
834
+		$parts      = explode('.', (string) $gmt_offset);
835
+		if (count($parts) === 1) {
836
+			$parts[1] = '00';
837
+		} else {
838
+			// convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
839
+			// to minutes, eg 30 or 15, respectively
840
+			$hour_fraction = (float) ('0.' . $parts[1]);
841
+			$parts[1]      = (string) $hour_fraction * 60;
842
+		}
843
+		return sprintf(esc_html__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
844
+	}
845 845
 
846 846
 
847 847
 
848
-    /**
849
-     * So PHP does this awesome thing where if you are trying to get a timestamp
850
-     * for a month using a string like "February" or "February 2017",
851
-     * and you don't specify a day as part of your string,
852
-     * then PHP will use whatever the current day of the month is.
853
-     * IF the current day of the month happens to be the 30th or 31st,
854
-     * then PHP gets really confused by a date like February 30,
855
-     * so instead of saying
856
-     *      "Hey February only has 28 days (this year)...
857
-     *      ...you must have meant the last day of the month!"
858
-     * PHP does the next most logical thing, and bumps the date up to March 2nd,
859
-     * because someone requesting February 30th obviously meant March 1st!
860
-     * The way around this is to always set the day to the first,
861
-     * so that the month will stay on the month you wanted.
862
-     * this method will add that "1" into your date regardless of the format.
863
-     *
864
-     * @param string $month
865
-     * @return string
866
-     */
867
-    public static function first_of_month_timestamp($month = '')
868
-    {
869
-        $month = (string) $month;
870
-        $year  = '';
871
-        // check if the incoming string has a year in it or not
872
-        if (preg_match('/\b\d{4}\b/', $month, $matches)) {
873
-            $year = $matches[0];
874
-            // ten remove that from the month string as well as any spaces
875
-            $month = trim(str_replace($year, '', $month));
876
-            // add a space before the year
877
-            $year = " {$year}";
878
-        }
879
-        // return timestamp for something like "February 1 2017"
880
-        return strtotime("{$month} 1{$year}");
881
-    }
848
+	/**
849
+	 * So PHP does this awesome thing where if you are trying to get a timestamp
850
+	 * for a month using a string like "February" or "February 2017",
851
+	 * and you don't specify a day as part of your string,
852
+	 * then PHP will use whatever the current day of the month is.
853
+	 * IF the current day of the month happens to be the 30th or 31st,
854
+	 * then PHP gets really confused by a date like February 30,
855
+	 * so instead of saying
856
+	 *      "Hey February only has 28 days (this year)...
857
+	 *      ...you must have meant the last day of the month!"
858
+	 * PHP does the next most logical thing, and bumps the date up to March 2nd,
859
+	 * because someone requesting February 30th obviously meant March 1st!
860
+	 * The way around this is to always set the day to the first,
861
+	 * so that the month will stay on the month you wanted.
862
+	 * this method will add that "1" into your date regardless of the format.
863
+	 *
864
+	 * @param string $month
865
+	 * @return string
866
+	 */
867
+	public static function first_of_month_timestamp($month = '')
868
+	{
869
+		$month = (string) $month;
870
+		$year  = '';
871
+		// check if the incoming string has a year in it or not
872
+		if (preg_match('/\b\d{4}\b/', $month, $matches)) {
873
+			$year = $matches[0];
874
+			// ten remove that from the month string as well as any spaces
875
+			$month = trim(str_replace($year, '', $month));
876
+			// add a space before the year
877
+			$year = " {$year}";
878
+		}
879
+		// return timestamp for something like "February 1 2017"
880
+		return strtotime("{$month} 1{$year}");
881
+	}
882 882
 
883 883
 
884
-    /**
885
-     * This simply returns the timestamp for tomorrow (midnight next day) in this sites timezone.  So it may be midnight
886
-     * for this sites timezone, but the timestamp could be some other time GMT.
887
-     */
888
-    public static function tomorrow()
889
-    {
890
-        // The multiplication of -1 ensures that we switch positive offsets to negative and negative offsets to positive
891
-        // before adding to the timestamp.  Why? Because we want tomorrow to be for midnight the next day in THIS timezone
892
-        // not an offset from midnight in UTC.  So if we're starting with UTC 00:00:00, then we want to make sure the
893
-        // final timestamp is equivalent to midnight in this timezone as represented in GMT.
894
-        return strtotime('tomorrow') + (self::get_site_timezone_gmt_offset() * -1);
895
-    }
884
+	/**
885
+	 * This simply returns the timestamp for tomorrow (midnight next day) in this sites timezone.  So it may be midnight
886
+	 * for this sites timezone, but the timestamp could be some other time GMT.
887
+	 */
888
+	public static function tomorrow()
889
+	{
890
+		// The multiplication of -1 ensures that we switch positive offsets to negative and negative offsets to positive
891
+		// before adding to the timestamp.  Why? Because we want tomorrow to be for midnight the next day in THIS timezone
892
+		// not an offset from midnight in UTC.  So if we're starting with UTC 00:00:00, then we want to make sure the
893
+		// final timestamp is equivalent to midnight in this timezone as represented in GMT.
894
+		return strtotime('tomorrow') + (self::get_site_timezone_gmt_offset() * -1);
895
+	}
896 896
 
897 897
 
898
-    /**
899
-     * **
900
-     * Gives a nicely-formatted list of timezone strings.
901
-     * Copied from the core wp function by the same name so we could customize to remove UTC offsets.
902
-     *
903
-     * @since     4.9.40.rc.008
904
-     * @staticvar bool $mo_loaded
905
-     * @staticvar string $locale_loaded
906
-     * @param string $selected_zone Selected timezone.
907
-     * @param string $locale        Optional. Locale to load the timezones in. Default current site locale.
908
-     * @return string
909
-     */
910
-    public static function wp_timezone_choice($selected_zone, $locale = null)
911
-    {
912
-        static $mo_loaded = false, $locale_loaded = null;
913
-        $continents = array(
914
-            'Africa',
915
-            'America',
916
-            'Antarctica',
917
-            'Arctic',
918
-            'Asia',
919
-            'Atlantic',
920
-            'Australia',
921
-            'Europe',
922
-            'Indian',
923
-            'Pacific',
924
-        );
925
-        // Load translations for continents and cities.
926
-        if (! $mo_loaded || $locale !== $locale_loaded) {
927
-            $locale_loaded = $locale ? $locale : get_locale();
928
-            $mofile        = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
929
-            unload_textdomain('continents-cities');
930
-            load_textdomain('continents-cities', $mofile);
931
-            $mo_loaded = true;
932
-        }
933
-        $zone_data = array();
934
-        foreach (timezone_identifiers_list() as $zone) {
935
-            $zone = explode('/', $zone);
936
-            if (! in_array($zone[0], $continents, true)) {
937
-                continue;
938
-            }
939
-            // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
940
-            $exists      = array(
941
-                0 => isset($zone[0]) && $zone[0],
942
-                1 => isset($zone[1]) && $zone[1],
943
-                2 => isset($zone[2]) && $zone[2],
944
-            );
945
-            $exists[3]   = $exists[0] && $zone[0] !== 'Etc';
946
-            $exists[4]   = $exists[1] && $exists[3];
947
-            $exists[5]   = $exists[2] && $exists[3];
948
-            // phpcs:disable WordPress.WP.I18n.NonSingularStringLiteralText
949
-            // phpcs:disable WordPress.WP.I18n.TextDomainMismatch
950
-            // disabled because this code is copied from WordPress and is a WordPress domain
951
-            $zone_data[] = array(
952
-                'continent'   => $exists[0] ? $zone[0] : '',
953
-                'city'        => $exists[1] ? $zone[1] : '',
954
-                'subcity'     => $exists[2] ? $zone[2] : '',
955
-                't_continent' => $exists[3]
956
-                    ? translate(str_replace('_', ' ', $zone[0]), 'continents-cities')
957
-                    : '',
958
-                't_city'      => $exists[4]
959
-                    ? translate(str_replace('_', ' ', $zone[1]), 'continents-cities')
960
-                    : '',
961
-                't_subcity'   => $exists[5]
962
-                    ? translate(str_replace('_', ' ', $zone[2]), 'continents-cities')
963
-                    : '',
964
-            );
965
-            // phpcs:enable
966
-        }
967
-        usort($zone_data, '_wp_timezone_choice_usort_callback');
968
-        $structure = array();
969
-        if (empty($selected_zone)) {
970
-            $structure[] = '<option selected value="">' . esc_html__('Select a city', 'event_espresso') . '</option>';
971
-        }
972
-        foreach ($zone_data as $key => $zone) {
973
-            // Build value in an array to join later
974
-            $value = array($zone['continent']);
975
-            if (empty($zone['city'])) {
976
-                // It's at the continent level (generally won't happen)
977
-                $display = $zone['t_continent'];
978
-            } else {
979
-                // It's inside a continent group
980
-                // Continent optgroup
981
-                if (! isset($zone_data[ $key - 1 ]) || $zone_data[ $key - 1 ]['continent'] !== $zone['continent']) {
982
-                    $label       = $zone['t_continent'];
983
-                    $structure[] = '<optgroup label="' . esc_attr($label) . '">';
984
-                }
985
-                // Add the city to the value
986
-                $value[] = $zone['city'];
987
-                $display = $zone['t_city'];
988
-                if (! empty($zone['subcity'])) {
989
-                    // Add the subcity to the value
990
-                    $value[] = $zone['subcity'];
991
-                    $display .= ' - ' . $zone['t_subcity'];
992
-                }
993
-            }
994
-            // Build the value
995
-            $value       = implode('/', $value);
996
-            $selected    = $value === $selected_zone ? ' selected' : '';
997
-            $structure[] = '<option value="' . esc_attr($value) . '"' . $selected . '>'
998
-                           . esc_html($display)
999
-                           . '</option>';
1000
-            // Close continent optgroup
1001
-            if (
1002
-                ! empty($zone['city'])
1003
-                && (
1004
-                    ! isset($zone_data[ $key + 1 ])
1005
-                    || (isset($zone_data[ $key + 1 ]) && $zone_data[ $key + 1 ]['continent'] !== $zone['continent'])
1006
-                )
1007
-            ) {
1008
-                $structure[] = '</optgroup>';
1009
-            }
1010
-        }
1011
-        return implode("\n", $structure);
1012
-    }
898
+	/**
899
+	 * **
900
+	 * Gives a nicely-formatted list of timezone strings.
901
+	 * Copied from the core wp function by the same name so we could customize to remove UTC offsets.
902
+	 *
903
+	 * @since     4.9.40.rc.008
904
+	 * @staticvar bool $mo_loaded
905
+	 * @staticvar string $locale_loaded
906
+	 * @param string $selected_zone Selected timezone.
907
+	 * @param string $locale        Optional. Locale to load the timezones in. Default current site locale.
908
+	 * @return string
909
+	 */
910
+	public static function wp_timezone_choice($selected_zone, $locale = null)
911
+	{
912
+		static $mo_loaded = false, $locale_loaded = null;
913
+		$continents = array(
914
+			'Africa',
915
+			'America',
916
+			'Antarctica',
917
+			'Arctic',
918
+			'Asia',
919
+			'Atlantic',
920
+			'Australia',
921
+			'Europe',
922
+			'Indian',
923
+			'Pacific',
924
+		);
925
+		// Load translations for continents and cities.
926
+		if (! $mo_loaded || $locale !== $locale_loaded) {
927
+			$locale_loaded = $locale ? $locale : get_locale();
928
+			$mofile        = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
929
+			unload_textdomain('continents-cities');
930
+			load_textdomain('continents-cities', $mofile);
931
+			$mo_loaded = true;
932
+		}
933
+		$zone_data = array();
934
+		foreach (timezone_identifiers_list() as $zone) {
935
+			$zone = explode('/', $zone);
936
+			if (! in_array($zone[0], $continents, true)) {
937
+				continue;
938
+			}
939
+			// This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
940
+			$exists      = array(
941
+				0 => isset($zone[0]) && $zone[0],
942
+				1 => isset($zone[1]) && $zone[1],
943
+				2 => isset($zone[2]) && $zone[2],
944
+			);
945
+			$exists[3]   = $exists[0] && $zone[0] !== 'Etc';
946
+			$exists[4]   = $exists[1] && $exists[3];
947
+			$exists[5]   = $exists[2] && $exists[3];
948
+			// phpcs:disable WordPress.WP.I18n.NonSingularStringLiteralText
949
+			// phpcs:disable WordPress.WP.I18n.TextDomainMismatch
950
+			// disabled because this code is copied from WordPress and is a WordPress domain
951
+			$zone_data[] = array(
952
+				'continent'   => $exists[0] ? $zone[0] : '',
953
+				'city'        => $exists[1] ? $zone[1] : '',
954
+				'subcity'     => $exists[2] ? $zone[2] : '',
955
+				't_continent' => $exists[3]
956
+					? translate(str_replace('_', ' ', $zone[0]), 'continents-cities')
957
+					: '',
958
+				't_city'      => $exists[4]
959
+					? translate(str_replace('_', ' ', $zone[1]), 'continents-cities')
960
+					: '',
961
+				't_subcity'   => $exists[5]
962
+					? translate(str_replace('_', ' ', $zone[2]), 'continents-cities')
963
+					: '',
964
+			);
965
+			// phpcs:enable
966
+		}
967
+		usort($zone_data, '_wp_timezone_choice_usort_callback');
968
+		$structure = array();
969
+		if (empty($selected_zone)) {
970
+			$structure[] = '<option selected value="">' . esc_html__('Select a city', 'event_espresso') . '</option>';
971
+		}
972
+		foreach ($zone_data as $key => $zone) {
973
+			// Build value in an array to join later
974
+			$value = array($zone['continent']);
975
+			if (empty($zone['city'])) {
976
+				// It's at the continent level (generally won't happen)
977
+				$display = $zone['t_continent'];
978
+			} else {
979
+				// It's inside a continent group
980
+				// Continent optgroup
981
+				if (! isset($zone_data[ $key - 1 ]) || $zone_data[ $key - 1 ]['continent'] !== $zone['continent']) {
982
+					$label       = $zone['t_continent'];
983
+					$structure[] = '<optgroup label="' . esc_attr($label) . '">';
984
+				}
985
+				// Add the city to the value
986
+				$value[] = $zone['city'];
987
+				$display = $zone['t_city'];
988
+				if (! empty($zone['subcity'])) {
989
+					// Add the subcity to the value
990
+					$value[] = $zone['subcity'];
991
+					$display .= ' - ' . $zone['t_subcity'];
992
+				}
993
+			}
994
+			// Build the value
995
+			$value       = implode('/', $value);
996
+			$selected    = $value === $selected_zone ? ' selected' : '';
997
+			$structure[] = '<option value="' . esc_attr($value) . '"' . $selected . '>'
998
+						   . esc_html($display)
999
+						   . '</option>';
1000
+			// Close continent optgroup
1001
+			if (
1002
+				! empty($zone['city'])
1003
+				&& (
1004
+					! isset($zone_data[ $key + 1 ])
1005
+					|| (isset($zone_data[ $key + 1 ]) && $zone_data[ $key + 1 ]['continent'] !== $zone['continent'])
1006
+				)
1007
+			) {
1008
+				$structure[] = '</optgroup>';
1009
+			}
1010
+		}
1011
+		return implode("\n", $structure);
1012
+	}
1013 1013
 
1014 1014
 
1015
-    /**
1016
-     * Shim for the WP function `get_user_locale` that was added in WordPress 4.7.0
1017
-     *
1018
-     * @param int|WP_User $user_id
1019
-     * @return string
1020
-     */
1021
-    public static function get_user_locale($user_id = 0)
1022
-    {
1023
-        if (function_exists('get_user_locale')) {
1024
-            return get_user_locale($user_id);
1025
-        }
1026
-        return get_locale();
1027
-    }
1015
+	/**
1016
+	 * Shim for the WP function `get_user_locale` that was added in WordPress 4.7.0
1017
+	 *
1018
+	 * @param int|WP_User $user_id
1019
+	 * @return string
1020
+	 */
1021
+	public static function get_user_locale($user_id = 0)
1022
+	{
1023
+		if (function_exists('get_user_locale')) {
1024
+			return get_user_locale($user_id);
1025
+		}
1026
+		return get_locale();
1027
+	}
1028 1028
 
1029 1029
 
1030
-    /**
1031
-     * Return the appropriate helper adapter for DTT related things.
1032
-     *
1033
-     * @return HelperInterface
1034
-     * @throws InvalidArgumentException
1035
-     * @throws InvalidDataTypeException
1036
-     * @throws InvalidInterfaceException
1037
-     */
1038
-    private static function getHelperAdapter()
1039
-    {
1040
-        $dtt_helper_fqcn = PHP_VERSION_ID < 50600
1041
-            ? 'EventEspresso\core\services\helpers\datetime\PhpCompatLessFiveSixHelper'
1042
-            : 'EventEspresso\core\services\helpers\datetime\PhpCompatGreaterFiveSixHelper';
1043
-        return LoaderFactory::getLoader()->getShared($dtt_helper_fqcn);
1044
-    }
1030
+	/**
1031
+	 * Return the appropriate helper adapter for DTT related things.
1032
+	 *
1033
+	 * @return HelperInterface
1034
+	 * @throws InvalidArgumentException
1035
+	 * @throws InvalidDataTypeException
1036
+	 * @throws InvalidInterfaceException
1037
+	 */
1038
+	private static function getHelperAdapter()
1039
+	{
1040
+		$dtt_helper_fqcn = PHP_VERSION_ID < 50600
1041
+			? 'EventEspresso\core\services\helpers\datetime\PhpCompatLessFiveSixHelper'
1042
+			: 'EventEspresso\core\services\helpers\datetime\PhpCompatGreaterFiveSixHelper';
1043
+		return LoaderFactory::getLoader()->getShared($dtt_helper_fqcn);
1044
+	}
1045 1045
 
1046 1046
 
1047
-    /**
1048
-     * Helper function for setting the timezone on a DateTime object.
1049
-     * This is implemented to standardize a workaround for a PHP bug outlined in
1050
-     * https://events.codebasehq.com/projects/event-espresso/tickets/11407 and
1051
-     * https://events.codebasehq.com/projects/event-espresso/tickets/11233
1052
-     *
1053
-     * @param DateTime     $datetime
1054
-     * @param DateTimeZone $timezone
1055
-     */
1056
-    public static function setTimezone(DateTime $datetime, DateTimeZone $timezone)
1057
-    {
1058
-        $datetime->setTimezone($timezone);
1059
-        $datetime->getTimestamp();
1060
-    }
1047
+	/**
1048
+	 * Helper function for setting the timezone on a DateTime object.
1049
+	 * This is implemented to standardize a workaround for a PHP bug outlined in
1050
+	 * https://events.codebasehq.com/projects/event-espresso/tickets/11407 and
1051
+	 * https://events.codebasehq.com/projects/event-espresso/tickets/11233
1052
+	 *
1053
+	 * @param DateTime     $datetime
1054
+	 * @param DateTimeZone $timezone
1055
+	 */
1056
+	public static function setTimezone(DateTime $datetime, DateTimeZone $timezone)
1057
+	{
1058
+		$datetime->setTimezone($timezone);
1059
+		$datetime->getTimestamp();
1060
+	}
1061 1061
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0, $coerce = true)
133 133
     {
134
-        $gmt_offset =  (int) $gmt_offset;
134
+        $gmt_offset = (int) $gmt_offset;
135 135
         /** @var array[] $abbreviations */
136 136
         $abbreviations = DateTimeZone::listAbbreviations();
137 137
         foreach ($abbreviations as $abbreviation) {
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
      */
327 327
     protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
328 328
     {
329
-        if (! $DateTime instanceof DateTime) {
329
+        if ( ! $DateTime instanceof DateTime) {
330 330
             throw new EE_Error(
331 331
                 sprintf(
332 332
                     esc_html__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
@@ -336,25 +336,25 @@  discard block
 block discarded – undo
336 336
         }
337 337
         switch ($period) {
338 338
             case 'years':
339
-                $value = 'P' . $value . 'Y';
339
+                $value = 'P'.$value.'Y';
340 340
                 break;
341 341
             case 'months':
342
-                $value = 'P' . $value . 'M';
342
+                $value = 'P'.$value.'M';
343 343
                 break;
344 344
             case 'weeks':
345
-                $value = 'P' . $value . 'W';
345
+                $value = 'P'.$value.'W';
346 346
                 break;
347 347
             case 'days':
348
-                $value = 'P' . $value . 'D';
348
+                $value = 'P'.$value.'D';
349 349
                 break;
350 350
             case 'hours':
351
-                $value = 'PT' . $value . 'H';
351
+                $value = 'PT'.$value.'H';
352 352
                 break;
353 353
             case 'minutes':
354
-                $value = 'PT' . $value . 'M';
354
+                $value = 'PT'.$value.'M';
355 355
                 break;
356 356
             case 'seconds':
357
-                $value = 'PT' . $value . 'S';
357
+                $value = 'PT'.$value.'S';
358 358
                 break;
359 359
         }
360 360
         switch ($operand) {
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      */
383 383
     protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
384 384
     {
385
-        if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
385
+        if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
386 386
             throw new EE_Error(
387 387
                 sprintf(
388 388
                     esc_html__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
                 'date' => $date_format['js'],
496 496
                 'time' => $time_format['js'],
497 497
             ),
498
-            'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
498
+            'moment' => $date_format['moment'].' '.$time_format['moment'],
499 499
             'moment_split' => array(
500 500
                 'date' => $date_format['moment'],
501 501
                 'time' => $time_format['moment']
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
          *
519 519
          * @var array
520 520
          */
521
-        $symbols_map          = array(
521
+        $symbols_map = array(
522 522
             // Day
523 523
             // 01
524 524
             'd' => array(
@@ -670,26 +670,26 @@  discard block
 block discarded – undo
670 670
         $escaping             = false;
671 671
         $format_string_length = strlen($format_string);
672 672
         for ($i = 0; $i < $format_string_length; $i++) {
673
-            $char = $format_string[ $i ];
673
+            $char = $format_string[$i];
674 674
             if ($char === '\\') { // PHP date format escaping character
675 675
                 $i++;
676 676
                 if ($escaping) {
677
-                    $jquery_ui_format .= $format_string[ $i ];
678
-                    $moment_format    .= $format_string[ $i ];
677
+                    $jquery_ui_format .= $format_string[$i];
678
+                    $moment_format    .= $format_string[$i];
679 679
                 } else {
680
-                    $jquery_ui_format .= '\'' . $format_string[ $i ];
681
-                    $moment_format    .= $format_string[ $i ];
680
+                    $jquery_ui_format .= '\''.$format_string[$i];
681
+                    $moment_format    .= $format_string[$i];
682 682
                 }
683 683
                 $escaping = true;
684 684
             } else {
685 685
                 if ($escaping) {
686 686
                     $jquery_ui_format .= "'";
687 687
                     $moment_format    .= "'";
688
-                    $escaping         = false;
688
+                    $escaping = false;
689 689
                 }
690
-                if (isset($symbols_map[ $char ])) {
691
-                    $jquery_ui_format .= $symbols_map[ $char ]['js'];
692
-                    $moment_format    .= $symbols_map[ $char ]['moment'];
690
+                if (isset($symbols_map[$char])) {
691
+                    $jquery_ui_format .= $symbols_map[$char]['js'];
692
+                    $moment_format    .= $symbols_map[$char]['moment'];
693 693
                 } else {
694 694
                     $jquery_ui_format .= $char;
695 695
                     $moment_format    .= $char;
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
     {
748 748
 
749 749
         if (
750
-            (! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
750
+            ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
751 751
             || ($date_1->format(EE_Datetime_Field::mysql_time_format) !== '00:00:00'
752 752
                 || $date_2->format(
753 753
                     EE_Datetime_Field::mysql_time_format
@@ -783,8 +783,8 @@  discard block
 block discarded – undo
783 783
             ? $DateTimeZone->getOffset(new DateTime('now')) / HOUR_IN_SECONDS
784 784
             : (float) get_option('gmt_offset');
785 785
         $query_interval = $offset < 0
786
-            ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
787
-            : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
786
+            ? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)'
787
+            : 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)';
788 788
         return $query_interval;
789 789
     }
790 790
 
@@ -801,16 +801,16 @@  discard block
 block discarded – undo
801 801
     public static function get_timezone_string_for_display()
802 802
     {
803 803
         $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
804
-        if (! empty($pretty_timezone)) {
804
+        if ( ! empty($pretty_timezone)) {
805 805
             return esc_html($pretty_timezone);
806 806
         }
807 807
         $timezone_string = get_option('timezone_string');
808 808
         if ($timezone_string) {
809 809
             static $mo_loaded = false;
810 810
             // Load translations for continents and cities just like wp_timezone_choice does
811
-            if (! $mo_loaded) {
811
+            if ( ! $mo_loaded) {
812 812
                 $locale = get_locale();
813
-                $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
813
+                $mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo';
814 814
                 load_textdomain('continents-cities', $mofile);
815 815
                 $mo_loaded = true;
816 816
             }
@@ -837,10 +837,10 @@  discard block
 block discarded – undo
837 837
         } else {
838 838
             // convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
839 839
             // to minutes, eg 30 or 15, respectively
840
-            $hour_fraction = (float) ('0.' . $parts[1]);
840
+            $hour_fraction = (float) ('0.'.$parts[1]);
841 841
             $parts[1]      = (string) $hour_fraction * 60;
842 842
         }
843
-        return sprintf(esc_html__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
843
+        return sprintf(esc_html__('UTC%1$s', 'event_espresso'), $prefix.implode(':', $parts));
844 844
     }
845 845
 
846 846
 
@@ -923,9 +923,9 @@  discard block
 block discarded – undo
923 923
             'Pacific',
924 924
         );
925 925
         // Load translations for continents and cities.
926
-        if (! $mo_loaded || $locale !== $locale_loaded) {
926
+        if ( ! $mo_loaded || $locale !== $locale_loaded) {
927 927
             $locale_loaded = $locale ? $locale : get_locale();
928
-            $mofile        = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
928
+            $mofile        = WP_LANG_DIR.'/continents-cities-'.$locale_loaded.'.mo';
929 929
             unload_textdomain('continents-cities');
930 930
             load_textdomain('continents-cities', $mofile);
931 931
             $mo_loaded = true;
@@ -933,11 +933,11 @@  discard block
 block discarded – undo
933 933
         $zone_data = array();
934 934
         foreach (timezone_identifiers_list() as $zone) {
935 935
             $zone = explode('/', $zone);
936
-            if (! in_array($zone[0], $continents, true)) {
936
+            if ( ! in_array($zone[0], $continents, true)) {
937 937
                 continue;
938 938
             }
939 939
             // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
940
-            $exists      = array(
940
+            $exists = array(
941 941
                 0 => isset($zone[0]) && $zone[0],
942 942
                 1 => isset($zone[1]) && $zone[1],
943 943
                 2 => isset($zone[2]) && $zone[2],
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
         usort($zone_data, '_wp_timezone_choice_usort_callback');
968 968
         $structure = array();
969 969
         if (empty($selected_zone)) {
970
-            $structure[] = '<option selected value="">' . esc_html__('Select a city', 'event_espresso') . '</option>';
970
+            $structure[] = '<option selected value="">'.esc_html__('Select a city', 'event_espresso').'</option>';
971 971
         }
972 972
         foreach ($zone_data as $key => $zone) {
973 973
             // Build value in an array to join later
@@ -978,31 +978,31 @@  discard block
 block discarded – undo
978 978
             } else {
979 979
                 // It's inside a continent group
980 980
                 // Continent optgroup
981
-                if (! isset($zone_data[ $key - 1 ]) || $zone_data[ $key - 1 ]['continent'] !== $zone['continent']) {
981
+                if ( ! isset($zone_data[$key - 1]) || $zone_data[$key - 1]['continent'] !== $zone['continent']) {
982 982
                     $label       = $zone['t_continent'];
983
-                    $structure[] = '<optgroup label="' . esc_attr($label) . '">';
983
+                    $structure[] = '<optgroup label="'.esc_attr($label).'">';
984 984
                 }
985 985
                 // Add the city to the value
986 986
                 $value[] = $zone['city'];
987 987
                 $display = $zone['t_city'];
988
-                if (! empty($zone['subcity'])) {
988
+                if ( ! empty($zone['subcity'])) {
989 989
                     // Add the subcity to the value
990 990
                     $value[] = $zone['subcity'];
991
-                    $display .= ' - ' . $zone['t_subcity'];
991
+                    $display .= ' - '.$zone['t_subcity'];
992 992
                 }
993 993
             }
994 994
             // Build the value
995 995
             $value       = implode('/', $value);
996 996
             $selected    = $value === $selected_zone ? ' selected' : '';
997
-            $structure[] = '<option value="' . esc_attr($value) . '"' . $selected . '>'
997
+            $structure[] = '<option value="'.esc_attr($value).'"'.$selected.'>'
998 998
                            . esc_html($display)
999 999
                            . '</option>';
1000 1000
             // Close continent optgroup
1001 1001
             if (
1002 1002
                 ! empty($zone['city'])
1003 1003
                 && (
1004
-                    ! isset($zone_data[ $key + 1 ])
1005
-                    || (isset($zone_data[ $key + 1 ]) && $zone_data[ $key + 1 ]['continent'] !== $zone['continent'])
1004
+                    ! isset($zone_data[$key + 1])
1005
+                    || (isset($zone_data[$key + 1]) && $zone_data[$key + 1]['continent'] !== $zone['continent'])
1006 1006
                 )
1007 1007
             ) {
1008 1008
                 $structure[] = '</optgroup>';
Please login to merge, or discard this patch.
core/templates/json_linked_data_for_event.template.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
   "eventStatus": [ "<?php echo esc_url_raw($event_status); ?>" ],
30 30
   "offers": [
31 31
     <?php
32
-    $i = 0;
33
-    foreach ($event_tickets as $ticket) {?>
32
+	$i = 0;
33
+	foreach ($event_tickets as $ticket) {?>
34 34
     {
35 35
       "@type": "Offer",
36 36
       "url": "<?php echo esc_url_raw($event_permalink); ?>",
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
       "price": "<?php echo esc_html($ticket['price']); ?>",
40 40
       "priceCurrency": "<?php echo esc_html($currency); ?>"
41 41
         <?php if (isset($ticket['availability'])) {
42
-            ?>,"availability": "<?php echo esc_url_raw('https://schema.org/' . $ticket['availability']); ?>"
42
+			?>,"availability": "<?php echo esc_url_raw('https://schema.org/' . $ticket['availability']); ?>"
43 43
         <?php } ?>
44 44
     }<?php
45
-    $i++;
46
-    if ($i < count($event_tickets)) {
47
-        echo ',';
48
-    }
49
-    }
50
-    ?>
45
+	$i++;
46
+	if ($i < count($event_tickets)) {
47
+		echo ',';
48
+	}
49
+	}
50
+	?>
51 51
     ]<?php
52
-    if ($venue_name) {
53
-        ?>,
52
+	if ($venue_name) {
53
+		?>,
54 54
   "location": {
55 55
     "@type": "Place",
56 56
     "name": <?php echo wp_json_encode($venue_name); ?>,
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
     }
64 64
   }
65 65
         <?php
66
-    } ?>
66
+	} ?>
67 67
     <?php
68
-    if ($event_image) {
69
-        ?>,
68
+	if ($event_image) {
69
+		?>,
70 70
   "image": "<?php echo esc_url_raw($event_image); ?>"
71 71
         <?php
72
-    } ?>
72
+	} ?>
73 73
     <?php do_action('AHEE__json_linked_data_for_event__template'); ?>
74 74
 }
75 75
 
Please login to merge, or discard this patch.
display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php 2 patches
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -13,180 +13,180 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     * enqueues css and js, so that this can be called statically
18
-     */
19
-    public static function enqueue_styles_and_scripts()
20
-    {
21
-        wp_register_style(
22
-            'checkbox_dropdown_selector',
23
-            EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css',
24
-            array('espresso_default'),
25
-            EVENT_ESPRESSO_VERSION
26
-        );
27
-        wp_register_style(
28
-            'espresso_default',
29
-            EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
30
-            array('dashicons'),
31
-            EVENT_ESPRESSO_VERSION
32
-        );
33
-        wp_enqueue_style('checkbox_dropdown_selector');
34
-        wp_register_script(
35
-            'checkbox_dropdown_selector',
36
-            EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js',
37
-            array('jquery'),
38
-            EVENT_ESPRESSO_VERSION,
39
-            true
40
-        );
41
-        wp_localize_script(
42
-            'ticket_selector',
43
-            'eeDTS',
44
-            array(
45
-                'maxChecked' => EE_Registry::instance()
46
-                    ->CFG
47
-                    ->template_settings
48
-                    ->EED_Ticket_Selector
49
-                    ->getDatetimeSelectorMaxChecked()
50
-            )
51
-        );
52
-        wp_enqueue_script('checkbox_dropdown_selector');
53
-    }
54
-
55
-
56
-
57
-    /**
58
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
59
-     */
60
-    public function enqueue_js()
61
-    {
62
-        EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
63
-    }
64
-
65
-
66
-
67
-    /**
68
-     * callback for Iframe::addStylesheets() child class methods
69
-     *
70
-     * @param array $iframe_css
71
-     * @return array
72
-     */
73
-    public function iframe_css(array $iframe_css)
74
-    {
75
-        $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css';
76
-        return $iframe_css;
77
-    }
78
-
79
-
80
-
81
-    /**
82
-     * callback for Iframe::addScripts() child class methods
83
-     *
84
-     * @param array $iframe_js
85
-     * @return array
86
-     */
87
-    public function iframe_js(array $iframe_js)
88
-    {
89
-        $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js';
90
-        return $iframe_js;
91
-    }
92
-
93
-
94
-    /**
95
-     * @throws EE_Error
96
-     * @return string of html to display the field
97
-     */
98
-    public function display()
99
-    {
100
-        $input = $this->get_input();
101
-        $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : '';
102
-        // $multi = count( $input->options() ) > 1 ? TRUE : FALSE;
103
-        $input->set_label_sizes();
104
-        $label_size_class = $input->get_label_size_class();
105
-        if (! is_array($input->raw_value()) && $input->raw_value() !== null) {
106
-            EE_Error::doing_it_wrong(
107
-                'EE_Checkbox_Display_Strategy::display()',
108
-                sprintf(
109
-                    esc_html__(
110
-                        'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"',
111
-                        'event_espresso'
112
-                    ),
113
-                    $input->html_id(),
114
-                    var_export($input->raw_value(), true),
115
-                    $input->html_name() . '[]'
116
-                ),
117
-                '4.8.1'
118
-            );
119
-        }
120
-
121
-
122
-        $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv');
123
-        $html .= '<button id="' . $input->html_id() . '-btn"';
124
-        // $html .= ' name="' . $input->html_name() . '"';
125
-        $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"';
126
-        $html .= ' style="' . $input->html_style() . '"';
127
-        $html .= ' data-target="' . $input->html_id() . '-options-dv"';
128
-        $html .= ' ' . $input->other_html_attributes() . '>';
129
-        $html .= '<span class="checkbox-dropdown-selector-selected-spn">';
130
-        $html .= $select_button_text;
131
-        $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>';
132
-        $html .= '</button>';
133
-        $html .= EEH_HTML::div(
134
-            '',
135
-            $input->html_id() . '-options-dv',
136
-            'checkbox-dropdown-selector'
137
-        );
138
-        $html .= EEH_HTML::link(
139
-            '',
140
-            '<span class="dashicons dashicons-no"></span>',
141
-            esc_html__('close datetime selector', 'event_espresso'),
142
-            '',
143
-            'close-espresso-notice'
144
-        );
145
-        $html .= EEH_HTML::ul();
146
-        $input_raw_value = (array) $input->raw_value();
147
-        foreach ($input->options() as $value => $display_text) {
148
-            $html .= EEH_HTML::li();
149
-            $value = $input->get_normalization_strategy()->unnormalize_one($value);
150
-            $html_id = $this->get_sub_input_id($value);
151
-            $html .= EEH_HTML::nl(0, 'checkbox');
152
-            $html .= '<label for="'
153
-                     . $html_id
154
-                     . '" id="'
155
-                     . $html_id
156
-                     . '-lbl" class="ee-checkbox-label-after'
157
-                     . $label_size_class
158
-                     . '">';
159
-            $html .= EEH_HTML::nl(1, 'checkbox');
160
-            $html .= '<input type="checkbox"';
161
-            $html .= ' name="' . $input->html_name() . '[]"';
162
-            $html .= ' id="' . $html_id . '"';
163
-            $html .= ' class="' . $input->html_class() . '-option"';
164
-            $html .= $input->html_style() ? ' style="' . $input->html_style() . '"' : '';
165
-            $html .= ' value="' . esc_attr($value) . '"';
166
-            $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
167
-                ? ' checked'
168
-                : '';
169
-            $html .= ' ' . $this->_input->other_html_attributes();
170
-            $html .= '>';
171
-            $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>';
172
-            $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
173
-            $html .= EEH_HTML::lix();
174
-        }
175
-        $html .= EEH_HTML::ulx();
176
-        $html .= EEH_HTML::divx();
177
-        $html .= EEH_HTML::divx();
178
-        $html .= EEH_HTML::p(
179
-            apply_filters(
180
-                'FHEE__EE_Checkbox_Dropdown_Selector_Display_Strategy__display__html',
181
-                esc_html__(
182
-                    'To view additional ticket options, click the "Filter by Date" button and select more dates.',
183
-                    'event_espresso'
184
-                )
185
-            ),
186
-            $input->html_id() . '-date-time-filter-notice-pg',
187
-            'date-time-filter-notice-pg small-text lt-grey-text'
188
-        );
189
-        $html .= \EEH_HTML::br();
190
-        return $html;
191
-    }
16
+	/**
17
+	 * enqueues css and js, so that this can be called statically
18
+	 */
19
+	public static function enqueue_styles_and_scripts()
20
+	{
21
+		wp_register_style(
22
+			'checkbox_dropdown_selector',
23
+			EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css',
24
+			array('espresso_default'),
25
+			EVENT_ESPRESSO_VERSION
26
+		);
27
+		wp_register_style(
28
+			'espresso_default',
29
+			EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
30
+			array('dashicons'),
31
+			EVENT_ESPRESSO_VERSION
32
+		);
33
+		wp_enqueue_style('checkbox_dropdown_selector');
34
+		wp_register_script(
35
+			'checkbox_dropdown_selector',
36
+			EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js',
37
+			array('jquery'),
38
+			EVENT_ESPRESSO_VERSION,
39
+			true
40
+		);
41
+		wp_localize_script(
42
+			'ticket_selector',
43
+			'eeDTS',
44
+			array(
45
+				'maxChecked' => EE_Registry::instance()
46
+					->CFG
47
+					->template_settings
48
+					->EED_Ticket_Selector
49
+					->getDatetimeSelectorMaxChecked()
50
+			)
51
+		);
52
+		wp_enqueue_script('checkbox_dropdown_selector');
53
+	}
54
+
55
+
56
+
57
+	/**
58
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
59
+	 */
60
+	public function enqueue_js()
61
+	{
62
+		EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
63
+	}
64
+
65
+
66
+
67
+	/**
68
+	 * callback for Iframe::addStylesheets() child class methods
69
+	 *
70
+	 * @param array $iframe_css
71
+	 * @return array
72
+	 */
73
+	public function iframe_css(array $iframe_css)
74
+	{
75
+		$iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css';
76
+		return $iframe_css;
77
+	}
78
+
79
+
80
+
81
+	/**
82
+	 * callback for Iframe::addScripts() child class methods
83
+	 *
84
+	 * @param array $iframe_js
85
+	 * @return array
86
+	 */
87
+	public function iframe_js(array $iframe_js)
88
+	{
89
+		$iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js';
90
+		return $iframe_js;
91
+	}
92
+
93
+
94
+	/**
95
+	 * @throws EE_Error
96
+	 * @return string of html to display the field
97
+	 */
98
+	public function display()
99
+	{
100
+		$input = $this->get_input();
101
+		$select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : '';
102
+		// $multi = count( $input->options() ) > 1 ? TRUE : FALSE;
103
+		$input->set_label_sizes();
104
+		$label_size_class = $input->get_label_size_class();
105
+		if (! is_array($input->raw_value()) && $input->raw_value() !== null) {
106
+			EE_Error::doing_it_wrong(
107
+				'EE_Checkbox_Display_Strategy::display()',
108
+				sprintf(
109
+					esc_html__(
110
+						'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"',
111
+						'event_espresso'
112
+					),
113
+					$input->html_id(),
114
+					var_export($input->raw_value(), true),
115
+					$input->html_name() . '[]'
116
+				),
117
+				'4.8.1'
118
+			);
119
+		}
120
+
121
+
122
+		$html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv');
123
+		$html .= '<button id="' . $input->html_id() . '-btn"';
124
+		// $html .= ' name="' . $input->html_name() . '"';
125
+		$html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"';
126
+		$html .= ' style="' . $input->html_style() . '"';
127
+		$html .= ' data-target="' . $input->html_id() . '-options-dv"';
128
+		$html .= ' ' . $input->other_html_attributes() . '>';
129
+		$html .= '<span class="checkbox-dropdown-selector-selected-spn">';
130
+		$html .= $select_button_text;
131
+		$html .= '</span> <span class="dashicons dashicons-arrow-down"></span>';
132
+		$html .= '</button>';
133
+		$html .= EEH_HTML::div(
134
+			'',
135
+			$input->html_id() . '-options-dv',
136
+			'checkbox-dropdown-selector'
137
+		);
138
+		$html .= EEH_HTML::link(
139
+			'',
140
+			'<span class="dashicons dashicons-no"></span>',
141
+			esc_html__('close datetime selector', 'event_espresso'),
142
+			'',
143
+			'close-espresso-notice'
144
+		);
145
+		$html .= EEH_HTML::ul();
146
+		$input_raw_value = (array) $input->raw_value();
147
+		foreach ($input->options() as $value => $display_text) {
148
+			$html .= EEH_HTML::li();
149
+			$value = $input->get_normalization_strategy()->unnormalize_one($value);
150
+			$html_id = $this->get_sub_input_id($value);
151
+			$html .= EEH_HTML::nl(0, 'checkbox');
152
+			$html .= '<label for="'
153
+					 . $html_id
154
+					 . '" id="'
155
+					 . $html_id
156
+					 . '-lbl" class="ee-checkbox-label-after'
157
+					 . $label_size_class
158
+					 . '">';
159
+			$html .= EEH_HTML::nl(1, 'checkbox');
160
+			$html .= '<input type="checkbox"';
161
+			$html .= ' name="' . $input->html_name() . '[]"';
162
+			$html .= ' id="' . $html_id . '"';
163
+			$html .= ' class="' . $input->html_class() . '-option"';
164
+			$html .= $input->html_style() ? ' style="' . $input->html_style() . '"' : '';
165
+			$html .= ' value="' . esc_attr($value) . '"';
166
+			$html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
167
+				? ' checked'
168
+				: '';
169
+			$html .= ' ' . $this->_input->other_html_attributes();
170
+			$html .= '>';
171
+			$html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>';
172
+			$html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
173
+			$html .= EEH_HTML::lix();
174
+		}
175
+		$html .= EEH_HTML::ulx();
176
+		$html .= EEH_HTML::divx();
177
+		$html .= EEH_HTML::divx();
178
+		$html .= EEH_HTML::p(
179
+			apply_filters(
180
+				'FHEE__EE_Checkbox_Dropdown_Selector_Display_Strategy__display__html',
181
+				esc_html__(
182
+					'To view additional ticket options, click the "Filter by Date" button and select more dates.',
183
+					'event_espresso'
184
+				)
185
+			),
186
+			$input->html_id() . '-date-time-filter-notice-pg',
187
+			'date-time-filter-notice-pg small-text lt-grey-text'
188
+		);
189
+		$html .= \EEH_HTML::br();
190
+		return $html;
191
+	}
192 192
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
     {
21 21
         wp_register_style(
22 22
             'checkbox_dropdown_selector',
23
-            EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css',
23
+            EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css',
24 24
             array('espresso_default'),
25 25
             EVENT_ESPRESSO_VERSION
26 26
         );
27 27
         wp_register_style(
28 28
             'espresso_default',
29
-            EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
29
+            EE_GLOBAL_ASSETS_URL.'css/espresso_default.css',
30 30
             array('dashicons'),
31 31
             EVENT_ESPRESSO_VERSION
32 32
         );
33 33
         wp_enqueue_style('checkbox_dropdown_selector');
34 34
         wp_register_script(
35 35
             'checkbox_dropdown_selector',
36
-            EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js',
36
+            EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js',
37 37
             array('jquery'),
38 38
             EVENT_ESPRESSO_VERSION,
39 39
             true
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function iframe_css(array $iframe_css)
74 74
     {
75
-        $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css';
75
+        $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css';
76 76
         return $iframe_css;
77 77
     }
78 78
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public function iframe_js(array $iframe_js)
88 88
     {
89
-        $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js';
89
+        $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js';
90 90
         return $iframe_js;
91 91
     }
92 92
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         // $multi = count( $input->options() ) > 1 ? TRUE : FALSE;
103 103
         $input->set_label_sizes();
104 104
         $label_size_class = $input->get_label_size_class();
105
-        if (! is_array($input->raw_value()) && $input->raw_value() !== null) {
105
+        if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) {
106 106
             EE_Error::doing_it_wrong(
107 107
                 'EE_Checkbox_Display_Strategy::display()',
108 108
                 sprintf(
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                     ),
113 113
                     $input->html_id(),
114 114
                     var_export($input->raw_value(), true),
115
-                    $input->html_name() . '[]'
115
+                    $input->html_name().'[]'
116 116
                 ),
117 117
                 '4.8.1'
118 118
             );
@@ -120,19 +120,19 @@  discard block
 block discarded – undo
120 120
 
121 121
 
122 122
         $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv');
123
-        $html .= '<button id="' . $input->html_id() . '-btn"';
123
+        $html .= '<button id="'.$input->html_id().'-btn"';
124 124
         // $html .= ' name="' . $input->html_name() . '"';
125
-        $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"';
126
-        $html .= ' style="' . $input->html_style() . '"';
127
-        $html .= ' data-target="' . $input->html_id() . '-options-dv"';
128
-        $html .= ' ' . $input->other_html_attributes() . '>';
125
+        $html .= ' class="'.$input->html_class().' checkbox-dropdown-selector-btn button-secondary button"';
126
+        $html .= ' style="'.$input->html_style().'"';
127
+        $html .= ' data-target="'.$input->html_id().'-options-dv"';
128
+        $html .= ' '.$input->other_html_attributes().'>';
129 129
         $html .= '<span class="checkbox-dropdown-selector-selected-spn">';
130 130
         $html .= $select_button_text;
131 131
         $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>';
132 132
         $html .= '</button>';
133 133
         $html .= EEH_HTML::div(
134 134
             '',
135
-            $input->html_id() . '-options-dv',
135
+            $input->html_id().'-options-dv',
136 136
             'checkbox-dropdown-selector'
137 137
         );
138 138
         $html .= EEH_HTML::link(
@@ -158,18 +158,18 @@  discard block
 block discarded – undo
158 158
                      . '">';
159 159
             $html .= EEH_HTML::nl(1, 'checkbox');
160 160
             $html .= '<input type="checkbox"';
161
-            $html .= ' name="' . $input->html_name() . '[]"';
162
-            $html .= ' id="' . $html_id . '"';
163
-            $html .= ' class="' . $input->html_class() . '-option"';
164
-            $html .= $input->html_style() ? ' style="' . $input->html_style() . '"' : '';
165
-            $html .= ' value="' . esc_attr($value) . '"';
161
+            $html .= ' name="'.$input->html_name().'[]"';
162
+            $html .= ' id="'.$html_id.'"';
163
+            $html .= ' class="'.$input->html_class().'-option"';
164
+            $html .= $input->html_style() ? ' style="'.$input->html_style().'"' : '';
165
+            $html .= ' value="'.esc_attr($value).'"';
166 166
             $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
167 167
                 ? ' checked'
168 168
                 : '';
169
-            $html .= ' ' . $this->_input->other_html_attributes();
169
+            $html .= ' '.$this->_input->other_html_attributes();
170 170
             $html .= '>';
171
-            $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>';
172
-            $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
171
+            $html .= '<span class="datetime-selector-option-text-spn">'.$display_text.'</span>';
172
+            $html .= EEH_HTML::nl(-1, 'checkbox').'</label>';
173 173
             $html .= EEH_HTML::lix();
174 174
         }
175 175
         $html .= EEH_HTML::ulx();
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
                     'event_espresso'
184 184
                 )
185 185
             ),
186
-            $input->html_id() . '-date-time-filter-notice-pg',
186
+            $input->html_id().'-date-time-filter-notice-pg',
187 187
             'date-time-filter-notice-pg small-text lt-grey-text'
188 188
         );
189 189
         $html .= \EEH_HTML::br();
Please login to merge, or discard this patch.
form_sections/strategies/display/EE_Checkbox_Display_Strategy.strategy.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -12,60 +12,60 @@
 block discarded – undo
12 12
 class EE_Checkbox_Display_Strategy extends EE_Compound_Input_Display_Strategy
13 13
 {
14 14
 
15
-    /**
16
-     * @throws EE_Error
17
-     * @return string of html to display the field
18
-     */
19
-    public function display()
20
-    {
21
-        $input = $this->get_input();
22
-        $input->set_label_sizes();
23
-        $label_size_class = $input->get_label_size_class();
24
-        $html = '';
25
-        if (! is_array($input->raw_value()) && $input->raw_value() !== null) {
26
-            EE_Error::doing_it_wrong(
27
-                'EE_Checkbox_Display_Strategy::display()',
28
-                sprintf(
29
-                    esc_html_x(
30
-                        'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"',
31
-                        'Input values for checkboxes should be an array of values, but the value for input "form-input-id" is "form-input-value". Please verify that the input name is exactly "form_input_name[]"',
32
-                        'event_espresso'
33
-                    ),
34
-                    $input->html_id(),
35
-                    var_export($input->raw_value(), true),
36
-                    $input->html_name() . '[]'
37
-                ),
38
-                '4.8.1'
39
-            );
40
-        }
41
-        $input_raw_value = (array) $input->raw_value();
42
-        foreach ($input->options() as $value => $display_text) {
43
-            $value = $input->get_normalization_strategy()->unnormalize_one($value);
44
-            $html_id = $this->get_sub_input_id($value);
45
-            $html .= EEH_HTML::nl(0, 'checkbox');
46
-            $html .= '<label for="'
47
-                     . $html_id
48
-                     . '" id="'
49
-                     . $html_id
50
-                     . '-lbl" class="ee-checkbox-label-after'
51
-                     . $label_size_class
52
-                     . '">';
53
-            $html .= EEH_HTML::nl(1, 'checkbox');
54
-            $html .= '<input type="checkbox"';
55
-            $html .= ' name="' . $input->html_name() . '[]"';
56
-            $html .= ' id="' . $html_id . '"';
57
-            $html .= ' class="' . $input->html_class() . '"';
58
-            $html .= ' style="' . $input->html_style() . '"';
59
-            $html .= ' value="' . esc_attr($value) . '"';
60
-            $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
61
-                ? ' checked'
62
-                : '';
63
-            $html .= ' ' . $this->_input->other_html_attributes();
64
-            $html .= ' data-question_label="' . $input->html_label_id() . '"';
65
-            $html .= '>&nbsp;';
66
-            $html .= $display_text;
67
-            $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
68
-        }
69
-        return $html;
70
-    }
15
+	/**
16
+	 * @throws EE_Error
17
+	 * @return string of html to display the field
18
+	 */
19
+	public function display()
20
+	{
21
+		$input = $this->get_input();
22
+		$input->set_label_sizes();
23
+		$label_size_class = $input->get_label_size_class();
24
+		$html = '';
25
+		if (! is_array($input->raw_value()) && $input->raw_value() !== null) {
26
+			EE_Error::doing_it_wrong(
27
+				'EE_Checkbox_Display_Strategy::display()',
28
+				sprintf(
29
+					esc_html_x(
30
+						'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"',
31
+						'Input values for checkboxes should be an array of values, but the value for input "form-input-id" is "form-input-value". Please verify that the input name is exactly "form_input_name[]"',
32
+						'event_espresso'
33
+					),
34
+					$input->html_id(),
35
+					var_export($input->raw_value(), true),
36
+					$input->html_name() . '[]'
37
+				),
38
+				'4.8.1'
39
+			);
40
+		}
41
+		$input_raw_value = (array) $input->raw_value();
42
+		foreach ($input->options() as $value => $display_text) {
43
+			$value = $input->get_normalization_strategy()->unnormalize_one($value);
44
+			$html_id = $this->get_sub_input_id($value);
45
+			$html .= EEH_HTML::nl(0, 'checkbox');
46
+			$html .= '<label for="'
47
+					 . $html_id
48
+					 . '" id="'
49
+					 . $html_id
50
+					 . '-lbl" class="ee-checkbox-label-after'
51
+					 . $label_size_class
52
+					 . '">';
53
+			$html .= EEH_HTML::nl(1, 'checkbox');
54
+			$html .= '<input type="checkbox"';
55
+			$html .= ' name="' . $input->html_name() . '[]"';
56
+			$html .= ' id="' . $html_id . '"';
57
+			$html .= ' class="' . $input->html_class() . '"';
58
+			$html .= ' style="' . $input->html_style() . '"';
59
+			$html .= ' value="' . esc_attr($value) . '"';
60
+			$html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
61
+				? ' checked'
62
+				: '';
63
+			$html .= ' ' . $this->_input->other_html_attributes();
64
+			$html .= ' data-question_label="' . $input->html_label_id() . '"';
65
+			$html .= '>&nbsp;';
66
+			$html .= $display_text;
67
+			$html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
68
+		}
69
+		return $html;
70
+	}
71 71
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
         $input->set_label_sizes();
23 23
         $label_size_class = $input->get_label_size_class();
24 24
         $html = '';
25
-        if (! is_array($input->raw_value()) && $input->raw_value() !== null) {
25
+        if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) {
26 26
             EE_Error::doing_it_wrong(
27 27
                 'EE_Checkbox_Display_Strategy::display()',
28 28
                 sprintf(
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
                     ),
34 34
                     $input->html_id(),
35 35
                     var_export($input->raw_value(), true),
36
-                    $input->html_name() . '[]'
36
+                    $input->html_name().'[]'
37 37
                 ),
38 38
                 '4.8.1'
39 39
             );
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
                      . '">';
53 53
             $html .= EEH_HTML::nl(1, 'checkbox');
54 54
             $html .= '<input type="checkbox"';
55
-            $html .= ' name="' . $input->html_name() . '[]"';
56
-            $html .= ' id="' . $html_id . '"';
57
-            $html .= ' class="' . $input->html_class() . '"';
58
-            $html .= ' style="' . $input->html_style() . '"';
59
-            $html .= ' value="' . esc_attr($value) . '"';
55
+            $html .= ' name="'.$input->html_name().'[]"';
56
+            $html .= ' id="'.$html_id.'"';
57
+            $html .= ' class="'.$input->html_class().'"';
58
+            $html .= ' style="'.$input->html_style().'"';
59
+            $html .= ' value="'.esc_attr($value).'"';
60 60
             $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
61 61
                 ? ' checked'
62 62
                 : '';
63
-            $html .= ' ' . $this->_input->other_html_attributes();
64
-            $html .= ' data-question_label="' . $input->html_label_id() . '"';
63
+            $html .= ' '.$this->_input->other_html_attributes();
64
+            $html .= ' data-question_label="'.$input->html_label_id().'"';
65 65
             $html .= '>&nbsp;';
66 66
             $html .= $display_text;
67
-            $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
67
+            $html .= EEH_HTML::nl(-1, 'checkbox').'</label>';
68 68
         }
69 69
         return $html;
70 70
     }
Please login to merge, or discard this patch.
form_sections/strategies/display/EE_Select_Display_Strategy.strategy.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -15,78 +15,78 @@
 block discarded – undo
15 15
 class EE_Select_Display_Strategy extends EE_Display_Strategy_Base
16 16
 {
17 17
 
18
-    /**
19
-     *
20
-     * @throws EE_Error
21
-     * @return string of html to display the field
22
-     */
23
-    public function display()
24
-    {
25
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
26
-            throw new EE_Error(sprintf(esc_html__('Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso')));
27
-        }
18
+	/**
19
+	 *
20
+	 * @throws EE_Error
21
+	 * @return string of html to display the field
22
+	 */
23
+	public function display()
24
+	{
25
+		if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
26
+			throw new EE_Error(sprintf(esc_html__('Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso')));
27
+		}
28 28
 
29
-        $html = EEH_HTML::nl(0, 'select');
30
-        $html .= '<select';
31
-        $html .= $this->_attributes_string(
32
-            $this->_standard_attributes_array()
33
-        );
34
-        $html .= '>';
29
+		$html = EEH_HTML::nl(0, 'select');
30
+		$html .= '<select';
31
+		$html .= $this->_attributes_string(
32
+			$this->_standard_attributes_array()
33
+		);
34
+		$html .= '>';
35 35
 
36
-        if (EEH_Array::is_multi_dimensional_array($this->_input->options())) {
37
-            EEH_HTML::indent(1, 'optgroup');
38
-            foreach ($this->_input->options() as $opt_group_label => $opt_group) {
39
-                if (! empty($opt_group_label)) {
40
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
41
-                }
42
-                EEH_HTML::indent(1, 'option');
43
-                $html .= $this->_display_options($opt_group);
44
-                EEH_HTML::indent(-1, 'option');
45
-                if (! empty($opt_group_label)) {
46
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '</optgroup>';
47
-                }
48
-            }
49
-            EEH_HTML::indent(-1, 'optgroup');
50
-        } else {
51
-            $html .= $this->_display_options($this->_input->options());
52
-        }
36
+		if (EEH_Array::is_multi_dimensional_array($this->_input->options())) {
37
+			EEH_HTML::indent(1, 'optgroup');
38
+			foreach ($this->_input->options() as $opt_group_label => $opt_group) {
39
+				if (! empty($opt_group_label)) {
40
+					$html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
41
+				}
42
+				EEH_HTML::indent(1, 'option');
43
+				$html .= $this->_display_options($opt_group);
44
+				EEH_HTML::indent(-1, 'option');
45
+				if (! empty($opt_group_label)) {
46
+					$html .= EEH_HTML::nl(0, 'optgroup') . '</optgroup>';
47
+				}
48
+			}
49
+			EEH_HTML::indent(-1, 'optgroup');
50
+		} else {
51
+			$html .= $this->_display_options($this->_input->options());
52
+		}
53 53
 
54
-        $html .= EEH_HTML::nl(0, 'select') . '</select>';
55
-        return $html;
56
-    }
54
+		$html .= EEH_HTML::nl(0, 'select') . '</select>';
55
+		return $html;
56
+	}
57 57
 
58 58
 
59 59
 
60
-    /**
61
-     * Displays a flat list of options as option tags
62
-     * @param array $options
63
-     * @return string
64
-     */
65
-    protected function _display_options($options)
66
-    {
67
-        $html = '';
68
-        EEH_HTML::indent(1, 'option');
69
-        foreach ($options as $value => $display_text) {
70
-            // even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123",
71
-            // PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
72
-            $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value);
73
-            $selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected' : '';
74
-            $html .= EEH_HTML::nl(0, 'option') . '<option value="' . esc_attr($unnormalized_value) . '"' . $selected . '>' . $display_text . '</option>';
75
-        }
76
-        EEH_HTML::indent(-1, 'option');
77
-        return $html;
78
-    }
60
+	/**
61
+	 * Displays a flat list of options as option tags
62
+	 * @param array $options
63
+	 * @return string
64
+	 */
65
+	protected function _display_options($options)
66
+	{
67
+		$html = '';
68
+		EEH_HTML::indent(1, 'option');
69
+		foreach ($options as $value => $display_text) {
70
+			// even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123",
71
+			// PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
72
+			$unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value);
73
+			$selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected' : '';
74
+			$html .= EEH_HTML::nl(0, 'option') . '<option value="' . esc_attr($unnormalized_value) . '"' . $selected . '>' . $display_text . '</option>';
75
+		}
76
+		EEH_HTML::indent(-1, 'option');
77
+		return $html;
78
+	}
79 79
 
80 80
 
81 81
 
82
-    /**
83
-     * Checks if that value is the one selected
84
-     *
85
-     * @param string|int $option_value unnormalized value option (string). How it will appear in the HTML.
86
-     * @return string
87
-     */
88
-    protected function _check_if_option_selected($option_value)
89
-    {
90
-        return $option_value === $this->_input->raw_value();
91
-    }
82
+	/**
83
+	 * Checks if that value is the one selected
84
+	 *
85
+	 * @param string|int $option_value unnormalized value option (string). How it will appear in the HTML.
86
+	 * @return string
87
+	 */
88
+	protected function _check_if_option_selected($option_value)
89
+	{
90
+		return $option_value === $this->_input->raw_value();
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public function display()
24 24
     {
25
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
25
+        if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) {
26 26
             throw new EE_Error(sprintf(esc_html__('Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso')));
27 27
         }
28 28
 
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
         if (EEH_Array::is_multi_dimensional_array($this->_input->options())) {
37 37
             EEH_HTML::indent(1, 'optgroup');
38 38
             foreach ($this->_input->options() as $opt_group_label => $opt_group) {
39
-                if (! empty($opt_group_label)) {
40
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
39
+                if ( ! empty($opt_group_label)) {
40
+                    $html .= EEH_HTML::nl(0, 'optgroup').'<optgroup label="'.esc_attr($opt_group_label).'">';
41 41
                 }
42 42
                 EEH_HTML::indent(1, 'option');
43 43
                 $html .= $this->_display_options($opt_group);
44 44
                 EEH_HTML::indent(-1, 'option');
45
-                if (! empty($opt_group_label)) {
46
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '</optgroup>';
45
+                if ( ! empty($opt_group_label)) {
46
+                    $html .= EEH_HTML::nl(0, 'optgroup').'</optgroup>';
47 47
                 }
48 48
             }
49 49
             EEH_HTML::indent(-1, 'optgroup');
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             $html .= $this->_display_options($this->_input->options());
52 52
         }
53 53
 
54
-        $html .= EEH_HTML::nl(0, 'select') . '</select>';
54
+        $html .= EEH_HTML::nl(0, 'select').'</select>';
55 55
         return $html;
56 56
     }
57 57
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             // PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
72 72
             $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value);
73 73
             $selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected' : '';
74
-            $html .= EEH_HTML::nl(0, 'option') . '<option value="' . esc_attr($unnormalized_value) . '"' . $selected . '>' . $display_text . '</option>';
74
+            $html .= EEH_HTML::nl(0, 'option').'<option value="'.esc_attr($unnormalized_value).'"'.$selected.'>'.$display_text.'</option>';
75 75
         }
76 76
         EEH_HTML::indent(-1, 'option');
77 77
         return $html;
Please login to merge, or discard this patch.