Completed
Branch FET/11183/improvements-to-pue-... (232f50)
by
unknown
43:46 queued 26:36
created
templates/txn_admin_details_main_meta_box_txn_details.template.php 3 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
                                 <div id="payment-accntng-<?php echo $PAY_ID; ?>"><?php echo $payment->extra_accntng(); ?></div>
160 160
                             </td>
161 161
                             <td class=" jst-rght">
162
-                                <?php $payment_class = $payment->amount() > 0 ? 'txn-admin-payment-status-' . $payment->STS_ID() : 'txn-admin-payment-status-PDC'; ?>
162
+                                <?php $payment_class = $payment->amount() > 0 ? 'txn-admin-payment-status-'.$payment->STS_ID() : 'txn-admin-payment-status-PDC'; ?>
163 163
                                 <span class="<?php echo $payment_class; ?>">
164 164
 							<div id="payment-amount-<?php echo $PAY_ID; ?>"
165 165
                                  style="display:inline;"><?php echo EEH_Template::format_currency($payment->amount(),
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
                     <?php endforeach; // $payment?>
174 174
                     <?php
175 175
                     $pay_totals_class = $payment_total > $grand_raw_total ? ' important-notice' : '';
176
-                    $overpaid = $payment_total > $grand_raw_total ? '<span id="overpaid">' . esc_html__('This transaction has been overpaid ! ',
177
-                            'event_espresso') . '</span>' : '';
176
+                    $overpaid = $payment_total > $grand_raw_total ? '<span id="overpaid">'.esc_html__('This transaction has been overpaid ! ',
177
+                            'event_espresso').'</span>' : '';
178 178
                     ?>
179 179
                     <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr hidden">
180 180
                         <td class=" jst-rght" colspan="11">
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
                     <tr id="txn-admin-payments-total-tr"
185 185
                         class="admin-primary-mbox-total-tr<?php echo $pay_totals_class; ?>">
186 186
                         <th class=" jst-rght" colspan="10"><span
187
-                                    id="payments-total-spn"><?php echo $overpaid . sprintf(esc_html__('Payments Total %s',
187
+                                    id="payments-total-spn"><?php echo $overpaid.sprintf(esc_html__('Payments Total %s',
188 188
                                         'event_espresso'),
189
-                                        '(' . EE_Registry::instance()->CFG->currency->code . ')'); ?></span></th>
189
+                                        '('.EE_Registry::instance()->CFG->currency->code.')'); ?></span></th>
190 190
                         <th class=" jst-rght"><span
191 191
                                     id="txn-admin-payment-total"><?php echo EEH_Template::format_currency($payment_total,
192 192
                                     false, false); ?></span></th>
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
             <h2 id="admin-modal-dialog-apply-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon"
300 300
                 style="display:none;">
301 301
                 <div class="ee-icon ee-icon-cash-add float-left"></div>
302
-                <?php echo esc_html__('Apply a Payment to Transaction #', 'event_espresso') . $txn_nmbr['value']; ?>
302
+                <?php echo esc_html__('Apply a Payment to Transaction #', 'event_espresso').$txn_nmbr['value']; ?>
303 303
             </h2>
304 304
 
305 305
             <h2 id="admin-modal-dialog-edit-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon"
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
             <h2 id="admin-modal-dialog-apply-refund-h2" class="admin-modal-dialog-h2 hdr-has-icon"
329 329
                 style="display:none;">
330 330
                 <div class="ee-icon ee-icon-cash-remove float-left"></div>
331
-                <?php echo esc_html__('Apply a Refund to Transaction #', 'event_espresso') . $txn_nmbr['value']; ?>
331
+                <?php echo esc_html__('Apply a Refund to Transaction #', 'event_espresso').$txn_nmbr['value']; ?>
332 332
             </h2>
333 333
 
334 334
             <form name="txn-admin-apply-payment-frm" id="txn-admin-apply-payment-frm"
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
                 style="display:none;">
558 558
                 <span class="ee-icon ee-icon-cash-add"></span>
559 559
                 <?php echo esc_html__('Delete Payment/Refund for Transaction #',
560
-                        'event_espresso') . $txn_nmbr['value']; ?>
560
+                        'event_espresso').$txn_nmbr['value']; ?>
561 561
             </h2>
562 562
 
563 563
             <form name="txn-admin-delete-payment-frm" id="txn-admin-delete-payment-frm"
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
                     <?php foreach ($delivered_messages[$TXN_ID] as $timestamp => $delivered_message) :
644 644
                         ?>
645 645
                         <tr>
646
-                            <td class="jst-left"><?php echo date(get_option('date_format') . ' ' . get_option('time_format'),
646
+                            <td class="jst-left"><?php echo date(get_option('date_format').' '.get_option('time_format'),
647 647
                                     ($timestamp + (get_option('gmt_offset') * HOUR_IN_SECONDS))); ?></td>
648 648
                             <td class="jst-left"><?php echo isset($delivered_message['message_type']) ? $delivered_message['message_type'] : ''; ?></td>
649 649
                             <td class="jst-left"><?php echo isset($delivered_message['pay_status']) ? $delivered_message['pay_status'] : ''; ?></td>
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -191,10 +191,13 @@  discard block
 block discarded – undo
191 191
                                     id="txn-admin-payment-total"><?php echo EEH_Template::format_currency($payment_total,
192 192
                                     false, false); ?></span></th>
193 193
                     </tr>
194
-                <?php else : ?>
194
+                <?php else {
195
+	: ?>
195 196
                     <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr">
196 197
                         <td class=" jst-rght" colspan="11">
197
-                            <span class="important-notice"><?php echo $no_payment_text; ?></span>
198
+                            <span class="important-notice"><?php echo $no_payment_text;
199
+}
200
+?></span>
198 201
                         </td>
199 202
                     </tr>
200 203
                     <tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr hidden">
@@ -285,10 +288,13 @@  discard block
 block discarded – undo
285 288
                         <?php esc_html_e('Apply Refund', 'event_espresso'); ?>
286 289
                     </a>
287 290
                 </li>
288
-            <?php else : ?>
291
+            <?php else {
292
+	: ?>
289 293
                 <li>
290 294
                     <p><?php esc_html__('You do not have access to apply payments or refunds.',
291
-                            'event_espresso'); ?></p>
295
+                            'event_espresso');
296
+}
297
+?></p>
292 298
                 </li>
293 299
             <?php endif; ?>
294 300
         </ul>
Please login to merge, or discard this patch.
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     <a id="display-additional-transaction-session-info" class="display-the-hidden smaller-text"
13 13
        rel="additional-transaction-session-info">
14 14
         <span class="dashicons dashicons-plus-alt"></span><?php esc_html_e('view additional transaction session details',
15
-            'event_espresso'); ?>
15
+			'event_espresso'); ?>
16 16
     </a>
17 17
 
18 18
     <div id="additional-transaction-session-info-dv" class="hidden">
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
         <a id="hide-additional-transaction-session-info" class="hide-the-displayed hidden smaller-text"
21 21
            rel="additional-transaction-session-info">
22 22
             <span class="dashicons dashicons-dismiss"></span><?php esc_html_e('hide additional transaction session details',
23
-                'event_espresso'); ?>
23
+				'event_espresso'); ?>
24 24
         </a>
25 25
         <br class="clear"/>
26 26
 
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
 
46 46
 
47 47
     <?php if ($attendee instanceof EE_Attendee && ($grand_raw_total > 0 || $TXN_status !== EEM_Transaction::complete_status_code || ! empty($payments))) :
48
-        $no_payment_text = $can_edit_payments
49
-            ? esc_html__(
50
-                'No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.',
51
-                'event_espresso'
52
-            )
53
-            : esc_html__(
54
-                'No payments have been applied to this transaction yet.',
55
-                'event_espresso'
56
-            );
57
-        ?>
48
+		$no_payment_text = $can_edit_payments
49
+			? esc_html__(
50
+				'No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.',
51
+				'event_espresso'
52
+			)
53
+			: esc_html__(
54
+				'No payments have been applied to this transaction yet.',
55
+				'event_espresso'
56
+			);
57
+		?>
58 58
 
59 59
         <h3 class="admin-primary-mbox-h4 hdr-has-icon">
60 60
             <span class="ee-icon ee-icon-cash"></span><?php esc_html_e('Payment Details', 'event_espresso'); ?>
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
                 <?php if ($payments) : ?>
83 83
                     <?php $payment_total = 0; ?>
84 84
                     <?php foreach ($payments as $PAY_ID => $payment) :
85
-                        $existing_reg_payment_json = isset($existing_reg_payments[$PAY_ID])
86
-                            ? wp_json_encode($existing_reg_payments[$PAY_ID])
87
-                            : '{}';
88
-                        ?>
85
+						$existing_reg_payment_json = isset($existing_reg_payments[$PAY_ID])
86
+							? wp_json_encode($existing_reg_payments[$PAY_ID])
87
+							: '{}';
88
+						?>
89 89
                         <tr id="txn-admin-payment-tr-<?php echo $PAY_ID; ?>">
90 90
                             <td>
91 91
                                 <span id="payment-status-<?php echo $PAY_ID; ?>"
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
                             <td class=" jst-left">
133 133
                                 <div id="payment-gateway-<?php echo $PAY_ID; ?>">
134 134
                                     <?php echo $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__("Unknown",
135
-                                        'event_espresso'); ?>
135
+										'event_espresso'); ?>
136 136
                                 </div>
137 137
                                 <div id="payment-gateway-id-<?php echo $PAY_ID; ?>"
138 138
                                      class="hidden"><?php echo $payment->payment_method() ? $payment->payment_method()->ID() : 0; ?></div>
@@ -154,19 +154,19 @@  discard block
 block discarded – undo
154 154
                                 <span class="<?php echo $payment_class; ?>">
155 155
 							<div id="payment-amount-<?php echo $PAY_ID; ?>"
156 156
                                  style="display:inline;"><?php echo EEH_Template::format_currency($payment->amount(),
157
-                                    false, false); ?></div>
157
+									false, false); ?></div>
158 158
 						</span>
159 159
                             </td>
160 160
                         </tr>
161 161
                         <?php
162
-                        $payment_total += $payment->STS_ID() == 'PAP' ? $payment->amount() : 0;
163
-                        ?>
162
+						$payment_total += $payment->STS_ID() == 'PAP' ? $payment->amount() : 0;
163
+						?>
164 164
                     <?php endforeach; // $payment?>
165 165
                     <?php
166
-                    $pay_totals_class = $payment_total > $grand_raw_total ? ' important-notice' : '';
167
-                    $overpaid = $payment_total > $grand_raw_total ? '<span id="overpaid">' . esc_html__('This transaction has been overpaid ! ',
168
-                            'event_espresso') . '</span>' : '';
169
-                    ?>
166
+					$pay_totals_class = $payment_total > $grand_raw_total ? ' important-notice' : '';
167
+					$overpaid = $payment_total > $grand_raw_total ? '<span id="overpaid">' . esc_html__('This transaction has been overpaid ! ',
168
+							'event_espresso') . '</span>' : '';
169
+					?>
170 170
                     <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr hidden">
171 171
                         <td class=" jst-rght" colspan="11">
172 172
                             <span class="important-notice"><?php echo $no_payment_text; ?></span>
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
                         class="admin-primary-mbox-total-tr<?php echo $pay_totals_class; ?>">
177 177
                         <th class=" jst-rght" colspan="10"><span
178 178
                                     id="payments-total-spn"><?php echo $overpaid . sprintf(esc_html__('Payments Total %s',
179
-                                        'event_espresso'),
180
-                                        '(' . EE_Registry::instance()->CFG->currency->code . ')'); ?></span></th>
179
+										'event_espresso'),
180
+										'(' . EE_Registry::instance()->CFG->currency->code . ')'); ?></span></th>
181 181
                         <th class=" jst-rght"><span
182 182
                                     id="txn-admin-payment-total"><?php echo EEH_Template::format_currency($payment_total,
183
-                                    false, false); ?></span></th>
183
+									false, false); ?></span></th>
184 184
                     </tr>
185 185
                 <?php else : ?>
186 186
                     <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr">
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
                     <tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr hidden">
192 192
                         <th class=" jst-rght" colspan="10"><span
193 193
                                     id="payments-total-spn"><?php echo esc_html__('Payments Total',
194
-                                    'event_espresso'); ?></span></th>
194
+									'event_espresso'); ?></span></th>
195 195
                         <th class=" jst-rght"><span id="txn-admin-payment-total"></span></th>
196 196
                     </tr>
197 197
                 <?php endif; // $payments
198
-                ?>
198
+				?>
199 199
 
200 200
                 <tr id="txn-admin-payment-empty-row-tr" class="hidden">
201 201
                     <td>
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 
261 261
         <ul id="txn-admin-payment-options-ul">
262 262
             <?php if ($can_edit_payments) :
263
-                ?>
263
+				?>
264 264
                 <li>
265 265
                     <a id="display-txn-admin-apply-payment" class="button-primary no-icon no-hide"
266 266
                        rel="txn-admin-apply-payment"> <!--display-the-hidden -->
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
             <?php else : ?>
277 277
                 <li>
278 278
                     <p><?php esc_html__('You do not have access to apply payments or refunds.',
279
-                            'event_espresso'); ?></p>
279
+							'event_espresso'); ?></p>
280 280
                 </li>
281 281
             <?php endif; ?>
282 282
         </ul>
@@ -294,23 +294,23 @@  discard block
 block discarded – undo
294 294
                 style="display:none;">
295 295
                 <div class="ee-icon ee-icon-cash-edit float-left"></div>
296 296
                 <?php
297
-                echo sprintf(
298
-                    __('Edit Payment #%s for Transaction #%s', 'event_espresso'),
299
-                    '<span></span>',
300
-                    $txn_nmbr['value']
301
-                );
302
-                ?>
297
+				echo sprintf(
298
+					__('Edit Payment #%s for Transaction #%s', 'event_espresso'),
299
+					'<span></span>',
300
+					$txn_nmbr['value']
301
+				);
302
+				?>
303 303
             </h2>
304 304
 
305 305
             <h2 id="admin-modal-dialog-edit-refund-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;">
306 306
                 <div class="ee-icon ee-icon-cash-edit float-left"></div>
307 307
                 <?php
308
-                echo sprintf(
309
-                    __('Edit Refund #%s for Transaction #%s', 'event_espresso'),
310
-                    '<span></span>',
311
-                    $txn_nmbr['value']
312
-                );
313
-                ?>
308
+				echo sprintf(
309
+					__('Edit Refund #%s for Transaction #%s', 'event_espresso'),
310
+					'<span></span>',
311
+					$txn_nmbr['value']
312
+				);
313
+				?>
314 314
             </h2>
315 315
 
316 316
             <h2 id="admin-modal-dialog-apply-refund-h2" class="admin-modal-dialog-h2 hdr-has-icon"
@@ -343,55 +343,55 @@  discard block
 block discarded – undo
343 343
 
344 344
                         <div class="txn-admin-apply-payment-date-dv admin-modal-dialog-row">
345 345
                             <div class="validation-notice-dv"><?php esc_html_e('The following is  a required field',
346
-                                    'event_espresso'); ?></div>
346
+									'event_espresso'); ?></div>
347 347
                             <label for="txn-admin-payment-date-inp" class=""><?php esc_html_e('Payment Date',
348
-                                    'event_espresso'); ?></label>
348
+									'event_espresso'); ?></label>
349 349
                             <input name="txn_admin_payment[date]" id="txn-admin-payment-date-inp"
350 350
                                    class="txn-admin-apply-payment-inp required" type="text"
351 351
                                    value="<?php echo date('Y-m-d g:i a', current_time('timestamp')); ?>"/>
352 352
                             <p class="description"><?php esc_html_e('The date the payment was actually made on',
353
-                                    'event_espresso'); ?></p>
353
+									'event_espresso'); ?></p>
354 354
                         </div>
355 355
 
356 356
                         <div class="txn-admin-apply-payment-amount-dv admin-modal-dialog-row">
357 357
                             <div class="validation-notice-dv"><?php esc_html_e('The following is  a required field',
358
-                                    'event_espresso'); ?></div>
358
+									'event_espresso'); ?></div>
359 359
                             <label for="txn-admin-payment-amount-inp" class=""><?php esc_html_e('Amount',
360
-                                    'event_espresso'); ?></label>
360
+									'event_espresso'); ?></label>
361 361
                             <input name="txn_admin_payment[amount]" id="txn-admin-payment-amount-inp"
362 362
                                    class="txn-admin-apply-payment-inp required" type="text" value=""/>
363 363
                             <p class="description"><?php esc_html_e('The amount of the payment',
364
-                                    'event_espresso'); ?></p>
364
+									'event_espresso'); ?></p>
365 365
                         </div>
366 366
 
367 367
                         <div class="txn-admin-apply-payment-method-dv admin-modal-dialog-row">
368 368
                             <div class="validation-notice-dv"><?php esc_html_e('The following is  a required field',
369
-                                    'event_espresso'); ?></div>
369
+									'event_espresso'); ?></div>
370 370
                             <label for="txn-admin-payment-method-inp" class=""><?php esc_html_e('Method of Payment',
371
-                                    'event_espresso'); ?></label>
371
+									'event_espresso'); ?></label>
372 372
                             <select name="txn_admin_payment[PMD_ID]" id="txn-admin-payment-method-slct"
373 373
                                     class="txn-admin-apply-payment-slct required" type="text">
374 374
                                 <?php foreach ($payment_methods as $method) : ?>
375 375
                                     <?php $selected = $method->slug() == 'cash' ? ' selected="selected"' : ''; ?>
376 376
                                     <option id="payment-method-opt-<?php echo $method->slug(); ?>"
377 377
                                             value="<?php echo $method->ID(); ?>"<?php echo $selected; ?>><?php echo sanitize_key($method->admin_desc()) ? substr($method->admin_desc(),
378
-                                            0, 128) : $method->admin_name(); ?>&nbsp;&nbsp;
378
+											0, 128) : $method->admin_name(); ?>&nbsp;&nbsp;
379 379
                                     </option>
380 380
                                 <?php endforeach; ?>
381 381
                             </select>
382 382
                             <p class="description"><?php esc_html_e('Whether the payment was made via PayPal, Credit Card, Cheque, or Cash',
383
-                                    'event_espresso'); ?></p>
383
+									'event_espresso'); ?></p>
384 384
                         </div>
385 385
 
386 386
                         <div class="mop-PP mop-CC mop-CHQ mop">
387 387
                             <div class="txn-admin-apply-payment-gw-txn-id-dv admin-modal-dialog-row">
388 388
                                 <label for="txn-admin-payment-txn-id-inp" class=""><?php esc_html_e('TXN ID / CHQ #',
389
-                                        'event_espresso'); ?></label>
389
+										'event_espresso'); ?></label>
390 390
                                 <input name="txn_admin_payment[txn_id_chq_nmbr]"
391 391
                                        id="txn-admin-payment-txn-id-chq-nmbr-inp" class="txn-admin-apply-payment-inp"
392 392
                                        type="text" maxlength="100"/>
393 393
                                 <p class="description"><?php esc_html_e('The Transaction ID sent back from the payment gateway, or the Cheque #',
394
-                                        'event_espresso'); ?></p>
394
+										'event_espresso'); ?></p>
395 395
                             </div>
396 396
                         </div>
397 397
 
@@ -403,14 +403,14 @@  discard block
 block discarded – undo
403 403
                                        id="txn-admin-payment-gateway-response-inp" class="txn-admin-apply-payment-inp"
404 404
                                        type="text"/>
405 405
                                 <p class="description"><?php esc_html_e('The gateway response string (optional)',
406
-                                        'event_espresso'); ?></p>
406
+										'event_espresso'); ?></p>
407 407
                             </div>
408 408
                         </div>
409 409
 
410 410
                         <div class="mop-PP mop-CC mop">
411 411
                             <div class="txn-admin-apply-payment-status-dv admin-modal-dialog-row">
412 412
                                 <label for="txn-admin-payment-status-inp" class=""><?php esc_html_e('Payment Status',
413
-                                        'event_espresso'); ?></label>
413
+										'event_espresso'); ?></label>
414 414
                                 <select name="txn_admin_payment[status]" id="txn-admin-payment-status-slct"
415 415
                                         class="txn-admin-apply-payment-slct" type="text">
416 416
                                     <?php foreach ($payment_status as $STS_ID => $STS_code) : ?>
@@ -422,35 +422,35 @@  discard block
 block discarded – undo
422 422
                                     <?php endforeach; ?>
423 423
                                 </select>
424 424
                                 <p class="description"><?php esc_html_e('Whether the payment was approved, cancelled, declined or failed after submission to the gateway',
425
-                                        'event_espresso'); ?></p>
425
+										'event_espresso'); ?></p>
426 426
                             </div>
427 427
                         </div>
428 428
 
429 429
                         <div class="txn-admin-apply-payment-po-nmbr-dv admin-modal-dialog-row">
430 430
                             <label for="txn-admin-payment-po-nmbr-inp" class=""><?php esc_html_e('P.O. / S.O. #',
431
-                                    'event_espresso'); ?></label>
431
+									'event_espresso'); ?></label>
432 432
                             <input name="txn_admin_payment[po_number]" id="txn-admin-payment-po-nmbr-inp"
433 433
                                    class="txn-admin-apply-payment-inp" type="text" maxlength="100"/>
434 434
                             <p class="description"><?php esc_html_e('The Purchase or Sales Order Number if any (optional)',
435
-                                    'event_espresso'); ?></p>
435
+									'event_espresso'); ?></p>
436 436
                         </div>
437 437
 
438 438
                         <div class="txn-admin-apply-payment-accounting-dv admin-modal-dialog-row">
439 439
                             <label for="txn-admin-payment-accounting-inp"
440 440
                                    class="last"><?php esc_html_e('Notes / Extra Accounting',
441
-                                    'event_espresso'); ?></label>
441
+									'event_espresso'); ?></label>
442 442
                             <input name="txn_admin_payment[accounting]" id="txn-admin-payment-accounting-inp"
443 443
                                    class="txn-admin-apply-payment-inp" type="text" value="<?php echo $REG_code; ?>"
444 444
                                    maxlength="100"/> <input type="hidden" id="txn-admin-reg-code-inp"
445 445
                                                             value="<?php echo $REG_code; ?>"/>
446 446
                             <p class="description"><?php esc_html_e('An extra field you may use for accounting purposes or simple notes. Defaults to the primary registrant\'s registration code.',
447
-                                    'event_espresso'); ?></p>
447
+									'event_espresso'); ?></p>
448 448
                         </div>
449 449
 
450 450
                         <div class="txn-admin-apply-payment-registrations-dv admin-modal-dialog-row">
451 451
                             <label for="txn-admin-payment-registrations-inp"
452 452
                                    class="last"><?php esc_html_e('Registrations to Apply Payment to:',
453
-                                    'event_espresso'); ?></label>
453
+									'event_espresso'); ?></label>
454 454
                             <label class="txn-admin-apply-payment-to-registrations-lbl">
455 455
                                 <input type="radio" value="1" id="txn-admin-apply-payment-to-all-registrations-inp"
456 456
                                        name="txn_admin_payment[apply_to_all_registrations]" checked="checked"/>
@@ -467,10 +467,10 @@  discard block
 block discarded – undo
467 467
                         <div class="txn-admin-payment-reg-status-dv admin-modal-dialog-row">
468 468
                             <label for="txn-admin-payment-reg-status-inp"
469 469
                                    class="last"><?php esc_html_e('Change Registration Status?',
470
-                                    'event_espresso'); ?></label>
470
+									'event_espresso'); ?></label>
471 471
                             <?php echo $status_change_select; ?>
472 472
                             <p class="description"><?php esc_html_e('If you wish to change the status for the registrations selected above, then select which status from this dropdown.',
473
-                                    'event_espresso'); ?></p>
473
+									'event_espresso'); ?></p>
474 474
                             <br/>
475 475
                         </div>
476 476
 
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
                             </label>
491 491
                             <br class="clear-float"/>
492 492
                             <p class="description"><?php printf(esc_html__('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.',
493
-                                    'event_espresso'), '<strong>', '</strong>', '<br />'); ?></p>
493
+									'event_espresso'), '<strong>', '</strong>', '<br />'); ?></p>
494 494
                             <label></label>
495 495
                         </div>
496 496
                         <div class="clear"></div>
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
                     </li>
531 531
                     <li>
532 532
                         <span id="ee-ajax-processing-text" style="display:none;"><?php esc_html_e('Processing...',
533
-                                'event_espresso'); ?></span>
533
+								'event_espresso'); ?></span>
534 534
                     </li>
535 535
                 </ul>
536 536
 
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
                 style="display:none;">
546 546
                 <span class="ee-icon ee-icon-cash-add"></span>
547 547
                 <?php echo esc_html__('Delete Payment/Refund for Transaction #',
548
-                        'event_espresso') . $txn_nmbr['value']; ?>
548
+						'event_espresso') . $txn_nmbr['value']; ?>
549 549
             </h2>
550 550
 
551 551
             <form name="txn-admin-delete-payment-frm" id="txn-admin-delete-payment-frm"
@@ -566,10 +566,10 @@  discard block
 block discarded – undo
566 566
                         <div class="txn-admin-apply-payment-accounting-dv admin-modal-dialog-row">
567 567
                             <label for="delete-txn-admin-payment-reg-status-inp"
568 568
                                    class="last"><?php esc_html_e('Change Registration Status?',
569
-                                    'event_espresso'); ?></label>
569
+									'event_espresso'); ?></label>
570 570
                             <?php echo $delete_status_change_select; ?>
571 571
                             <p class="description"><?php printf(esc_html__('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',
572
-                                    'event_espresso'), '<strong>', '</strong>'); ?></p>
572
+									'event_espresso'), '<strong>', '</strong>'); ?></p>
573 573
                         </div>
574 574
 
575 575
                         <div class="ee-attention txn-admin-apply-payment-accounting-dv admin-modal-dialog-row">
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
                                    class="last"><?php esc_html_e('Send Related Messages?', 'event_espresso'); ?></label>
578 578
                             <input type="checkbox" value="1" name="delete_txn_reg_status_change[send_notifications]">
579 579
                             <p class="description"><?php esc_html_e('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.',
580
-                                    'event_espresso'); ?></p>
580
+									'event_espresso'); ?></p>
581 581
                         </div>
582 582
                         <div class="clear"></div>
583 583
 
@@ -609,13 +609,13 @@  discard block
 block discarded – undo
609 609
     <?php endif; // $grand_raw_total > 0?>
610 610
 
611 611
     <?php
612
-    if (WP_DEBUG) {
613
-        $delivered_messages = get_option('EED_Messages__payment', array());
614
-        if (isset($delivered_messages[$TXN_ID])) {
615
-            ?>
612
+	if (WP_DEBUG) {
613
+		$delivered_messages = get_option('EED_Messages__payment', array());
614
+		if (isset($delivered_messages[$TXN_ID])) {
615
+			?>
616 616
             <h4 class="admin-primary-mbox-h4 hdr-has-icon"><span
617 617
                         class="dashicons dashicons-email-alt"></span><?php esc_html_e('Messages Sent to Primary Registrant',
618
-                    'event_espresso'); ?></h4>
618
+					'event_espresso'); ?></h4>
619 619
 
620 620
             <div class="admin-primary-mbox-tbl-wrap">
621 621
                 <table class="admin-primary-mbox-tbl">
@@ -629,10 +629,10 @@  discard block
 block discarded – undo
629 629
                     </thead>
630 630
                     <tbody>
631 631
                     <?php foreach ($delivered_messages[$TXN_ID] as $timestamp => $delivered_message) :
632
-                        ?>
632
+						?>
633 633
                         <tr>
634 634
                             <td class="jst-left"><?php echo date(get_option('date_format') . ' ' . get_option('time_format'),
635
-                                    ($timestamp + (get_option('gmt_offset') * HOUR_IN_SECONDS))); ?></td>
635
+									($timestamp + (get_option('gmt_offset') * HOUR_IN_SECONDS))); ?></td>
636 636
                             <td class="jst-left"><?php echo isset($delivered_message['message_type']) ? $delivered_message['message_type'] : ''; ?></td>
637 637
                             <td class="jst-left"><?php echo isset($delivered_message['pay_status']) ? $delivered_message['pay_status'] : ''; ?></td>
638 638
                             <td class="jst-left"><?php echo isset($delivered_message['txn_status']) ? $delivered_message['txn_status'] : ''; ?></td>
@@ -642,9 +642,9 @@  discard block
 block discarded – undo
642 642
                 </table>
643 643
             </div>
644 644
             <?php
645
-        }
646
-    }
647
-    ?>
645
+		}
646
+	}
647
+	?>
648 648
 
649 649
 
650 650
 </div>
Please login to merge, or discard this patch.
widgets/upcoming_events/EEW_Upcoming_Events.widget.php 1 patch
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	public function __construct() {
33 33
 		parent::__construct(
34
-			__( 'Event Espresso Upcoming Events', 'event_espresso' ),
35
-			 array( 'description' => __( 'A widget to display your upcoming events.', 'event_espresso' ))
34
+			__('Event Espresso Upcoming Events', 'event_espresso'),
35
+			 array('description' => __('A widget to display your upcoming events.', 'event_espresso'))
36 36
 		);
37 37
 	}
38 38
 
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 	 * @param array $instance Previously saved values from database.
46 46
 	 * @return string|void
47 47
 	 */
48
-	public function form( $instance ) {
48
+	public function form($instance) {
49 49
 
50
-		EE_Registry::instance()->load_class( 'Question_Option', array(), FALSE, FALSE, TRUE );
50
+		EE_Registry::instance()->load_class('Question_Option', array(), FALSE, FALSE, TRUE);
51 51
 		// Set up some default widget settings.
52 52
 		$defaults = array(
53 53
 			'title' => __('Upcoming Events', 'event_espresso'),
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
 			'image_size' => 'medium'
64 64
 		);
65 65
 
66
-		$instance = wp_parse_args( (array) $instance, $defaults );
66
+		$instance = wp_parse_args((array) $instance, $defaults);
67 67
 		// don't add HTML labels for EE_Form_Fields generated inputs
68
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', '__return_empty_string' );
68
+		add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
69 69
 		$yes_no_values = array(
70
-			EE_Question_Option::new_instance( array( 'QSO_value' => FALSE, 'QSO_desc' => __('No', 'event_espresso'))),
71
-			EE_Question_Option::new_instance( array( 'QSO_value' => TRUE, 'QSO_desc' => __('Yes', 'event_espresso')))
70
+			EE_Question_Option::new_instance(array('QSO_value' => FALSE, 'QSO_desc' => __('No', 'event_espresso'))),
71
+			EE_Question_Option::new_instance(array('QSO_value' => TRUE, 'QSO_desc' => __('Yes', 'event_espresso')))
72 72
 		);
73 73
 		$sort_values = array(
74
-			EE_Question_Option::new_instance( array( 'QSO_value' => 'ASC', 'QSO_desc' => __('ASC', 'event_espresso'))),
75
-			EE_Question_Option::new_instance( array( 'QSO_value' => 'DESC', 'QSO_desc' => __('DESC', 'event_espresso')))
74
+			EE_Question_Option::new_instance(array('QSO_value' => 'ASC', 'QSO_desc' => __('ASC', 'event_espresso'))),
75
+			EE_Question_Option::new_instance(array('QSO_value' => 'DESC', 'QSO_desc' => __('DESC', 'event_espresso')))
76 76
 		);
77 77
 
78 78
 	?>
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 			<label for="<?php echo $this->get_field_id('title'); ?>">
84 84
 				<?php _e('Title:', 'event_espresso'); ?>
85 85
 			</label>
86
-			<input id="<?php echo $this->get_field_id('title'); ?>" class="widefat" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" type="text" />
86
+			<input id="<?php echo $this->get_field_id('title'); ?>" class="widefat" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title']); ?>" type="text" />
87 87
 		</p>
88 88
 		<p>
89 89
 			<label for="<?php echo $this->get_field_id('category_name'); ?>">
@@ -92,16 +92,16 @@  discard block
 block discarded – undo
92 92
 			<?php
93 93
 			$event_categories = array();
94 94
 			/** @type EEM_Term $EEM_Term */
95
-			$EEM_Term = EE_Registry::instance()->load_model( 'Term' );
96
-			$categories = $EEM_Term->get_all_ee_categories( TRUE );
97
-			if ( $categories ) {
98
-				foreach ( $categories as $category ) {
99
-					if ( $category instanceof EE_Term ) {
100
-						$event_categories[] = EE_Question_Option::new_instance( array( 'QSO_value' => $category->get( 'slug' ), 'QSO_desc' => $category->get( 'name' )));
95
+			$EEM_Term = EE_Registry::instance()->load_model('Term');
96
+			$categories = $EEM_Term->get_all_ee_categories(TRUE);
97
+			if ($categories) {
98
+				foreach ($categories as $category) {
99
+					if ($category instanceof EE_Term) {
100
+						$event_categories[] = EE_Question_Option::new_instance(array('QSO_value' => $category->get('slug'), 'QSO_desc' => $category->get('name')));
101 101
 					}
102 102
 				}
103 103
 			}
104
-			array_unshift( $event_categories, EE_Question_Option::new_instance( array( 'QSO_value' => '', 'QSO_desc' => __(' - display all - ', 'event_espresso'))));
104
+			array_unshift($event_categories, EE_Question_Option::new_instance(array('QSO_value' => '', 'QSO_desc' => __(' - display all - ', 'event_espresso'))));
105 105
 			echo EEH_Form_Fields::select(
106 106
 				 __('Event Category:', 'event_espresso'),
107 107
 				$instance['category_name'],
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 				 __('Show Expired Events:', 'event_espresso'),
127 127
 				$instance['show_expired'],
128 128
 				array(
129
-					EE_Question_Option::new_instance( array( 'QSO_value' => 0, 'QSO_desc' => __('No', 'event_espresso'))), 
130
-					EE_Question_Option::new_instance( array( 'QSO_value' => 1, 'QSO_desc' => __('Yes', 'event_espresso'))), 
131
-					EE_Question_Option::new_instance( array( 'QSO_value' => 2, 'QSO_desc' => __('Show Only Expired', 'event_espresso'))), 
129
+					EE_Question_Option::new_instance(array('QSO_value' => 0, 'QSO_desc' => __('No', 'event_espresso'))), 
130
+					EE_Question_Option::new_instance(array('QSO_value' => 1, 'QSO_desc' => __('Yes', 'event_espresso'))), 
131
+					EE_Question_Option::new_instance(array('QSO_value' => 2, 'QSO_desc' => __('Show Only Expired', 'event_espresso'))), 
132 132
 				),
133 133
 				$this->get_field_name('show_expired'),
134 134
 				$this->get_field_id('show_expired')
@@ -156,16 +156,16 @@  discard block
 block discarded – undo
156 156
 			<?php
157 157
 			$image_sizes = array();
158 158
 			$sizes = get_intermediate_image_sizes();
159
-			if ( $sizes ) {
159
+			if ($sizes) {
160 160
 				// loop thru images and create option objects out of them
161
-				foreach ( $sizes as $image_size ) {
162
-					$image_size = trim( $image_size );
161
+				foreach ($sizes as $image_size) {
162
+					$image_size = trim($image_size);
163 163
 					// no big images plz
164
-					if ( ! in_array( $image_size, array( 'large', 'post-thumbnail' ))) {
165
-						$image_sizes[] = EE_Question_Option::new_instance( array( 'QSO_value' => $image_size, 'QSO_desc' => $image_size ));
164
+					if ( ! in_array($image_size, array('large', 'post-thumbnail'))) {
165
+						$image_sizes[] = EE_Question_Option::new_instance(array('QSO_value' => $image_size, 'QSO_desc' => $image_size));
166 166
 					}
167 167
 				}
168
-				$image_sizes[] = EE_Question_Option::new_instance( array( 'QSO_value' => 'none', 'QSO_desc' =>  __('don\'t show images', 'event_espresso') ));
168
+				$image_sizes[] = EE_Question_Option::new_instance(array('QSO_value' => 'none', 'QSO_desc' =>  __('don\'t show images', 'event_espresso')));
169 169
 			}
170 170
 			echo EEH_Form_Fields::select(
171 171
 				 __('Image Size:', 'event_espresso'),
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 			<label for="<?php echo $this->get_field_id('date_limit'); ?>">
224 224
 				<?php _e('Number of Dates to Display:', 'event_espresso'); ?>
225 225
 			</label>
226
-			<input id="<?php echo $this->get_field_id('date_limit'); ?>" name="<?php echo $this->get_field_name('date_limit'); ?>" value="<?php echo esc_attr( $instance['date_limit'] ); ?>" size="3" type="text" />
226
+			<input id="<?php echo $this->get_field_id('date_limit'); ?>" name="<?php echo $this->get_field_name('date_limit'); ?>" value="<?php echo esc_attr($instance['date_limit']); ?>" size="3" type="text" />
227 227
 		</p>
228 228
 		<p>
229 229
 			<label for="<?php echo $this->get_field_id('date_range'); ?>">
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
 	 *
256 256
 	 * @return array Updated safe values to be saved.
257 257
 	 */
258
-	public function update( $new_instance, $old_instance ) {
258
+	public function update($new_instance, $old_instance) {
259 259
 		$instance = $old_instance;
260
-		$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
260
+		$instance['title'] = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : '';
261 261
 		$instance['category_name'] = $new_instance['category_name'];
262 262
 		$instance['show_expired'] = $new_instance['show_expired'];
263 263
 		$instance['limit'] = $new_instance['limit'];
@@ -281,18 +281,18 @@  discard block
 block discarded – undo
281 281
 	 * @param array $args     Widget arguments.
282 282
 	 * @param array $instance Saved values from database.
283 283
 	 */
284
-	public function widget( $args, $instance ) {
284
+	public function widget($args, $instance) {
285 285
 
286 286
 		global $post;
287 287
 		// make sure there is some kinda post object
288
-		if ( $post instanceof WP_Post ) {
288
+		if ($post instanceof WP_Post) {
289 289
 			$before_widget = '';
290 290
 			$before_title = '';
291 291
 			$after_title = '';
292 292
 			$after_widget = '';
293 293
 			// but NOT an events archives page, cuz that would be like two event lists on the same page
294
-			$show_everywhere = isset( $instance['show_everywhere'] ) ? (bool) absint( $instance['show_everywhere'] ) : TRUE;
295
-			if ( $show_everywhere || ! ( $post->post_type == 'espresso_events' && is_archive() )) {
294
+			$show_everywhere = isset($instance['show_everywhere']) ? (bool) absint($instance['show_everywhere']) : TRUE;
295
+			if ($show_everywhere || ! ($post->post_type == 'espresso_events' && is_archive())) {
296 296
 				// let's use some of the event helper functions'
297 297
 				// make separate vars out of attributes
298 298
 
@@ -311,88 +311,88 @@  discard block
 block discarded – undo
311 311
 				// Before widget (defined by themes).
312 312
 				echo $before_widget;
313 313
 				// Display the widget title if one was input (before and after defined by themes).
314
-				if ( ! empty( $title )) {
315
-					echo $before_title . $title . $after_title;
314
+				if ( ! empty($title)) {
315
+					echo $before_title.$title.$after_title;
316 316
 				}
317 317
 				// grab widget settings
318
-				$category = isset( $instance['category_name'] ) && ! empty( $instance['category_name'] ) ? $instance['category_name'] : FALSE;
319
-				$show_expired = isset( $instance['show_expired'] ) ? absint( $instance['show_expired'] ) : 0;
320
-				$image_size = isset( $instance['image_size'] ) && ! empty( $instance['image_size'] ) ? $instance['image_size'] : 'medium';
321
-				$show_desc = isset( $instance['show_desc'] ) ? (bool) absint( $instance['show_desc'] ) : TRUE;
322
-				$show_dates = isset( $instance['show_dates'] ) ? (bool) absint( $instance['show_dates'] ) : TRUE;
323
-				$date_limit = isset( $instance['date_limit'] ) && ! empty( $instance['date_limit'] ) ? $instance['date_limit'] : NULL;
324
-				$date_range = isset( $instance['date_range'] ) && ! empty( $instance['date_range'] ) ? $instance['date_range'] : FALSE;
318
+				$category = isset($instance['category_name']) && ! empty($instance['category_name']) ? $instance['category_name'] : FALSE;
319
+				$show_expired = isset($instance['show_expired']) ? absint($instance['show_expired']) : 0;
320
+				$image_size = isset($instance['image_size']) && ! empty($instance['image_size']) ? $instance['image_size'] : 'medium';
321
+				$show_desc = isset($instance['show_desc']) ? (bool) absint($instance['show_desc']) : TRUE;
322
+				$show_dates = isset($instance['show_dates']) ? (bool) absint($instance['show_dates']) : TRUE;
323
+				$date_limit = isset($instance['date_limit']) && ! empty($instance['date_limit']) ? $instance['date_limit'] : NULL;
324
+				$date_range = isset($instance['date_range']) && ! empty($instance['date_range']) ? $instance['date_range'] : FALSE;
325 325
 				// start to build our where clause
326 326
 				$where = array(
327 327
 //					'Datetime.DTT_is_primary' => 1,
328
-					'status' => array( 'IN', array( 'publish', 'sold_out' ) )
328
+					'status' => array('IN', array('publish', 'sold_out'))
329 329
 				);
330 330
 				// add category
331
-				if ( $category ) {
331
+				if ($category) {
332 332
 					$where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
333 333
 					$where['Term_Taxonomy.Term.slug'] = $category;
334 334
 				}
335 335
 				// if NOT expired then we want events that start today or in the future
336 336
 				// if NOT show expired then we want events that start today or in the future 
337
-				if ( $show_expired == 0 ) { 
338
-				 	$where['Datetime.DTT_EVT_end'] = array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ); 
337
+				if ($show_expired == 0) { 
338
+				 	$where['Datetime.DTT_EVT_end'] = array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')); 
339 339
 				} 
340 340
 				// if show ONLY expired we want events that ended prior to today 
341
-				if ( $show_expired == 2 ) { 
342
-					$where['Datetime.DTT_EVT_end'] = array( '<=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) ); 
341
+				if ($show_expired == 2) { 
342
+					$where['Datetime.DTT_EVT_end'] = array('<=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start')); 
343 343
 				}
344 344
 				// allow $where to be filtered
345
-				$where = apply_filters( 'FHEE__EEW_Upcoming_Events__widget__where', $where, $category, $show_expired );
345
+				$where = apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $category, $show_expired);
346 346
 				// run the query
347
-				$events = EE_Registry::instance()->load_model( 'Event' )->get_all( array(
347
+				$events = EE_Registry::instance()->load_model('Event')->get_all(array(
348 348
 					$where,
349
-					'limit' => $instance['limit'] > 0 ? '0,' . $instance['limit'] : '0,10',
349
+					'limit' => $instance['limit'] > 0 ? '0,'.$instance['limit'] : '0,10',
350 350
 					'order_by' => 'Datetime.DTT_EVT_start',
351 351
 					'order' => isset($instance['sort']) ? $instance['sort'] : 'ASC',
352 352
 					'group_by' => 'EVT_ID'
353 353
 				));
354 354
 
355
-				if ( ! empty( $events )) {
355
+				if ( ! empty($events)) {
356 356
 					echo '<ul class="ee-upcoming-events-widget-ul">';
357
-					foreach ( $events as $event ) {
358
-						if ( $event instanceof EE_Event && ( !is_single() || $post->ID != $event->ID() ) ) {
357
+					foreach ($events as $event) {
358
+						if ($event instanceof EE_Event && ( ! is_single() || $post->ID != $event->ID())) {
359 359
 							//printr( $event, '$event  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
360
-							echo '<li id="ee-upcoming-events-widget-li-' . $event->ID() . '" class="ee-upcoming-events-widget-li">';
360
+							echo '<li id="ee-upcoming-events-widget-li-'.$event->ID().'" class="ee-upcoming-events-widget-li">';
361 361
 							// how big is the event name ?
362
-							$name_length = strlen( $event->name() );
363
-							switch( $name_length ) {
362
+							$name_length = strlen($event->name());
363
+							switch ($name_length) {
364 364
 								case $name_length > 70 :
365
-									$len_class =  ' three-line';
365
+									$len_class = ' three-line';
366 366
 									break;
367 367
 								case $name_length > 35 :
368
-									$len_class =  ' two-line';
368
+									$len_class = ' two-line';
369 369
 									break;
370 370
 								default :
371
-									$len_class =  ' one-line';
371
+									$len_class = ' one-line';
372 372
 							}
373
-							$event_url = apply_filters( 'FHEE_EEW_Upcoming_Events__widget__event_url', $event->get_permalink(), $event );
374
-							echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a' . $len_class . '" href="' . $event_url . '">' . $event->name() . '</a></h5>';
375
-							if ( post_password_required( $event->ID() ) ) {
376
-								$pswd_form = apply_filters( 'FHEE_EEW_Upcoming_Events__widget__password_form', get_the_password_form( $event->ID() ), $event );
373
+							$event_url = apply_filters('FHEE_EEW_Upcoming_Events__widget__event_url', $event->get_permalink(), $event);
374
+							echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a'.$len_class.'" href="'.$event_url.'">'.$event->name().'</a></h5>';
375
+							if (post_password_required($event->ID())) {
376
+								$pswd_form = apply_filters('FHEE_EEW_Upcoming_Events__widget__password_form', get_the_password_form($event->ID()), $event);
377 377
 								echo $pswd_form;
378 378
 							} else {
379
-								if ( has_post_thumbnail( $event->ID() ) && $image_size != 'none' ) {
380
-									echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="' . $event_url . '">' . get_the_post_thumbnail( $event->ID(), $image_size ) . '</a></div>';
379
+								if (has_post_thumbnail($event->ID()) && $image_size != 'none') {
380
+									echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="'.$event_url.'">'.get_the_post_thumbnail($event->ID(), $image_size).'</a></div>';
381 381
 								}
382
-								$desc = $event->short_description( 25 );
383
-								if ( $show_dates ) {
384
-									$date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', get_option( 'date_format' ));
385
-									$time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', get_option( 'time_format' ));
386
-									$single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', get_option( 'date_format' ));
387
-									$single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', get_option( 'time_format' ));
388
-									if ( $date_range == TRUE ) {
389
-										echo espresso_event_date_range( $date_format, $time_format, $single_date_format, $single_time_format, $event->ID() );
390
-									}else{
391
-										echo espresso_list_of_event_dates( $event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit );
382
+								$desc = $event->short_description(25);
383
+								if ($show_dates) {
384
+									$date_format = apply_filters('FHEE__espresso_event_date_range__date_format', get_option('date_format'));
385
+									$time_format = apply_filters('FHEE__espresso_event_date_range__time_format', get_option('time_format'));
386
+									$single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', get_option('date_format'));
387
+									$single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', get_option('time_format'));
388
+									if ($date_range == TRUE) {
389
+										echo espresso_event_date_range($date_format, $time_format, $single_date_format, $single_time_format, $event->ID());
390
+									} else {
391
+										echo espresso_list_of_event_dates($event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit);
392 392
 									}
393 393
 								}
394
-								if ( $show_desc && $desc ) {
395
-									echo '<p style="margin-top: .5em">' . $desc . '</p>';
394
+								if ($show_desc && $desc) {
395
+									echo '<p style="margin-top: .5em">'.$desc.'</p>';
396 396
 								}
397 397
 							}
398 398
 							echo '</li>';
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 	 * @return string
417 417
 	 */
418 418
 	public function make_the_title_a_link($title) {
419
-	    return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>';
419
+	    return '<a href="'.EEH_Event_View::event_archive_url().'">'.$title.'</a>';
420 420
 	}
421 421
 
422 422
 }
Please login to merge, or discard this patch.
modules/ticket_selector/ProcessTicketSelector.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     /**
43 43
      * cancelTicketSelections
44 44
      *
45
-     * @return        string
45
+     * @return        false|null
46 46
      * @throws EE_Error
47 47
      * @throws InvalidArgumentException
48 48
      * @throws InvalidInterfaceException
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
     /**
115 115
      * process_ticket_selections
116 116
      *
117
-     * @return array|bool
117
+     * @return null|boolean
118 118
      * @throws \ReflectionException
119 119
      * @throws InvalidArgumentException
120 120
      * @throws InvalidInterfaceException
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
      * validate_post_data
299 299
      *
300 300
      * @param int $id
301
-     * @return array|FALSE
301
+     * @return string
302 302
      * @throws \ReflectionException
303 303
      * @throws InvalidArgumentException
304 304
      * @throws InvalidInterfaceException
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
      *
422 422
      * @param EE_Ticket $ticket
423 423
      * @param int        $qty
424
-     * @return TRUE on success, FALSE on fail
424
+     * @return boolean on success, FALSE on fail
425 425
      * @throws InvalidArgumentException
426 426
      * @throws InvalidInterfaceException
427 427
      * @throws InvalidDataTypeException
Please login to merge, or discard this patch.
Indentation   +579 added lines, -579 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 use InvalidArgumentException;
15 15
 
16 16
 if (! defined('EVENT_ESPRESSO_VERSION')) {
17
-    exit('No direct script access allowed');
17
+	exit('No direct script access allowed');
18 18
 }
19 19
 
20 20
 
@@ -31,602 +31,602 @@  discard block
 block discarded – undo
31 31
 class ProcessTicketSelector
32 32
 {
33 33
 
34
-    /**
35
-     * array of datetimes and the spaces available for them
36
-     *
37
-     * @var array[][]
38
-     */
39
-    private static $_available_spaces = array();
34
+	/**
35
+	 * array of datetimes and the spaces available for them
36
+	 *
37
+	 * @var array[][]
38
+	 */
39
+	private static $_available_spaces = array();
40 40
 
41 41
 
42
-    /**
43
-     * cancelTicketSelections
44
-     *
45
-     * @return        string
46
-     * @throws EE_Error
47
-     * @throws InvalidArgumentException
48
-     * @throws InvalidInterfaceException
49
-     * @throws InvalidDataTypeException
50
-     */
51
-    public function cancelTicketSelections()
52
-    {
53
-        // check nonce
54
-        if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
55
-            return false;
56
-        }
57
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
58
-        if (EE_Registry::instance()->REQ->is_set('event_id')) {
59
-            wp_safe_redirect(
60
-                EEH_Event_View::event_link_url(
61
-                    EE_Registry::instance()->REQ->get('event_id')
62
-                )
63
-            );
64
-        } else {
65
-            wp_safe_redirect(
66
-                site_url('/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
67
-            );
68
-        }
69
-        exit();
70
-    }
42
+	/**
43
+	 * cancelTicketSelections
44
+	 *
45
+	 * @return        string
46
+	 * @throws EE_Error
47
+	 * @throws InvalidArgumentException
48
+	 * @throws InvalidInterfaceException
49
+	 * @throws InvalidDataTypeException
50
+	 */
51
+	public function cancelTicketSelections()
52
+	{
53
+		// check nonce
54
+		if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
55
+			return false;
56
+		}
57
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
58
+		if (EE_Registry::instance()->REQ->is_set('event_id')) {
59
+			wp_safe_redirect(
60
+				EEH_Event_View::event_link_url(
61
+					EE_Registry::instance()->REQ->get('event_id')
62
+				)
63
+			);
64
+		} else {
65
+			wp_safe_redirect(
66
+				site_url('/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
67
+			);
68
+		}
69
+		exit();
70
+	}
71 71
 
72 72
 
73
-    /**
74
-     * processTicketSelectorNonce
75
-     *
76
-     * @param  string $nonce_name
77
-     * @param string  $id
78
-     * @return bool
79
-     * @throws InvalidArgumentException
80
-     * @throws InvalidInterfaceException
81
-     * @throws InvalidDataTypeException
82
-     */
83
-    private function processTicketSelectorNonce($nonce_name, $id = '')
84
-    {
85
-        $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
86
-        if (
87
-            ! is_admin()
88
-            && (
89
-                ! EE_Registry::instance()->REQ->is_set($nonce_name_with_id)
90
-                || ! wp_verify_nonce(
91
-                    EE_Registry::instance()->REQ->get($nonce_name_with_id),
92
-                    $nonce_name
93
-                )
94
-            )
95
-        ) {
96
-            EE_Error::add_error(
97
-                sprintf(
98
-                    __(
99
-                        'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
100
-                        'event_espresso'
101
-                    ),
102
-                    '<br/>'
103
-                ),
104
-                __FILE__,
105
-                __FUNCTION__,
106
-                __LINE__
107
-            );
108
-            return false;
109
-        }
110
-        return true;
111
-    }
73
+	/**
74
+	 * processTicketSelectorNonce
75
+	 *
76
+	 * @param  string $nonce_name
77
+	 * @param string  $id
78
+	 * @return bool
79
+	 * @throws InvalidArgumentException
80
+	 * @throws InvalidInterfaceException
81
+	 * @throws InvalidDataTypeException
82
+	 */
83
+	private function processTicketSelectorNonce($nonce_name, $id = '')
84
+	{
85
+		$nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
86
+		if (
87
+			! is_admin()
88
+			&& (
89
+				! EE_Registry::instance()->REQ->is_set($nonce_name_with_id)
90
+				|| ! wp_verify_nonce(
91
+					EE_Registry::instance()->REQ->get($nonce_name_with_id),
92
+					$nonce_name
93
+				)
94
+			)
95
+		) {
96
+			EE_Error::add_error(
97
+				sprintf(
98
+					__(
99
+						'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
100
+						'event_espresso'
101
+					),
102
+					'<br/>'
103
+				),
104
+				__FILE__,
105
+				__FUNCTION__,
106
+				__LINE__
107
+			);
108
+			return false;
109
+		}
110
+		return true;
111
+	}
112 112
 
113 113
 
114
-    /**
115
-     * process_ticket_selections
116
-     *
117
-     * @return array|bool
118
-     * @throws \ReflectionException
119
-     * @throws InvalidArgumentException
120
-     * @throws InvalidInterfaceException
121
-     * @throws InvalidDataTypeException
122
-     * @throws EE_Error
123
-     */
124
-    public function processTicketSelections()
125
-    {
126
-        do_action('EED_Ticket_Selector__process_ticket_selections__before');
127
-        $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
128
-        if($request->isBot()) {
129
-            wp_safe_redirect(
130
-                apply_filters(
131
-                    'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url',
132
-                    site_url()
133
-                )
134
-            );
135
-            exit();
136
-        }
137
-        // do we have an event id?
138
-        if (! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
139
-            // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
140
-            EE_Error::add_error(
141
-                sprintf(
142
-                    __(
143
-                        'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
144
-                        'event_espresso'
145
-                    ),
146
-                    '<br/>'
147
-                ),
148
-                __FILE__,
149
-                __FUNCTION__,
150
-                __LINE__
151
-            );
152
-        }
153
-        //if event id is valid
154
-        $id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
155
-        //		d( \EE_Registry::instance()->REQ );
156
-        self::$_available_spaces = array(
157
-            'tickets'   => array(),
158
-            'datetimes' => array(),
159
-        );
160
-        //we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
161
-        // When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
162
-        EE_Registry::instance()->load_core('Session');
163
-        // unless otherwise requested, clear the session
164
-        if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
165
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
166
-        }
167
-        //d( \EE_Registry::instance()->SSN );
168
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
169
-        // validate/sanitize data
170
-        $valid = $this->validatePostData($id);
171
-        //EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
172
-        //EEH_Debug_Tools::printr( $valid, '$valid', __FILE__, __LINE__ );
173
-        //EEH_Debug_Tools::printr( $valid[ 'total_tickets' ], 'total_tickets', __FILE__, __LINE__ );
174
-        //EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ );
175
-        //check total tickets ordered vs max number of attendees that can register
176
-        if ($valid['total_tickets'] > $valid['max_atndz']) {
177
-            // ordering too many tickets !!!
178
-            $total_tickets_string = _n(
179
-                'You have attempted to purchase %s ticket.',
180
-                'You have attempted to purchase %s tickets.',
181
-                $valid['total_tickets'],
182
-                'event_espresso'
183
-            );
184
-            $limit_error_1        = sprintf($total_tickets_string, $valid['total_tickets']);
185
-            // dev only message
186
-            $max_atndz_string = _n(
187
-                'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
188
-                'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
189
-                $valid['max_atndz'],
190
-                'event_espresso'
191
-            );
192
-            $limit_error_2    = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
193
-            EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
194
-        } else {
195
-            // all data appears to be valid
196
-            $tckts_slctd   = false;
197
-            $tickets_added = 0;
198
-            $valid         = apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data',
199
-                $valid);
200
-            if ($valid['total_tickets'] > 0) {
201
-                // load cart
202
-                EE_Registry::instance()->load_core('Cart');
203
-                // cycle thru the number of data rows sent from the event listing
204
-                for ($x = 0; $x < $valid['rows']; $x++) {
205
-                    // does this row actually contain a ticket quantity?
206
-                    if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
207
-                        // YES we have a ticket quantity
208
-                        $tckts_slctd = true;
209
-                        //						d( $valid['ticket_obj'][$x] );
210
-                        if ($valid['ticket_obj'][ $x ] instanceof EE_Ticket) {
211
-                            // then add ticket to cart
212
-                            $tickets_added += $this->addTicketToCart(
213
-                                $valid['ticket_obj'][ $x ],
214
-                                $valid['qty'][ $x ]
215
-                            );
216
-                            if (EE_Error::has_error()) {
217
-                                break;
218
-                            }
219
-                        } else {
220
-                            // nothing added to cart retrieved
221
-                            EE_Error::add_error(
222
-                                sprintf(
223
-                                    __(
224
-                                        'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
225
-                                        'event_espresso'
226
-                                    ),
227
-                                    '<br/>'
228
-                                ),
229
-                                __FILE__, __FUNCTION__, __LINE__
230
-                            );
231
-                        }
232
-                    }
233
-                }
234
-            }
235
-            do_action(
236
-                'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
237
-                EE_Registry::instance()->CART,
238
-                $this
239
-            );
240
-            //d( \EE_Registry::instance()->CART );
241
-            //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
242
-            if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd)) {
243
-                if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
244
-                    do_action(
245
-                        'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
246
-                        EE_Registry::instance()->CART,
247
-                        $this
248
-                    );
249
-                    EE_Registry::instance()->CART->recalculate_all_cart_totals();
250
-                    EE_Registry::instance()->CART->save_cart(false);
251
-                    // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
252
-                    // just return TRUE for registrations being made from admin
253
-                    if (is_admin()) {
254
-                        return true;
255
-                    }
256
-                    EE_Error::get_notices(false, true);
257
-                    wp_safe_redirect(
258
-                        apply_filters(
259
-                            'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
260
-                            EE_Registry::instance()->CFG->core->reg_page_url()
261
-                        )
262
-                    );
263
-                    exit();
264
-                } else {
265
-                    if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
266
-                        // nothing added to cart
267
-                        EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'),
268
-                            __FILE__, __FUNCTION__, __LINE__);
269
-                    }
270
-                }
271
-            } else {
272
-                // no ticket quantities were selected
273
-                EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.',
274
-                    'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
275
-            }
276
-        }
277
-        //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
278
-        // at this point, just return if registration is being made from admin
279
-        if (is_admin()) {
280
-            return false;
281
-        }
282
-        if ($valid['return_url']) {
283
-            EE_Error::get_notices(false, true);
284
-            wp_safe_redirect($valid['return_url']);
285
-            exit();
286
-        } elseif (isset($event_to_add['id'])) {
287
-            EE_Error::get_notices(false, true);
288
-            wp_safe_redirect(get_permalink($event_to_add['id']));
289
-            exit();
290
-        } else {
291
-            echo EE_Error::get_notices();
292
-        }
293
-        return false;
294
-    }
114
+	/**
115
+	 * process_ticket_selections
116
+	 *
117
+	 * @return array|bool
118
+	 * @throws \ReflectionException
119
+	 * @throws InvalidArgumentException
120
+	 * @throws InvalidInterfaceException
121
+	 * @throws InvalidDataTypeException
122
+	 * @throws EE_Error
123
+	 */
124
+	public function processTicketSelections()
125
+	{
126
+		do_action('EED_Ticket_Selector__process_ticket_selections__before');
127
+		$request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
128
+		if($request->isBot()) {
129
+			wp_safe_redirect(
130
+				apply_filters(
131
+					'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url',
132
+					site_url()
133
+				)
134
+			);
135
+			exit();
136
+		}
137
+		// do we have an event id?
138
+		if (! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
139
+			// $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
140
+			EE_Error::add_error(
141
+				sprintf(
142
+					__(
143
+						'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
144
+						'event_espresso'
145
+					),
146
+					'<br/>'
147
+				),
148
+				__FILE__,
149
+				__FUNCTION__,
150
+				__LINE__
151
+			);
152
+		}
153
+		//if event id is valid
154
+		$id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
155
+		//		d( \EE_Registry::instance()->REQ );
156
+		self::$_available_spaces = array(
157
+			'tickets'   => array(),
158
+			'datetimes' => array(),
159
+		);
160
+		//we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
161
+		// When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
162
+		EE_Registry::instance()->load_core('Session');
163
+		// unless otherwise requested, clear the session
164
+		if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
165
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
166
+		}
167
+		//d( \EE_Registry::instance()->SSN );
168
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
169
+		// validate/sanitize data
170
+		$valid = $this->validatePostData($id);
171
+		//EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
172
+		//EEH_Debug_Tools::printr( $valid, '$valid', __FILE__, __LINE__ );
173
+		//EEH_Debug_Tools::printr( $valid[ 'total_tickets' ], 'total_tickets', __FILE__, __LINE__ );
174
+		//EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ );
175
+		//check total tickets ordered vs max number of attendees that can register
176
+		if ($valid['total_tickets'] > $valid['max_atndz']) {
177
+			// ordering too many tickets !!!
178
+			$total_tickets_string = _n(
179
+				'You have attempted to purchase %s ticket.',
180
+				'You have attempted to purchase %s tickets.',
181
+				$valid['total_tickets'],
182
+				'event_espresso'
183
+			);
184
+			$limit_error_1        = sprintf($total_tickets_string, $valid['total_tickets']);
185
+			// dev only message
186
+			$max_atndz_string = _n(
187
+				'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
188
+				'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
189
+				$valid['max_atndz'],
190
+				'event_espresso'
191
+			);
192
+			$limit_error_2    = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
193
+			EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
194
+		} else {
195
+			// all data appears to be valid
196
+			$tckts_slctd   = false;
197
+			$tickets_added = 0;
198
+			$valid         = apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data',
199
+				$valid);
200
+			if ($valid['total_tickets'] > 0) {
201
+				// load cart
202
+				EE_Registry::instance()->load_core('Cart');
203
+				// cycle thru the number of data rows sent from the event listing
204
+				for ($x = 0; $x < $valid['rows']; $x++) {
205
+					// does this row actually contain a ticket quantity?
206
+					if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
207
+						// YES we have a ticket quantity
208
+						$tckts_slctd = true;
209
+						//						d( $valid['ticket_obj'][$x] );
210
+						if ($valid['ticket_obj'][ $x ] instanceof EE_Ticket) {
211
+							// then add ticket to cart
212
+							$tickets_added += $this->addTicketToCart(
213
+								$valid['ticket_obj'][ $x ],
214
+								$valid['qty'][ $x ]
215
+							);
216
+							if (EE_Error::has_error()) {
217
+								break;
218
+							}
219
+						} else {
220
+							// nothing added to cart retrieved
221
+							EE_Error::add_error(
222
+								sprintf(
223
+									__(
224
+										'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
225
+										'event_espresso'
226
+									),
227
+									'<br/>'
228
+								),
229
+								__FILE__, __FUNCTION__, __LINE__
230
+							);
231
+						}
232
+					}
233
+				}
234
+			}
235
+			do_action(
236
+				'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
237
+				EE_Registry::instance()->CART,
238
+				$this
239
+			);
240
+			//d( \EE_Registry::instance()->CART );
241
+			//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
242
+			if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd)) {
243
+				if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
244
+					do_action(
245
+						'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
246
+						EE_Registry::instance()->CART,
247
+						$this
248
+					);
249
+					EE_Registry::instance()->CART->recalculate_all_cart_totals();
250
+					EE_Registry::instance()->CART->save_cart(false);
251
+					// exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
252
+					// just return TRUE for registrations being made from admin
253
+					if (is_admin()) {
254
+						return true;
255
+					}
256
+					EE_Error::get_notices(false, true);
257
+					wp_safe_redirect(
258
+						apply_filters(
259
+							'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
260
+							EE_Registry::instance()->CFG->core->reg_page_url()
261
+						)
262
+					);
263
+					exit();
264
+				} else {
265
+					if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
266
+						// nothing added to cart
267
+						EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'),
268
+							__FILE__, __FUNCTION__, __LINE__);
269
+					}
270
+				}
271
+			} else {
272
+				// no ticket quantities were selected
273
+				EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.',
274
+					'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
275
+			}
276
+		}
277
+		//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
278
+		// at this point, just return if registration is being made from admin
279
+		if (is_admin()) {
280
+			return false;
281
+		}
282
+		if ($valid['return_url']) {
283
+			EE_Error::get_notices(false, true);
284
+			wp_safe_redirect($valid['return_url']);
285
+			exit();
286
+		} elseif (isset($event_to_add['id'])) {
287
+			EE_Error::get_notices(false, true);
288
+			wp_safe_redirect(get_permalink($event_to_add['id']));
289
+			exit();
290
+		} else {
291
+			echo EE_Error::get_notices();
292
+		}
293
+		return false;
294
+	}
295 295
 
296 296
 
297
-    /**
298
-     * validate_post_data
299
-     *
300
-     * @param int $id
301
-     * @return array|FALSE
302
-     * @throws \ReflectionException
303
-     * @throws InvalidArgumentException
304
-     * @throws InvalidInterfaceException
305
-     * @throws InvalidDataTypeException
306
-     * @throws EE_Error
307
-     */
308
-    private function validatePostData($id = 0)
309
-    {
310
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
311
-        if (! $id) {
312
-            EE_Error::add_error(
313
-                __('The event id provided was not valid.', 'event_espresso'),
314
-                __FILE__,
315
-                __FUNCTION__,
316
-                __LINE__
317
-            );
318
-            return false;
319
-        }
320
-        // start with an empty array()
321
-        $valid_data = array();
322
-        // grab valid id
323
-        $valid_data['id'] = $id;
324
-        // array of other form names
325
-        $inputs_to_clean = array(
326
-            'event_id'   => 'tkt-slctr-event-id',
327
-            'max_atndz'  => 'tkt-slctr-max-atndz-',
328
-            'rows'       => 'tkt-slctr-rows-',
329
-            'qty'        => 'tkt-slctr-qty-',
330
-            'ticket_id'  => 'tkt-slctr-ticket-id-',
331
-            'return_url' => 'tkt-slctr-return-url-',
332
-        );
333
-        // let's track the total number of tickets ordered.'
334
-        $valid_data['total_tickets'] = 0;
335
-        // cycle through $inputs_to_clean array
336
-        foreach ($inputs_to_clean as $what => $input_to_clean) {
337
-            // check for POST data
338
-            if (EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
339
-                // grab value
340
-                $input_value = EE_Registry::instance()->REQ->get($input_to_clean . $id);
341
-                switch ($what) {
342
-                    // integers
343
-                    case 'event_id':
344
-                        $valid_data[ $what ] = absint($input_value);
345
-                        // get event via the event id we put in the form
346
-                        $valid_data['event'] = EE_Registry::instance()
347
-                                                           ->load_model('Event')
348
-                                                           ->get_one_by_ID($valid_data['event_id']);
349
-                        break;
350
-                    case 'rows':
351
-                    case 'max_atndz':
352
-                        $valid_data[ $what ] = absint($input_value);
353
-                        break;
354
-                    // arrays of integers
355
-                    case 'qty':
356
-                        /** @var array $row_qty */
357
-                        $row_qty = $input_value;
358
-                        // if qty is coming from a radio button input, then we need to assemble an array of rows
359
-                        if (! is_array($row_qty)) {
360
-                            // get number of rows
361
-                            $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
362
-                                ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
363
-                                : 1;
364
-                            // explode ints by the dash
365
-                            $row_qty = explode('-', $row_qty);
366
-                            $row     = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
367
-                            $qty     = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
368
-                            $row_qty = array($row => $qty);
369
-                            for ($x = 1; $x <= $rows; $x++) {
370
-                                if (! isset($row_qty[ $x ])) {
371
-                                    $row_qty[ $x ] = 0;
372
-                                }
373
-                            }
374
-                        }
375
-                        ksort($row_qty);
376
-                        // cycle thru values
377
-                        foreach ($row_qty as $qty) {
378
-                            $qty = absint($qty);
379
-                            // sanitize as integers
380
-                            $valid_data[ $what ][]       = $qty;
381
-                            $valid_data['total_tickets'] += $qty;
382
-                        }
383
-                        break;
384
-                    // array of integers
385
-                    case 'ticket_id':
386
-                        $value_array = array();
387
-                        // cycle thru values
388
-                        foreach ((array) $input_value as $key => $value) {
389
-                            // allow only numbers, letters,  spaces, commas and dashes
390
-                            $value_array[ $key ] = wp_strip_all_tags($value);
391
-                            // get ticket via the ticket id we put in the form
392
-                            $ticket_obj                       = EE_Registry::instance()
393
-                                                                            ->load_model('Ticket')
394
-                                                                            ->get_one_by_ID($value);
395
-                            $valid_data['ticket_obj'][ $key ] = $ticket_obj;
396
-                        }
397
-                        $valid_data[ $what ] = $value_array;
398
-                        break;
399
-                    case 'return_url' :
400
-                        // grab and sanitize return-url
401
-                        $input_value = esc_url_raw($input_value);
402
-                        // was the request coming from an iframe ? if so, then:
403
-                        if (strpos($input_value, 'event_list=iframe')) {
404
-                            // get anchor fragment
405
-                            $input_value = explode('#', $input_value);
406
-                            $input_value = end($input_value);
407
-                            // use event list url instead, but append anchor
408
-                            $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
409
-                        }
410
-                        $valid_data[ $what ] = $input_value;
411
-                        break;
412
-                }    // end switch $what
413
-            }
414
-        }    // end foreach $inputs_to_clean
415
-        return $valid_data;
416
-    }
297
+	/**
298
+	 * validate_post_data
299
+	 *
300
+	 * @param int $id
301
+	 * @return array|FALSE
302
+	 * @throws \ReflectionException
303
+	 * @throws InvalidArgumentException
304
+	 * @throws InvalidInterfaceException
305
+	 * @throws InvalidDataTypeException
306
+	 * @throws EE_Error
307
+	 */
308
+	private function validatePostData($id = 0)
309
+	{
310
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
311
+		if (! $id) {
312
+			EE_Error::add_error(
313
+				__('The event id provided was not valid.', 'event_espresso'),
314
+				__FILE__,
315
+				__FUNCTION__,
316
+				__LINE__
317
+			);
318
+			return false;
319
+		}
320
+		// start with an empty array()
321
+		$valid_data = array();
322
+		// grab valid id
323
+		$valid_data['id'] = $id;
324
+		// array of other form names
325
+		$inputs_to_clean = array(
326
+			'event_id'   => 'tkt-slctr-event-id',
327
+			'max_atndz'  => 'tkt-slctr-max-atndz-',
328
+			'rows'       => 'tkt-slctr-rows-',
329
+			'qty'        => 'tkt-slctr-qty-',
330
+			'ticket_id'  => 'tkt-slctr-ticket-id-',
331
+			'return_url' => 'tkt-slctr-return-url-',
332
+		);
333
+		// let's track the total number of tickets ordered.'
334
+		$valid_data['total_tickets'] = 0;
335
+		// cycle through $inputs_to_clean array
336
+		foreach ($inputs_to_clean as $what => $input_to_clean) {
337
+			// check for POST data
338
+			if (EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
339
+				// grab value
340
+				$input_value = EE_Registry::instance()->REQ->get($input_to_clean . $id);
341
+				switch ($what) {
342
+					// integers
343
+					case 'event_id':
344
+						$valid_data[ $what ] = absint($input_value);
345
+						// get event via the event id we put in the form
346
+						$valid_data['event'] = EE_Registry::instance()
347
+														   ->load_model('Event')
348
+														   ->get_one_by_ID($valid_data['event_id']);
349
+						break;
350
+					case 'rows':
351
+					case 'max_atndz':
352
+						$valid_data[ $what ] = absint($input_value);
353
+						break;
354
+					// arrays of integers
355
+					case 'qty':
356
+						/** @var array $row_qty */
357
+						$row_qty = $input_value;
358
+						// if qty is coming from a radio button input, then we need to assemble an array of rows
359
+						if (! is_array($row_qty)) {
360
+							// get number of rows
361
+							$rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
362
+								? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
363
+								: 1;
364
+							// explode ints by the dash
365
+							$row_qty = explode('-', $row_qty);
366
+							$row     = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
367
+							$qty     = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
368
+							$row_qty = array($row => $qty);
369
+							for ($x = 1; $x <= $rows; $x++) {
370
+								if (! isset($row_qty[ $x ])) {
371
+									$row_qty[ $x ] = 0;
372
+								}
373
+							}
374
+						}
375
+						ksort($row_qty);
376
+						// cycle thru values
377
+						foreach ($row_qty as $qty) {
378
+							$qty = absint($qty);
379
+							// sanitize as integers
380
+							$valid_data[ $what ][]       = $qty;
381
+							$valid_data['total_tickets'] += $qty;
382
+						}
383
+						break;
384
+					// array of integers
385
+					case 'ticket_id':
386
+						$value_array = array();
387
+						// cycle thru values
388
+						foreach ((array) $input_value as $key => $value) {
389
+							// allow only numbers, letters,  spaces, commas and dashes
390
+							$value_array[ $key ] = wp_strip_all_tags($value);
391
+							// get ticket via the ticket id we put in the form
392
+							$ticket_obj                       = EE_Registry::instance()
393
+																			->load_model('Ticket')
394
+																			->get_one_by_ID($value);
395
+							$valid_data['ticket_obj'][ $key ] = $ticket_obj;
396
+						}
397
+						$valid_data[ $what ] = $value_array;
398
+						break;
399
+					case 'return_url' :
400
+						// grab and sanitize return-url
401
+						$input_value = esc_url_raw($input_value);
402
+						// was the request coming from an iframe ? if so, then:
403
+						if (strpos($input_value, 'event_list=iframe')) {
404
+							// get anchor fragment
405
+							$input_value = explode('#', $input_value);
406
+							$input_value = end($input_value);
407
+							// use event list url instead, but append anchor
408
+							$input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
409
+						}
410
+						$valid_data[ $what ] = $input_value;
411
+						break;
412
+				}    // end switch $what
413
+			}
414
+		}    // end foreach $inputs_to_clean
415
+		return $valid_data;
416
+	}
417 417
 
418 418
 
419
-    /**
420
-     * adds a ticket to the cart
421
-     *
422
-     * @param EE_Ticket $ticket
423
-     * @param int        $qty
424
-     * @return TRUE on success, FALSE on fail
425
-     * @throws InvalidArgumentException
426
-     * @throws InvalidInterfaceException
427
-     * @throws InvalidDataTypeException
428
-     * @throws EE_Error
429
-     */
430
-    private function addTicketToCart(EE_Ticket $ticket = null, $qty = 1)
431
-    {
432
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
433
-        // get the number of spaces left for this datetime ticket
434
-        $available_spaces = $this->ticketDatetimeAvailability($ticket);
435
-        // compare available spaces against the number of tickets being purchased
436
-        if ($available_spaces >= $qty) {
437
-            // allow addons to prevent a ticket from being added to cart
438
-            if (
439
-            ! apply_filters(
440
-                'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
441
-                true,
442
-                $ticket,
443
-                $qty,
444
-                $available_spaces
445
-            )
446
-            ) {
447
-                return false;
448
-            }
449
-            $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
450
-            // add event to cart
451
-            if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
452
-                $this->recalculateTicketDatetimeAvailability($ticket, $qty);
453
-                return true;
454
-            }
455
-            return false;
456
-        }
457
-        // tickets can not be purchased but let's find the exact number left
458
-        // for the last ticket selected PRIOR to subtracting tickets
459
-        $available_spaces = $this->ticketDatetimeAvailability($ticket, true);
460
-        // greedy greedy greedy eh?
461
-        if ($available_spaces > 0) {
462
-            if (
463
-            apply_filters(
464
-                'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
465
-                true,
466
-                $ticket,
467
-                $qty,
468
-                $available_spaces
469
-            )
470
-            ) {
471
-                $this->displayAvailabilityError($available_spaces);
472
-            }
473
-        } else {
474
-            EE_Error::add_error(
475
-                __(
476
-                    'We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
477
-                    'event_espresso'
478
-                ),
479
-                __FILE__, __FUNCTION__, __LINE__
480
-            );
481
-        }
482
-        return false;
483
-    }
419
+	/**
420
+	 * adds a ticket to the cart
421
+	 *
422
+	 * @param EE_Ticket $ticket
423
+	 * @param int        $qty
424
+	 * @return TRUE on success, FALSE on fail
425
+	 * @throws InvalidArgumentException
426
+	 * @throws InvalidInterfaceException
427
+	 * @throws InvalidDataTypeException
428
+	 * @throws EE_Error
429
+	 */
430
+	private function addTicketToCart(EE_Ticket $ticket = null, $qty = 1)
431
+	{
432
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
433
+		// get the number of spaces left for this datetime ticket
434
+		$available_spaces = $this->ticketDatetimeAvailability($ticket);
435
+		// compare available spaces against the number of tickets being purchased
436
+		if ($available_spaces >= $qty) {
437
+			// allow addons to prevent a ticket from being added to cart
438
+			if (
439
+			! apply_filters(
440
+				'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
441
+				true,
442
+				$ticket,
443
+				$qty,
444
+				$available_spaces
445
+			)
446
+			) {
447
+				return false;
448
+			}
449
+			$qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
450
+			// add event to cart
451
+			if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
452
+				$this->recalculateTicketDatetimeAvailability($ticket, $qty);
453
+				return true;
454
+			}
455
+			return false;
456
+		}
457
+		// tickets can not be purchased but let's find the exact number left
458
+		// for the last ticket selected PRIOR to subtracting tickets
459
+		$available_spaces = $this->ticketDatetimeAvailability($ticket, true);
460
+		// greedy greedy greedy eh?
461
+		if ($available_spaces > 0) {
462
+			if (
463
+			apply_filters(
464
+				'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
465
+				true,
466
+				$ticket,
467
+				$qty,
468
+				$available_spaces
469
+			)
470
+			) {
471
+				$this->displayAvailabilityError($available_spaces);
472
+			}
473
+		} else {
474
+			EE_Error::add_error(
475
+				__(
476
+					'We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
477
+					'event_espresso'
478
+				),
479
+				__FILE__, __FUNCTION__, __LINE__
480
+			);
481
+		}
482
+		return false;
483
+	}
484 484
 
485 485
 
486
-    /**
487
-     * @param int $available_spaces
488
-     * @throws InvalidArgumentException
489
-     * @throws InvalidInterfaceException
490
-     * @throws InvalidDataTypeException
491
-     * @throws EE_Error
492
-     */
493
-    private function displayAvailabilityError($available_spaces = 1)
494
-    {
495
-        // add error messaging - we're using the _n function that will generate
496
-        // the appropriate singular or plural message based on the number of $available_spaces
497
-        if (EE_Registry::instance()->CART->all_ticket_quantity_count()) {
498
-            $msg = sprintf(
499
-                _n(
500
-                    'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
501
-                    'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
502
-                    $available_spaces,
503
-                    'event_espresso'
504
-                ),
505
-                $available_spaces,
506
-                '<br />'
507
-            );
508
-        } else {
509
-            $msg = sprintf(
510
-                _n(
511
-                    'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
512
-                    'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
513
-                    $available_spaces,
514
-                    'event_espresso'
515
-                ),
516
-                $available_spaces,
517
-                '<br />'
518
-            );
519
-        }
520
-        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
521
-    }
486
+	/**
487
+	 * @param int $available_spaces
488
+	 * @throws InvalidArgumentException
489
+	 * @throws InvalidInterfaceException
490
+	 * @throws InvalidDataTypeException
491
+	 * @throws EE_Error
492
+	 */
493
+	private function displayAvailabilityError($available_spaces = 1)
494
+	{
495
+		// add error messaging - we're using the _n function that will generate
496
+		// the appropriate singular or plural message based on the number of $available_spaces
497
+		if (EE_Registry::instance()->CART->all_ticket_quantity_count()) {
498
+			$msg = sprintf(
499
+				_n(
500
+					'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
501
+					'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
502
+					$available_spaces,
503
+					'event_espresso'
504
+				),
505
+				$available_spaces,
506
+				'<br />'
507
+			);
508
+		} else {
509
+			$msg = sprintf(
510
+				_n(
511
+					'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
512
+					'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
513
+					$available_spaces,
514
+					'event_espresso'
515
+				),
516
+				$available_spaces,
517
+				'<br />'
518
+			);
519
+		}
520
+		EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
521
+	}
522 522
 
523 523
 
524
-    /**
525
-     * ticketDatetimeAvailability
526
-     * creates an array of tickets plus all of the datetimes available to each ticket
527
-     * and tracks the spaces remaining for each of those datetimes
528
-     *
529
-     * @param EE_Ticket $ticket - selected ticket
530
-     * @param bool      $get_original_ticket_spaces
531
-     * @return int
532
-     * @throws InvalidArgumentException
533
-     * @throws InvalidInterfaceException
534
-     * @throws InvalidDataTypeException
535
-     * @throws EE_Error
536
-     */
537
-    private function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
538
-    {
539
-        // if the $_available_spaces array has not been set up yet...
540
-        if (! isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
541
-            $this->setInitialTicketDatetimeAvailability($ticket);
542
-        }
543
-        $available_spaces = $ticket->qty() - $ticket->sold();
544
-        if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
545
-            // loop thru tickets, which will ALSO include individual ticket records AND a total
546
-            foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
547
-                // if we want the original datetime availability BEFORE we started subtracting tickets ?
548
-                if ($get_original_ticket_spaces) {
549
-                    // then grab the available spaces from the "tickets" array
550
-                    // and compare with the above to get the lowest number
551
-                    $available_spaces = min(
552
-                        $available_spaces,
553
-                        self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
554
-                    );
555
-                } else {
556
-                    // we want the updated ticket availability as stored in the "datetimes" array
557
-                    $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ]);
558
-                }
559
-            }
560
-        }
561
-        return $available_spaces;
562
-    }
524
+	/**
525
+	 * ticketDatetimeAvailability
526
+	 * creates an array of tickets plus all of the datetimes available to each ticket
527
+	 * and tracks the spaces remaining for each of those datetimes
528
+	 *
529
+	 * @param EE_Ticket $ticket - selected ticket
530
+	 * @param bool      $get_original_ticket_spaces
531
+	 * @return int
532
+	 * @throws InvalidArgumentException
533
+	 * @throws InvalidInterfaceException
534
+	 * @throws InvalidDataTypeException
535
+	 * @throws EE_Error
536
+	 */
537
+	private function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
538
+	{
539
+		// if the $_available_spaces array has not been set up yet...
540
+		if (! isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
541
+			$this->setInitialTicketDatetimeAvailability($ticket);
542
+		}
543
+		$available_spaces = $ticket->qty() - $ticket->sold();
544
+		if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
545
+			// loop thru tickets, which will ALSO include individual ticket records AND a total
546
+			foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
547
+				// if we want the original datetime availability BEFORE we started subtracting tickets ?
548
+				if ($get_original_ticket_spaces) {
549
+					// then grab the available spaces from the "tickets" array
550
+					// and compare with the above to get the lowest number
551
+					$available_spaces = min(
552
+						$available_spaces,
553
+						self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
554
+					);
555
+				} else {
556
+					// we want the updated ticket availability as stored in the "datetimes" array
557
+					$available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ]);
558
+				}
559
+			}
560
+		}
561
+		return $available_spaces;
562
+	}
563 563
 
564 564
 
565
-    /**
566
-     * @param EE_Ticket $ticket
567
-     * @return void
568
-     * @throws InvalidArgumentException
569
-     * @throws InvalidInterfaceException
570
-     * @throws InvalidDataTypeException
571
-     * @throws EE_Error
572
-     */
573
-    private function setInitialTicketDatetimeAvailability(EE_Ticket $ticket)
574
-    {
575
-        // first, get all of the datetimes that are available to this ticket
576
-        $datetimes = $ticket->get_many_related(
577
-            'Datetime',
578
-            array(
579
-                array(
580
-                    'DTT_EVT_end' => array(
581
-                        '>=',
582
-                        EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
583
-                    ),
584
-                ),
585
-                'order_by' => array('DTT_EVT_start' => 'ASC'),
586
-            )
587
-        );
588
-        if (! empty($datetimes)) {
589
-            // now loop thru all of the datetimes
590
-            foreach ($datetimes as $datetime) {
591
-                if ($datetime instanceof EE_Datetime) {
592
-                    // the number of spaces available for the datetime without considering individual ticket quantities
593
-                    $spaces_remaining = $datetime->spaces_remaining();
594
-                    // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
595
-                    // or the datetime spaces remaining) to this ticket using the datetime ID as the key
596
-                    self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
597
-                        $ticket->qty() - $ticket->sold(),
598
-                        $spaces_remaining
599
-                    );
600
-                    // if the remaining spaces for this datetime is already set,
601
-                    // then compare that against the datetime spaces remaining, and take the lowest number,
602
-                    // else just take the datetime spaces remaining, and assign to the datetimes array
603
-                    self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset(
604
-                        self::$_available_spaces['datetimes'][ $datetime->ID() ]
605
-                    )
606
-                        ? min(self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
607
-                        : $spaces_remaining;
608
-                }
609
-            }
610
-        }
611
-    }
565
+	/**
566
+	 * @param EE_Ticket $ticket
567
+	 * @return void
568
+	 * @throws InvalidArgumentException
569
+	 * @throws InvalidInterfaceException
570
+	 * @throws InvalidDataTypeException
571
+	 * @throws EE_Error
572
+	 */
573
+	private function setInitialTicketDatetimeAvailability(EE_Ticket $ticket)
574
+	{
575
+		// first, get all of the datetimes that are available to this ticket
576
+		$datetimes = $ticket->get_many_related(
577
+			'Datetime',
578
+			array(
579
+				array(
580
+					'DTT_EVT_end' => array(
581
+						'>=',
582
+						EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
583
+					),
584
+				),
585
+				'order_by' => array('DTT_EVT_start' => 'ASC'),
586
+			)
587
+		);
588
+		if (! empty($datetimes)) {
589
+			// now loop thru all of the datetimes
590
+			foreach ($datetimes as $datetime) {
591
+				if ($datetime instanceof EE_Datetime) {
592
+					// the number of spaces available for the datetime without considering individual ticket quantities
593
+					$spaces_remaining = $datetime->spaces_remaining();
594
+					// save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
595
+					// or the datetime spaces remaining) to this ticket using the datetime ID as the key
596
+					self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
597
+						$ticket->qty() - $ticket->sold(),
598
+						$spaces_remaining
599
+					);
600
+					// if the remaining spaces for this datetime is already set,
601
+					// then compare that against the datetime spaces remaining, and take the lowest number,
602
+					// else just take the datetime spaces remaining, and assign to the datetimes array
603
+					self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset(
604
+						self::$_available_spaces['datetimes'][ $datetime->ID() ]
605
+					)
606
+						? min(self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
607
+						: $spaces_remaining;
608
+				}
609
+			}
610
+		}
611
+	}
612 612
 
613 613
 
614
-    /**
615
-     * @param    EE_Ticket $ticket
616
-     * @param    int        $qty
617
-     * @return    void
618
-     * @throws EE_Error
619
-     */
620
-    private function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
621
-    {
622
-        if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
623
-            // loop thru tickets, which will ALSO include individual ticket records AND a total
624
-            foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
625
-                // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
626
-                self::$_available_spaces['datetimes'][ $DTD_ID ] -= $qty;
627
-            }
628
-        }
629
-    }
614
+	/**
615
+	 * @param    EE_Ticket $ticket
616
+	 * @param    int        $qty
617
+	 * @return    void
618
+	 * @throws EE_Error
619
+	 */
620
+	private function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
621
+	{
622
+		if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
623
+			// loop thru tickets, which will ALSO include individual ticket records AND a total
624
+			foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
625
+				// subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
626
+				self::$_available_spaces['datetimes'][ $DTD_ID ] -= $qty;
627
+			}
628
+		}
629
+	}
630 630
 }
631 631
 // End of file ProcessTicketSelector.php
632 632
 // Location: /ProcessTicketSelector.php
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use EventEspresso\core\services\loaders\LoaderFactory;
14 14
 use InvalidArgumentException;
15 15
 
16
-if (! defined('EVENT_ESPRESSO_VERSION')) {
16
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
17 17
     exit('No direct script access allowed');
18 18
 }
19 19
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     public function cancelTicketSelections()
52 52
     {
53 53
         // check nonce
54
-        if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
54
+        if ( ! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
55 55
             return false;
56 56
         }
57 57
         EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
             );
64 64
         } else {
65 65
             wp_safe_redirect(
66
-                site_url('/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
66
+                site_url('/'.EE_Registry::instance()->CFG->core->event_cpt_slug.'/')
67 67
             );
68 68
         }
69 69
         exit();
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     {
126 126
         do_action('EED_Ticket_Selector__process_ticket_selections__before');
127 127
         $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
128
-        if($request->isBot()) {
128
+        if ($request->isBot()) {
129 129
             wp_safe_redirect(
130 130
                 apply_filters(
131 131
                     'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url',
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             exit();
136 136
         }
137 137
         // do we have an event id?
138
-        if (! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
138
+        if ( ! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
139 139
             // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
140 140
             EE_Error::add_error(
141 141
                 sprintf(
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
                 $valid['total_tickets'],
182 182
                 'event_espresso'
183 183
             );
184
-            $limit_error_1        = sprintf($total_tickets_string, $valid['total_tickets']);
184
+            $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
185 185
             // dev only message
186 186
             $max_atndz_string = _n(
187 187
                 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
                 $valid['max_atndz'],
190 190
                 'event_espresso'
191 191
             );
192
-            $limit_error_2    = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
193
-            EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
192
+            $limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
193
+            EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__);
194 194
         } else {
195 195
             // all data appears to be valid
196 196
             $tckts_slctd   = false;
@@ -203,15 +203,15 @@  discard block
 block discarded – undo
203 203
                 // cycle thru the number of data rows sent from the event listing
204 204
                 for ($x = 0; $x < $valid['rows']; $x++) {
205 205
                     // does this row actually contain a ticket quantity?
206
-                    if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
206
+                    if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
207 207
                         // YES we have a ticket quantity
208 208
                         $tckts_slctd = true;
209 209
                         //						d( $valid['ticket_obj'][$x] );
210
-                        if ($valid['ticket_obj'][ $x ] instanceof EE_Ticket) {
210
+                        if ($valid['ticket_obj'][$x] instanceof EE_Ticket) {
211 211
                             // then add ticket to cart
212 212
                             $tickets_added += $this->addTicketToCart(
213
-                                $valid['ticket_obj'][ $x ],
214
-                                $valid['qty'][ $x ]
213
+                                $valid['ticket_obj'][$x],
214
+                                $valid['qty'][$x]
215 215
                             );
216 216
                             if (EE_Error::has_error()) {
217 217
                                 break;
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
                     );
263 263
                     exit();
264 264
                 } else {
265
-                    if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
265
+                    if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
266 266
                         // nothing added to cart
267 267
                         EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'),
268 268
                             __FILE__, __FUNCTION__, __LINE__);
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
     private function validatePostData($id = 0)
309 309
     {
310 310
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
311
-        if (! $id) {
311
+        if ( ! $id) {
312 312
             EE_Error::add_error(
313 313
                 __('The event id provided was not valid.', 'event_espresso'),
314 314
                 __FILE__,
@@ -335,13 +335,13 @@  discard block
 block discarded – undo
335 335
         // cycle through $inputs_to_clean array
336 336
         foreach ($inputs_to_clean as $what => $input_to_clean) {
337 337
             // check for POST data
338
-            if (EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
338
+            if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) {
339 339
                 // grab value
340
-                $input_value = EE_Registry::instance()->REQ->get($input_to_clean . $id);
340
+                $input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id);
341 341
                 switch ($what) {
342 342
                     // integers
343 343
                     case 'event_id':
344
-                        $valid_data[ $what ] = absint($input_value);
344
+                        $valid_data[$what] = absint($input_value);
345 345
                         // get event via the event id we put in the form
346 346
                         $valid_data['event'] = EE_Registry::instance()
347 347
                                                            ->load_model('Event')
@@ -349,17 +349,17 @@  discard block
 block discarded – undo
349 349
                         break;
350 350
                     case 'rows':
351 351
                     case 'max_atndz':
352
-                        $valid_data[ $what ] = absint($input_value);
352
+                        $valid_data[$what] = absint($input_value);
353 353
                         break;
354 354
                     // arrays of integers
355 355
                     case 'qty':
356 356
                         /** @var array $row_qty */
357 357
                         $row_qty = $input_value;
358 358
                         // if qty is coming from a radio button input, then we need to assemble an array of rows
359
-                        if (! is_array($row_qty)) {
359
+                        if ( ! is_array($row_qty)) {
360 360
                             // get number of rows
361
-                            $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
362
-                                ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
361
+                            $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id)
362
+                                ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id))
363 363
                                 : 1;
364 364
                             // explode ints by the dash
365 365
                             $row_qty = explode('-', $row_qty);
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
                             $qty     = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
368 368
                             $row_qty = array($row => $qty);
369 369
                             for ($x = 1; $x <= $rows; $x++) {
370
-                                if (! isset($row_qty[ $x ])) {
371
-                                    $row_qty[ $x ] = 0;
370
+                                if ( ! isset($row_qty[$x])) {
371
+                                    $row_qty[$x] = 0;
372 372
                                 }
373 373
                             }
374 374
                         }
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
                         foreach ($row_qty as $qty) {
378 378
                             $qty = absint($qty);
379 379
                             // sanitize as integers
380
-                            $valid_data[ $what ][]       = $qty;
380
+                            $valid_data[$what][] = $qty;
381 381
                             $valid_data['total_tickets'] += $qty;
382 382
                         }
383 383
                         break;
@@ -387,14 +387,14 @@  discard block
 block discarded – undo
387 387
                         // cycle thru values
388 388
                         foreach ((array) $input_value as $key => $value) {
389 389
                             // allow only numbers, letters,  spaces, commas and dashes
390
-                            $value_array[ $key ] = wp_strip_all_tags($value);
390
+                            $value_array[$key] = wp_strip_all_tags($value);
391 391
                             // get ticket via the ticket id we put in the form
392 392
                             $ticket_obj                       = EE_Registry::instance()
393 393
                                                                             ->load_model('Ticket')
394 394
                                                                             ->get_one_by_ID($value);
395
-                            $valid_data['ticket_obj'][ $key ] = $ticket_obj;
395
+                            $valid_data['ticket_obj'][$key] = $ticket_obj;
396 396
                         }
397
-                        $valid_data[ $what ] = $value_array;
397
+                        $valid_data[$what] = $value_array;
398 398
                         break;
399 399
                     case 'return_url' :
400 400
                         // grab and sanitize return-url
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
                             $input_value = explode('#', $input_value);
406 406
                             $input_value = end($input_value);
407 407
                             // use event list url instead, but append anchor
408
-                            $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
408
+                            $input_value = EEH_Event_View::event_archive_url().'#'.$input_value;
409 409
                         }
410
-                        $valid_data[ $what ] = $input_value;
410
+                        $valid_data[$what] = $input_value;
411 411
                         break;
412 412
                 }    // end switch $what
413 413
             }
@@ -537,24 +537,24 @@  discard block
 block discarded – undo
537 537
     private function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
538 538
     {
539 539
         // if the $_available_spaces array has not been set up yet...
540
-        if (! isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
540
+        if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
541 541
             $this->setInitialTicketDatetimeAvailability($ticket);
542 542
         }
543 543
         $available_spaces = $ticket->qty() - $ticket->sold();
544
-        if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
544
+        if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
545 545
             // loop thru tickets, which will ALSO include individual ticket records AND a total
546
-            foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
546
+            foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
547 547
                 // if we want the original datetime availability BEFORE we started subtracting tickets ?
548 548
                 if ($get_original_ticket_spaces) {
549 549
                     // then grab the available spaces from the "tickets" array
550 550
                     // and compare with the above to get the lowest number
551 551
                     $available_spaces = min(
552 552
                         $available_spaces,
553
-                        self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
553
+                        self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]
554 554
                     );
555 555
                 } else {
556 556
                     // we want the updated ticket availability as stored in the "datetimes" array
557
-                    $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ]);
557
+                    $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]);
558 558
                 }
559 559
             }
560 560
         }
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
                 'order_by' => array('DTT_EVT_start' => 'ASC'),
586 586
             )
587 587
         );
588
-        if (! empty($datetimes)) {
588
+        if ( ! empty($datetimes)) {
589 589
             // now loop thru all of the datetimes
590 590
             foreach ($datetimes as $datetime) {
591 591
                 if ($datetime instanceof EE_Datetime) {
@@ -593,17 +593,17 @@  discard block
 block discarded – undo
593 593
                     $spaces_remaining = $datetime->spaces_remaining();
594 594
                     // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
595 595
                     // or the datetime spaces remaining) to this ticket using the datetime ID as the key
596
-                    self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
596
+                    self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(
597 597
                         $ticket->qty() - $ticket->sold(),
598 598
                         $spaces_remaining
599 599
                     );
600 600
                     // if the remaining spaces for this datetime is already set,
601 601
                     // then compare that against the datetime spaces remaining, and take the lowest number,
602 602
                     // else just take the datetime spaces remaining, and assign to the datetimes array
603
-                    self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset(
604
-                        self::$_available_spaces['datetimes'][ $datetime->ID() ]
603
+                    self::$_available_spaces['datetimes'][$datetime->ID()] = isset(
604
+                        self::$_available_spaces['datetimes'][$datetime->ID()]
605 605
                     )
606
-                        ? min(self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
606
+                        ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining)
607 607
                         : $spaces_remaining;
608 608
                 }
609 609
             }
@@ -619,11 +619,11 @@  discard block
 block discarded – undo
619 619
      */
620 620
     private function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
621 621
     {
622
-        if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
622
+        if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
623 623
             // loop thru tickets, which will ALSO include individual ticket records AND a total
624
-            foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
624
+            foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
625 625
                 // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
626
-                self::$_available_spaces['datetimes'][ $DTD_ID ] -= $qty;
626
+                self::$_available_spaces['datetimes'][$DTD_ID] -= $qty;
627 627
             }
628 628
         }
629 629
     }
Please login to merge, or discard this patch.
core/bootstrap_espresso.php 2 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -9,22 +9,22 @@  discard block
 block discarded – undo
9 9
  */
10 10
 function espresso_load_error_handling()
11 11
 {
12
-    static $error_handling_loaded = false;
13
-    if ($error_handling_loaded) {
14
-        return;
15
-    }
16
-    // load debugging tools
17
-    if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
18
-        require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
19
-        \EEH_Debug_Tools::instance();
20
-    }
21
-    // load error handling
22
-    if (is_readable(EE_CORE . 'EE_Error.core.php')) {
23
-        require_once EE_CORE . 'EE_Error.core.php';
24
-    } else {
25
-        wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
26
-    }
27
-    $error_handling_loaded = true;
12
+	static $error_handling_loaded = false;
13
+	if ($error_handling_loaded) {
14
+		return;
15
+	}
16
+	// load debugging tools
17
+	if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
18
+		require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
19
+		\EEH_Debug_Tools::instance();
20
+	}
21
+	// load error handling
22
+	if (is_readable(EE_CORE . 'EE_Error.core.php')) {
23
+		require_once EE_CORE . 'EE_Error.core.php';
24
+	} else {
25
+		wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
26
+	}
27
+	$error_handling_loaded = true;
28 28
 }
29 29
 
30 30
 
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
  */
39 39
 function espresso_load_required($classname, $full_path_to_file)
40 40
 {
41
-    if (is_readable($full_path_to_file)) {
42
-        require_once $full_path_to_file;
43
-    } else {
44
-        throw new \EE_Error (
45
-            sprintf(
46
-                esc_html__(
47
-                    'The %s class file could not be located or is not readable due to file permissions.',
48
-                    'event_espresso'
49
-                ),
50
-                $classname
51
-            )
52
-        );
53
-    }
41
+	if (is_readable($full_path_to_file)) {
42
+		require_once $full_path_to_file;
43
+	} else {
44
+		throw new \EE_Error (
45
+			sprintf(
46
+				esc_html__(
47
+					'The %s class file could not be located or is not readable due to file permissions.',
48
+					'event_espresso'
49
+				),
50
+				$classname
51
+			)
52
+		);
53
+	}
54 54
 }
55 55
 
56 56
 
@@ -69,41 +69,41 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function bootstrap_espresso()
71 71
 {
72
-    require_once __DIR__ . '/espresso_definitions.php';
73
-    try {
74
-        espresso_load_error_handling();
75
-        espresso_load_required(
76
-            'EEH_Base',
77
-            EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
78
-        );
79
-        espresso_load_required(
80
-            'EEH_File',
81
-            EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
82
-        );
83
-        espresso_load_required(
84
-            'EEH_File',
85
-            EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
86
-        );
87
-        espresso_load_required(
88
-            'EEH_Array',
89
-            EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
90
-        );
91
-        // instantiate and configure PSR4 autoloader
92
-        espresso_load_required(
93
-            'Psr4Autoloader',
94
-            EE_CORE . 'Psr4Autoloader.php'
95
-        );
96
-        espresso_load_required(
97
-            'EE_Psr4AutoloaderInit',
98
-            EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
99
-        );
100
-        $AutoloaderInit = new EE_Psr4AutoloaderInit();
101
-        $AutoloaderInit->initializeAutoloader();
102
-        new EventEspresso\core\services\bootstrap\BootstrapCore();
103
-    } catch (Exception $e) {
104
-        require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php';
105
-        new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
106
-    }
72
+	require_once __DIR__ . '/espresso_definitions.php';
73
+	try {
74
+		espresso_load_error_handling();
75
+		espresso_load_required(
76
+			'EEH_Base',
77
+			EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
78
+		);
79
+		espresso_load_required(
80
+			'EEH_File',
81
+			EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
82
+		);
83
+		espresso_load_required(
84
+			'EEH_File',
85
+			EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
86
+		);
87
+		espresso_load_required(
88
+			'EEH_Array',
89
+			EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
90
+		);
91
+		// instantiate and configure PSR4 autoloader
92
+		espresso_load_required(
93
+			'Psr4Autoloader',
94
+			EE_CORE . 'Psr4Autoloader.php'
95
+		);
96
+		espresso_load_required(
97
+			'EE_Psr4AutoloaderInit',
98
+			EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
99
+		);
100
+		$AutoloaderInit = new EE_Psr4AutoloaderInit();
101
+		$AutoloaderInit->initializeAutoloader();
102
+		new EventEspresso\core\services\bootstrap\BootstrapCore();
103
+	} catch (Exception $e) {
104
+		require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php';
105
+		new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
106
+	}
107 107
 }
108 108
 
109 109
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
         return;
15 15
     }
16 16
     // load debugging tools
17
-    if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
18
-        require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
17
+    if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) {
18
+        require_once EE_HELPERS.'EEH_Debug_Tools.helper.php';
19 19
         \EEH_Debug_Tools::instance();
20 20
     }
21 21
     // load error handling
22
-    if (is_readable(EE_CORE . 'EE_Error.core.php')) {
23
-        require_once EE_CORE . 'EE_Error.core.php';
22
+    if (is_readable(EE_CORE.'EE_Error.core.php')) {
23
+        require_once EE_CORE.'EE_Error.core.php';
24 24
     } else {
25 25
         wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
26 26
     }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     if (is_readable($full_path_to_file)) {
42 42
         require_once $full_path_to_file;
43 43
     } else {
44
-        throw new \EE_Error (
44
+        throw new \EE_Error(
45 45
             sprintf(
46 46
                 esc_html__(
47 47
                     'The %s class file could not be located or is not readable due to file permissions.',
@@ -69,39 +69,39 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function bootstrap_espresso()
71 71
 {
72
-    require_once __DIR__ . '/espresso_definitions.php';
72
+    require_once __DIR__.'/espresso_definitions.php';
73 73
     try {
74 74
         espresso_load_error_handling();
75 75
         espresso_load_required(
76 76
             'EEH_Base',
77
-            EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
77
+            EE_CORE.'helpers'.DS.'EEH_Base.helper.php'
78 78
         );
79 79
         espresso_load_required(
80 80
             'EEH_File',
81
-            EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
81
+            EE_CORE.'interfaces'.DS.'EEHI_File.interface.php'
82 82
         );
83 83
         espresso_load_required(
84 84
             'EEH_File',
85
-            EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
85
+            EE_CORE.'helpers'.DS.'EEH_File.helper.php'
86 86
         );
87 87
         espresso_load_required(
88 88
             'EEH_Array',
89
-            EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
89
+            EE_CORE.'helpers'.DS.'EEH_Array.helper.php'
90 90
         );
91 91
         // instantiate and configure PSR4 autoloader
92 92
         espresso_load_required(
93 93
             'Psr4Autoloader',
94
-            EE_CORE . 'Psr4Autoloader.php'
94
+            EE_CORE.'Psr4Autoloader.php'
95 95
         );
96 96
         espresso_load_required(
97 97
             'EE_Psr4AutoloaderInit',
98
-            EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
98
+            EE_CORE.'EE_Psr4AutoloaderInit.core.php'
99 99
         );
100 100
         $AutoloaderInit = new EE_Psr4AutoloaderInit();
101 101
         $AutoloaderInit->initializeAutoloader();
102 102
         new EventEspresso\core\services\bootstrap\BootstrapCore();
103 103
     } catch (Exception $e) {
104
-        require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php';
104
+        require_once EE_CORE.'exceptions'.DS.'ExceptionStackTraceDisplay.php';
105 105
         new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
106 106
     }
107 107
 }
Please login to merge, or discard this patch.
core/EE_Data_Migration_Manager.core.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 use EventEspresso\core\exceptions\InvalidDataTypeException;
4 4
 use EventEspresso\core\exceptions\InvalidInterfaceException;
5 5
 use EventEspresso\core\interfaces\ResettableInterface;
6
-
7 6
 use EventEspresso\core\services\database\TableManager;
8 7
 use EventEspresso\core\services\database\TableAnalysis;
9 8
 
Please login to merge, or discard this patch.
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
 	protected $script_migration_versions;
137 137
 
138 138
 	/**
139
-     * 	@var EE_Data_Migration_Manager $_instance
139
+	 * 	@var EE_Data_Migration_Manager $_instance
140 140
 	 * 	@access 	private
141
-     */
141
+	 */
142 142
 	private static $_instance = NULL;
143 143
 
144 144
 
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
 	 */
323 323
 	public function get_data_migration_script_folders(){
324 324
 		return  apply_filters(
325
-		    'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',
326
-            array('Core' => EE_CORE.'data_migration_scripts')
327
-        );
325
+			'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',
326
+			array('Core' => EE_CORE.'data_migration_scripts')
327
+		);
328 328
 	}
329 329
 
330 330
 	/**
@@ -337,15 +337,15 @@  discard block
 block discarded – undo
337 337
 	 * @throws EE_Error
338 338
 	 */
339 339
 	public function script_migrates_to_version($migration_script_name, $eeAddonClass = ''){
340
-	    if(isset($this->script_migration_versions[ $migration_script_name ])){
341
-	        return $this->script_migration_versions[ $migration_script_name ];
342
-        }
340
+		if(isset($this->script_migration_versions[ $migration_script_name ])){
341
+			return $this->script_migration_versions[ $migration_script_name ];
342
+		}
343 343
 		$dms_info = $this->parse_dms_classname($migration_script_name);
344
-        $this->script_migration_versions[ $migration_script_name ] = array(
344
+		$this->script_migration_versions[ $migration_script_name ] = array(
345 345
 			'slug'=> $eeAddonClass !== '' ? $eeAddonClass : $dms_info[ 'slug' ],
346 346
 			'version'=> $dms_info[ 'major_version' ] . "." . $dms_info[ 'minor_version' ] . "." . $dms_info[ 'micro_version' ]
347
-        );
348
-        return $this->script_migration_versions[ $migration_script_name ];
347
+		);
348
+		return $this->script_migration_versions[ $migration_script_name ];
349 349
 	}
350 350
 
351 351
 	/**
@@ -736,60 +736,60 @@  discard block
 block discarded – undo
736 736
 	}
737 737
 
738 738
 
739
-    /**
740
-     * Gets all the data migration scripts available in the core folder and folders
741
-     * in addons. Has the side effect of adding them for autoloading
742
-     *
743
-     * @return array keys are expected classnames, values are their filepaths
744
-     * @throws InvalidInterfaceException
745
-     * @throws InvalidDataTypeException
746
-     * @throws EE_Error
747
-     * @throws InvalidArgumentException
748
-     */
749
-    public function get_all_data_migration_scripts_available()
750
-    {
751
-        if (! $this->_data_migration_class_to_filepath_map) {
752
-            $this->_data_migration_class_to_filepath_map = array();
753
-            foreach ($this->get_data_migration_script_folders() as $eeAddonClass => $folder_path) {
754
-                // strip any placeholders added to classname to make it a unique array key
755
-                $eeAddonClass = trim($eeAddonClass, '*');
756
-                $eeAddonClass = $eeAddonClass === 'Core' || class_exists($eeAddonClass)
757
-                    ? $eeAddonClass
758
-                    : '';
759
-                $folder_path  = EEH_File::end_with_directory_separator($folder_path);
760
-                $files        = glob($folder_path . '*.dms.php');
761
-                if (empty($files)) {
762
-                    continue;
763
-                }
764
-                foreach ($files as $file) {
765
-                    $pos_of_last_slash = strrpos($file, DS);
766
-                    $classname         = str_replace('.dms.php', '', substr($file, $pos_of_last_slash + 1));
767
-                    $migrates_to       = $this->script_migrates_to_version($classname, $eeAddonClass);
768
-                    $slug              = $migrates_to['slug'];
769
-                    //check that the slug as contained in the DMS is associated with
770
-                    //the slug of an addon or core
771
-                    if ($slug !== 'Core' && EE_Registry::instance()->get_addon_by_name($slug) === null) {
772
-                        EE_Error::doing_it_wrong(
773
-                            __FUNCTION__,
774
-                            sprintf(
775
-                                esc_html__(
776
-                                    'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ',
777
-                                    'event_espresso'
778
-                                ),
779
-                                $classname,
780
-                                $slug,
781
-                                implode(', ', array_keys(EE_Registry::instance()->get_addons_by_name()))
782
-                            ),
783
-                            '4.3.0.alpha.019'
784
-                        );
785
-                    }
786
-                    $this->_data_migration_class_to_filepath_map[ $classname ] = $file;
787
-                }
788
-            }
789
-            EEH_Autoloader::register_autoloader($this->_data_migration_class_to_filepath_map);
790
-        }
791
-        return $this->_data_migration_class_to_filepath_map;
792
-    }
739
+	/**
740
+	 * Gets all the data migration scripts available in the core folder and folders
741
+	 * in addons. Has the side effect of adding them for autoloading
742
+	 *
743
+	 * @return array keys are expected classnames, values are their filepaths
744
+	 * @throws InvalidInterfaceException
745
+	 * @throws InvalidDataTypeException
746
+	 * @throws EE_Error
747
+	 * @throws InvalidArgumentException
748
+	 */
749
+	public function get_all_data_migration_scripts_available()
750
+	{
751
+		if (! $this->_data_migration_class_to_filepath_map) {
752
+			$this->_data_migration_class_to_filepath_map = array();
753
+			foreach ($this->get_data_migration_script_folders() as $eeAddonClass => $folder_path) {
754
+				// strip any placeholders added to classname to make it a unique array key
755
+				$eeAddonClass = trim($eeAddonClass, '*');
756
+				$eeAddonClass = $eeAddonClass === 'Core' || class_exists($eeAddonClass)
757
+					? $eeAddonClass
758
+					: '';
759
+				$folder_path  = EEH_File::end_with_directory_separator($folder_path);
760
+				$files        = glob($folder_path . '*.dms.php');
761
+				if (empty($files)) {
762
+					continue;
763
+				}
764
+				foreach ($files as $file) {
765
+					$pos_of_last_slash = strrpos($file, DS);
766
+					$classname         = str_replace('.dms.php', '', substr($file, $pos_of_last_slash + 1));
767
+					$migrates_to       = $this->script_migrates_to_version($classname, $eeAddonClass);
768
+					$slug              = $migrates_to['slug'];
769
+					//check that the slug as contained in the DMS is associated with
770
+					//the slug of an addon or core
771
+					if ($slug !== 'Core' && EE_Registry::instance()->get_addon_by_name($slug) === null) {
772
+						EE_Error::doing_it_wrong(
773
+							__FUNCTION__,
774
+							sprintf(
775
+								esc_html__(
776
+									'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ',
777
+									'event_espresso'
778
+								),
779
+								$classname,
780
+								$slug,
781
+								implode(', ', array_keys(EE_Registry::instance()->get_addons_by_name()))
782
+							),
783
+							'4.3.0.alpha.019'
784
+						);
785
+					}
786
+					$this->_data_migration_class_to_filepath_map[ $classname ] = $file;
787
+				}
788
+			}
789
+			EEH_Autoloader::register_autoloader($this->_data_migration_class_to_filepath_map);
790
+		}
791
+		return $this->_data_migration_class_to_filepath_map;
792
+	}
793 793
 
794 794
 
795 795
 
@@ -961,12 +961,12 @@  discard block
 block discarded – undo
961 961
 	}
962 962
 
963 963
 /**
964
-	 * Resets the borked data migration scripts so they're no longer borked
965
-	 * so we can again attempt to migrate
966
-	 *
967
-	 * @return bool
968
-	 * @throws EE_Error
969
-	 */
964
+ * Resets the borked data migration scripts so they're no longer borked
965
+ * so we can again attempt to migrate
966
+ *
967
+ * @return bool
968
+ * @throws EE_Error
969
+ */
970 970
 	public function reattempt(){
971 971
 		//find if the last-ran script was borked
972 972
 		//set it as being non-borked (we shouldn't ever get DMSs that we don't recognize)
Please login to merge, or discard this patch.
Spacing   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * of this EE installation. Keys should be the name of the version the script upgraded to
86 86
 	 * @var EE_Data_Migration_Script_Base[]
87 87
 	 */
88
-	private $_data_migrations_ran =null;
88
+	private $_data_migrations_ran = null;
89 89
 	/**
90 90
 	 * The last ran script. It's nice to store this somewhere accessible, as its easiest
91 91
 	 * to know which was the last run by which is the newest wp option; but in most of the code
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 */
151 151
 	public static function instance() {
152 152
 		// check if class object is instantiated
153
-		if ( ! self::$_instance instanceof EE_Data_Migration_Manager ) {
153
+		if ( ! self::$_instance instanceof EE_Data_Migration_Manager) {
154 154
 			self::$_instance = new self();
155 155
 		}
156 156
 		return self::$_instance;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * all new usages of the singleton should be made with Classname::instance()) and returns it
161 161
 	 * @return EE_Data_Migration_Manager
162 162
 	 */
163
-	public static function reset(){
163
+	public static function reset() {
164 164
 		self::$_instance = NULL;
165 165
 		return self::instance();
166 166
 	}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	/**
171 171
 	 * constructor
172 172
 	 */
173
-	private function __construct(){
173
+	private function __construct() {
174 174
 		$this->stati_that_indicate_to_continue_migrations = array(
175 175
 			self::status_continue,
176 176
 			self::status_completed
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
 		);
190 190
 		//make sure we've included the base migration script, because we may need the EE_DMS_Unknown_1_0_0 class
191 191
 		//to be defined, because right now it doesn't get autoloaded on its own
192
-		EE_Registry::instance()->load_core( 'Data_Migration_Class_Base', array(), TRUE );
193
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Base', array(), TRUE );
194
-		EE_Registry::instance()->load_core( 'DMS_Unknown_1_0_0', array(), TRUE );
195
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage', array(), TRUE );
196
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage_Table', array(), TRUE );
197
-		$this->_table_manager = EE_Registry::instance()->create( 'TableManager', array(), true );
198
-		$this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true );
192
+		EE_Registry::instance()->load_core('Data_Migration_Class_Base', array(), TRUE);
193
+		EE_Registry::instance()->load_core('Data_Migration_Script_Base', array(), TRUE);
194
+		EE_Registry::instance()->load_core('DMS_Unknown_1_0_0', array(), TRUE);
195
+		EE_Registry::instance()->load_core('Data_Migration_Script_Stage', array(), TRUE);
196
+		EE_Registry::instance()->load_core('Data_Migration_Script_Stage_Table', array(), TRUE);
197
+		$this->_table_manager = EE_Registry::instance()->create('TableManager', array(), true);
198
+		$this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
199 199
 	}
200 200
 
201 201
 
@@ -208,21 +208,21 @@  discard block
 block discarded – undo
208 208
 	 * @param string $option_name (see EE_Data_Migration_Manage::_save_migrations_ran() where the option name is set)
209 209
 	 * @return array where the first item is the plugin slug (eg 'Core','Calendar',etc) and the 2nd is the version of that plugin (eg '4.1.0')
210 210
 	 */
211
-	private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name){
211
+	private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name) {
212 212
 		$plugin_slug_and_version_string = str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_name);
213 213
 		//check if $plugin_slug_and_version_string is like '4.1.0' (4.1-style) or 'Core.4.1.0' (4.2-style)
214
-		$parts = explode(".",$plugin_slug_and_version_string);
214
+		$parts = explode(".", $plugin_slug_and_version_string);
215 215
 
216
-		if(count($parts) == 4){
216
+		if (count($parts) == 4) {
217 217
 			//it's 4.2-style.eg Core.4.1.0
218
-			$plugin_slug = $parts[0];//eg Core
218
+			$plugin_slug = $parts[0]; //eg Core
219 219
 			$version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0
220
-		}else{
220
+		} else {
221 221
 			//it's 4.1-style: eg 4.1.0
222 222
 			$plugin_slug = 'Core';
223
-			$version_string = $plugin_slug_and_version_string;//eg 4.1.0
223
+			$version_string = $plugin_slug_and_version_string; //eg 4.1.0
224 224
 		}
225
-		return array($plugin_slug,$version_string);
225
+		return array($plugin_slug, $version_string);
226 226
 	}
227 227
 
228 228
 	/**
@@ -233,21 +233,21 @@  discard block
 block discarded – undo
233 233
 	 * @return EE_Data_Migration_Script_Base
234 234
 	 * @throws EE_Error
235 235
 	 */
236
-	private function _get_dms_class_from_wp_option($dms_option_name,$dms_option_value){
236
+	private function _get_dms_class_from_wp_option($dms_option_name, $dms_option_value) {
237 237
 		$data_migration_data = maybe_unserialize($dms_option_value);
238
-		if(isset($data_migration_data['class']) && class_exists($data_migration_data['class'])){
238
+		if (isset($data_migration_data['class']) && class_exists($data_migration_data['class'])) {
239 239
 			$class = new $data_migration_data['class'];
240
-			if($class instanceof EE_Data_Migration_Script_Base){
240
+			if ($class instanceof EE_Data_Migration_Script_Base) {
241 241
 				$class->instantiate_from_array_of_properties($data_migration_data);
242 242
 				return $class;
243
-			}else{
243
+			} else {
244 244
 				//huh, so its an object but not a data migration script?? that shouldn't happen
245 245
 				//just leave it as an array (which will probably just get ignored)
246
-				throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class']));
246
+				throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'), $data_migration_data['class']));
247 247
 			}
248
-		}else{
248
+		} else {
249 249
 			//so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists
250
-			throw new EE_Error(sprintf(__("The wp option  with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name));
250
+			throw new EE_Error(sprintf(__("The wp option  with key '%s' does not represent a DMS", 'event_espresso'), $dms_option_name));
251 251
 		}
252 252
 	}
253 253
 	/**
@@ -255,34 +255,34 @@  discard block
 block discarded – undo
255 255
 	 * the last ran which hasn't finished yet
256 256
 	 * @return array where each element should be an array of EE_Data_Migration_Script_Base (but also has a few legacy arrays in there - which should probably be ignored)
257 257
 	 */
258
-	public function get_data_migrations_ran(){
259
-		if( ! $this->_data_migrations_ran ){
258
+	public function get_data_migrations_ran() {
259
+		if ( ! $this->_data_migrations_ran) {
260 260
 			//setup autoloaders for each of the scripts in there
261 261
 			$this->get_all_data_migration_scripts_available();
262
-			$data_migrations_options = $this->get_all_migration_script_options();//get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array()));
262
+			$data_migrations_options = $this->get_all_migration_script_options(); //get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array()));
263 263
 
264 264
 			$data_migrations_ran = array();
265 265
 			//convert into data migration script classes where possible
266
-			foreach($data_migrations_options as $data_migration_option){
267
-				list($plugin_slug,$version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']);
266
+			foreach ($data_migrations_options as $data_migration_option) {
267
+				list($plugin_slug, $version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']);
268 268
 
269
-				try{
270
-					$class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'],$data_migration_option['option_value']);
269
+				try {
270
+					$class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'], $data_migration_option['option_value']);
271 271
 					$data_migrations_ran[$plugin_slug][$version_string] = $class;
272 272
 					//ok so far THIS is the 'last-ran-script'... unless we find another on next iteration
273 273
 					$this->_last_ran_script = $class;
274
-					if( ! $class->is_completed()){
274
+					if ( ! $class->is_completed()) {
275 275
 						//sometimes we also like to know which was the last incomplete script (or if there are any at all)
276 276
 						$this->_last_ran_incomplete_script = $class;
277 277
 					}
278
-				}catch(EE_Error $e){
278
+				} catch (EE_Error $e) {
279 279
 					//ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs
280 280
 					$data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']);
281 281
 				}
282 282
 			}
283 283
 			//so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays
284 284
 			$this->_data_migrations_ran = $data_migrations_ran;
285
-			 if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran) ){
285
+			 if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) {
286 286
 				$this->_data_migrations_ran = array();
287 287
 			}
288 288
 		}
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @param        $new_table
300 300
 	 * @return mixed string or int
301 301
 	 */
302
-	public function get_mapping_new_pk( $script_name, $old_table, $old_pk, $new_table){
302
+	public function get_mapping_new_pk($script_name, $old_table, $old_pk, $new_table) {
303 303
 		$script = EE_Registry::instance()->load_dms($script_name);
304 304
 		$mapping = $script->get_mapping_new_pk($old_table, $old_pk, $new_table);
305 305
 		return $mapping;
@@ -310,9 +310,9 @@  discard block
 block discarded – undo
310 310
 	 * option returned in this array is the most-recently ran DMS option
311 311
 	 * @return array
312 312
 	 */
313
-	 public function get_all_migration_script_options(){
313
+	 public function get_all_migration_script_options() {
314 314
 		global $wpdb;
315
-		return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC",ARRAY_A);
315
+		return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC", ARRAY_A);
316 316
 	}
317 317
 
318 318
 	/**
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 * @return array where each value is the full folder path of a folder containing data migration scripts, WITH slashes at the end of the
321 321
 	 * folder name.
322 322
 	 */
323
-	public function get_data_migration_script_folders(){
323
+	public function get_data_migration_script_folders() {
324 324
 		return  apply_filters(
325 325
 		    'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',
326 326
             array('Core' => EE_CORE.'data_migration_scripts')
@@ -336,16 +336,16 @@  discard block
 block discarded – undo
336 336
 	 * }
337 337
 	 * @throws EE_Error
338 338
 	 */
339
-	public function script_migrates_to_version($migration_script_name, $eeAddonClass = ''){
340
-	    if(isset($this->script_migration_versions[ $migration_script_name ])){
341
-	        return $this->script_migration_versions[ $migration_script_name ];
339
+	public function script_migrates_to_version($migration_script_name, $eeAddonClass = '') {
340
+	    if (isset($this->script_migration_versions[$migration_script_name])) {
341
+	        return $this->script_migration_versions[$migration_script_name];
342 342
         }
343 343
 		$dms_info = $this->parse_dms_classname($migration_script_name);
344
-        $this->script_migration_versions[ $migration_script_name ] = array(
345
-			'slug'=> $eeAddonClass !== '' ? $eeAddonClass : $dms_info[ 'slug' ],
346
-			'version'=> $dms_info[ 'major_version' ] . "." . $dms_info[ 'minor_version' ] . "." . $dms_info[ 'micro_version' ]
344
+        $this->script_migration_versions[$migration_script_name] = array(
345
+			'slug'=> $eeAddonClass !== '' ? $eeAddonClass : $dms_info['slug'],
346
+			'version'=> $dms_info['major_version'].".".$dms_info['minor_version'].".".$dms_info['micro_version']
347 347
         );
348
-        return $this->script_migration_versions[ $migration_script_name ];
348
+        return $this->script_migration_versions[$migration_script_name];
349 349
 	}
350 350
 
351 351
 	/**
@@ -354,13 +354,13 @@  discard block
 block discarded – undo
354 354
 	 * @return array with keys 'slug','major_version','minor_version', and 'micro_version' (the last 3 are ints)
355 355
 	 * @throws EE_Error
356 356
 	 */
357
-	public function parse_dms_classname($classname){
357
+	public function parse_dms_classname($classname) {
358 358
 		$matches = array();
359
-		preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~',$classname,$matches);
360
-		if( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))){
361
-				throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"),$classname));
359
+		preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~', $classname, $matches);
360
+		if ( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) {
361
+				throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"), $classname));
362 362
 		}
363
-		return array('slug'=>$matches[1],'major_version'=>intval($matches[2]),'minor_version'=>intval($matches[3]),'micro_version'=>intval($matches[4]));
363
+		return array('slug'=>$matches[1], 'major_version'=>intval($matches[2]), 'minor_version'=>intval($matches[3]), 'micro_version'=>intval($matches[4]));
364 364
 	}
365 365
 	/**
366 366
 	 * Ensures that the option indicating the current DB version is set. This should only be
@@ -369,33 +369,33 @@  discard block
 block discarded – undo
369 369
 	 * to 4.1.x.
370 370
 	 * @return string of current db state
371 371
 	 */
372
-	public function ensure_current_database_state_is_set(){
373
-		$espresso_db_core_updates = get_option( 'espresso_db_update', array() );
372
+	public function ensure_current_database_state_is_set() {
373
+		$espresso_db_core_updates = get_option('espresso_db_update', array());
374 374
 		$db_state = get_option(EE_Data_Migration_Manager::current_database_state);
375
-		if( ! $db_state ){
375
+		if ( ! $db_state) {
376 376
 			//mark the DB as being in the state as the last version in there.
377 377
 			//this is done to trigger maintenance mode and do data migration scripts
378 378
 			//if the admin installed this version of EE over 3.1.x or 4.0.x
379 379
 			//otherwise, the normal maintenance mode code is fine
380 380
 			$previous_versions_installed = array_keys($espresso_db_core_updates);
381 381
 			$previous_version_installed = end($previous_versions_installed);
382
-			if(version_compare('4.1.0', $previous_version_installed)){
382
+			if (version_compare('4.1.0', $previous_version_installed)) {
383 383
 				//last installed version was less than 4.1
384 384
 				//so we want the data migrations to happen. SO, we're going to say the DB is at that state
385 385
 //				echo "4.1.0 is greater than $previous_version_installed! update the option";
386 386
 				$db_state = array('Core'=>$previous_version_installed);
387
-			}else{
387
+			} else {
388 388
 //					echo "4.1.0 is SMALLER than $previous_version_installed";
389 389
 					$db_state = array('Core'=>EVENT_ESPRESSO_VERSION);
390 390
 			}
391
-			update_option(EE_Data_Migration_Manager::current_database_state,$db_state);
391
+			update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
392 392
 		}
393 393
 		//in 4.1, $db_state would have only been a simple string like '4.1.0',
394 394
 		//but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's
395 395
 		//db, and possibly other keys for other addons like 'Calendar','Permissions',etc
396
-		if( ! is_array($db_state)){
396
+		if ( ! is_array($db_state)) {
397 397
 			$db_state = array('Core'=>$db_state);
398
-			update_option(EE_Data_Migration_Manager::current_database_state,$db_state);
398
+			update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
399 399
 		}
400 400
 		return $db_state;
401 401
 	}
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 	 * or they don't apply), returns an empty array
407 407
 	 * @return EE_Data_Migration_Script_Base[]
408 408
 	 */
409
-	public function check_for_applicable_data_migration_scripts(){
409
+	public function check_for_applicable_data_migration_scripts() {
410 410
 		//get the option describing what options have already run
411 411
 		$scripts_ran = $this->get_data_migrations_ran();
412 412
 		//$scripts_ran = array('4.1.0.core'=>array('monkey'=>null));
@@ -419,62 +419,62 @@  discard block
 block discarded – undo
419 419
 		$iteration = 0;
420 420
 		$next_database_state_to_consider = $current_database_state;
421 421
 		$theoretical_database_state = NULL;
422
-		do{
422
+		do {
423 423
 			//the next state after the currently-considered one will start off looking the same as the current, but we may make additions...
424 424
 			$theoretical_database_state = $next_database_state_to_consider;
425 425
 			//the next db state to consider is "what would the DB be like had we run all the scripts we found that applied last time?)
426
-			foreach($script_class_and_filepaths_available as $classname => $filepath){
426
+			foreach ($script_class_and_filepaths_available as $classname => $filepath) {
427 427
 
428 428
 				$migrates_to_version = $this->script_migrates_to_version($classname);
429
-				$script_converts_plugin_slug = $migrates_to_version[ 'slug' ];
430
-				$script_converts_to_version = $migrates_to_version[ 'version' ];
429
+				$script_converts_plugin_slug = $migrates_to_version['slug'];
430
+				$script_converts_to_version = $migrates_to_version['version'];
431 431
 				//check if this version script is DONE or not; or if it's never been ran
432
-				if(		! $scripts_ran ||
432
+				if ( ! $scripts_ran ||
433 433
 						! isset($scripts_ran[$script_converts_plugin_slug]) ||
434
-						! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])){
434
+						! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])) {
435 435
 					//we haven't ran this conversion script before
436 436
 					//now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available
437
-					$script = new $classname( $this->_get_table_manager(), $this->_get_table_analysis() );
437
+					$script = new $classname($this->_get_table_manager(), $this->_get_table_analysis());
438 438
 					/* @var $script EE_Data_Migration_Script_Base */
439 439
 					$can_migrate = $script->can_migrate_from_version($theoretical_database_state);
440
-					if($can_migrate){
440
+					if ($can_migrate) {
441 441
 						$script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script;
442 442
 						$migrates_to_version = $script->migrates_to_version();
443
-						$next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ];
443
+						$next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version'];
444 444
 						unset($script_class_and_filepaths_available[$classname]);
445 445
 					}
446
-				} elseif($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base){
446
+				} elseif ($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base) {
447 447
 					//this script has been ran, or at least started
448 448
 					$script = $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version];
449
-					if( $script->get_status() != self::status_completed){
449
+					if ($script->get_status() != self::status_completed) {
450 450
 						//this script is already underway... keep going with it
451 451
 						$script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script;
452 452
 						$migrates_to_version = $script->migrates_to_version();
453
-						$next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ];
453
+						$next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version'];
454 454
 						unset($script_class_and_filepaths_available[$classname]);
455
-					}else{
455
+					} else {
456 456
 						//it must have a status that indicates it has finished, so we don't want to try and run it again
457 457
 					}
458
-				}else{
458
+				} else {
459 459
 					//it exists but it's not  a proper data migration script
460 460
 					//maybe the script got renamed? or was simply removed from EE?
461 461
 					//either way, its certainly not runnable!
462 462
 				}
463 463
 			}
464 464
 			$iteration++;
465
-		}while( $next_database_state_to_consider != $theoretical_database_state && $iteration<6);
465
+		}while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6);
466 466
 		//ok we have all the scripts that should run, now let's make them into flat array
467 467
 		$scripts_that_should_run = array();
468
-		foreach($script_classes_that_should_run_per_iteration as $scripts_at_priority){
468
+		foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) {
469 469
 			ksort($scripts_at_priority);
470
-			foreach($scripts_at_priority as $scripts){
471
-				foreach($scripts as $script){
470
+			foreach ($scripts_at_priority as $scripts) {
471
+				foreach ($scripts as $script) {
472 472
 					$scripts_that_should_run[get_class($script)] = $script;
473 473
 				}
474 474
 			}
475 475
 		}
476 476
 
477
-		do_action( 'AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run );
477
+		do_action('AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run);
478 478
 		return $scripts_that_should_run;
479 479
 	}
480 480
 
@@ -488,14 +488,14 @@  discard block
 block discarded – undo
488 488
 	 * @param bool $include_completed_scripts
489 489
 	 * @return EE_Data_Migration_Script_Base
490 490
 	 */
491
-	public function get_last_ran_script($include_completed_scripts = false){
491
+	public function get_last_ran_script($include_completed_scripts = false) {
492 492
 		//make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script
493
-		if( ! $this->_data_migrations_ran){
493
+		if ( ! $this->_data_migrations_ran) {
494 494
 			$this->get_data_migrations_ran();
495 495
 		}
496
-		if($include_completed_scripts){
496
+		if ($include_completed_scripts) {
497 497
 			return $this->_last_ran_script;
498
-		}else{
498
+		} else {
499 499
 			return $this->_last_ran_incomplete_script;
500 500
 		}
501 501
 	}
@@ -518,19 +518,19 @@  discard block
 block discarded – undo
518 518
 	 * 		@type string $message string describing what was done during this step
519 519
 	 * }
520 520
 	 */
521
-	public function migration_step( $step_size = 0 ){
521
+	public function migration_step($step_size = 0) {
522 522
 
523 523
 		//bandaid fix for issue https://events.codebasehq.com/projects/event-espresso/tickets/7535
524
-		if ( class_exists( 'EE_CPT_Strategy' ) ) {
525
-			remove_action( 'pre_get_posts', array( EE_CPT_Strategy::instance(), 'pre_get_posts' ), 5 );
524
+		if (class_exists('EE_CPT_Strategy')) {
525
+			remove_action('pre_get_posts', array(EE_CPT_Strategy::instance(), 'pre_get_posts'), 5);
526 526
 		}
527 527
 
528
-		try{
528
+		try {
529 529
 			$currently_executing_script = $this->get_last_ran_script();
530
-			if( ! $currently_executing_script){
530
+			if ( ! $currently_executing_script) {
531 531
 				//Find the next script that needs to execute
532 532
 				$scripts = $this->check_for_applicable_data_migration_scripts();
533
-				if( ! $scripts ){
533
+				if ( ! $scripts) {
534 534
 					//huh, no more scripts to run... apparently we're done!
535 535
 					//but dont forget to make sure initial data is there
536 536
 					//we should be good to allow them to exit maintenance mode now
@@ -551,18 +551,18 @@  discard block
 block discarded – undo
551 551
 				//and add to the array/wp option showing the scripts ran
552 552
 //				$this->_data_migrations_ran[$this->script_migrates_to_version(get_class($currently_executing_script))] = $currently_executing_script;
553 553
 				$migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script));
554
-				$plugin_slug = $migrates_to[ 'slug' ];
555
-				$version = $migrates_to[ 'version' ];
554
+				$plugin_slug = $migrates_to['slug'];
555
+				$version = $migrates_to['version'];
556 556
 				$this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script;
557 557
 			}
558 558
 			$current_script_name = get_class($currently_executing_script);
559
-		}catch(Exception $e){
559
+		} catch (Exception $e) {
560 560
 			//an exception occurred while trying to get migration scripts
561 561
 
562
-			$message =  sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() );
562
+			$message = sprintf(__("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage().'<br>', $e->getTraceAsString());
563 563
 			//record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations
564 564
 			//but that's ok-- it's just an FYI to support that we couldn't even run any data migrations
565
-			$this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"),$message));
565
+			$this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"), $message));
566 566
 			return array(
567 567
 				'records_to_migrate'=>1,
568 568
 				'records_migrated'=>0,
@@ -572,16 +572,16 @@  discard block
 block discarded – undo
572 572
 			);
573 573
 		}
574 574
 		//ok so we definitely have a data migration script
575
-		try{
575
+		try {
576 576
 			//how big of a bite do we want to take? Allow users to easily override via their wp-config
577
-			if( ! absint( $step_size ) > 0 ){
578
-				$step_size = defined( 'EE_MIGRATION_STEP_SIZE' ) && absint( EE_MIGRATION_STEP_SIZE ) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size;
577
+			if ( ! absint($step_size) > 0) {
578
+				$step_size = defined('EE_MIGRATION_STEP_SIZE') && absint(EE_MIGRATION_STEP_SIZE) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size;
579 579
 			}
580 580
 			//do what we came to do!
581 581
 			$currently_executing_script->migration_step($step_size);
582 582
 			//can we wrap it up and verify default data?
583 583
 			$init_dbs = false;
584
-			switch($currently_executing_script->get_status()){
584
+			switch ($currently_executing_script->get_status()) {
585 585
 				case EE_Data_Migration_Manager::status_continue:
586 586
 					$response_array = array(
587 587
 						'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
@@ -593,16 +593,16 @@  discard block
 block discarded – undo
593 593
 				case EE_Data_Migration_Manager::status_completed:
594 594
 					//ok so THAT script has completed
595 595
 					$this->update_current_database_state_to($this->script_migrates_to_version($current_script_name));
596
-					$response_array =  array(
596
+					$response_array = array(
597 597
 							'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
598 598
 							'records_migrated'=>$currently_executing_script->count_records_migrated(),
599 599
 							'status'=> EE_Data_Migration_Manager::status_completed,
600 600
 							'message'=>$currently_executing_script->get_feedback_message(),
601
-							'script'=> sprintf(__("%s Completed",'event_espresso'),$currently_executing_script->pretty_name())
601
+							'script'=> sprintf(__("%s Completed", 'event_espresso'), $currently_executing_script->pretty_name())
602 602
 						);
603 603
 					//check if there are any more after this one.
604 604
 					$scripts_remaining = $this->check_for_applicable_data_migration_scripts();
605
-					if( ! $scripts_remaining ){
605
+					if ( ! $scripts_remaining) {
606 606
 						//we should be good to allow them to exit maintenance mode now
607 607
 						EE_Maintenance_Mode::instance()->set_maintenance_level(intval(EE_Maintenance_Mode::level_0_not_in_maintenance));
608 608
 						////huh, no more scripts to run... apparently we're done!
@@ -616,39 +616,39 @@  discard block
 block discarded – undo
616 616
 						'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
617 617
 						'records_migrated'=>$currently_executing_script->count_records_migrated(),
618 618
 						'status'=> $currently_executing_script->get_status(),
619
-						'message'=>  sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ",$currently_executing_script->get_errors())),
619
+						'message'=>  sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ", $currently_executing_script->get_errors())),
620 620
 						'script'=>$currently_executing_script->pretty_name()
621 621
 					);
622 622
 					break;
623 623
 			}
624
-		}catch(Exception $e){
624
+		} catch (Exception $e) {
625 625
 			//ok so some exception was thrown which killed the data migration script
626 626
 			//double-check we have a real script
627
-			if($currently_executing_script instanceof EE_Data_Migration_Script_Base){
627
+			if ($currently_executing_script instanceof EE_Data_Migration_Script_Base) {
628 628
 				$script_name = $currently_executing_script->pretty_name();
629 629
 				$currently_executing_script->set_broken();
630 630
 				$currently_executing_script->add_error($e->getMessage());
631
-			}else{
631
+			} else {
632 632
 				$script_name = __("Error getting Migration Script", "event_espresso");
633 633
 			}
634 634
 			$response_array = array(
635 635
 				'records_to_migrate'=>1,
636 636
 				'records_migrated'=>0,
637 637
 				'status'=>self::status_fatal_error,
638
-				'message'=>  sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"),$e->getMessage()),
638
+				'message'=>  sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"), $e->getMessage()),
639 639
 				'script'=>$script_name
640 640
 			);
641 641
 		}
642 642
 		$successful_save = $this->_save_migrations_ran();
643
-		if($successful_save !== TRUE){
643
+		if ($successful_save !== TRUE) {
644 644
 			//ok so the current wp option didn't save. that's tricky, because we'd like to update it
645 645
 			//and mark it as having a fatal error, but remember- WE CAN'T SAVE THIS WP OPTION!
646 646
 			//however, if we throw an exception, and return that, then the next request
647 647
 			//won't have as much info in it, and it may be able to save
648
-			throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"),$successful_save));
648
+			throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"), $successful_save));
649 649
 		}
650 650
 		//if we're all done, initialize EE plugins' default data etc.
651
-		if( $init_dbs ) {
651
+		if ($init_dbs) {
652 652
 			$this->initialize_db_for_enqueued_ee_plugins();
653 653
 		}
654 654
 		return $response_array;
@@ -666,23 +666,23 @@  discard block
 block discarded – undo
666 666
 	 * 'message'=>a string, containing any message you want to show to the user. We may decide to split this up into errors, notifications, and successes
667 667
 	 * 'script'=>a pretty name of the script currently running
668 668
 	 */
669
-	public function response_to_migration_ajax_request(){
669
+	public function response_to_migration_ajax_request() {
670 670
 //		//start output buffer just to make sure we don't mess up the json
671 671
 		ob_start();
672
-		try{
672
+		try {
673 673
 			$response = $this->migration_step();
674
-		}catch(Exception $e){
674
+		} catch (Exception $e) {
675 675
 			$response = array(
676 676
 				'records_to_migrate'=>0,
677 677
 				'records_migrated'=>0,
678 678
 				'status'=> EE_Data_Migration_Manager::status_fatal_error,
679
-				'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"),$e->getMessage()),
679
+				'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"), $e->getMessage()),
680 680
 				'script'=>'Unknown');
681 681
 			$this->add_error_to_migrations_ran($e->getMessage()."; Stack trace:".$e->getTraceAsString());
682 682
 		}
683 683
 		$warnings_etc = @ob_get_contents();
684 684
 		ob_end_clean();
685
-		$response['message'] .=$warnings_etc;
685
+		$response['message'] .= $warnings_etc;
686 686
 		return $response;
687 687
 	}
688 688
 
@@ -695,14 +695,14 @@  discard block
 block discarded – undo
695 695
 	 * }
696 696
 	 * @return void
697 697
 	 */
698
-	public function update_current_database_state_to($slug_and_version = null){
699
-		if( ! $slug_and_version ){
698
+	public function update_current_database_state_to($slug_and_version = null) {
699
+		if ( ! $slug_and_version) {
700 700
 			//no version was provided, assume it should be at the current code version
701 701
 			$slug_and_version = array('slug' => 'Core', 'version' => espresso_version());
702 702
 		}
703 703
 		$current_database_state = get_option(self::current_database_state);
704
-		$current_database_state[ $slug_and_version[ 'slug' ] ]=$slug_and_version[ 'version' ];
705
-		update_option(self::current_database_state,$current_database_state);
704
+		$current_database_state[$slug_and_version['slug']] = $slug_and_version['version'];
705
+		update_option(self::current_database_state, $current_database_state);
706 706
 	}
707 707
 
708 708
 	/**
@@ -713,20 +713,20 @@  discard block
 block discarded – undo
713 713
 	 * }
714 714
 	 * @return boolean
715 715
 	 */
716
-	public function database_needs_updating_to( $slug_and_version ) {
716
+	public function database_needs_updating_to($slug_and_version) {
717 717
 
718
-		$slug = $slug_and_version[ 'slug' ];
719
-		$version = $slug_and_version[ 'version' ];
718
+		$slug = $slug_and_version['slug'];
719
+		$version = $slug_and_version['version'];
720 720
 		$current_database_state = get_option(self::current_database_state);
721
-		if( ! isset( $current_database_state[ $slug ] ) ) {
721
+		if ( ! isset($current_database_state[$slug])) {
722 722
 			return true;
723
-		}else{
723
+		} else {
724 724
 			//just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes
725
-			$version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3);
726
-			$version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 );
725
+			$version_parts_current_db_state = array_slice(explode('.', $current_database_state[$slug]), 0, 3);
726
+			$version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3);
727 727
 			$needs_updating = false;
728
-			foreach($version_parts_current_db_state as $offset => $version_part_in_current_db_state ) {
729
-				if( $version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ] ) {
728
+			foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) {
729
+				if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[$offset]) {
730 730
 					$needs_updating = true;
731 731
 					break;
732 732
 				}
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
      */
749 749
     public function get_all_data_migration_scripts_available()
750 750
     {
751
-        if (! $this->_data_migration_class_to_filepath_map) {
751
+        if ( ! $this->_data_migration_class_to_filepath_map) {
752 752
             $this->_data_migration_class_to_filepath_map = array();
753 753
             foreach ($this->get_data_migration_script_folders() as $eeAddonClass => $folder_path) {
754 754
                 // strip any placeholders added to classname to make it a unique array key
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
                     ? $eeAddonClass
758 758
                     : '';
759 759
                 $folder_path  = EEH_File::end_with_directory_separator($folder_path);
760
-                $files        = glob($folder_path . '*.dms.php');
760
+                $files        = glob($folder_path.'*.dms.php');
761 761
                 if (empty($files)) {
762 762
                     continue;
763 763
                 }
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
                             '4.3.0.alpha.019'
784 784
                         );
785 785
                     }
786
-                    $this->_data_migration_class_to_filepath_map[ $classname ] = $file;
786
+                    $this->_data_migration_class_to_filepath_map[$classname] = $file;
787 787
                 }
788 788
             }
789 789
             EEH_Autoloader::register_autoloader($this->_data_migration_class_to_filepath_map);
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 	 * from each addon, and check if they need updating,
799 799
 	 * @return boolean
800 800
 	 */
801
-	public function addons_need_updating(){
801
+	public function addons_need_updating() {
802 802
 		return false;
803 803
 	}
804 804
 	/**
@@ -807,25 +807,25 @@  discard block
 block discarded – undo
807 807
 	 * @param string $error_message
808 808
 	 * @throws EE_Error
809 809
 	 */
810
-	public function add_error_to_migrations_ran($error_message){
810
+	public function add_error_to_migrations_ran($error_message) {
811 811
 		//get last-ran migration script
812 812
 		global $wpdb;
813
-		$last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1",ARRAY_A);
813
+		$last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1", ARRAY_A);
814 814
 
815 815
 		$last_ran_migration_script_properties = isset($last_migration_script_option['option_value']) ? maybe_unserialize($last_migration_script_option['option_value']) : null;
816 816
 		//now, tread lightly because we're here because a FATAL non-catchable error
817 817
 		//was thrown last time when we were trying to run a data migration script
818 818
 		//so the fatal error could have happened while getting the migration script
819 819
 		//or doing running it...
820
-		$versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix,"",$last_migration_script_option['option_name']) : null;
820
+		$versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $last_migration_script_option['option_name']) : null;
821 821
 
822 822
 		//check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet
823 823
 		//because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done)
824
-		if(isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed){
824
+		if (isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed) {
825 825
 			//ok then just add this error to its list of errors
826 826
 			$last_ran_migration_script_properties['_errors'][] = $error_message;
827 827
 			$last_ran_migration_script_properties['_status'] = self::status_fatal_error;
828
-		}else{
828
+		} else {
829 829
 			//so we don't even know which script was last running
830 830
 			//use the data migration error stub, which is designed specifically for this type of thing
831 831
 			$general_migration_error = new EE_DMS_Unknown_1_0_0();
@@ -835,39 +835,39 @@  discard block
 block discarded – undo
835 835
 			$versions_migrated_to = 'Unknown.1.0.0';
836 836
 			//now just to make sure appears as last (in case the were previously a fatal error like this)
837 837
 			//delete the old one
838
-			delete_option( self::data_migration_script_option_prefix . $versions_migrated_to );
838
+			delete_option(self::data_migration_script_option_prefix.$versions_migrated_to);
839 839
 		}
840
-		update_option(self::data_migration_script_option_prefix.$versions_migrated_to,$last_ran_migration_script_properties);
840
+		update_option(self::data_migration_script_option_prefix.$versions_migrated_to, $last_ran_migration_script_properties);
841 841
 
842 842
 	}
843 843
 	/**
844 844
 	 * saves what data migrations have ran to the database
845 845
 	 * @return mixed TRUE if successfully saved migrations ran, string if an error occurred
846 846
 	 */
847
-	protected function _save_migrations_ran(){
848
-		if($this->_data_migrations_ran == null){
847
+	protected function _save_migrations_ran() {
848
+		if ($this->_data_migrations_ran == null) {
849 849
 			$this->get_data_migrations_ran();
850 850
 		}
851 851
 		//now, we don't want to save actual classes to the DB because that's messy
852 852
 		$successful_updates = true;
853
-		foreach($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin){
854
-			foreach($migrations_ran_for_plugin as $version_string => $array_or_migration_obj){
853
+		foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) {
854
+			foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) {
855 855
 	//			echo "saving migration script to $version_string<br>";
856 856
 				$plugin_slug_for_use_in_option_name = $plugin_slug.".";
857 857
 				$option_name = self::data_migration_script_option_prefix.$plugin_slug_for_use_in_option_name.$version_string;
858 858
 				$old_option_value = get_option($option_name);
859
-				if($array_or_migration_obj instanceof EE_Data_Migration_Script_Base){
859
+				if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) {
860 860
 					$script_array_for_saving = $array_or_migration_obj->properties_as_array();
861
-					if( $old_option_value != $script_array_for_saving){
862
-						$successful_updates = update_option($option_name,$script_array_for_saving);
861
+					if ($old_option_value != $script_array_for_saving) {
862
+						$successful_updates = update_option($option_name, $script_array_for_saving);
863 863
 					}
864
-				}else{//we don't know what this array-thing is. So just save it as-is
864
+				} else {//we don't know what this array-thing is. So just save it as-is
865 865
 	//				$array_of_migrations[$version_string] = $array_or_migration_obj;
866
-					if($old_option_value != $array_or_migration_obj){
867
-						$successful_updates = update_option($option_name,$array_or_migration_obj);
866
+					if ($old_option_value != $array_or_migration_obj) {
867
+						$successful_updates = update_option($option_name, $array_or_migration_obj);
868 868
 					}
869 869
 				}
870
-				if( ! $successful_updates ){
870
+				if ( ! $successful_updates) {
871 871
 					global $wpdb;
872 872
 					return $wpdb->last_error;
873 873
 				}
@@ -891,17 +891,17 @@  discard block
 block discarded – undo
891 891
 	 * @return EE_Data_Migration_Script_Base
892 892
 	 * @throws EE_Error
893 893
 	 */
894
-	function _instantiate_script_from_properties_array($properties_array){
895
-		if( ! isset($properties_array['class'])){
896
-			throw new EE_Error(sprintf(__("Properties array  has no 'class' properties. Here's what it has: %s", "event_espresso"),implode(",",$properties_array)));
894
+	function _instantiate_script_from_properties_array($properties_array) {
895
+		if ( ! isset($properties_array['class'])) {
896
+			throw new EE_Error(sprintf(__("Properties array  has no 'class' properties. Here's what it has: %s", "event_espresso"), implode(",", $properties_array)));
897 897
 		}
898 898
 		$class_name = $properties_array['class'];
899
-		if( ! class_exists($class_name)){
900
-			throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"),$class_name));
899
+		if ( ! class_exists($class_name)) {
900
+			throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"), $class_name));
901 901
 		}
902 902
 		$class = new $class_name;
903
-		if( ! $class instanceof EE_Data_Migration_Script_Base){
904
-			throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"),$class_name,get_class($class)));
903
+		if ( ! $class instanceof EE_Data_Migration_Script_Base) {
904
+			throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"), $class_name, get_class($class)));
905 905
 		}
906 906
 		$class->instantiate_from_array_of_properties($properties_array);
907 907
 		return $class;
@@ -913,25 +913,25 @@  discard block
 block discarded – undo
913 913
 	 * @param string $plugin_slug the slug for the ee plugin we are searching for. Default is 'Core'
914 914
 	 * @return string
915 915
 	 */
916
-	public function get_most_up_to_date_dms($plugin_slug = 'Core'){
916
+	public function get_most_up_to_date_dms($plugin_slug = 'Core') {
917 917
 		$class_to_filepath_map = $this->get_all_data_migration_scripts_available();
918 918
 		$most_up_to_date_dms_classname = NULL;
919
-		foreach($class_to_filepath_map as $classname => $filepath){
920
-			if($most_up_to_date_dms_classname === NULL){
919
+		foreach ($class_to_filepath_map as $classname => $filepath) {
920
+			if ($most_up_to_date_dms_classname === NULL) {
921 921
 				$migrates_to = $this->script_migrates_to_version($classname);
922
-				$this_plugin_slug = $migrates_to[ 'slug' ];
922
+				$this_plugin_slug = $migrates_to['slug'];
923 923
 //				$version_string = $migrates_to[ 'version' ];
924 924
 //				$details = $this->parse_dms_classname($classname);
925
-				if($this_plugin_slug == $plugin_slug){
925
+				if ($this_plugin_slug == $plugin_slug) {
926 926
 					//if it's for core, it wins
927 927
 					$most_up_to_date_dms_classname = $classname;
928 928
 				}
929 929
 				//if it wasn't for core, we must keep searching for one that is!
930 930
 				continue;
931
-			}else{
932
-				$champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname);
931
+			} else {
932
+				$champion_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms_classname);
933 933
 				$contender_migrates_to = $this->script_migrates_to_version($classname);
934
-				if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){
934
+				if ($contender_migrates_to['slug'] == $plugin_slug && version_compare($champion_migrates_to['version'], $contender_migrates_to['version'], '<')) {
935 935
 					//so the contenders version is higher and its for Core
936 936
 					$most_up_to_date_dms_classname = $classname;
937 937
 				}
@@ -951,11 +951,11 @@  discard block
 block discarded – undo
951 951
 	 * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc
952 952
 	 * @return EE_Data_Migration_Script_Base
953 953
 	 */
954
-	public function get_migration_ran( $version, $plugin_slug = 'Core' ) {
954
+	public function get_migration_ran($version, $plugin_slug = 'Core') {
955 955
 		$migrations_ran = $this->get_data_migrations_ran();
956
-		if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){
957
-			return $migrations_ran[ $plugin_slug ][ $version ];
958
-		}else{
956
+		if (isset($migrations_ran[$plugin_slug]) && isset($migrations_ran[$plugin_slug][$version])) {
957
+			return $migrations_ran[$plugin_slug][$version];
958
+		} else {
959 959
 			return NULL;
960 960
 		}
961 961
 	}
@@ -967,20 +967,20 @@  discard block
 block discarded – undo
967 967
 	 * @return bool
968 968
 	 * @throws EE_Error
969 969
 	 */
970
-	public function reattempt(){
970
+	public function reattempt() {
971 971
 		//find if the last-ran script was borked
972 972
 		//set it as being non-borked (we shouldn't ever get DMSs that we don't recognize)
973 973
 		//add an 'error' saying that we attempted to reset
974 974
 		//does it have a stage that was borked too? if so make it no longer borked
975 975
 		//add an 'error' saying we attempted to reset
976 976
 		$last_ran_script = $this->get_last_ran_script();
977
-		if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){
977
+		if ($last_ran_script instanceof EE_DMS_Unknown_1_0_0) {
978 978
 			//if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it)
979 979
 			$last_ran_script->set_completed();
980
-		}elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) {
980
+		}elseif ($last_ran_script instanceof EE_Data_Migration_Script_Base) {
981 981
 			$last_ran_script->reattempt();
982
-		}else{
983
-			throw new EE_Error( sprintf( __( 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso' ), print_r( $last_ran_script, true ) ) );
982
+		} else {
983
+			throw new EE_Error(sprintf(__('Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso'), print_r($last_ran_script, true)));
984 984
 		}
985 985
 		return $this->_save_migrations_ran();
986 986
 	}
@@ -990,19 +990,19 @@  discard block
 block discarded – undo
990 990
 	 * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc
991 991
 	 * @return boolean
992 992
 	 */
993
-	public function migration_has_ran( $version, $plugin_slug = 'Core' ) {
994
-		return $this->get_migration_ran( $version, $plugin_slug ) !== NULL;
993
+	public function migration_has_ran($version, $plugin_slug = 'Core') {
994
+		return $this->get_migration_ran($version, $plugin_slug) !== NULL;
995 995
 	}
996 996
 	/**
997 997
 	 * Enqueues this ee plugin to have its data initialized
998 998
 	 * @param string $plugin_slug either 'Core' or EE_Addon::name()'s return value
999 999
 	 */
1000
-	public function enqueue_db_initialization_for( $plugin_slug ) {
1000
+	public function enqueue_db_initialization_for($plugin_slug) {
1001 1001
 		$queue = $this->get_db_initialization_queue();
1002
-		if( ! in_array( $plugin_slug, $queue ) ) {
1002
+		if ( ! in_array($plugin_slug, $queue)) {
1003 1003
 			$queue[] = $plugin_slug;
1004 1004
 		}
1005
-		update_option( self::db_init_queue_option_name, $queue );
1005
+		update_option(self::db_init_queue_option_name, $queue);
1006 1006
 	}
1007 1007
 	/**
1008 1008
 	 * Calls EE_Addon::initialize_db_if_no_migrations_required() on each addon
@@ -1012,26 +1012,26 @@  discard block
 block discarded – undo
1012 1012
 	public function initialize_db_for_enqueued_ee_plugins() {
1013 1013
 //		EEH_Debug_Tools::instance()->start_timer( 'initialize_db_for_enqueued_ee_plugins' );
1014 1014
 		$queue = $this->get_db_initialization_queue();
1015
-		foreach( $queue as $plugin_slug ) {
1016
-			$most_up_to_date_dms = $this->get_most_up_to_date_dms( $plugin_slug );
1017
-			if( ! $most_up_to_date_dms ) {
1015
+		foreach ($queue as $plugin_slug) {
1016
+			$most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug);
1017
+			if ( ! $most_up_to_date_dms) {
1018 1018
 				//if there is NO DMS for this plugin, obviously there's no schema to verify anyways
1019 1019
 				$verify_db = false;
1020
-			}else{
1021
-				$most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms );
1022
-				$verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to );
1020
+			} else {
1021
+				$most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms);
1022
+				$verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to);
1023 1023
 			}
1024
-			if( $plugin_slug == 'Core' ){
1024
+			if ($plugin_slug == 'Core') {
1025 1025
 				EE_System::instance()->initialize_db_if_no_migrations_required(
1026 1026
 						false,
1027 1027
 						$verify_db
1028 1028
 					);
1029
-			}else{
1029
+			} else {
1030 1030
 				//just loop through the addons to make sure their database is setup
1031
-				foreach( EE_Registry::instance()->addons as $addon ) {
1032
-					if( $addon->name() == $plugin_slug ) {
1031
+				foreach (EE_Registry::instance()->addons as $addon) {
1032
+					if ($addon->name() == $plugin_slug) {
1033 1033
 
1034
-						$addon->initialize_db_if_no_migrations_required( $verify_db );
1034
+						$addon->initialize_db_if_no_migrations_required($verify_db);
1035 1035
 						break;
1036 1036
 					}
1037 1037
 				}
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 //		EEH_Debug_Tools::instance()->show_times();
1042 1042
 		//because we just initialized the DBs for the enqueued ee plugins
1043 1043
 		//we don't need to keep remembering which ones needed to be initialized
1044
-		delete_option( self::db_init_queue_option_name );
1044
+		delete_option(self::db_init_queue_option_name);
1045 1045
 	}
1046 1046
 
1047 1047
 	/**
@@ -1050,8 +1050,8 @@  discard block
 block discarded – undo
1050 1050
 	 * 'Core', or the return value of EE_Addon::name() for an addon
1051 1051
 	 * @return array
1052 1052
 	 */
1053
-	public function get_db_initialization_queue(){
1054
-		return get_option ( self::db_init_queue_option_name, array() );
1053
+	public function get_db_initialization_queue() {
1054
+		return get_option(self::db_init_queue_option_name, array());
1055 1055
 	}
1056 1056
 
1057 1057
 	/**
@@ -1061,13 +1061,13 @@  discard block
 block discarded – undo
1061 1061
 	 * @throws EE_Error
1062 1062
 	 */
1063 1063
 	protected function _get_table_analysis() {
1064
-		if( $this->_table_analysis instanceof TableAnalysis ) {
1064
+		if ($this->_table_analysis instanceof TableAnalysis) {
1065 1065
 			return $this->_table_analysis;
1066 1066
 		} else {
1067 1067
 			throw new EE_Error(
1068 1068
 				sprintf(
1069
-					__( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'),
1070
-					get_class( $this )
1069
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
1070
+					get_class($this)
1071 1071
 				)
1072 1072
 			);
1073 1073
 		}
@@ -1080,13 +1080,13 @@  discard block
 block discarded – undo
1080 1080
 	 * @throws EE_Error
1081 1081
 	 */
1082 1082
 	protected function _get_table_manager() {
1083
-		if( $this->_table_manager instanceof TableManager ) {
1083
+		if ($this->_table_manager instanceof TableManager) {
1084 1084
 			return $this->_table_manager;
1085 1085
 		} else {
1086 1086
 			throw new EE_Error(
1087 1087
 				sprintf(
1088
-					__( 'Table manager class on class %1$s is not set properly.', 'event_espresso'),
1089
-					get_class( $this )
1088
+					__('Table manager class on class %1$s is not set properly.', 'event_espresso'),
1089
+					get_class($this)
1090 1090
 				)
1091 1091
 			);
1092 1092
 		}
Please login to merge, or discard this patch.
strategies/validation/EE_Many_Valued_Validation_Strategy.strategy.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@
 block discarded – undo
45 45
 				}
46 46
 			}
47 47
 		}
48
-        return true;
49
-    }
48
+		return true;
49
+	}
50 50
 
51 51
 
52 52
 
Please login to merge, or discard this patch.
modules/add_new_state/EED_Add_New_State.module.php 1 patch
Indentation   +738 added lines, -738 removed lines patch added patch discarded remove patch
@@ -22,744 +22,744 @@
 block discarded – undo
22 22
 
23 23
 
24 24
 
25
-    /**
26
-     * @return EED_Module|EED_Add_New_State
27
-     */
28
-    public static function instance()
29
-    {
30
-        return parent::get_instance(__CLASS__);
31
-    }
32
-
33
-
34
-
35
-    /**
36
-     * set_hooks - for hooking into EE Core, other modules, etc
37
-     *
38
-     * @return void
39
-     */
40
-    public static function set_hooks()
41
-    {
42
-        add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
43
-        add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0);
44
-        add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10);
45
-        add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
46
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
47
-        add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
48
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
49
-        add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
50
-            array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1);
51
-        add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
52
-            array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5);
53
-        add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
54
-            array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5);
55
-        add_filter('FHEE__EE_State_Select_Input____construct__state_options',
56
-            array('EED_Add_New_State', 'state_options'), 10, 1);
57
-        add_filter('FHEE__EE_Country_Select_Input____construct__country_options',
58
-            array('EED_Add_New_State', 'country_options'), 10, 1);
59
-    }
60
-
61
-
62
-
63
-    /**
64
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
65
-     *
66
-     * @return void
67
-     */
68
-    public static function set_hooks_admin()
69
-    {
70
-        add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
71
-        add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
72
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
73
-        add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
74
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
75
-        add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
76
-        add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
77
-        add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
78
-            array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1);
79
-        add_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
80
-            array('EED_Add_New_State', 'update_country_settings'), 10, 3);
81
-        add_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
82
-            array('EED_Add_New_State', 'update_country_settings'), 10, 3);
83
-        add_filter('FHEE__EE_State_Select_Input____construct__state_options',
84
-            array('EED_Add_New_State', 'state_options'), 10, 1);
85
-        add_filter('FHEE__EE_Country_Select_Input____construct__country_options',
86
-            array('EED_Add_New_State', 'country_options'), 10, 1);
87
-        add_filter('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
88
-            array('EED_Add_New_State', 'filter_checkout_request_params'), 10, 1);
89
-        add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
90
-            array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5);
91
-        add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
92
-            array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5);
93
-    }
94
-
95
-
96
-
97
-    /**
98
-     * @return void
99
-     */
100
-    public static function set_definitions()
101
-    {
102
-        define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
103
-        define('ANS_TEMPLATES_PATH', str_replace(
104
-                                         '\\',
105
-                                         DS,
106
-                                         plugin_dir_path(__FILE__)) . 'templates' . DS
107
-        );
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * @param WP $WP
114
-     * @return void
115
-     */
116
-    public function run($WP)
117
-    {
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * @return void
124
-     */
125
-    public static function translate_js_strings()
126
-    {
127
-        EE_Registry::$i18n_js_strings['ans_no_country']        = esc_html__(
128
-            'In order to proceed, you need to select the Country that your State/Province belongs to.',
129
-            'event_espresso'
130
-        );
131
-        EE_Registry::$i18n_js_strings['ans_no_name']           = esc_html__(
132
-            'In order to proceed, you need to enter the name of your State/Province.',
133
-            'event_espresso'
134
-        );
135
-        EE_Registry::$i18n_js_strings['ans_no_abbreviation']   = esc_html__(
136
-            'In order to proceed, you need to enter an abbreviation for the name of your State/Province.',
137
-            'event_espresso'
138
-        );
139
-        EE_Registry::$i18n_js_strings['ans_save_success']      = esc_html__(
140
-            'The new state was successfully saved to the database.',
141
-            'event_espresso'
142
-        );
143
-        EE_Registry::$i18n_js_strings['ans_server_save_error'] = esc_html__(
144
-            'An unknown error has occurred on the server while saving the new state to the database.',
145
-            'event_espresso'
146
-        );
147
-    }
148
-
149
-
150
-
151
-    /**
152
-     * @return void
153
-     */
154
-    public static function wp_enqueue_scripts()
155
-    {
156
-        if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
157
-            wp_register_script('add_new_state', ANS_ASSETS_URL . 'add_new_state.js',
158
-                array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true);
159
-            wp_enqueue_script('add_new_state');
160
-        }
161
-    }
162
-
163
-
164
-
165
-    /**
166
-     * display_add_new_state_micro_form
167
-     *
168
-     * @param EE_Form_Section_Proper $question_group_reg_form
169
-     * @return string
170
-     * @throws EE_Error
171
-     * @throws InvalidArgumentException
172
-     * @throws InvalidDataTypeException
173
-     * @throws InvalidInterfaceException
174
-     */
175
-    //	public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){
176
-    public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form)
177
-    {
178
-        // only add the 'new_state_micro_form' when displaying reg forms,
179
-        // not during processing since we process the 'new_state_micro_form' in it's own AJAX request
180
-        $action = EE_Registry::instance()->REQ->get('action', '');
181
-        // is the "state" question in this form section?
182
-        $input = $question_group_reg_form->get_subsection('state');
183
-        if ($action === 'process_reg_step' || $action === 'update_reg_step') {
184
-            //ok then all we need to do is make sure the input's HTML name is consistent
185
-            //by forcing it to set it now, like it did while getting the form for display
186
-            if ($input instanceof EE_State_Select_Input) {
187
-                $input->html_name();
188
-            }
189
-            return $question_group_reg_form;
190
-        }
191
-        // we're only doing this for state select inputs
192
-        if ($input instanceof EE_State_Select_Input && ! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
193
-            // grab any set values from the request
194
-            $country_name        = str_replace('state', 'nsmf_new_state_country', $input->html_name());
195
-            $state_name          = str_replace('state', 'nsmf_new_state_name', $input->html_name());
196
-            $abbrv_name          = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name());
197
-            $new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
198
-            $country_options     = array();
199
-            $countries           = EEM_Country::instance()->get_all_countries();
200
-            if (! empty($countries)) {
201
-                foreach ($countries as $country) {
202
-                    if ($country instanceof EE_Country) {
203
-                        $country_options[$country->ID()] = $country->name();
204
-                    }
205
-                }
206
-            }
207
-            $new_state_micro_form = new EE_Form_Section_Proper(
208
-                array(
209
-                    'name'            => 'new_state_micro_form',
210
-                    'html_id'         => 'new_state_micro_form',
211
-                    'layout_strategy' => new EE_Div_Per_Section_Layout(),
212
-                    'subsections'     => array(
213
-                        // add hidden input to indicate that a new state is being added
214
-                        'add_new_state'               => new EE_Hidden_Input(
215
-                            array(
216
-                                'html_name' => str_replace(
217
-                                    'state',
218
-                                    'nsmf_add_new_state',
219
-                                    $input->html_name()
220
-                                ),
221
-                                'html_id'   => str_replace(
222
-                                    'state',
223
-                                    'nsmf_add_new_state',
224
-                                    $input->html_id()
225
-                                ),
226
-                                'default'   => 0,
227
-                            )
228
-                        ),
229
-                        // add link for displaying hidden container
230
-                        'click_here_link'             => new EE_Form_Section_HTML(
231
-                            apply_filters(
232
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link',
233
-                                EEH_HTML::link(
234
-                                    '',
235
-                                    esc_html__('click here to add a new state/province', 'event_espresso'),
236
-                                    '',
237
-                                    'display-' . $input->html_id(),
238
-                                    'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
239
-                                    '',
240
-                                    'data-target="' . $input->html_id() . '"'
241
-                                )
242
-                            )
243
-                        ),
244
-                        // add initial html for hidden container
245
-                        'add_new_state_micro_form'    => new EE_Form_Section_HTML(
246
-                            apply_filters(
247
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
248
-                                EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv',
249
-                                    'display: none;') .
250
-                                EEH_HTML::h6(
251
-                                    esc_html__(
252
-                                        'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:',
253
-                                        'event_espresso'
254
-                                    )
255
-                                ) .
256
-                                EEH_HTML::ul() .
257
-                                EEH_HTML::li(
258
-                                    esc_html__(
259
-                                        'first select the Country that your State/Province belongs to',
260
-                                        'event_espresso'
261
-                                    )
262
-                                ) .
263
-                                EEH_HTML::li(
264
-                                    esc_html__('enter the name of your State/Province', 'event_espresso')
265
-                                ) .
266
-                                EEH_HTML::li(
267
-                                    esc_html__(
268
-                                        'enter a two to six letter abbreviation for the name of your State/Province',
269
-                                        'event_espresso'
270
-                                    )
271
-                                ) .
272
-                                EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) .
273
-                                EEH_HTML::ulx()
274
-                            )
275
-                        ),
276
-                        // NEW STATE COUNTRY
277
-                        'new_state_country'           => new EE_Country_Select_Input(
278
-                            $country_options,
279
-                            array(
280
-                                'html_name'       => $country_name,
281
-                                'html_id'         => str_replace(
282
-                                    'state',
283
-                                    'nsmf_new_state_country', $input->html_id()
284
-                                ),
285
-                                'html_class'      => $input->html_class() . ' new-state-country',
286
-                                'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'),
287
-                                'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
288
-                                'required'        => false,
289
-                            )
290
-                        ),
291
-                        // NEW STATE NAME
292
-                        'new_state_name'              => new EE_Text_Input(
293
-                            array(
294
-                                'html_name'       => $state_name,
295
-                                'html_id'         => str_replace(
296
-                                    'state',
297
-                                    'nsmf_new_state_name', $input->html_id()
298
-                                ),
299
-                                'html_class'      => $input->html_class() . ' new-state-state',
300
-                                'html_label_text' => esc_html__('New State/Province Name',
301
-                                    'event_espresso'),
302
-                                'default'         => EE_Registry::instance()->REQ->get($state_name, ''),
303
-                                'required'        => false,
304
-                            )
305
-                        ),
306
-                        'spacer'                      => new EE_Form_Section_HTML(EEH_HTML::br()),
307
-                        // NEW STATE NAME
308
-                        'new_state_abbrv'             => new EE_Text_Input(
309
-                            array(
310
-                                'html_name'             => $abbrv_name,
311
-                                'html_id'               => str_replace('state', 'nsmf_new_state_abbrv',
312
-                                    $input->html_id()),
313
-                                'html_class'            => $input->html_class() . ' new-state-abbrv',
314
-                                'html_label_text'       => esc_html__(
315
-                                                               'New State/Province Abbreviation',
316
-                                                               'event_espresso'
317
-                                                           ) . ' *',
318
-                                'html_other_attributes' => 'size="24"',
319
-                                'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
320
-                                'required'              => false,
321
-                            )
322
-                        ),
323
-                        // "submit" button
324
-                        'add_new_state_submit_button' => new EE_Form_Section_HTML(
325
-                            apply_filters(
326
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
327
-                                EEH_HTML::nbsp(3) .
328
-                                EEH_HTML::link(
329
-                                    '',
330
-                                    esc_html__('ADD', 'event_espresso'),
331
-                                    '',
332
-                                    'submit-' . $new_state_submit_id,
333
-                                    'ee-form-add-new-state-submit button button-secondary',
334
-                                    '',
335
-                                    'data-target="' . $new_state_submit_id . '"'
336
-                                )
337
-                            )
338
-                        ),
339
-                        // extra info
340
-                        'add_new_state_extra'         => new EE_Form_Section_HTML(
341
-                            apply_filters(
342
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra',
343
-                                EEH_HTML::br(2)
344
-                                .
345
-                                EEH_HTML::div('', '', 'small-text')
346
-                                .
347
-                                EEH_HTML::strong(
348
-                                    '* ' .
349
-                                    esc_html__(
350
-                                        'Don\'t know your State/Province Abbreviation?',
351
-                                        'event_espresso'
352
-                                    )
353
-                                )
354
-                                .
355
-                                EEH_HTML::br()
356
-                                .
357
-                                sprintf(
358
-                                    esc_html__(
359
-                                        'You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).',
360
-                                        'event_espresso'
361
-                                    ),
362
-                                    EEH_HTML::link(
363
-                                        'http://en.wikipedia.org/wiki/ISO_3166-2',
364
-                                        'http://en.wikipedia.org/wiki/ISO_3166-2',
365
-                                        '',
366
-                                        '',
367
-                                        'ee-form-add-new-state-wiki-lnk',
368
-                                        '',
369
-                                        'target="_blank"'
370
-                                    )
371
-                                )
372
-                                .
373
-                                EEH_HTML::divx()
374
-                                .
375
-                                EEH_HTML::br()
376
-                                .
377
-                                EEH_HTML::link(
378
-                                    '',
379
-                                    esc_html__('cancel new State/Province', 'event_espresso'),
380
-                                    '',
381
-                                    'hide-' . $input->html_id(),
382
-                                    'ee-form-cancel-new-state-lnk smaller-text',
383
-                                    '',
384
-                                    'data-target="' . $input->html_id() . '"'
385
-                                )
386
-                                .
387
-                                EEH_HTML::divx()
388
-                                .
389
-                                EEH_HTML::br()
390
-                            )
391
-                        ),
392
-                    ),
393
-                )
394
-            );
395
-            $question_group_reg_form->add_subsections(
396
-                array('new_state_micro_form' => $new_state_micro_form),
397
-                'state',
398
-                false
399
-            );
400
-        }
401
-        return $question_group_reg_form;
402
-    }
403
-
404
-
405
-
406
-    /**
407
-     * set_new_state_input_width
408
-     *
409
-     * @return int|string
410
-     * @throws EE_Error
411
-     * @throws InvalidArgumentException
412
-     * @throws InvalidDataTypeException
413
-     * @throws InvalidInterfaceException
414
-     * @throws ReflectionException
415
-     */
416
-    public static function add_new_state()
417
-    {
418
-        $REQ = EE_Registry::instance()->load_core('Request_Handler');
419
-        if (absint($REQ->get('nsmf_add_new_state')) === 1) {
420
-            EE_Registry::instance()->load_model('State');
421
-            // grab country ISO code, new state name, and new state abbreviation
422
-            $state_country = $REQ->is_set('nsmf_new_state_country')
423
-                ? sanitize_text_field($REQ->get('nsmf_new_state_country'))
424
-                : false;
425
-            $state_name    = $REQ->is_set('nsmf_new_state_name')
426
-                ? sanitize_text_field($REQ->get('nsmf_new_state_name'))
427
-                : false;
428
-            $state_abbr    = $REQ->is_set('nsmf_new_state_abbrv')
429
-                ? sanitize_text_field($REQ->get('nsmf_new_state_abbrv'))
430
-                : false;
431
-            if ($state_country && $state_name && $state_abbr) {
432
-                $new_state = EED_Add_New_State::save_new_state_to_db(array(
433
-                    'CNT_ISO'    => strtoupper($state_country),
434
-                    'STA_abbrev' => strtoupper($state_abbr),
435
-                    'STA_name'   => ucwords($state_name),
436
-                    'STA_active' => false,
437
-                ));
438
-                if ($new_state instanceof EE_State) {
439
-                    // clean house
440
-                    EE_Registry::instance()->REQ->un_set('nsmf_add_new_state');
441
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_country');
442
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_name');
443
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv');
444
-                    // get any existing new states
445
-                    $new_states                   = EE_Registry::instance()->SSN->get_session_data(
446
-                        'nsmf_new_states'
447
-                    );
448
-                    $new_states[$new_state->ID()] = $new_state;
449
-                    EE_Registry::instance()->SSN->set_session_data(
450
-                        array('nsmf_new_states' => $new_states)
451
-                    );
452
-                    if (EE_Registry::instance()->REQ->ajax) {
453
-                        echo wp_json_encode(array(
454
-                            'success'      => true,
455
-                            'id'           => $new_state->ID(),
456
-                            'name'         => $new_state->name(),
457
-                            'abbrev'       => $new_state->abbrev(),
458
-                            'country_iso'  => $new_state->country_iso(),
459
-                            'country_name' => $new_state->country()->name(),
460
-                        ));
461
-                        exit();
462
-                    }
463
-                    return $new_state->ID();
464
-                }
465
-            } else {
466
-                $error = esc_html__(
467
-                    'A new State/Province could not be added because invalid or missing data was received.',
468
-                    'event_espresso'
469
-                );
470
-                if (EE_Registry::instance()->REQ->ajax) {
471
-                    echo wp_json_encode(array('error' => $error));
472
-                    exit();
473
-                }
474
-                EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
475
-            }
476
-        }
477
-        return false;
478
-    }
479
-
480
-
481
-
482
-    /**
483
-     * recursively drills down through request params to remove any that were added by this module
484
-     *
485
-     * @param array $request_params
486
-     * @return array
487
-     */
488
-    public static function filter_checkout_request_params($request_params)
489
-    {
490
-        foreach ($request_params as $form_section) {
491
-            if (is_array($form_section)) {
492
-                EED_Add_New_State::unset_new_state_request_params($form_section);
493
-                EED_Add_New_State::filter_checkout_request_params($form_section);
494
-            }
495
-        }
496
-        return $request_params;
497
-    }
498
-
499
-
500
-
501
-    /**
502
-     * @param array $request_params
503
-     * @return array
504
-     */
505
-    public static function unset_new_state_request_params($request_params)
506
-    {
507
-        unset(
508
-            $request_params['new_state_micro_form'],
509
-            $request_params['new_state_micro_add_new_state'],
510
-            $request_params['new_state_micro_new_state_country'],
511
-            $request_params['new_state_micro_new_state_name'],
512
-            $request_params['new_state_micro_new_state_abbrv']
513
-        );
514
-        return $request_params;
515
-    }
516
-
517
-
518
-
519
-    /**
520
-     * @param array $props_n_values
521
-     * @return bool
522
-     * @throws EE_Error
523
-     * @throws InvalidArgumentException
524
-     * @throws InvalidDataTypeException
525
-     * @throws InvalidInterfaceException
526
-     */
527
-    public static function save_new_state_to_db($props_n_values = array())
528
-    {
529
-        $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
530
-        if (! empty($existing_state)) {
531
-            return array_pop($existing_state);
532
-        }
533
-        $new_state = EE_State::new_instance($props_n_values);
534
-        if ($new_state instanceof EE_State) {
535
-            $country_settings_url = add_query_arg(
536
-                array(
537
-                    'page'    => 'espresso_general_settings',
538
-                    'action'  => 'country_settings',
539
-                    'country' => $new_state->country_iso(),
540
-                ),
541
-                admin_url('admin.php')
542
-            );
543
-            // if not non-ajax admin
544
-            new PersistentAdminNotice(
545
-                'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(),
546
-                sprintf(
547
-                    esc_html__(
548
-                        'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.',
549
-                        'event_espresso'
550
-                    ),
551
-                    '<b>' . $new_state->name() . '</b>',
552
-                    '<b>' . $new_state->abbrev() . '</b>',
553
-                    '<b>' . $new_state->country()->name() . '</b>',
554
-                    '<a href="'
555
-                    . $country_settings_url
556
-                    . '">'
557
-                    . esc_html__('Event Espresso - General Settings > Countries Tab',
558
-                        'event_espresso')
559
-                    . '</a>',
560
-                    '<br />'
561
-                )
562
-            );
563
-            $new_state->save();
564
-            EEM_State::instance()->reset_cached_states();
565
-            return $new_state;
566
-        }
567
-        return false;
568
-    }
569
-
570
-
571
-
572
-    /**
573
-     * @param string $CNT_ISO
574
-     * @param string $STA_ID
575
-     * @param array  $cols_n_values
576
-     * @return void
577
-     * @throws DomainException
578
-     * @throws EE_Error
579
-     * @throws InvalidArgumentException
580
-     * @throws InvalidDataTypeException
581
-     * @throws InvalidInterfaceException
582
-     */
583
-    public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
584
-    {
585
-        if (! $CNT_ISO) {
586
-            EE_Error::add_error(
587
-                esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'),
588
-                __FILE__,
589
-                __FUNCTION__,
590
-                __LINE__
591
-            );
592
-        }
593
-        $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
594
-            : false;
595
-        if (! $STA_abbrev && ! empty($STA_ID)) {
596
-            $state = EEM_State::instance()->get_one_by_ID($STA_ID);
597
-            if ($state instanceof EE_State) {
598
-                $STA_abbrev = $state->abbrev();
599
-            }
600
-        }
601
-        if (! $STA_abbrev) {
602
-            EE_Error::add_error(
603
-                esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
604
-                __FILE__,
605
-                __FUNCTION__,
606
-                __LINE__
607
-            );
608
-        }
609
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
610
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
611
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
612
-        );
613
-        $persistent_admin_notice_manager->dismissNotice($CNT_ISO . '-' . $STA_abbrev, true, true);
614
-    }
615
-
616
-
617
-
618
-    /**
619
-     * @param EE_State[]                            $state_options
620
-     * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step
621
-     * @param EE_Registration                       $registration
622
-     * @param EE_Question                           $question
623
-     * @param                                       $answer
624
-     * @return array
625
-     * @throws EE_Error
626
-     * @throws InvalidArgumentException
627
-     * @throws InvalidDataTypeException
628
-     * @throws InvalidInterfaceException
629
-     */
630
-    public static function inject_new_reg_state_into_options(
631
-        $state_options = array(),
632
-        EE_SPCO_Reg_Step_Attendee_Information $reg_step,
633
-        EE_Registration $registration,
634
-        EE_Question $question,
635
-        $answer
636
-    ) {
637
-        if ($answer instanceof EE_Answer && $question instanceof EE_Question
638
-            && $question->type() === EEM_Question::QST_type_state
639
-        ) {
640
-            $STA_ID = $answer->value();
641
-            if (! empty($STA_ID)) {
642
-                $state = EEM_State::instance()->get_one_by_ID($STA_ID);
643
-                if ($state instanceof EE_State) {
644
-                    $country = $state->country();
645
-                    if ($country instanceof EE_Country) {
646
-                        if (! isset($state_options[$country->name()])) {
647
-                            $state_options[$country->name()] = array();
648
-                        }
649
-                        if (! isset($state_options[$country->name()][$STA_ID])) {
650
-                            $state_options[$country->name()][$STA_ID] = $state->name();
651
-                        }
652
-                    }
653
-                }
654
-            }
655
-        }
656
-        return $state_options;
657
-    }
658
-
659
-
660
-
661
-    /**
662
-     * @param EE_Country[]                          $country_options
663
-     * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step
664
-     * @param EE_Registration                       $registration
665
-     * @param EE_Question                           $question
666
-     * @param                                       $answer
667
-     * @return array
668
-     * @throws EE_Error
669
-     * @throws InvalidArgumentException
670
-     * @throws InvalidDataTypeException
671
-     * @throws InvalidInterfaceException
672
-     */
673
-    public static function inject_new_reg_country_into_options(
674
-        $country_options = array(),
675
-        EE_SPCO_Reg_Step_Attendee_Information $reg_step,
676
-        EE_Registration $registration,
677
-        EE_Question $question,
678
-        $answer
679
-    ) {
680
-        if ($answer instanceof EE_Answer && $question instanceof EE_Question
681
-            && $question->type()
682
-               === EEM_Question::QST_type_country
683
-        ) {
684
-            $CNT_ISO = $answer->value();
685
-            if (! empty($CNT_ISO)) {
686
-                $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
687
-                if ($country instanceof EE_Country) {
688
-                    if (! isset($country_options[$CNT_ISO])) {
689
-                        $country_options[$CNT_ISO] = $country->name();
690
-                    }
691
-                }
692
-            }
693
-        }
694
-        return $country_options;
695
-    }
696
-
697
-
698
-
699
-    /**
700
-     * @param EE_State[] $state_options
701
-     * @return array
702
-     * @throws EE_Error
703
-     * @throws InvalidArgumentException
704
-     * @throws InvalidDataTypeException
705
-     * @throws InvalidInterfaceException
706
-     */
707
-    public static function state_options($state_options = array())
708
-    {
709
-        $new_states = EED_Add_New_State::_get_new_states();
710
-        foreach ($new_states as $new_state) {
711
-            if (
712
-                $new_state instanceof EE_State
713
-                && $new_state->country() instanceof EE_Country
714
-            ) {
715
-                $state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name();
716
-            }
717
-        }
718
-        return $state_options;
719
-    }
720
-
721
-
722
-
723
-    /**
724
-     * @return array
725
-     * @throws InvalidArgumentException
726
-     * @throws InvalidDataTypeException
727
-     * @throws InvalidInterfaceException
728
-     */
729
-    protected static function _get_new_states()
730
-    {
731
-        $new_states = array();
732
-        if (EE_Registry::instance()->SSN instanceof EE_Session) {
733
-            $new_states = EE_Registry::instance()->SSN->get_session_data(
734
-                'nsmf_new_states'
735
-            );
736
-        }
737
-        return is_array($new_states) ? $new_states : array();
738
-    }
739
-
740
-
741
-
742
-    /**
743
-     * @param EE_Country[] $country_options
744
-     * @return array
745
-     * @throws EE_Error
746
-     * @throws InvalidArgumentException
747
-     * @throws InvalidDataTypeException
748
-     * @throws InvalidInterfaceException
749
-     */
750
-    public static function country_options($country_options = array())
751
-    {
752
-        $new_states = EED_Add_New_State::_get_new_states();
753
-        foreach ($new_states as $new_state) {
754
-            if (
755
-                $new_state instanceof EE_State
756
-                && $new_state->country() instanceof EE_Country
757
-            ) {
758
-                $country_options[$new_state->country()->ID()] = $new_state->country()->name();
759
-            }
760
-        }
761
-        return $country_options;
762
-    }
25
+	/**
26
+	 * @return EED_Module|EED_Add_New_State
27
+	 */
28
+	public static function instance()
29
+	{
30
+		return parent::get_instance(__CLASS__);
31
+	}
32
+
33
+
34
+
35
+	/**
36
+	 * set_hooks - for hooking into EE Core, other modules, etc
37
+	 *
38
+	 * @return void
39
+	 */
40
+	public static function set_hooks()
41
+	{
42
+		add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
43
+		add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0);
44
+		add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10);
45
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
46
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
47
+		add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
48
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
49
+		add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
50
+			array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1);
51
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
52
+			array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5);
53
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
54
+			array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5);
55
+		add_filter('FHEE__EE_State_Select_Input____construct__state_options',
56
+			array('EED_Add_New_State', 'state_options'), 10, 1);
57
+		add_filter('FHEE__EE_Country_Select_Input____construct__country_options',
58
+			array('EED_Add_New_State', 'country_options'), 10, 1);
59
+	}
60
+
61
+
62
+
63
+	/**
64
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
65
+	 *
66
+	 * @return void
67
+	 */
68
+	public static function set_hooks_admin()
69
+	{
70
+		add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
71
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
72
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
73
+		add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
74
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
75
+		add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
76
+		add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
77
+		add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
78
+			array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1);
79
+		add_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
80
+			array('EED_Add_New_State', 'update_country_settings'), 10, 3);
81
+		add_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
82
+			array('EED_Add_New_State', 'update_country_settings'), 10, 3);
83
+		add_filter('FHEE__EE_State_Select_Input____construct__state_options',
84
+			array('EED_Add_New_State', 'state_options'), 10, 1);
85
+		add_filter('FHEE__EE_Country_Select_Input____construct__country_options',
86
+			array('EED_Add_New_State', 'country_options'), 10, 1);
87
+		add_filter('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
88
+			array('EED_Add_New_State', 'filter_checkout_request_params'), 10, 1);
89
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
90
+			array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5);
91
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
92
+			array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5);
93
+	}
94
+
95
+
96
+
97
+	/**
98
+	 * @return void
99
+	 */
100
+	public static function set_definitions()
101
+	{
102
+		define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
103
+		define('ANS_TEMPLATES_PATH', str_replace(
104
+										 '\\',
105
+										 DS,
106
+										 plugin_dir_path(__FILE__)) . 'templates' . DS
107
+		);
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * @param WP $WP
114
+	 * @return void
115
+	 */
116
+	public function run($WP)
117
+	{
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * @return void
124
+	 */
125
+	public static function translate_js_strings()
126
+	{
127
+		EE_Registry::$i18n_js_strings['ans_no_country']        = esc_html__(
128
+			'In order to proceed, you need to select the Country that your State/Province belongs to.',
129
+			'event_espresso'
130
+		);
131
+		EE_Registry::$i18n_js_strings['ans_no_name']           = esc_html__(
132
+			'In order to proceed, you need to enter the name of your State/Province.',
133
+			'event_espresso'
134
+		);
135
+		EE_Registry::$i18n_js_strings['ans_no_abbreviation']   = esc_html__(
136
+			'In order to proceed, you need to enter an abbreviation for the name of your State/Province.',
137
+			'event_espresso'
138
+		);
139
+		EE_Registry::$i18n_js_strings['ans_save_success']      = esc_html__(
140
+			'The new state was successfully saved to the database.',
141
+			'event_espresso'
142
+		);
143
+		EE_Registry::$i18n_js_strings['ans_server_save_error'] = esc_html__(
144
+			'An unknown error has occurred on the server while saving the new state to the database.',
145
+			'event_espresso'
146
+		);
147
+	}
148
+
149
+
150
+
151
+	/**
152
+	 * @return void
153
+	 */
154
+	public static function wp_enqueue_scripts()
155
+	{
156
+		if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
157
+			wp_register_script('add_new_state', ANS_ASSETS_URL . 'add_new_state.js',
158
+				array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true);
159
+			wp_enqueue_script('add_new_state');
160
+		}
161
+	}
162
+
163
+
164
+
165
+	/**
166
+	 * display_add_new_state_micro_form
167
+	 *
168
+	 * @param EE_Form_Section_Proper $question_group_reg_form
169
+	 * @return string
170
+	 * @throws EE_Error
171
+	 * @throws InvalidArgumentException
172
+	 * @throws InvalidDataTypeException
173
+	 * @throws InvalidInterfaceException
174
+	 */
175
+	//	public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){
176
+	public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form)
177
+	{
178
+		// only add the 'new_state_micro_form' when displaying reg forms,
179
+		// not during processing since we process the 'new_state_micro_form' in it's own AJAX request
180
+		$action = EE_Registry::instance()->REQ->get('action', '');
181
+		// is the "state" question in this form section?
182
+		$input = $question_group_reg_form->get_subsection('state');
183
+		if ($action === 'process_reg_step' || $action === 'update_reg_step') {
184
+			//ok then all we need to do is make sure the input's HTML name is consistent
185
+			//by forcing it to set it now, like it did while getting the form for display
186
+			if ($input instanceof EE_State_Select_Input) {
187
+				$input->html_name();
188
+			}
189
+			return $question_group_reg_form;
190
+		}
191
+		// we're only doing this for state select inputs
192
+		if ($input instanceof EE_State_Select_Input && ! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
193
+			// grab any set values from the request
194
+			$country_name        = str_replace('state', 'nsmf_new_state_country', $input->html_name());
195
+			$state_name          = str_replace('state', 'nsmf_new_state_name', $input->html_name());
196
+			$abbrv_name          = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name());
197
+			$new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
198
+			$country_options     = array();
199
+			$countries           = EEM_Country::instance()->get_all_countries();
200
+			if (! empty($countries)) {
201
+				foreach ($countries as $country) {
202
+					if ($country instanceof EE_Country) {
203
+						$country_options[$country->ID()] = $country->name();
204
+					}
205
+				}
206
+			}
207
+			$new_state_micro_form = new EE_Form_Section_Proper(
208
+				array(
209
+					'name'            => 'new_state_micro_form',
210
+					'html_id'         => 'new_state_micro_form',
211
+					'layout_strategy' => new EE_Div_Per_Section_Layout(),
212
+					'subsections'     => array(
213
+						// add hidden input to indicate that a new state is being added
214
+						'add_new_state'               => new EE_Hidden_Input(
215
+							array(
216
+								'html_name' => str_replace(
217
+									'state',
218
+									'nsmf_add_new_state',
219
+									$input->html_name()
220
+								),
221
+								'html_id'   => str_replace(
222
+									'state',
223
+									'nsmf_add_new_state',
224
+									$input->html_id()
225
+								),
226
+								'default'   => 0,
227
+							)
228
+						),
229
+						// add link for displaying hidden container
230
+						'click_here_link'             => new EE_Form_Section_HTML(
231
+							apply_filters(
232
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link',
233
+								EEH_HTML::link(
234
+									'',
235
+									esc_html__('click here to add a new state/province', 'event_espresso'),
236
+									'',
237
+									'display-' . $input->html_id(),
238
+									'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
239
+									'',
240
+									'data-target="' . $input->html_id() . '"'
241
+								)
242
+							)
243
+						),
244
+						// add initial html for hidden container
245
+						'add_new_state_micro_form'    => new EE_Form_Section_HTML(
246
+							apply_filters(
247
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
248
+								EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv',
249
+									'display: none;') .
250
+								EEH_HTML::h6(
251
+									esc_html__(
252
+										'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:',
253
+										'event_espresso'
254
+									)
255
+								) .
256
+								EEH_HTML::ul() .
257
+								EEH_HTML::li(
258
+									esc_html__(
259
+										'first select the Country that your State/Province belongs to',
260
+										'event_espresso'
261
+									)
262
+								) .
263
+								EEH_HTML::li(
264
+									esc_html__('enter the name of your State/Province', 'event_espresso')
265
+								) .
266
+								EEH_HTML::li(
267
+									esc_html__(
268
+										'enter a two to six letter abbreviation for the name of your State/Province',
269
+										'event_espresso'
270
+									)
271
+								) .
272
+								EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) .
273
+								EEH_HTML::ulx()
274
+							)
275
+						),
276
+						// NEW STATE COUNTRY
277
+						'new_state_country'           => new EE_Country_Select_Input(
278
+							$country_options,
279
+							array(
280
+								'html_name'       => $country_name,
281
+								'html_id'         => str_replace(
282
+									'state',
283
+									'nsmf_new_state_country', $input->html_id()
284
+								),
285
+								'html_class'      => $input->html_class() . ' new-state-country',
286
+								'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'),
287
+								'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
288
+								'required'        => false,
289
+							)
290
+						),
291
+						// NEW STATE NAME
292
+						'new_state_name'              => new EE_Text_Input(
293
+							array(
294
+								'html_name'       => $state_name,
295
+								'html_id'         => str_replace(
296
+									'state',
297
+									'nsmf_new_state_name', $input->html_id()
298
+								),
299
+								'html_class'      => $input->html_class() . ' new-state-state',
300
+								'html_label_text' => esc_html__('New State/Province Name',
301
+									'event_espresso'),
302
+								'default'         => EE_Registry::instance()->REQ->get($state_name, ''),
303
+								'required'        => false,
304
+							)
305
+						),
306
+						'spacer'                      => new EE_Form_Section_HTML(EEH_HTML::br()),
307
+						// NEW STATE NAME
308
+						'new_state_abbrv'             => new EE_Text_Input(
309
+							array(
310
+								'html_name'             => $abbrv_name,
311
+								'html_id'               => str_replace('state', 'nsmf_new_state_abbrv',
312
+									$input->html_id()),
313
+								'html_class'            => $input->html_class() . ' new-state-abbrv',
314
+								'html_label_text'       => esc_html__(
315
+															   'New State/Province Abbreviation',
316
+															   'event_espresso'
317
+														   ) . ' *',
318
+								'html_other_attributes' => 'size="24"',
319
+								'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
320
+								'required'              => false,
321
+							)
322
+						),
323
+						// "submit" button
324
+						'add_new_state_submit_button' => new EE_Form_Section_HTML(
325
+							apply_filters(
326
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
327
+								EEH_HTML::nbsp(3) .
328
+								EEH_HTML::link(
329
+									'',
330
+									esc_html__('ADD', 'event_espresso'),
331
+									'',
332
+									'submit-' . $new_state_submit_id,
333
+									'ee-form-add-new-state-submit button button-secondary',
334
+									'',
335
+									'data-target="' . $new_state_submit_id . '"'
336
+								)
337
+							)
338
+						),
339
+						// extra info
340
+						'add_new_state_extra'         => new EE_Form_Section_HTML(
341
+							apply_filters(
342
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra',
343
+								EEH_HTML::br(2)
344
+								.
345
+								EEH_HTML::div('', '', 'small-text')
346
+								.
347
+								EEH_HTML::strong(
348
+									'* ' .
349
+									esc_html__(
350
+										'Don\'t know your State/Province Abbreviation?',
351
+										'event_espresso'
352
+									)
353
+								)
354
+								.
355
+								EEH_HTML::br()
356
+								.
357
+								sprintf(
358
+									esc_html__(
359
+										'You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).',
360
+										'event_espresso'
361
+									),
362
+									EEH_HTML::link(
363
+										'http://en.wikipedia.org/wiki/ISO_3166-2',
364
+										'http://en.wikipedia.org/wiki/ISO_3166-2',
365
+										'',
366
+										'',
367
+										'ee-form-add-new-state-wiki-lnk',
368
+										'',
369
+										'target="_blank"'
370
+									)
371
+								)
372
+								.
373
+								EEH_HTML::divx()
374
+								.
375
+								EEH_HTML::br()
376
+								.
377
+								EEH_HTML::link(
378
+									'',
379
+									esc_html__('cancel new State/Province', 'event_espresso'),
380
+									'',
381
+									'hide-' . $input->html_id(),
382
+									'ee-form-cancel-new-state-lnk smaller-text',
383
+									'',
384
+									'data-target="' . $input->html_id() . '"'
385
+								)
386
+								.
387
+								EEH_HTML::divx()
388
+								.
389
+								EEH_HTML::br()
390
+							)
391
+						),
392
+					),
393
+				)
394
+			);
395
+			$question_group_reg_form->add_subsections(
396
+				array('new_state_micro_form' => $new_state_micro_form),
397
+				'state',
398
+				false
399
+			);
400
+		}
401
+		return $question_group_reg_form;
402
+	}
403
+
404
+
405
+
406
+	/**
407
+	 * set_new_state_input_width
408
+	 *
409
+	 * @return int|string
410
+	 * @throws EE_Error
411
+	 * @throws InvalidArgumentException
412
+	 * @throws InvalidDataTypeException
413
+	 * @throws InvalidInterfaceException
414
+	 * @throws ReflectionException
415
+	 */
416
+	public static function add_new_state()
417
+	{
418
+		$REQ = EE_Registry::instance()->load_core('Request_Handler');
419
+		if (absint($REQ->get('nsmf_add_new_state')) === 1) {
420
+			EE_Registry::instance()->load_model('State');
421
+			// grab country ISO code, new state name, and new state abbreviation
422
+			$state_country = $REQ->is_set('nsmf_new_state_country')
423
+				? sanitize_text_field($REQ->get('nsmf_new_state_country'))
424
+				: false;
425
+			$state_name    = $REQ->is_set('nsmf_new_state_name')
426
+				? sanitize_text_field($REQ->get('nsmf_new_state_name'))
427
+				: false;
428
+			$state_abbr    = $REQ->is_set('nsmf_new_state_abbrv')
429
+				? sanitize_text_field($REQ->get('nsmf_new_state_abbrv'))
430
+				: false;
431
+			if ($state_country && $state_name && $state_abbr) {
432
+				$new_state = EED_Add_New_State::save_new_state_to_db(array(
433
+					'CNT_ISO'    => strtoupper($state_country),
434
+					'STA_abbrev' => strtoupper($state_abbr),
435
+					'STA_name'   => ucwords($state_name),
436
+					'STA_active' => false,
437
+				));
438
+				if ($new_state instanceof EE_State) {
439
+					// clean house
440
+					EE_Registry::instance()->REQ->un_set('nsmf_add_new_state');
441
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_country');
442
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_name');
443
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv');
444
+					// get any existing new states
445
+					$new_states                   = EE_Registry::instance()->SSN->get_session_data(
446
+						'nsmf_new_states'
447
+					);
448
+					$new_states[$new_state->ID()] = $new_state;
449
+					EE_Registry::instance()->SSN->set_session_data(
450
+						array('nsmf_new_states' => $new_states)
451
+					);
452
+					if (EE_Registry::instance()->REQ->ajax) {
453
+						echo wp_json_encode(array(
454
+							'success'      => true,
455
+							'id'           => $new_state->ID(),
456
+							'name'         => $new_state->name(),
457
+							'abbrev'       => $new_state->abbrev(),
458
+							'country_iso'  => $new_state->country_iso(),
459
+							'country_name' => $new_state->country()->name(),
460
+						));
461
+						exit();
462
+					}
463
+					return $new_state->ID();
464
+				}
465
+			} else {
466
+				$error = esc_html__(
467
+					'A new State/Province could not be added because invalid or missing data was received.',
468
+					'event_espresso'
469
+				);
470
+				if (EE_Registry::instance()->REQ->ajax) {
471
+					echo wp_json_encode(array('error' => $error));
472
+					exit();
473
+				}
474
+				EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
475
+			}
476
+		}
477
+		return false;
478
+	}
479
+
480
+
481
+
482
+	/**
483
+	 * recursively drills down through request params to remove any that were added by this module
484
+	 *
485
+	 * @param array $request_params
486
+	 * @return array
487
+	 */
488
+	public static function filter_checkout_request_params($request_params)
489
+	{
490
+		foreach ($request_params as $form_section) {
491
+			if (is_array($form_section)) {
492
+				EED_Add_New_State::unset_new_state_request_params($form_section);
493
+				EED_Add_New_State::filter_checkout_request_params($form_section);
494
+			}
495
+		}
496
+		return $request_params;
497
+	}
498
+
499
+
500
+
501
+	/**
502
+	 * @param array $request_params
503
+	 * @return array
504
+	 */
505
+	public static function unset_new_state_request_params($request_params)
506
+	{
507
+		unset(
508
+			$request_params['new_state_micro_form'],
509
+			$request_params['new_state_micro_add_new_state'],
510
+			$request_params['new_state_micro_new_state_country'],
511
+			$request_params['new_state_micro_new_state_name'],
512
+			$request_params['new_state_micro_new_state_abbrv']
513
+		);
514
+		return $request_params;
515
+	}
516
+
517
+
518
+
519
+	/**
520
+	 * @param array $props_n_values
521
+	 * @return bool
522
+	 * @throws EE_Error
523
+	 * @throws InvalidArgumentException
524
+	 * @throws InvalidDataTypeException
525
+	 * @throws InvalidInterfaceException
526
+	 */
527
+	public static function save_new_state_to_db($props_n_values = array())
528
+	{
529
+		$existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
530
+		if (! empty($existing_state)) {
531
+			return array_pop($existing_state);
532
+		}
533
+		$new_state = EE_State::new_instance($props_n_values);
534
+		if ($new_state instanceof EE_State) {
535
+			$country_settings_url = add_query_arg(
536
+				array(
537
+					'page'    => 'espresso_general_settings',
538
+					'action'  => 'country_settings',
539
+					'country' => $new_state->country_iso(),
540
+				),
541
+				admin_url('admin.php')
542
+			);
543
+			// if not non-ajax admin
544
+			new PersistentAdminNotice(
545
+				'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(),
546
+				sprintf(
547
+					esc_html__(
548
+						'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.',
549
+						'event_espresso'
550
+					),
551
+					'<b>' . $new_state->name() . '</b>',
552
+					'<b>' . $new_state->abbrev() . '</b>',
553
+					'<b>' . $new_state->country()->name() . '</b>',
554
+					'<a href="'
555
+					. $country_settings_url
556
+					. '">'
557
+					. esc_html__('Event Espresso - General Settings > Countries Tab',
558
+						'event_espresso')
559
+					. '</a>',
560
+					'<br />'
561
+				)
562
+			);
563
+			$new_state->save();
564
+			EEM_State::instance()->reset_cached_states();
565
+			return $new_state;
566
+		}
567
+		return false;
568
+	}
569
+
570
+
571
+
572
+	/**
573
+	 * @param string $CNT_ISO
574
+	 * @param string $STA_ID
575
+	 * @param array  $cols_n_values
576
+	 * @return void
577
+	 * @throws DomainException
578
+	 * @throws EE_Error
579
+	 * @throws InvalidArgumentException
580
+	 * @throws InvalidDataTypeException
581
+	 * @throws InvalidInterfaceException
582
+	 */
583
+	public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
584
+	{
585
+		if (! $CNT_ISO) {
586
+			EE_Error::add_error(
587
+				esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'),
588
+				__FILE__,
589
+				__FUNCTION__,
590
+				__LINE__
591
+			);
592
+		}
593
+		$STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
594
+			: false;
595
+		if (! $STA_abbrev && ! empty($STA_ID)) {
596
+			$state = EEM_State::instance()->get_one_by_ID($STA_ID);
597
+			if ($state instanceof EE_State) {
598
+				$STA_abbrev = $state->abbrev();
599
+			}
600
+		}
601
+		if (! $STA_abbrev) {
602
+			EE_Error::add_error(
603
+				esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
604
+				__FILE__,
605
+				__FUNCTION__,
606
+				__LINE__
607
+			);
608
+		}
609
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
610
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
611
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
612
+		);
613
+		$persistent_admin_notice_manager->dismissNotice($CNT_ISO . '-' . $STA_abbrev, true, true);
614
+	}
615
+
616
+
617
+
618
+	/**
619
+	 * @param EE_State[]                            $state_options
620
+	 * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step
621
+	 * @param EE_Registration                       $registration
622
+	 * @param EE_Question                           $question
623
+	 * @param                                       $answer
624
+	 * @return array
625
+	 * @throws EE_Error
626
+	 * @throws InvalidArgumentException
627
+	 * @throws InvalidDataTypeException
628
+	 * @throws InvalidInterfaceException
629
+	 */
630
+	public static function inject_new_reg_state_into_options(
631
+		$state_options = array(),
632
+		EE_SPCO_Reg_Step_Attendee_Information $reg_step,
633
+		EE_Registration $registration,
634
+		EE_Question $question,
635
+		$answer
636
+	) {
637
+		if ($answer instanceof EE_Answer && $question instanceof EE_Question
638
+			&& $question->type() === EEM_Question::QST_type_state
639
+		) {
640
+			$STA_ID = $answer->value();
641
+			if (! empty($STA_ID)) {
642
+				$state = EEM_State::instance()->get_one_by_ID($STA_ID);
643
+				if ($state instanceof EE_State) {
644
+					$country = $state->country();
645
+					if ($country instanceof EE_Country) {
646
+						if (! isset($state_options[$country->name()])) {
647
+							$state_options[$country->name()] = array();
648
+						}
649
+						if (! isset($state_options[$country->name()][$STA_ID])) {
650
+							$state_options[$country->name()][$STA_ID] = $state->name();
651
+						}
652
+					}
653
+				}
654
+			}
655
+		}
656
+		return $state_options;
657
+	}
658
+
659
+
660
+
661
+	/**
662
+	 * @param EE_Country[]                          $country_options
663
+	 * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step
664
+	 * @param EE_Registration                       $registration
665
+	 * @param EE_Question                           $question
666
+	 * @param                                       $answer
667
+	 * @return array
668
+	 * @throws EE_Error
669
+	 * @throws InvalidArgumentException
670
+	 * @throws InvalidDataTypeException
671
+	 * @throws InvalidInterfaceException
672
+	 */
673
+	public static function inject_new_reg_country_into_options(
674
+		$country_options = array(),
675
+		EE_SPCO_Reg_Step_Attendee_Information $reg_step,
676
+		EE_Registration $registration,
677
+		EE_Question $question,
678
+		$answer
679
+	) {
680
+		if ($answer instanceof EE_Answer && $question instanceof EE_Question
681
+			&& $question->type()
682
+			   === EEM_Question::QST_type_country
683
+		) {
684
+			$CNT_ISO = $answer->value();
685
+			if (! empty($CNT_ISO)) {
686
+				$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
687
+				if ($country instanceof EE_Country) {
688
+					if (! isset($country_options[$CNT_ISO])) {
689
+						$country_options[$CNT_ISO] = $country->name();
690
+					}
691
+				}
692
+			}
693
+		}
694
+		return $country_options;
695
+	}
696
+
697
+
698
+
699
+	/**
700
+	 * @param EE_State[] $state_options
701
+	 * @return array
702
+	 * @throws EE_Error
703
+	 * @throws InvalidArgumentException
704
+	 * @throws InvalidDataTypeException
705
+	 * @throws InvalidInterfaceException
706
+	 */
707
+	public static function state_options($state_options = array())
708
+	{
709
+		$new_states = EED_Add_New_State::_get_new_states();
710
+		foreach ($new_states as $new_state) {
711
+			if (
712
+				$new_state instanceof EE_State
713
+				&& $new_state->country() instanceof EE_Country
714
+			) {
715
+				$state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name();
716
+			}
717
+		}
718
+		return $state_options;
719
+	}
720
+
721
+
722
+
723
+	/**
724
+	 * @return array
725
+	 * @throws InvalidArgumentException
726
+	 * @throws InvalidDataTypeException
727
+	 * @throws InvalidInterfaceException
728
+	 */
729
+	protected static function _get_new_states()
730
+	{
731
+		$new_states = array();
732
+		if (EE_Registry::instance()->SSN instanceof EE_Session) {
733
+			$new_states = EE_Registry::instance()->SSN->get_session_data(
734
+				'nsmf_new_states'
735
+			);
736
+		}
737
+		return is_array($new_states) ? $new_states : array();
738
+	}
739
+
740
+
741
+
742
+	/**
743
+	 * @param EE_Country[] $country_options
744
+	 * @return array
745
+	 * @throws EE_Error
746
+	 * @throws InvalidArgumentException
747
+	 * @throws InvalidDataTypeException
748
+	 * @throws InvalidInterfaceException
749
+	 */
750
+	public static function country_options($country_options = array())
751
+	{
752
+		$new_states = EED_Add_New_State::_get_new_states();
753
+		foreach ($new_states as $new_state) {
754
+			if (
755
+				$new_state instanceof EE_State
756
+				&& $new_state->country() instanceof EE_Country
757
+			) {
758
+				$country_options[$new_state->country()->ID()] = $new_state->country()->name();
759
+			}
760
+		}
761
+		return $country_options;
762
+	}
763 763
 
764 764
 
765 765
 
Please login to merge, or discard this patch.
core/db_classes/EE_Attendee.class.php 2 patches
Indentation   +742 added lines, -742 removed lines patch added patch discarded remove patch
@@ -27,746 +27,746 @@
 block discarded – undo
27 27
 class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee
28 28
 {
29 29
 
30
-    /**
31
-     * Sets some dynamic defaults
32
-     *
33
-     * @param array  $fieldValues
34
-     * @param bool   $bydb
35
-     * @param string $timezone
36
-     * @param array  $date_formats
37
-     * @throws EE_Error
38
-     */
39
-    protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
40
-    {
41
-        if (! isset($fieldValues['ATT_full_name'])) {
42
-            $fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
43
-            $lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
44
-            $fieldValues['ATT_full_name'] = $fname . $lname;
45
-        }
46
-        if (! isset($fieldValues['ATT_slug'])) {
47
-            //			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
48
-            $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
49
-        }
50
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
51
-            $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
52
-        }
53
-        parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
54
-    }
55
-
56
-
57
-    /**
58
-     * @param array  $props_n_values          incoming values
59
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
60
-     *                                        used.)
61
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
62
-     *                                        date_format and the second value is the time format
63
-     * @return EE_Attendee
64
-     * @throws EE_Error
65
-     */
66
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
67
-    {
68
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
69
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
70
-    }
71
-
72
-
73
-    /**
74
-     * @param array  $props_n_values  incoming values from the database
75
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
76
-     *                                the website will be used.
77
-     * @return EE_Attendee
78
-     */
79
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
80
-    {
81
-        return new self($props_n_values, true, $timezone);
82
-    }
83
-
84
-
85
-    /**
86
-     *        Set Attendee First Name
87
-     *
88
-     * @access        public
89
-     * @param string $fname
90
-     * @throws EE_Error
91
-     */
92
-    public function set_fname($fname = '')
93
-    {
94
-        $this->set('ATT_fname', $fname);
95
-    }
96
-
97
-
98
-    /**
99
-     *        Set Attendee Last Name
100
-     *
101
-     * @access        public
102
-     * @param string $lname
103
-     * @throws EE_Error
104
-     */
105
-    public function set_lname($lname = '')
106
-    {
107
-        $this->set('ATT_lname', $lname);
108
-    }
109
-
110
-
111
-    /**
112
-     *        Set Attendee Address
113
-     *
114
-     * @access        public
115
-     * @param string $address
116
-     * @throws EE_Error
117
-     */
118
-    public function set_address($address = '')
119
-    {
120
-        $this->set('ATT_address', $address);
121
-    }
122
-
123
-
124
-    /**
125
-     *        Set Attendee Address2
126
-     *
127
-     * @access        public
128
-     * @param        string $address2
129
-     * @throws EE_Error
130
-     */
131
-    public function set_address2($address2 = '')
132
-    {
133
-        $this->set('ATT_address2', $address2);
134
-    }
135
-
136
-
137
-    /**
138
-     *        Set Attendee City
139
-     *
140
-     * @access        public
141
-     * @param        string $city
142
-     * @throws EE_Error
143
-     */
144
-    public function set_city($city = '')
145
-    {
146
-        $this->set('ATT_city', $city);
147
-    }
148
-
149
-
150
-    /**
151
-     *        Set Attendee State ID
152
-     *
153
-     * @access        public
154
-     * @param        int $STA_ID
155
-     * @throws EE_Error
156
-     */
157
-    public function set_state($STA_ID = 0)
158
-    {
159
-        $this->set('STA_ID', $STA_ID);
160
-    }
161
-
162
-
163
-    /**
164
-     *        Set Attendee Country ISO Code
165
-     *
166
-     * @access        public
167
-     * @param        string $CNT_ISO
168
-     * @throws EE_Error
169
-     */
170
-    public function set_country($CNT_ISO = '')
171
-    {
172
-        $this->set('CNT_ISO', $CNT_ISO);
173
-    }
174
-
175
-
176
-    /**
177
-     *        Set Attendee Zip/Postal Code
178
-     *
179
-     * @access        public
180
-     * @param        string $zip
181
-     * @throws EE_Error
182
-     */
183
-    public function set_zip($zip = '')
184
-    {
185
-        $this->set('ATT_zip', $zip);
186
-    }
187
-
188
-
189
-    /**
190
-     *        Set Attendee Email Address
191
-     *
192
-     * @access        public
193
-     * @param        string $email
194
-     * @throws EE_Error
195
-     */
196
-    public function set_email($email = '')
197
-    {
198
-        $this->set('ATT_email', $email);
199
-    }
200
-
201
-
202
-    /**
203
-     *        Set Attendee Phone
204
-     *
205
-     * @access        public
206
-     * @param        string $phone
207
-     * @throws EE_Error
208
-     */
209
-    public function set_phone($phone = '')
210
-    {
211
-        $this->set('ATT_phone', $phone);
212
-    }
213
-
214
-
215
-    /**
216
-     *        set deleted
217
-     *
218
-     * @access        public
219
-     * @param        bool $ATT_deleted
220
-     * @throws EE_Error
221
-     */
222
-    public function set_deleted($ATT_deleted = false)
223
-    {
224
-        $this->set('ATT_deleted', $ATT_deleted);
225
-    }
226
-
227
-
228
-    /**
229
-     * Returns the value for the post_author id saved with the cpt
230
-     *
231
-     * @since 4.5.0
232
-     * @return int
233
-     * @throws EE_Error
234
-     */
235
-    public function wp_user()
236
-    {
237
-        return $this->get('ATT_author');
238
-    }
239
-
240
-
241
-    /**
242
-     *        get Attendee First Name
243
-     *
244
-     * @access        public
245
-     * @return string
246
-     * @throws EE_Error
247
-     */
248
-    public function fname()
249
-    {
250
-        return $this->get('ATT_fname');
251
-    }
252
-
253
-
254
-    /**
255
-     * echoes out the attendee's first name
256
-     *
257
-     * @return void
258
-     * @throws EE_Error
259
-     */
260
-    public function e_full_name()
261
-    {
262
-        echo $this->full_name();
263
-    }
264
-
265
-
266
-    /**
267
-     * Returns the first and last name concatenated together with a space.
268
-     *
269
-     * @param bool $apply_html_entities
270
-     * @return string
271
-     * @throws EE_Error
272
-     */
273
-    public function full_name($apply_html_entities = false)
274
-    {
275
-        $full_name = array(
276
-            $this->fname(),
277
-            $this->lname(),
278
-        );
279
-        $full_name = array_filter($full_name);
280
-        $full_name = implode(' ', $full_name);
281
-        return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
282
-    }
283
-
284
-
285
-    /**
286
-     * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
287
-     * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
288
-     * attendee.
289
-     *
290
-     * @param bool $apply_html_entities
291
-     * @return string
292
-     * @throws EE_Error
293
-     */
294
-    public function ATT_full_name($apply_html_entities = false)
295
-    {
296
-        return $apply_html_entities
297
-            ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
298
-            : $this->get('ATT_full_name');
299
-    }
300
-
301
-
302
-    /**
303
-     *        get Attendee Last Name
304
-     *
305
-     * @access        public
306
-     * @return string
307
-     * @throws EE_Error
308
-     */
309
-    public function lname()
310
-    {
311
-        return $this->get('ATT_lname');
312
-    }
313
-
314
-
315
-    /**
316
-     * Gets the attendee's full address as an array so client code can decide hwo to display it
317
-     *
318
-     * @return array numerically indexed, with each part of the address that is known.
319
-     * Eg, if the user only responded to state and country,
320
-     * it would be array(0=>'Alabama',1=>'USA')
321
-     * @return array
322
-     * @throws EE_Error
323
-     */
324
-    public function full_address_as_array()
325
-    {
326
-        $full_address_array     = array();
327
-        $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
328
-        foreach ($initial_address_fields as $address_field_name) {
329
-            $address_fields_value = $this->get($address_field_name);
330
-            if (! empty($address_fields_value)) {
331
-                $full_address_array[] = $address_fields_value;
332
-            }
333
-        }
334
-        //now handle state and country
335
-        $state_obj = $this->state_obj();
336
-        if ($state_obj instanceof EE_State) {
337
-            $full_address_array[] = $state_obj->name();
338
-        }
339
-        $country_obj = $this->country_obj();
340
-        if ($country_obj instanceof EE_Country) {
341
-            $full_address_array[] = $country_obj->name();
342
-        }
343
-        //lastly get the xip
344
-        $zip_value = $this->zip();
345
-        if (! empty($zip_value)) {
346
-            $full_address_array[] = $zip_value;
347
-        }
348
-        return $full_address_array;
349
-    }
350
-
351
-
352
-    /**
353
-     *        get Attendee Address
354
-     *
355
-     * @return string
356
-     * @throws EE_Error
357
-     */
358
-    public function address()
359
-    {
360
-        return $this->get('ATT_address');
361
-    }
362
-
363
-
364
-    /**
365
-     *        get Attendee Address2
366
-     *
367
-     * @return string
368
-     * @throws EE_Error
369
-     */
370
-    public function address2()
371
-    {
372
-        return $this->get('ATT_address2');
373
-    }
374
-
375
-
376
-    /**
377
-     *        get Attendee City
378
-     *
379
-     * @return string
380
-     * @throws EE_Error
381
-     */
382
-    public function city()
383
-    {
384
-        return $this->get('ATT_city');
385
-    }
386
-
387
-
388
-    /**
389
-     *        get Attendee State ID
390
-     *
391
-     * @return string
392
-     * @throws EE_Error
393
-     */
394
-    public function state_ID()
395
-    {
396
-        return $this->get('STA_ID');
397
-    }
398
-
399
-
400
-    /**
401
-     * @return string
402
-     * @throws EE_Error
403
-     */
404
-    public function state_abbrev()
405
-    {
406
-        return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
407
-    }
408
-
409
-
410
-    /**
411
-     * Gets the state set to this attendee
412
-     *
413
-     * @return EE_State
414
-     * @throws EE_Error
415
-     */
416
-    public function state_obj()
417
-    {
418
-        return $this->get_first_related('State');
419
-    }
420
-
421
-
422
-    /**
423
-     * Returns the state's name, otherwise 'Unknown'
424
-     *
425
-     * @return string
426
-     * @throws EE_Error
427
-     */
428
-    public function state_name()
429
-    {
430
-        if ($this->state_obj()) {
431
-            return $this->state_obj()->name();
432
-        } else {
433
-            return '';
434
-        }
435
-    }
436
-
437
-
438
-    /**
439
-     * either displays the state abbreviation or the state name, as determined
440
-     * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
441
-     * defaults to abbreviation
442
-     *
443
-     * @return string
444
-     * @throws EE_Error
445
-     */
446
-    public function state()
447
-    {
448
-        if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
449
-            return $this->state_abbrev();
450
-        }
451
-        return $this->state_name();
452
-    }
453
-
454
-
455
-    /**
456
-     *    get Attendee Country ISO Code
457
-     *
458
-     * @return string
459
-     * @throws EE_Error
460
-     */
461
-    public function country_ID()
462
-    {
463
-        return $this->get('CNT_ISO');
464
-    }
465
-
466
-
467
-    /**
468
-     * Gets country set for this attendee
469
-     *
470
-     * @return EE_Country
471
-     * @throws EE_Error
472
-     */
473
-    public function country_obj()
474
-    {
475
-        return $this->get_first_related('Country');
476
-    }
477
-
478
-
479
-    /**
480
-     * Returns the country's name if known, otherwise 'Unknown'
481
-     *
482
-     * @return string
483
-     * @throws EE_Error
484
-     */
485
-    public function country_name()
486
-    {
487
-        if ($this->country_obj()) {
488
-            return $this->country_obj()->name();
489
-        }
490
-        return '';
491
-    }
492
-
493
-
494
-    /**
495
-     * either displays the country ISO2 code or the country name, as determined
496
-     * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
497
-     * defaults to abbreviation
498
-     *
499
-     * @return string
500
-     * @throws EE_Error
501
-     */
502
-    public function country()
503
-    {
504
-        if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
505
-            return $this->country_ID();
506
-        }
507
-        return $this->country_name();
508
-    }
509
-
510
-
511
-    /**
512
-     *        get Attendee Zip/Postal Code
513
-     *
514
-     * @return string
515
-     * @throws EE_Error
516
-     */
517
-    public function zip()
518
-    {
519
-        return $this->get('ATT_zip');
520
-    }
521
-
522
-
523
-    /**
524
-     *        get Attendee Email Address
525
-     *
526
-     * @return string
527
-     * @throws EE_Error
528
-     */
529
-    public function email()
530
-    {
531
-        return $this->get('ATT_email');
532
-    }
533
-
534
-
535
-    /**
536
-     *        get Attendee Phone #
537
-     *
538
-     * @return string
539
-     * @throws EE_Error
540
-     */
541
-    public function phone()
542
-    {
543
-        return $this->get('ATT_phone');
544
-    }
545
-
546
-
547
-    /**
548
-     *    get deleted
549
-     *
550
-     * @return        bool
551
-     * @throws EE_Error
552
-     */
553
-    public function deleted()
554
-    {
555
-        return $this->get('ATT_deleted');
556
-    }
557
-
558
-
559
-    /**
560
-     * Gets registrations of this attendee
561
-     *
562
-     * @param array $query_params
563
-     * @return EE_Registration[]
564
-     * @throws EE_Error
565
-     */
566
-    public function get_registrations($query_params = array())
567
-    {
568
-        return $this->get_many_related('Registration', $query_params);
569
-    }
570
-
571
-
572
-    /**
573
-     * Gets the most recent registration of this attendee
574
-     *
575
-     * @return EE_Registration
576
-     * @throws EE_Error
577
-     */
578
-    public function get_most_recent_registration()
579
-    {
580
-        return $this->get_first_related(
581
-            'Registration',
582
-            array('order_by' => array('REG_date' => 'DESC'))
583
-        ); //null, 'REG_date', 'DESC', '=', 'OBJECT_K');
584
-    }
585
-
586
-
587
-    /**
588
-     * Gets the most recent registration for this attend at this event
589
-     *
590
-     * @param int $event_id
591
-     * @return EE_Registration
592
-     * @throws EE_Error
593
-     */
594
-    public function get_most_recent_registration_for_event($event_id)
595
-    {
596
-        return $this->get_first_related(
597
-            'Registration',
598
-            array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))
599
-        );
600
-    }
601
-
602
-
603
-    /**
604
-     * returns any events attached to this attendee ($_Event property);
605
-     *
606
-     * @return array
607
-     * @throws EE_Error
608
-     */
609
-    public function events()
610
-    {
611
-        return $this->get_many_related('Event');
612
-    }
613
-
614
-
615
-    /**
616
-     * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
617
-     * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
618
-     * used to save the billing info
619
-     *
620
-     * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
621
-     * @return EE_Form_Section_Proper|null
622
-     * @throws EE_Error
623
-     */
624
-    public function billing_info_for_payment_method($payment_method)
625
-    {
626
-        $pm_type = $payment_method->type_obj();
627
-        if (! $pm_type instanceof EE_PMT_Base) {
628
-            return null;
629
-        }
630
-        $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
631
-        if (! $billing_info) {
632
-            return null;
633
-        }
634
-        $billing_form = $pm_type->billing_form();
635
-        //double-check the form isn't totally hidden, in which case pretend there is no form
636
-        $form_totally_hidden = true;
637
-        foreach($billing_form->inputs_in_subsections() as $input){
638
-            if(! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
639
-                $form_totally_hidden = false;
640
-                break;
641
-            }
642
-        }
643
-        if($form_totally_hidden) {
644
-            return null;
645
-        }
646
-        if ($billing_form instanceof EE_Form_Section_Proper) {
647
-            $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
648
-        }
649
-
650
-        return $billing_form;
651
-    }
652
-
653
-
654
-    /**
655
-     * Gets the postmeta key that holds this attendee's billing info for the
656
-     * specified payment method
657
-     *
658
-     * @param EE_Payment_Method $payment_method
659
-     * @return string
660
-     * @throws EE_Error
661
-     */
662
-    public function get_billing_info_postmeta_name($payment_method)
663
-    {
664
-        if ($payment_method->type_obj() instanceof EE_PMT_Base) {
665
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
666
-        }
667
-        return null;
668
-    }
669
-
670
-
671
-    /**
672
-     * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
673
-     * retrieve it
674
-     *
675
-     * @param EE_Billing_Attendee_Info_Form $billing_form
676
-     * @param EE_Payment_Method             $payment_method
677
-     * @return boolean
678
-     * @throws EE_Error
679
-     */
680
-    public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
681
-    {
682
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
683
-            EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
684
-            return false;
685
-        }
686
-        $billing_form->clean_sensitive_data();
687
-        return update_post_meta(
688
-            $this->ID(),
689
-            $this->get_billing_info_postmeta_name($payment_method),
690
-            $billing_form->input_values(true)
691
-        );
692
-    }
693
-
694
-
695
-    /**
696
-     * Return the link to the admin details for the object.
697
-     *
698
-     * @return string
699
-     * @throws EE_Error
700
-     * @throws InvalidArgumentException
701
-     * @throws InvalidDataTypeException
702
-     * @throws InvalidInterfaceException
703
-     * @throws ReflectionException
704
-     */
705
-    public function get_admin_details_link()
706
-    {
707
-        return $this->get_admin_edit_link();
708
-    }
709
-
710
-
711
-    /**
712
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
713
-     *
714
-     * @return string
715
-     * @throws EE_Error
716
-     * @throws InvalidArgumentException
717
-     * @throws ReflectionException
718
-     * @throws InvalidDataTypeException
719
-     * @throws InvalidInterfaceException
720
-     */
721
-    public function get_admin_edit_link()
722
-    {
723
-        EE_Registry::instance()->load_helper('URL');
724
-        return EEH_URL::add_query_args_and_nonce(
725
-            array(
726
-                'page'   => 'espresso_registrations',
727
-                'action' => 'edit_attendee',
728
-                'post'   => $this->ID(),
729
-            ),
730
-            admin_url('admin.php')
731
-        );
732
-    }
733
-
734
-
735
-    /**
736
-     * Returns the link to a settings page for the object.
737
-     *
738
-     * @return string
739
-     * @throws EE_Error
740
-     * @throws InvalidArgumentException
741
-     * @throws InvalidDataTypeException
742
-     * @throws InvalidInterfaceException
743
-     * @throws ReflectionException
744
-     */
745
-    public function get_admin_settings_link()
746
-    {
747
-        return $this->get_admin_edit_link();
748
-    }
749
-
750
-
751
-    /**
752
-     * Returns the link to the "overview" for the object (typically the "list table" view).
753
-     *
754
-     * @return string
755
-     * @throws EE_Error
756
-     * @throws InvalidArgumentException
757
-     * @throws ReflectionException
758
-     * @throws InvalidDataTypeException
759
-     * @throws InvalidInterfaceException
760
-     */
761
-    public function get_admin_overview_link()
762
-    {
763
-        EE_Registry::instance()->load_helper('URL');
764
-        return EEH_URL::add_query_args_and_nonce(
765
-            array(
766
-                'page'   => 'espresso_registrations',
767
-                'action' => 'contact_list',
768
-            ),
769
-            admin_url('admin.php')
770
-        );
771
-    }
30
+	/**
31
+	 * Sets some dynamic defaults
32
+	 *
33
+	 * @param array  $fieldValues
34
+	 * @param bool   $bydb
35
+	 * @param string $timezone
36
+	 * @param array  $date_formats
37
+	 * @throws EE_Error
38
+	 */
39
+	protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
40
+	{
41
+		if (! isset($fieldValues['ATT_full_name'])) {
42
+			$fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
43
+			$lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
44
+			$fieldValues['ATT_full_name'] = $fname . $lname;
45
+		}
46
+		if (! isset($fieldValues['ATT_slug'])) {
47
+			//			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
48
+			$fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
49
+		}
50
+		if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
51
+			$fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
52
+		}
53
+		parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
54
+	}
55
+
56
+
57
+	/**
58
+	 * @param array  $props_n_values          incoming values
59
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
60
+	 *                                        used.)
61
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
62
+	 *                                        date_format and the second value is the time format
63
+	 * @return EE_Attendee
64
+	 * @throws EE_Error
65
+	 */
66
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
67
+	{
68
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
69
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
70
+	}
71
+
72
+
73
+	/**
74
+	 * @param array  $props_n_values  incoming values from the database
75
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
76
+	 *                                the website will be used.
77
+	 * @return EE_Attendee
78
+	 */
79
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
80
+	{
81
+		return new self($props_n_values, true, $timezone);
82
+	}
83
+
84
+
85
+	/**
86
+	 *        Set Attendee First Name
87
+	 *
88
+	 * @access        public
89
+	 * @param string $fname
90
+	 * @throws EE_Error
91
+	 */
92
+	public function set_fname($fname = '')
93
+	{
94
+		$this->set('ATT_fname', $fname);
95
+	}
96
+
97
+
98
+	/**
99
+	 *        Set Attendee Last Name
100
+	 *
101
+	 * @access        public
102
+	 * @param string $lname
103
+	 * @throws EE_Error
104
+	 */
105
+	public function set_lname($lname = '')
106
+	{
107
+		$this->set('ATT_lname', $lname);
108
+	}
109
+
110
+
111
+	/**
112
+	 *        Set Attendee Address
113
+	 *
114
+	 * @access        public
115
+	 * @param string $address
116
+	 * @throws EE_Error
117
+	 */
118
+	public function set_address($address = '')
119
+	{
120
+		$this->set('ATT_address', $address);
121
+	}
122
+
123
+
124
+	/**
125
+	 *        Set Attendee Address2
126
+	 *
127
+	 * @access        public
128
+	 * @param        string $address2
129
+	 * @throws EE_Error
130
+	 */
131
+	public function set_address2($address2 = '')
132
+	{
133
+		$this->set('ATT_address2', $address2);
134
+	}
135
+
136
+
137
+	/**
138
+	 *        Set Attendee City
139
+	 *
140
+	 * @access        public
141
+	 * @param        string $city
142
+	 * @throws EE_Error
143
+	 */
144
+	public function set_city($city = '')
145
+	{
146
+		$this->set('ATT_city', $city);
147
+	}
148
+
149
+
150
+	/**
151
+	 *        Set Attendee State ID
152
+	 *
153
+	 * @access        public
154
+	 * @param        int $STA_ID
155
+	 * @throws EE_Error
156
+	 */
157
+	public function set_state($STA_ID = 0)
158
+	{
159
+		$this->set('STA_ID', $STA_ID);
160
+	}
161
+
162
+
163
+	/**
164
+	 *        Set Attendee Country ISO Code
165
+	 *
166
+	 * @access        public
167
+	 * @param        string $CNT_ISO
168
+	 * @throws EE_Error
169
+	 */
170
+	public function set_country($CNT_ISO = '')
171
+	{
172
+		$this->set('CNT_ISO', $CNT_ISO);
173
+	}
174
+
175
+
176
+	/**
177
+	 *        Set Attendee Zip/Postal Code
178
+	 *
179
+	 * @access        public
180
+	 * @param        string $zip
181
+	 * @throws EE_Error
182
+	 */
183
+	public function set_zip($zip = '')
184
+	{
185
+		$this->set('ATT_zip', $zip);
186
+	}
187
+
188
+
189
+	/**
190
+	 *        Set Attendee Email Address
191
+	 *
192
+	 * @access        public
193
+	 * @param        string $email
194
+	 * @throws EE_Error
195
+	 */
196
+	public function set_email($email = '')
197
+	{
198
+		$this->set('ATT_email', $email);
199
+	}
200
+
201
+
202
+	/**
203
+	 *        Set Attendee Phone
204
+	 *
205
+	 * @access        public
206
+	 * @param        string $phone
207
+	 * @throws EE_Error
208
+	 */
209
+	public function set_phone($phone = '')
210
+	{
211
+		$this->set('ATT_phone', $phone);
212
+	}
213
+
214
+
215
+	/**
216
+	 *        set deleted
217
+	 *
218
+	 * @access        public
219
+	 * @param        bool $ATT_deleted
220
+	 * @throws EE_Error
221
+	 */
222
+	public function set_deleted($ATT_deleted = false)
223
+	{
224
+		$this->set('ATT_deleted', $ATT_deleted);
225
+	}
226
+
227
+
228
+	/**
229
+	 * Returns the value for the post_author id saved with the cpt
230
+	 *
231
+	 * @since 4.5.0
232
+	 * @return int
233
+	 * @throws EE_Error
234
+	 */
235
+	public function wp_user()
236
+	{
237
+		return $this->get('ATT_author');
238
+	}
239
+
240
+
241
+	/**
242
+	 *        get Attendee First Name
243
+	 *
244
+	 * @access        public
245
+	 * @return string
246
+	 * @throws EE_Error
247
+	 */
248
+	public function fname()
249
+	{
250
+		return $this->get('ATT_fname');
251
+	}
252
+
253
+
254
+	/**
255
+	 * echoes out the attendee's first name
256
+	 *
257
+	 * @return void
258
+	 * @throws EE_Error
259
+	 */
260
+	public function e_full_name()
261
+	{
262
+		echo $this->full_name();
263
+	}
264
+
265
+
266
+	/**
267
+	 * Returns the first and last name concatenated together with a space.
268
+	 *
269
+	 * @param bool $apply_html_entities
270
+	 * @return string
271
+	 * @throws EE_Error
272
+	 */
273
+	public function full_name($apply_html_entities = false)
274
+	{
275
+		$full_name = array(
276
+			$this->fname(),
277
+			$this->lname(),
278
+		);
279
+		$full_name = array_filter($full_name);
280
+		$full_name = implode(' ', $full_name);
281
+		return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
282
+	}
283
+
284
+
285
+	/**
286
+	 * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
287
+	 * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
288
+	 * attendee.
289
+	 *
290
+	 * @param bool $apply_html_entities
291
+	 * @return string
292
+	 * @throws EE_Error
293
+	 */
294
+	public function ATT_full_name($apply_html_entities = false)
295
+	{
296
+		return $apply_html_entities
297
+			? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
298
+			: $this->get('ATT_full_name');
299
+	}
300
+
301
+
302
+	/**
303
+	 *        get Attendee Last Name
304
+	 *
305
+	 * @access        public
306
+	 * @return string
307
+	 * @throws EE_Error
308
+	 */
309
+	public function lname()
310
+	{
311
+		return $this->get('ATT_lname');
312
+	}
313
+
314
+
315
+	/**
316
+	 * Gets the attendee's full address as an array so client code can decide hwo to display it
317
+	 *
318
+	 * @return array numerically indexed, with each part of the address that is known.
319
+	 * Eg, if the user only responded to state and country,
320
+	 * it would be array(0=>'Alabama',1=>'USA')
321
+	 * @return array
322
+	 * @throws EE_Error
323
+	 */
324
+	public function full_address_as_array()
325
+	{
326
+		$full_address_array     = array();
327
+		$initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
328
+		foreach ($initial_address_fields as $address_field_name) {
329
+			$address_fields_value = $this->get($address_field_name);
330
+			if (! empty($address_fields_value)) {
331
+				$full_address_array[] = $address_fields_value;
332
+			}
333
+		}
334
+		//now handle state and country
335
+		$state_obj = $this->state_obj();
336
+		if ($state_obj instanceof EE_State) {
337
+			$full_address_array[] = $state_obj->name();
338
+		}
339
+		$country_obj = $this->country_obj();
340
+		if ($country_obj instanceof EE_Country) {
341
+			$full_address_array[] = $country_obj->name();
342
+		}
343
+		//lastly get the xip
344
+		$zip_value = $this->zip();
345
+		if (! empty($zip_value)) {
346
+			$full_address_array[] = $zip_value;
347
+		}
348
+		return $full_address_array;
349
+	}
350
+
351
+
352
+	/**
353
+	 *        get Attendee Address
354
+	 *
355
+	 * @return string
356
+	 * @throws EE_Error
357
+	 */
358
+	public function address()
359
+	{
360
+		return $this->get('ATT_address');
361
+	}
362
+
363
+
364
+	/**
365
+	 *        get Attendee Address2
366
+	 *
367
+	 * @return string
368
+	 * @throws EE_Error
369
+	 */
370
+	public function address2()
371
+	{
372
+		return $this->get('ATT_address2');
373
+	}
374
+
375
+
376
+	/**
377
+	 *        get Attendee City
378
+	 *
379
+	 * @return string
380
+	 * @throws EE_Error
381
+	 */
382
+	public function city()
383
+	{
384
+		return $this->get('ATT_city');
385
+	}
386
+
387
+
388
+	/**
389
+	 *        get Attendee State ID
390
+	 *
391
+	 * @return string
392
+	 * @throws EE_Error
393
+	 */
394
+	public function state_ID()
395
+	{
396
+		return $this->get('STA_ID');
397
+	}
398
+
399
+
400
+	/**
401
+	 * @return string
402
+	 * @throws EE_Error
403
+	 */
404
+	public function state_abbrev()
405
+	{
406
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
407
+	}
408
+
409
+
410
+	/**
411
+	 * Gets the state set to this attendee
412
+	 *
413
+	 * @return EE_State
414
+	 * @throws EE_Error
415
+	 */
416
+	public function state_obj()
417
+	{
418
+		return $this->get_first_related('State');
419
+	}
420
+
421
+
422
+	/**
423
+	 * Returns the state's name, otherwise 'Unknown'
424
+	 *
425
+	 * @return string
426
+	 * @throws EE_Error
427
+	 */
428
+	public function state_name()
429
+	{
430
+		if ($this->state_obj()) {
431
+			return $this->state_obj()->name();
432
+		} else {
433
+			return '';
434
+		}
435
+	}
436
+
437
+
438
+	/**
439
+	 * either displays the state abbreviation or the state name, as determined
440
+	 * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
441
+	 * defaults to abbreviation
442
+	 *
443
+	 * @return string
444
+	 * @throws EE_Error
445
+	 */
446
+	public function state()
447
+	{
448
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
449
+			return $this->state_abbrev();
450
+		}
451
+		return $this->state_name();
452
+	}
453
+
454
+
455
+	/**
456
+	 *    get Attendee Country ISO Code
457
+	 *
458
+	 * @return string
459
+	 * @throws EE_Error
460
+	 */
461
+	public function country_ID()
462
+	{
463
+		return $this->get('CNT_ISO');
464
+	}
465
+
466
+
467
+	/**
468
+	 * Gets country set for this attendee
469
+	 *
470
+	 * @return EE_Country
471
+	 * @throws EE_Error
472
+	 */
473
+	public function country_obj()
474
+	{
475
+		return $this->get_first_related('Country');
476
+	}
477
+
478
+
479
+	/**
480
+	 * Returns the country's name if known, otherwise 'Unknown'
481
+	 *
482
+	 * @return string
483
+	 * @throws EE_Error
484
+	 */
485
+	public function country_name()
486
+	{
487
+		if ($this->country_obj()) {
488
+			return $this->country_obj()->name();
489
+		}
490
+		return '';
491
+	}
492
+
493
+
494
+	/**
495
+	 * either displays the country ISO2 code or the country name, as determined
496
+	 * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
497
+	 * defaults to abbreviation
498
+	 *
499
+	 * @return string
500
+	 * @throws EE_Error
501
+	 */
502
+	public function country()
503
+	{
504
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
505
+			return $this->country_ID();
506
+		}
507
+		return $this->country_name();
508
+	}
509
+
510
+
511
+	/**
512
+	 *        get Attendee Zip/Postal Code
513
+	 *
514
+	 * @return string
515
+	 * @throws EE_Error
516
+	 */
517
+	public function zip()
518
+	{
519
+		return $this->get('ATT_zip');
520
+	}
521
+
522
+
523
+	/**
524
+	 *        get Attendee Email Address
525
+	 *
526
+	 * @return string
527
+	 * @throws EE_Error
528
+	 */
529
+	public function email()
530
+	{
531
+		return $this->get('ATT_email');
532
+	}
533
+
534
+
535
+	/**
536
+	 *        get Attendee Phone #
537
+	 *
538
+	 * @return string
539
+	 * @throws EE_Error
540
+	 */
541
+	public function phone()
542
+	{
543
+		return $this->get('ATT_phone');
544
+	}
545
+
546
+
547
+	/**
548
+	 *    get deleted
549
+	 *
550
+	 * @return        bool
551
+	 * @throws EE_Error
552
+	 */
553
+	public function deleted()
554
+	{
555
+		return $this->get('ATT_deleted');
556
+	}
557
+
558
+
559
+	/**
560
+	 * Gets registrations of this attendee
561
+	 *
562
+	 * @param array $query_params
563
+	 * @return EE_Registration[]
564
+	 * @throws EE_Error
565
+	 */
566
+	public function get_registrations($query_params = array())
567
+	{
568
+		return $this->get_many_related('Registration', $query_params);
569
+	}
570
+
571
+
572
+	/**
573
+	 * Gets the most recent registration of this attendee
574
+	 *
575
+	 * @return EE_Registration
576
+	 * @throws EE_Error
577
+	 */
578
+	public function get_most_recent_registration()
579
+	{
580
+		return $this->get_first_related(
581
+			'Registration',
582
+			array('order_by' => array('REG_date' => 'DESC'))
583
+		); //null, 'REG_date', 'DESC', '=', 'OBJECT_K');
584
+	}
585
+
586
+
587
+	/**
588
+	 * Gets the most recent registration for this attend at this event
589
+	 *
590
+	 * @param int $event_id
591
+	 * @return EE_Registration
592
+	 * @throws EE_Error
593
+	 */
594
+	public function get_most_recent_registration_for_event($event_id)
595
+	{
596
+		return $this->get_first_related(
597
+			'Registration',
598
+			array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))
599
+		);
600
+	}
601
+
602
+
603
+	/**
604
+	 * returns any events attached to this attendee ($_Event property);
605
+	 *
606
+	 * @return array
607
+	 * @throws EE_Error
608
+	 */
609
+	public function events()
610
+	{
611
+		return $this->get_many_related('Event');
612
+	}
613
+
614
+
615
+	/**
616
+	 * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
617
+	 * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
618
+	 * used to save the billing info
619
+	 *
620
+	 * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
621
+	 * @return EE_Form_Section_Proper|null
622
+	 * @throws EE_Error
623
+	 */
624
+	public function billing_info_for_payment_method($payment_method)
625
+	{
626
+		$pm_type = $payment_method->type_obj();
627
+		if (! $pm_type instanceof EE_PMT_Base) {
628
+			return null;
629
+		}
630
+		$billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
631
+		if (! $billing_info) {
632
+			return null;
633
+		}
634
+		$billing_form = $pm_type->billing_form();
635
+		//double-check the form isn't totally hidden, in which case pretend there is no form
636
+		$form_totally_hidden = true;
637
+		foreach($billing_form->inputs_in_subsections() as $input){
638
+			if(! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
639
+				$form_totally_hidden = false;
640
+				break;
641
+			}
642
+		}
643
+		if($form_totally_hidden) {
644
+			return null;
645
+		}
646
+		if ($billing_form instanceof EE_Form_Section_Proper) {
647
+			$billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
648
+		}
649
+
650
+		return $billing_form;
651
+	}
652
+
653
+
654
+	/**
655
+	 * Gets the postmeta key that holds this attendee's billing info for the
656
+	 * specified payment method
657
+	 *
658
+	 * @param EE_Payment_Method $payment_method
659
+	 * @return string
660
+	 * @throws EE_Error
661
+	 */
662
+	public function get_billing_info_postmeta_name($payment_method)
663
+	{
664
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
665
+			return 'billing_info_' . $payment_method->type_obj()->system_name();
666
+		}
667
+		return null;
668
+	}
669
+
670
+
671
+	/**
672
+	 * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
673
+	 * retrieve it
674
+	 *
675
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
676
+	 * @param EE_Payment_Method             $payment_method
677
+	 * @return boolean
678
+	 * @throws EE_Error
679
+	 */
680
+	public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
681
+	{
682
+		if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
683
+			EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
684
+			return false;
685
+		}
686
+		$billing_form->clean_sensitive_data();
687
+		return update_post_meta(
688
+			$this->ID(),
689
+			$this->get_billing_info_postmeta_name($payment_method),
690
+			$billing_form->input_values(true)
691
+		);
692
+	}
693
+
694
+
695
+	/**
696
+	 * Return the link to the admin details for the object.
697
+	 *
698
+	 * @return string
699
+	 * @throws EE_Error
700
+	 * @throws InvalidArgumentException
701
+	 * @throws InvalidDataTypeException
702
+	 * @throws InvalidInterfaceException
703
+	 * @throws ReflectionException
704
+	 */
705
+	public function get_admin_details_link()
706
+	{
707
+		return $this->get_admin_edit_link();
708
+	}
709
+
710
+
711
+	/**
712
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
713
+	 *
714
+	 * @return string
715
+	 * @throws EE_Error
716
+	 * @throws InvalidArgumentException
717
+	 * @throws ReflectionException
718
+	 * @throws InvalidDataTypeException
719
+	 * @throws InvalidInterfaceException
720
+	 */
721
+	public function get_admin_edit_link()
722
+	{
723
+		EE_Registry::instance()->load_helper('URL');
724
+		return EEH_URL::add_query_args_and_nonce(
725
+			array(
726
+				'page'   => 'espresso_registrations',
727
+				'action' => 'edit_attendee',
728
+				'post'   => $this->ID(),
729
+			),
730
+			admin_url('admin.php')
731
+		);
732
+	}
733
+
734
+
735
+	/**
736
+	 * Returns the link to a settings page for the object.
737
+	 *
738
+	 * @return string
739
+	 * @throws EE_Error
740
+	 * @throws InvalidArgumentException
741
+	 * @throws InvalidDataTypeException
742
+	 * @throws InvalidInterfaceException
743
+	 * @throws ReflectionException
744
+	 */
745
+	public function get_admin_settings_link()
746
+	{
747
+		return $this->get_admin_edit_link();
748
+	}
749
+
750
+
751
+	/**
752
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
753
+	 *
754
+	 * @return string
755
+	 * @throws EE_Error
756
+	 * @throws InvalidArgumentException
757
+	 * @throws ReflectionException
758
+	 * @throws InvalidDataTypeException
759
+	 * @throws InvalidInterfaceException
760
+	 */
761
+	public function get_admin_overview_link()
762
+	{
763
+		EE_Registry::instance()->load_helper('URL');
764
+		return EEH_URL::add_query_args_and_nonce(
765
+			array(
766
+				'page'   => 'espresso_registrations',
767
+				'action' => 'contact_list',
768
+			),
769
+			admin_url('admin.php')
770
+		);
771
+	}
772 772
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
      */
39 39
     protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
40 40
     {
41
-        if (! isset($fieldValues['ATT_full_name'])) {
42
-            $fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
41
+        if ( ! isset($fieldValues['ATT_full_name'])) {
42
+            $fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'].' ' : '';
43 43
             $lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
44
-            $fieldValues['ATT_full_name'] = $fname . $lname;
44
+            $fieldValues['ATT_full_name'] = $fname.$lname;
45 45
         }
46
-        if (! isset($fieldValues['ATT_slug'])) {
46
+        if ( ! isset($fieldValues['ATT_slug'])) {
47 47
             //			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
48 48
             $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
49 49
         }
50
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
50
+        if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
51 51
             $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
52 52
         }
53 53
         parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
         $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
328 328
         foreach ($initial_address_fields as $address_field_name) {
329 329
             $address_fields_value = $this->get($address_field_name);
330
-            if (! empty($address_fields_value)) {
330
+            if ( ! empty($address_fields_value)) {
331 331
                 $full_address_array[] = $address_fields_value;
332 332
             }
333 333
         }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
         }
343 343
         //lastly get the xip
344 344
         $zip_value = $this->zip();
345
-        if (! empty($zip_value)) {
345
+        if ( ! empty($zip_value)) {
346 346
             $full_address_array[] = $zip_value;
347 347
         }
348 348
         return $full_address_array;
@@ -624,23 +624,23 @@  discard block
 block discarded – undo
624 624
     public function billing_info_for_payment_method($payment_method)
625 625
     {
626 626
         $pm_type = $payment_method->type_obj();
627
-        if (! $pm_type instanceof EE_PMT_Base) {
627
+        if ( ! $pm_type instanceof EE_PMT_Base) {
628 628
             return null;
629 629
         }
630 630
         $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
631
-        if (! $billing_info) {
631
+        if ( ! $billing_info) {
632 632
             return null;
633 633
         }
634 634
         $billing_form = $pm_type->billing_form();
635 635
         //double-check the form isn't totally hidden, in which case pretend there is no form
636 636
         $form_totally_hidden = true;
637
-        foreach($billing_form->inputs_in_subsections() as $input){
638
-            if(! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
637
+        foreach ($billing_form->inputs_in_subsections() as $input) {
638
+            if ( ! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
639 639
                 $form_totally_hidden = false;
640 640
                 break;
641 641
             }
642 642
         }
643
-        if($form_totally_hidden) {
643
+        if ($form_totally_hidden) {
644 644
             return null;
645 645
         }
646 646
         if ($billing_form instanceof EE_Form_Section_Proper) {
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
     public function get_billing_info_postmeta_name($payment_method)
663 663
     {
664 664
         if ($payment_method->type_obj() instanceof EE_PMT_Base) {
665
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
665
+            return 'billing_info_'.$payment_method->type_obj()->system_name();
666 666
         }
667 667
         return null;
668 668
     }
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
      */
680 680
     public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
681 681
     {
682
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
682
+        if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
683 683
             EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
684 684
             return false;
685 685
         }
Please login to merge, or discard this patch.
form_sections/strategies/layout/EE_Form_Section_Layout_Base.strategy.php 2 patches
Indentation   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -15,288 +15,288 @@
 block discarded – undo
15 15
 abstract class EE_Form_Section_Layout_Base
16 16
 {
17 17
 
18
-    /**
19
-     * Form form section to lay out
20
-     *
21
-     * @var EE_Form_Section_Proper
22
-     */
23
-    protected $_form_section;
24
-
25
-
26
-
27
-    /**
28
-     *  __construct
29
-     */
30
-    public function __construct()
31
-    {
32
-    }
33
-
34
-
35
-
36
-    /**
37
-     * The form section on which this strategy is to perform
38
-     *
39
-     * @param EE_Form_Section_Proper $form
40
-     */
41
-    public function _construct_finalize(EE_Form_Section_Proper $form)
42
-    {
43
-        $this->_form_section = $form;
44
-    }
45
-
46
-
47
-
48
-    /**
49
-     * @return EE_Form_Section_Proper
50
-     */
51
-    public function form_section()
52
-    {
53
-        return $this->_form_section;
54
-    }
55
-
56
-
57
-
58
-    /**
59
-     * Also has teh side effect of enqueuing any needed JS and CSS for
60
-     * this form.
61
-     * Creates all the HTML necessary for displaying this form, its inputs, and
62
-     * proper subsections.
63
-     * Returns the HTML
64
-     *
65
-     * @return string HTML for displaying
66
-     * @throws EE_Error
67
-     */
68
-    public function layout_form()
69
-    {
70
-        $html = '';
71
-        // layout_form_begin
72
-        $html .= apply_filters(
73
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
74
-            $this->layout_form_begin(),
75
-            $this->_form_section
76
-        );
77
-        // layout_form_loop
78
-        $html .= apply_filters(
79
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
80
-            $this->layout_form_loop(),
81
-            $this->_form_section
82
-        );
83
-        // layout_form_end
84
-        $html .= apply_filters(
85
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
86
-            $this->layout_form_end(),
87
-            $this->_form_section
88
-        );
89
-        $html = $this->add_form_section_hooks_and_filters($html);
90
-        return $html;
91
-    }
92
-
93
-
94
-
95
-    /**
96
-     * @return string
97
-     * @throws EE_Error
98
-     */
99
-    public function layout_form_loop()
100
-    {
101
-        $html = '';
102
-        foreach ($this->_form_section->subsections() as $name => $subsection) {
103
-            if ($subsection instanceof EE_Form_Input_Base) {
104
-                $html .= apply_filters(
105
-                    'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
106
-                    . $name . '__in_' . $this->_form_section->name(),
107
-                    $this->layout_input($subsection),
108
-                    $this->_form_section,
109
-                    $subsection
110
-                );
111
-            } elseif ($subsection instanceof EE_Form_Section_Base) {
112
-                $html .= apply_filters(
113
-                    'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
114
-                    . $name . '__in_' . $this->_form_section->name(),
115
-                    $this->layout_subsection($subsection),
116
-                    $this->_form_section,
117
-                    $subsection
118
-                );
119
-            }
120
-        }
121
-        return $html;
122
-    }
123
-
124
-
125
-
126
-    /**
127
-     * Should be used to start teh form section (Eg a table tag, or a div tag, etc.)
128
-     *
129
-     * @return string
130
-     */
131
-    abstract public function layout_form_begin();
132
-
133
-
134
-
135
-    /**
136
-     * Should be used to end the form section (eg a /table tag, or a /div tag, etc)
137
-     *
138
-     * @return string
139
-     */
140
-    abstract public function layout_form_end();
141
-
142
-
143
-
144
-    /**
145
-     * Should be used internally by layout_form() to layout each input (eg, if this layout
146
-     * is putting each input in a row of its own, this should probably be called by a
147
-     *  foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop.
148
-     * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely
149
-     * customize the form's layout, but would like to make use of it for laying out
150
-     * 'easy-to-layout' inputs
151
-     *
152
-     * @param EE_Form_Input_Base $input
153
-     * @return string html
154
-     */
155
-    abstract public function layout_input($input);
156
-
157
-
158
-
159
-    /**
160
-     * Similar to layout_input(), should be used internally by layout_form() within a
161
-     * loop to layout each proper subsection. Unlike layout_input(), however, it is assumed
162
-     * that the proper subsection will layout its container, label, etc on its own.
163
-     *
164
-     * @param EE_Form_Section_Base $subsection
165
-     * @return string html
166
-     */
167
-    abstract public function layout_subsection($subsection);
168
-
169
-
170
-
171
-    /**
172
-     * Gets the HTML for the label tag and its contents for the input
173
-     *
174
-     * @param EE_Form_Input_Base $input
175
-     * @return string
176
-     */
177
-    public function display_label($input)
178
-    {
179
-        if($input->get_display_strategy() instanceof EE_Hidden_Display_Strategy){
180
-            return '';
181
-        }
182
-        $class = $input->required()
183
-            ? 'ee-required-label ' . $input->html_label_class()
184
-            : $input->html_label_class();
185
-        $label_text = $input->required()
186
-            ? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
187
-            : $input->html_label_text();
188
-        return '<label id="'
189
-               . $input->html_label_id()
190
-               . '" class="'
191
-               . $class
192
-               . '" style="'
193
-               . $input->html_label_style()
194
-               . '" for="' . $input->html_name()
195
-               . '">'
196
-               . $label_text
197
-               . '</label>';
198
-    }
199
-
200
-
201
-
202
-    /**
203
-     * Gets the HTML for all the form's form-wide errors (ie, errors which
204
-     * are not for specific inputs. E.g., if two inputs somehow disagree,
205
-     * those errors would probably be on the form section, not one of its inputs)
206
-     * @return string
207
-     */
208
-    public function display_form_wide_errors()
209
-    {
210
-        $html = '';
211
-        if ($this->_form_section->get_validation_errors()) {
212
-            $html .= "<div class='ee-form-wide-errors'>";
213
-            //get all the errors on THIS form section (errors which aren't
214
-            //for specific inputs, but instead for the entire form section)
215
-            foreach ($this->_form_section->get_validation_errors() as $error) {
216
-                $html .= $error->getMessage() . '<br>';
217
-            }
218
-            $html .= '</div>';
219
-        }
220
-        return apply_filters(
221
-            'FHEE__EE_Form_Section_Layout_Base__display_form_wide_errors',
222
-            $html,
223
-            $this
224
-        );
225
-    }
226
-
227
-
228
-
229
-    /**
230
-     * returns the HTML for the server-side validation errors for the specified input
231
-     * Note that if JS is enabled, it should remove these and instead
232
-     * populate the form's errors in the jquery validate fashion
233
-     * using the localized data provided to the JS
234
-     *
235
-     * @param EE_Form_Input_Base $input
236
-     * @return string
237
-     */
238
-    public function display_errors($input)
239
-    {
240
-        if ($input->get_validation_errors()) {
241
-            return "<label  id='"
242
-                   . $input->html_id()
243
-                   . "-error' class='error' for='{$input->html_name()}'>"
244
-                   . $input->get_validation_error_string()
245
-                   . '</label>';
246
-        }
247
-        return '';
248
-    }
249
-
250
-
251
-
252
-    /**
253
-     * Displays the help span for the specified input
254
-     *
255
-     * @param EE_Form_Input_Base $input
256
-     * @return string
257
-     */
258
-    public function display_help_text($input)
259
-    {
260
-        $help_text  = $input->html_help_text();
261
-        if ($help_text !== '' && $help_text !== null) {
262
-            $tag = is_admin() ? 'p' : 'span';
263
-            return '<'
264
-                   . $tag
265
-                   . ' id="'
266
-                   . $input->html_id()
267
-                   . '-help" class="'
268
-                   . $input->html_help_class()
269
-                   . '" style="'
270
-                   . $input->html_help_style()
271
-                   . '">'
272
-                   . $help_text
273
-                   . '</'
274
-                   . $tag
275
-                   . '>';
276
-        }
277
-        return '';
278
-    }
279
-
280
-
281
-
282
-    /**
283
-     * Does an action and hook onto the end of teh form
284
-     *
285
-     * @param string $html
286
-     * @return string
287
-     */
288
-    public function add_form_section_hooks_and_filters($html)
289
-    {
290
-        // replace dashes and spaces with underscores
291
-        $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
292
-        do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
293
-        $html = (string) apply_filters(
294
-            'AFEE__Form_Section_Layout__' . $hook_name . '__html',
295
-            $html,
296
-            $this->_form_section
297
-        );
298
-        $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
299
-        $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
300
-        return $html;
301
-    }
18
+	/**
19
+	 * Form form section to lay out
20
+	 *
21
+	 * @var EE_Form_Section_Proper
22
+	 */
23
+	protected $_form_section;
24
+
25
+
26
+
27
+	/**
28
+	 *  __construct
29
+	 */
30
+	public function __construct()
31
+	{
32
+	}
33
+
34
+
35
+
36
+	/**
37
+	 * The form section on which this strategy is to perform
38
+	 *
39
+	 * @param EE_Form_Section_Proper $form
40
+	 */
41
+	public function _construct_finalize(EE_Form_Section_Proper $form)
42
+	{
43
+		$this->_form_section = $form;
44
+	}
45
+
46
+
47
+
48
+	/**
49
+	 * @return EE_Form_Section_Proper
50
+	 */
51
+	public function form_section()
52
+	{
53
+		return $this->_form_section;
54
+	}
55
+
56
+
57
+
58
+	/**
59
+	 * Also has teh side effect of enqueuing any needed JS and CSS for
60
+	 * this form.
61
+	 * Creates all the HTML necessary for displaying this form, its inputs, and
62
+	 * proper subsections.
63
+	 * Returns the HTML
64
+	 *
65
+	 * @return string HTML for displaying
66
+	 * @throws EE_Error
67
+	 */
68
+	public function layout_form()
69
+	{
70
+		$html = '';
71
+		// layout_form_begin
72
+		$html .= apply_filters(
73
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
74
+			$this->layout_form_begin(),
75
+			$this->_form_section
76
+		);
77
+		// layout_form_loop
78
+		$html .= apply_filters(
79
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
80
+			$this->layout_form_loop(),
81
+			$this->_form_section
82
+		);
83
+		// layout_form_end
84
+		$html .= apply_filters(
85
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
86
+			$this->layout_form_end(),
87
+			$this->_form_section
88
+		);
89
+		$html = $this->add_form_section_hooks_and_filters($html);
90
+		return $html;
91
+	}
92
+
93
+
94
+
95
+	/**
96
+	 * @return string
97
+	 * @throws EE_Error
98
+	 */
99
+	public function layout_form_loop()
100
+	{
101
+		$html = '';
102
+		foreach ($this->_form_section->subsections() as $name => $subsection) {
103
+			if ($subsection instanceof EE_Form_Input_Base) {
104
+				$html .= apply_filters(
105
+					'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
106
+					. $name . '__in_' . $this->_form_section->name(),
107
+					$this->layout_input($subsection),
108
+					$this->_form_section,
109
+					$subsection
110
+				);
111
+			} elseif ($subsection instanceof EE_Form_Section_Base) {
112
+				$html .= apply_filters(
113
+					'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
114
+					. $name . '__in_' . $this->_form_section->name(),
115
+					$this->layout_subsection($subsection),
116
+					$this->_form_section,
117
+					$subsection
118
+				);
119
+			}
120
+		}
121
+		return $html;
122
+	}
123
+
124
+
125
+
126
+	/**
127
+	 * Should be used to start teh form section (Eg a table tag, or a div tag, etc.)
128
+	 *
129
+	 * @return string
130
+	 */
131
+	abstract public function layout_form_begin();
132
+
133
+
134
+
135
+	/**
136
+	 * Should be used to end the form section (eg a /table tag, or a /div tag, etc)
137
+	 *
138
+	 * @return string
139
+	 */
140
+	abstract public function layout_form_end();
141
+
142
+
143
+
144
+	/**
145
+	 * Should be used internally by layout_form() to layout each input (eg, if this layout
146
+	 * is putting each input in a row of its own, this should probably be called by a
147
+	 *  foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop.
148
+	 * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely
149
+	 * customize the form's layout, but would like to make use of it for laying out
150
+	 * 'easy-to-layout' inputs
151
+	 *
152
+	 * @param EE_Form_Input_Base $input
153
+	 * @return string html
154
+	 */
155
+	abstract public function layout_input($input);
156
+
157
+
158
+
159
+	/**
160
+	 * Similar to layout_input(), should be used internally by layout_form() within a
161
+	 * loop to layout each proper subsection. Unlike layout_input(), however, it is assumed
162
+	 * that the proper subsection will layout its container, label, etc on its own.
163
+	 *
164
+	 * @param EE_Form_Section_Base $subsection
165
+	 * @return string html
166
+	 */
167
+	abstract public function layout_subsection($subsection);
168
+
169
+
170
+
171
+	/**
172
+	 * Gets the HTML for the label tag and its contents for the input
173
+	 *
174
+	 * @param EE_Form_Input_Base $input
175
+	 * @return string
176
+	 */
177
+	public function display_label($input)
178
+	{
179
+		if($input->get_display_strategy() instanceof EE_Hidden_Display_Strategy){
180
+			return '';
181
+		}
182
+		$class = $input->required()
183
+			? 'ee-required-label ' . $input->html_label_class()
184
+			: $input->html_label_class();
185
+		$label_text = $input->required()
186
+			? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
187
+			: $input->html_label_text();
188
+		return '<label id="'
189
+			   . $input->html_label_id()
190
+			   . '" class="'
191
+			   . $class
192
+			   . '" style="'
193
+			   . $input->html_label_style()
194
+			   . '" for="' . $input->html_name()
195
+			   . '">'
196
+			   . $label_text
197
+			   . '</label>';
198
+	}
199
+
200
+
201
+
202
+	/**
203
+	 * Gets the HTML for all the form's form-wide errors (ie, errors which
204
+	 * are not for specific inputs. E.g., if two inputs somehow disagree,
205
+	 * those errors would probably be on the form section, not one of its inputs)
206
+	 * @return string
207
+	 */
208
+	public function display_form_wide_errors()
209
+	{
210
+		$html = '';
211
+		if ($this->_form_section->get_validation_errors()) {
212
+			$html .= "<div class='ee-form-wide-errors'>";
213
+			//get all the errors on THIS form section (errors which aren't
214
+			//for specific inputs, but instead for the entire form section)
215
+			foreach ($this->_form_section->get_validation_errors() as $error) {
216
+				$html .= $error->getMessage() . '<br>';
217
+			}
218
+			$html .= '</div>';
219
+		}
220
+		return apply_filters(
221
+			'FHEE__EE_Form_Section_Layout_Base__display_form_wide_errors',
222
+			$html,
223
+			$this
224
+		);
225
+	}
226
+
227
+
228
+
229
+	/**
230
+	 * returns the HTML for the server-side validation errors for the specified input
231
+	 * Note that if JS is enabled, it should remove these and instead
232
+	 * populate the form's errors in the jquery validate fashion
233
+	 * using the localized data provided to the JS
234
+	 *
235
+	 * @param EE_Form_Input_Base $input
236
+	 * @return string
237
+	 */
238
+	public function display_errors($input)
239
+	{
240
+		if ($input->get_validation_errors()) {
241
+			return "<label  id='"
242
+				   . $input->html_id()
243
+				   . "-error' class='error' for='{$input->html_name()}'>"
244
+				   . $input->get_validation_error_string()
245
+				   . '</label>';
246
+		}
247
+		return '';
248
+	}
249
+
250
+
251
+
252
+	/**
253
+	 * Displays the help span for the specified input
254
+	 *
255
+	 * @param EE_Form_Input_Base $input
256
+	 * @return string
257
+	 */
258
+	public function display_help_text($input)
259
+	{
260
+		$help_text  = $input->html_help_text();
261
+		if ($help_text !== '' && $help_text !== null) {
262
+			$tag = is_admin() ? 'p' : 'span';
263
+			return '<'
264
+				   . $tag
265
+				   . ' id="'
266
+				   . $input->html_id()
267
+				   . '-help" class="'
268
+				   . $input->html_help_class()
269
+				   . '" style="'
270
+				   . $input->html_help_style()
271
+				   . '">'
272
+				   . $help_text
273
+				   . '</'
274
+				   . $tag
275
+				   . '>';
276
+		}
277
+		return '';
278
+	}
279
+
280
+
281
+
282
+	/**
283
+	 * Does an action and hook onto the end of teh form
284
+	 *
285
+	 * @param string $html
286
+	 * @return string
287
+	 */
288
+	public function add_form_section_hooks_and_filters($html)
289
+	{
290
+		// replace dashes and spaces with underscores
291
+		$hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
292
+		do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
293
+		$html = (string) apply_filters(
294
+			'AFEE__Form_Section_Layout__' . $hook_name . '__html',
295
+			$html,
296
+			$this->_form_section
297
+		);
298
+		$html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
299
+		$html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
300
+		return $html;
301
+	}
302 302
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -70,19 +70,19 @@  discard block
 block discarded – undo
70 70
         $html = '';
71 71
         // layout_form_begin
72 72
         $html .= apply_filters(
73
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
73
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_'.$this->_form_section->name(),
74 74
             $this->layout_form_begin(),
75 75
             $this->_form_section
76 76
         );
77 77
         // layout_form_loop
78 78
         $html .= apply_filters(
79
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
79
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_'.$this->_form_section->name(),
80 80
             $this->layout_form_loop(),
81 81
             $this->_form_section
82 82
         );
83 83
         // layout_form_end
84 84
         $html .= apply_filters(
85
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
85
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_'.$this->_form_section->name(),
86 86
             $this->layout_form_end(),
87 87
             $this->_form_section
88 88
         );
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
             if ($subsection instanceof EE_Form_Input_Base) {
104 104
                 $html .= apply_filters(
105 105
                     'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
106
-                    . $name . '__in_' . $this->_form_section->name(),
106
+                    . $name.'__in_'.$this->_form_section->name(),
107 107
                     $this->layout_input($subsection),
108 108
                     $this->_form_section,
109 109
                     $subsection
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             } elseif ($subsection instanceof EE_Form_Section_Base) {
112 112
                 $html .= apply_filters(
113 113
                     'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
114
-                    . $name . '__in_' . $this->_form_section->name(),
114
+                    . $name.'__in_'.$this->_form_section->name(),
115 115
                     $this->layout_subsection($subsection),
116 116
                     $this->_form_section,
117 117
                     $subsection
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public function display_label($input)
178 178
     {
179
-        if($input->get_display_strategy() instanceof EE_Hidden_Display_Strategy){
179
+        if ($input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
180 180
             return '';
181 181
         }
182 182
         $class = $input->required()
183
-            ? 'ee-required-label ' . $input->html_label_class()
183
+            ? 'ee-required-label '.$input->html_label_class()
184 184
             : $input->html_label_class();
185 185
         $label_text = $input->required()
186
-            ? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
186
+            ? $input->html_label_text().'<span class="ee-asterisk">*</span>'
187 187
             : $input->html_label_text();
188 188
         return '<label id="'
189 189
                . $input->html_label_id()
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
                . $class
192 192
                . '" style="'
193 193
                . $input->html_label_style()
194
-               . '" for="' . $input->html_name()
194
+               . '" for="'.$input->html_name()
195 195
                . '">'
196 196
                . $label_text
197 197
                . '</label>';
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
             //get all the errors on THIS form section (errors which aren't
214 214
             //for specific inputs, but instead for the entire form section)
215 215
             foreach ($this->_form_section->get_validation_errors() as $error) {
216
-                $html .= $error->getMessage() . '<br>';
216
+                $html .= $error->getMessage().'<br>';
217 217
             }
218 218
             $html .= '</div>';
219 219
         }
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public function display_help_text($input)
259 259
     {
260
-        $help_text  = $input->html_help_text();
260
+        $help_text = $input->html_help_text();
261 261
         if ($help_text !== '' && $help_text !== null) {
262 262
             $tag = is_admin() ? 'p' : 'span';
263 263
             return '<'
@@ -289,14 +289,14 @@  discard block
 block discarded – undo
289 289
     {
290 290
         // replace dashes and spaces with underscores
291 291
         $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
292
-        do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
292
+        do_action('AHEE__Form_Section_Layout__'.$hook_name, $this->_form_section);
293 293
         $html = (string) apply_filters(
294
-            'AFEE__Form_Section_Layout__' . $hook_name . '__html',
294
+            'AFEE__Form_Section_Layout__'.$hook_name.'__html',
295 295
             $html,
296 296
             $this->_form_section
297 297
         );
298
-        $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
299
-        $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
298
+        $html .= EEH_HTML::nl().'<!-- AHEE__Form_Section_Layout__'.$hook_name.'__html -->';
299
+        $html .= EEH_HTML::nl().'<!-- AFEE__Form_Section_Layout__'.$hook_name.' -->';
300 300
         return $html;
301 301
     }
302 302
 }
Please login to merge, or discard this patch.