Completed
Branch BUG/escape-localized-variables (bce518)
by
unknown
09:04 queued 36s
created
libraries/line_item_display/EE_SPCO_Line_Item_Display_Strategy.strategy.php 2 patches
Indentation   +641 added lines, -641 removed lines patch added patch discarded remove patch
@@ -12,645 +12,645 @@
 block discarded – undo
12 12
 class EE_SPCO_Line_Item_Display_Strategy implements EEI_Line_Item_Display
13 13
 {
14 14
 
15
-    /**
16
-     * array of events
17
-     *
18
-     * @type EE_Line_Item[] $_events
19
-     */
20
-    private $_events = array();
21
-
22
-    /**
23
-     * whether to display the taxes row or not
24
-     *
25
-     * @type bool $_show_taxes
26
-     */
27
-    private $_show_taxes = false;
28
-
29
-    /**
30
-     * html for any tax rows
31
-     *
32
-     * @type string $_show_taxes
33
-     */
34
-    private $_taxes_html = '';
35
-
36
-    /**
37
-     * total amount including tax we can bill for at this time
38
-     *
39
-     * @type float $_grand_total
40
-     */
41
-    private $_grand_total = 0.00;
42
-
43
-    /**
44
-     * total number of items being billed for
45
-     *
46
-     * @type int $_total_items
47
-     */
48
-    private $_total_items = 0;
49
-
50
-
51
-
52
-    /**
53
-     * @return float
54
-     */
55
-    public function grand_total()
56
-    {
57
-        return $this->_grand_total;
58
-    }
59
-
60
-
61
-
62
-    /**
63
-     * @return int
64
-     */
65
-    public function total_items()
66
-    {
67
-        return $this->_total_items;
68
-    }
69
-
70
-
71
-
72
-    /**
73
-     * @param EE_Line_Item $line_item
74
-     * @param array        $options
75
-     * @param EE_Line_Item $parent_line_item
76
-     * @return mixed
77
-     * @throws EE_Error
78
-     */
79
-    public function display_line_item(
80
-        EE_Line_Item $line_item,
81
-        $options = array(),
82
-        EE_Line_Item $parent_line_item = null
83
-    ) {
84
-        $html = '';
85
-        // set some default options and merge with incoming
86
-        $default_options = array(
87
-            'show_desc' => true,  //    true        false
88
-            'odd'       => false,
89
-        );
90
-        $options = array_merge($default_options, (array) $options);
91
-        switch ($line_item->type()) {
92
-            case EEM_Line_Item::type_line_item:
93
-                $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes;
94
-                if ($line_item->OBJ_type() === 'Ticket') {
95
-                    // item row
96
-                    $html .= $this->_ticket_row($line_item, $options);
97
-                } else {
98
-                    // item row
99
-                    $html .= $this->_item_row($line_item, $options);
100
-                }
101
-                if (apply_filters(
102
-                    'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items',
103
-                    true
104
-                )
105
-                ) {
106
-                    // got any kids?
107
-                    foreach ($line_item->children() as $child_line_item) {
108
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
109
-                    }
110
-                }
111
-                break;
112
-            case EEM_Line_Item::type_sub_line_item:
113
-                $html .= $this->_sub_item_row($line_item, $options, $parent_line_item);
114
-                break;
115
-            case EEM_Line_Item::type_sub_total:
116
-                static $sub_total = 0;
117
-                $event_sub_total = 0;
118
-                $text = esc_html__('Sub-Total', 'event_espresso');
119
-                if ($line_item->OBJ_type() === 'Event') {
120
-                    $options['event_id'] = $event_id = $line_item->OBJ_ID();
121
-                    if (! isset($this->_events[ $options['event_id'] ])) {
122
-                        $event = EEM_Event::instance()->get_one_by_ID($options['event_id']);
123
-                        // if event has default reg status of Not Approved, then don't display info on it
124
-                        if ($event instanceof EE_Event
125
-                            && $event->default_registration_status() === EEM_Registration::status_id_not_approved
126
-                        ) {
127
-                            $display_event = false;
128
-                            // unless there are registrations for it that are returning to pay
129
-                            if (isset($options['registrations']) && is_array($options['registrations'])) {
130
-                                foreach ($options['registrations'] as $registration) {
131
-                                    if (! $registration instanceof EE_Registration) {
132
-                                        continue;
133
-                                    }
134
-                                    $display_event = $registration->event_ID() === $options['event_id']
135
-                                                     && $registration->status_ID() !== EEM_Registration::status_id_not_approved
136
-                                        ? true
137
-                                        : $display_event;
138
-                                }
139
-                            }
140
-                            if (! $display_event) {
141
-                                return '';
142
-                            }
143
-                        }
144
-                        $this->_events[ $options['event_id'] ] = 0;
145
-                        $html .= $this->_event_row($line_item);
146
-                        $text = esc_html__('Event Sub-Total', 'event_espresso');
147
-                    }
148
-                }
149
-                $child_line_items = $line_item->children();
150
-                // loop thru children
151
-                foreach ($child_line_items as $child_line_item) {
152
-                    // recursively feed children back into this method
153
-                    $html .= $this->display_line_item($child_line_item, $options, $line_item);
154
-                }
155
-                $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0;
156
-                $sub_total += $event_sub_total;
157
-                if ((
158
-                        // event subtotals
159
-                        $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1
160
-                    )
161
-                    || (
162
-                        // pre-tax subtotals
163
-                        $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1
164
-                    )
165
-                ) {
166
-                    $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total;
167
-                    $html .= $this->_sub_total_row($line_item, $text, $options);
168
-                }
169
-                break;
170
-            case EEM_Line_Item::type_tax:
171
-                if ($this->_show_taxes) {
172
-                    $this->_taxes_html .= $this->_tax_row($line_item, $options);
173
-                }
174
-                break;
175
-            case EEM_Line_Item::type_tax_sub_total:
176
-                if ($this->_show_taxes) {
177
-                    $child_line_items = $line_item->children();
178
-                    // loop thru children
179
-                    foreach ($child_line_items as $child_line_item) {
180
-                        // recursively feed children back into this method
181
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
182
-                    }
183
-                    if (count($child_line_items) > 1) {
184
-                        $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso'));
185
-                    }
186
-                }
187
-                break;
188
-            case EEM_Line_Item::type_total:
189
-                // get all child line items
190
-                $children = $line_item->children();
191
-                // loop thru all non-tax child line items
192
-                foreach ($children as $child_line_item) {
193
-                    if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) {
194
-                        // recursively feed children back into this method
195
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
196
-                    }
197
-                }
198
-                // now loop thru  tax child line items
199
-                foreach ($children as $child_line_item) {
200
-                    if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) {
201
-                        // recursively feed children back into this method
202
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
203
-                    }
204
-                }
205
-                $html .= $this->_taxes_html;
206
-                $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso'));
207
-                $html .= $this->_payments_and_amount_owing_rows($line_item, $options);
208
-                break;
209
-        }
210
-        return $html;
211
-    }
212
-
213
-
214
-
215
-    /**
216
-     * _event_row - basically a Heading row displayed once above each event's ticket rows
217
-     *
218
-     * @param EE_Line_Item $line_item
219
-     * @return mixed
220
-     */
221
-    private function _event_row(EE_Line_Item $line_item)
222
-    {
223
-        // start of row
224
-        $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd');
225
-        // event name td
226
-        $html .= EEH_HTML::td(
227
-            EEH_HTML::strong($line_item->name()),
228
-            '',
229
-            'event-header',
230
-            '',
231
-            ' colspan="4"'
232
-        );
233
-        // end of row
234
-        $html .= EEH_HTML::trx();
235
-        return $html;
236
-    }
237
-
238
-
239
-
240
-    /**
241
-     * _ticket_row
242
-     *
243
-     * @param EE_Line_Item $line_item
244
-     * @param array        $options
245
-     * @return mixed
246
-     * @throws EE_Error
247
-     */
248
-    private function _ticket_row(EE_Line_Item $line_item, $options = array())
249
-    {
250
-        // start of row
251
-        $row_class = $options['odd'] ? 'item odd' : 'item';
252
-        $html = EEH_HTML::tr('', '', $row_class);
253
-        // name && desc
254
-        $name_and_desc = apply_filters(
255
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
256
-            $line_item->name(),
257
-            $line_item
258
-        );
259
-        $name_and_desc .= apply_filters(
260
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
261
-            (
262
-                $options['show_desc']
263
-                    ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
264
-                    : ''
265
-            ),
266
-            $line_item,
267
-            $options
268
-        );
269
-        $name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
270
-        // name td
271
-        $html .= EEH_HTML::td( /*__FUNCTION__ .*/
272
-            $name_and_desc,
273
-            '',
274
-            'item_l'
275
-        );
276
-        // price td
277
-        $price = apply_filters(
278
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__price',
279
-            $line_item->unit_price_no_code(),
280
-            $line_item
281
-        );
282
-        $html .= EEH_HTML::td($price, '', 'item_c jst-rght');
283
-        // quantity td
284
-        $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
285
-        $this->_total_items += $line_item->quantity();
286
-        // determine total for line item
287
-        $total = apply_filters(
288
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__total',
289
-            $line_item->total(),
290
-            $line_item
291
-        );
292
-        $this->_events[ $options['event_id'] ] += $total;
293
-        // total td
294
-        $html .= EEH_HTML::td(
295
-            EEH_Template::format_currency($total, false, false),
296
-            '',
297
-            'item_r jst-rght'
298
-        );
299
-        // end of row
300
-        $html .= EEH_HTML::trx();
301
-        return $html;
302
-    }
303
-
304
-
305
-
306
-    /**
307
-     * _item_row
308
-     *
309
-     * @param EE_Line_Item $line_item
310
-     * @param array        $options
311
-     * @return mixed
312
-     * @throws EE_Error
313
-     */
314
-    private function _item_row(EE_Line_Item $line_item, $options = array())
315
-    {
316
-        // start of row
317
-        $row_class = $options['odd'] ? 'item odd' : 'item';
318
-        $html = EEH_HTML::tr('', '', $row_class);
319
-        $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : '';
320
-        // name && desc
321
-        $name_and_desc = apply_filters(
322
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
323
-            $obj_name . $line_item->name(),
324
-            $line_item
325
-        );
326
-        $name_and_desc .= apply_filters(
327
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
328
-            (
329
-                $options['show_desc']
330
-                ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
331
-                : ''
332
-            ),
333
-            $line_item,
334
-            $options
335
-        );
336
-        $name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
337
-        // name td
338
-        $html .= EEH_HTML::td($name_and_desc, '', 'item_l');
339
-        // price td
340
-        if ($line_item->is_percent()) {
341
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght');
342
-        } else {
343
-            $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
344
-        }
345
-        // quantity td
346
-        $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
347
-        // $total = $line_item->total() * $line_item->quantity();
348
-        $total = $line_item->total();
349
-        if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) {
350
-            $this->_events[ $options['event_id'] ] += $total;
351
-        }
352
-        // total td
353
-        $html .= EEH_HTML::td(
354
-            EEH_Template::format_currency($total, false, false),
355
-            '',
356
-            'item_r jst-rght'
357
-        );
358
-        // end of row
359
-        $html .= EEH_HTML::trx();
360
-        return $html;
361
-    }
362
-
363
-
364
-
365
-    /**
366
-     * _sub_item_row
367
-     *
368
-     * @param EE_Line_Item $line_item
369
-     * @param array        $options
370
-     * @param EE_Line_Item $parent_line_item
371
-     * @return mixed
372
-     * @throws EE_Error
373
-     */
374
-    private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null)
375
-    {
376
-        if ($parent_line_item instanceof  EE_Line_Item
377
-            && $line_item->children() === array()
378
-            && $line_item->name() === $parent_line_item->name()
379
-            && apply_filters(
380
-                'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__hide_main_sub_line_item',
381
-                true
382
-            )
383
-        ) {
384
-            return '';
385
-        }
386
-        // start of row
387
-        $html = EEH_HTML::tr('', '', 'item sub-item-row');
388
-        // name && desc
389
-        $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right')
390
-                         . $line_item->name();
391
-        $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '
392
-                                                  . $line_item->desc()
393
-                                                  . '</span>' : '';
394
-        // name td
395
-        $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item');
396
-        $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1;
397
-        // discount/surcharge td
398
-        if ($line_item->is_percent()) {
399
-            $html .= EEH_HTML::td(
400
-                EEH_Template::format_currency(
401
-                    $line_item->total() / $qty,
402
-                    false,
403
-                    false
404
-                ),
405
-                '',
406
-                'item_c jst-rght'
407
-            );
408
-        } else {
409
-            $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
410
-        }
411
-        // no quantity td
412
-        $html .= EEH_HTML::td();
413
-        // no total td
414
-        $html .= EEH_HTML::td();
415
-        // end of row
416
-        $html .= EEH_HTML::trx();
417
-        $html = apply_filters(
418
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__html',
419
-            $html,
420
-            $line_item,
421
-            $options,
422
-            $parent_line_item
423
-        );
424
-        return $html;
425
-    }
426
-
427
-
428
-
429
-    /**
430
-     * _tax_row
431
-     *
432
-     * @param EE_Line_Item $line_item
433
-     * @param array        $options
434
-     * @return mixed
435
-     * @throws EE_Error
436
-     */
437
-    private function _tax_row(EE_Line_Item $line_item, $options = array())
438
-    {
439
-        // start of row
440
-        $html = EEH_HTML::tr('', 'item sub-item tax-total');
441
-        // name && desc
442
-        $name_and_desc = $line_item->name();
443
-        $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
444
-                          . esc_html__(' * taxable items', 'event_espresso') . '</span>';
445
-        $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : '';
446
-        // name td
447
-        $html .= EEH_HTML::td( /*__FUNCTION__ .*/
448
-            $name_and_desc,
449
-            '',
450
-            'item_l sub-item'
451
-        );
452
-        // percent td
453
-        $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', '');
454
-        // empty td (price)
455
-        $html .= EEH_HTML::td(EEH_HTML::nbsp());
456
-        // total td
457
-        $html .= EEH_HTML::td(
458
-            EEH_Template::format_currency(
459
-                $line_item->total(),
460
-                false,
461
-                false
462
-            ),
463
-            '',
464
-            'item_r jst-rght'
465
-        );
466
-        // end of row
467
-        $html .= EEH_HTML::trx();
468
-        return $html;
469
-    }
470
-
471
-
472
-
473
-    /**
474
-     * _total_row
475
-     *
476
-     * @param EE_Line_Item $line_item
477
-     * @param string       $text
478
-     * @return mixed
479
-     * @throws EE_Error
480
-     */
481
-    private function _total_tax_row(EE_Line_Item $line_item, $text = '')
482
-    {
483
-        $html = '';
484
-        if ($line_item->total()) {
485
-            // start of row
486
-            $html = EEH_HTML::tr('', '', 'total_tr odd');
487
-            // total td
488
-            $html .= EEH_HTML::td(
489
-                $text,
490
-                '',
491
-                'total_currency total jst-rght',
492
-                '',
493
-                ' colspan="2"'
494
-            );
495
-            // empty td (price)
496
-            $html .= EEH_HTML::td(EEH_HTML::nbsp());
497
-            // total td
498
-            $html .= EEH_HTML::td(
499
-                EEH_Template::format_currency($line_item->total(), false, false),
500
-                '',
501
-                'total jst-rght'
502
-            );
503
-            // end of row
504
-            $html .= EEH_HTML::trx();
505
-        }
506
-        return $html;
507
-    }
508
-
509
-
510
-
511
-    /**
512
-     * _total_row
513
-     *
514
-     * @param EE_Line_Item $line_item
515
-     * @param string       $text
516
-     * @param array        $options
517
-     * @return mixed
518
-     * @throws EE_Error
519
-     */
520
-    private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array())
521
-    {
522
-        $html = '';
523
-        if ($line_item->total()) {
524
-            // start of row
525
-            $html = EEH_HTML::tr('', '', 'total_tr odd');
526
-            // total td
527
-            $html .= EEH_HTML::td(
528
-                $text,
529
-                '',
530
-                'total_currency total jst-rght',
531
-                '',
532
-                ' colspan="3"'
533
-            );
534
-            // total td
535
-            $html .= EEH_HTML::td(
536
-                EEH_Template::format_currency($options['sub_total'], false, false),
537
-                '',
538
-                'total jst-rght'
539
-            );
540
-            // end of row
541
-            $html .= EEH_HTML::trx();
542
-        }
543
-        return $html;
544
-    }
545
-
546
-
547
-
548
-    /**
549
-     * _total_row
550
-     *
551
-     * @param EE_Line_Item $line_item
552
-     * @param string       $text
553
-     * @return mixed
554
-     * @throws EE_Error
555
-     */
556
-    private function _total_row(EE_Line_Item $line_item, $text = '')
557
-    {
558
-        // start of row
559
-        $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd');
560
-        // total td
561
-        $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
562
-        // total td
563
-        $html .= EEH_HTML::td(
564
-            EEH_Template::format_currency($line_item->total(), false, false),
565
-            '',
566
-            'total jst-rght'
567
-        );
568
-        // end of row
569
-        $html .= EEH_HTML::trx();
570
-        return $html;
571
-    }
572
-
573
-
574
-
575
-    /**
576
-     * _payments_and_amount_owing_rows
577
-     *
578
-     * @param EE_Line_Item $line_item
579
-     * @param array        $options
580
-     * @return mixed
581
-     * @throws EE_Error
582
-     */
583
-    private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array())
584
-    {
585
-        $html = '';
586
-        $owing = $line_item->total();
587
-        $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID());
588
-        if ($transaction instanceof EE_Transaction) {
589
-            $registration_payments = array();
590
-            $registrations = ! empty($options['registrations'])
591
-                ? $options['registrations']
592
-                : $transaction->registrations();
593
-            foreach ($registrations as $registration) {
594
-                if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
595
-                    $registration_payments += $registration->registration_payments();
596
-                }
597
-            }
598
-            if (! empty($registration_payments)) {
599
-                foreach ($registration_payments as $registration_payment) {
600
-                    if ($registration_payment instanceof EE_Registration_Payment) {
601
-                        $owing -= $registration_payment->amount();
602
-                        $payment = $registration_payment->payment();
603
-                        $payment_desc = '';
604
-                        if ($payment instanceof EE_Payment) {
605
-                            $payment_desc = sprintf(
606
-                                esc_html__('Payment%1$s Received: %2$s', 'event_espresso'),
607
-                                $payment->txn_id_chq_nmbr() !== ''
608
-                                    ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> '
609
-                                    : '',
610
-                                $payment->timestamp()
611
-                            );
612
-                        }
613
-                        // start of row
614
-                        $html .= EEH_HTML::tr('', '', 'total_tr odd');
615
-                        // payment desc
616
-                        $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"');
617
-                        // total td
618
-                        $html .= EEH_HTML::td(
619
-                            EEH_Template::format_currency(
620
-                                $registration_payment->amount(),
621
-                                false,
622
-                                false
623
-                            ),
624
-                            '',
625
-                            'total jst-rght'
626
-                        );
627
-                        // end of row
628
-                        $html .= EEH_HTML::trx();
629
-                    }
630
-                }
631
-                if ($line_item->total()) {
632
-                    // start of row
633
-                    $html .= EEH_HTML::tr('', '', 'total_tr odd');
634
-                    // total td
635
-                    $html .= EEH_HTML::td(
636
-                        esc_html__('Amount Owing', 'event_espresso'),
637
-                        '',
638
-                        'total_currency total jst-rght',
639
-                        '',
640
-                        ' colspan="3"'
641
-                    );
642
-                    // total td
643
-                    $html .= EEH_HTML::td(
644
-                        EEH_Template::format_currency($owing, false, false),
645
-                        '',
646
-                        'total jst-rght'
647
-                    );
648
-                    // end of row
649
-                    $html .= EEH_HTML::trx();
650
-                }
651
-            }
652
-        }
653
-        $this->_grand_total = $owing;
654
-        return $html;
655
-    }
15
+	/**
16
+	 * array of events
17
+	 *
18
+	 * @type EE_Line_Item[] $_events
19
+	 */
20
+	private $_events = array();
21
+
22
+	/**
23
+	 * whether to display the taxes row or not
24
+	 *
25
+	 * @type bool $_show_taxes
26
+	 */
27
+	private $_show_taxes = false;
28
+
29
+	/**
30
+	 * html for any tax rows
31
+	 *
32
+	 * @type string $_show_taxes
33
+	 */
34
+	private $_taxes_html = '';
35
+
36
+	/**
37
+	 * total amount including tax we can bill for at this time
38
+	 *
39
+	 * @type float $_grand_total
40
+	 */
41
+	private $_grand_total = 0.00;
42
+
43
+	/**
44
+	 * total number of items being billed for
45
+	 *
46
+	 * @type int $_total_items
47
+	 */
48
+	private $_total_items = 0;
49
+
50
+
51
+
52
+	/**
53
+	 * @return float
54
+	 */
55
+	public function grand_total()
56
+	{
57
+		return $this->_grand_total;
58
+	}
59
+
60
+
61
+
62
+	/**
63
+	 * @return int
64
+	 */
65
+	public function total_items()
66
+	{
67
+		return $this->_total_items;
68
+	}
69
+
70
+
71
+
72
+	/**
73
+	 * @param EE_Line_Item $line_item
74
+	 * @param array        $options
75
+	 * @param EE_Line_Item $parent_line_item
76
+	 * @return mixed
77
+	 * @throws EE_Error
78
+	 */
79
+	public function display_line_item(
80
+		EE_Line_Item $line_item,
81
+		$options = array(),
82
+		EE_Line_Item $parent_line_item = null
83
+	) {
84
+		$html = '';
85
+		// set some default options and merge with incoming
86
+		$default_options = array(
87
+			'show_desc' => true,  //    true        false
88
+			'odd'       => false,
89
+		);
90
+		$options = array_merge($default_options, (array) $options);
91
+		switch ($line_item->type()) {
92
+			case EEM_Line_Item::type_line_item:
93
+				$this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes;
94
+				if ($line_item->OBJ_type() === 'Ticket') {
95
+					// item row
96
+					$html .= $this->_ticket_row($line_item, $options);
97
+				} else {
98
+					// item row
99
+					$html .= $this->_item_row($line_item, $options);
100
+				}
101
+				if (apply_filters(
102
+					'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items',
103
+					true
104
+				)
105
+				) {
106
+					// got any kids?
107
+					foreach ($line_item->children() as $child_line_item) {
108
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
109
+					}
110
+				}
111
+				break;
112
+			case EEM_Line_Item::type_sub_line_item:
113
+				$html .= $this->_sub_item_row($line_item, $options, $parent_line_item);
114
+				break;
115
+			case EEM_Line_Item::type_sub_total:
116
+				static $sub_total = 0;
117
+				$event_sub_total = 0;
118
+				$text = esc_html__('Sub-Total', 'event_espresso');
119
+				if ($line_item->OBJ_type() === 'Event') {
120
+					$options['event_id'] = $event_id = $line_item->OBJ_ID();
121
+					if (! isset($this->_events[ $options['event_id'] ])) {
122
+						$event = EEM_Event::instance()->get_one_by_ID($options['event_id']);
123
+						// if event has default reg status of Not Approved, then don't display info on it
124
+						if ($event instanceof EE_Event
125
+							&& $event->default_registration_status() === EEM_Registration::status_id_not_approved
126
+						) {
127
+							$display_event = false;
128
+							// unless there are registrations for it that are returning to pay
129
+							if (isset($options['registrations']) && is_array($options['registrations'])) {
130
+								foreach ($options['registrations'] as $registration) {
131
+									if (! $registration instanceof EE_Registration) {
132
+										continue;
133
+									}
134
+									$display_event = $registration->event_ID() === $options['event_id']
135
+													 && $registration->status_ID() !== EEM_Registration::status_id_not_approved
136
+										? true
137
+										: $display_event;
138
+								}
139
+							}
140
+							if (! $display_event) {
141
+								return '';
142
+							}
143
+						}
144
+						$this->_events[ $options['event_id'] ] = 0;
145
+						$html .= $this->_event_row($line_item);
146
+						$text = esc_html__('Event Sub-Total', 'event_espresso');
147
+					}
148
+				}
149
+				$child_line_items = $line_item->children();
150
+				// loop thru children
151
+				foreach ($child_line_items as $child_line_item) {
152
+					// recursively feed children back into this method
153
+					$html .= $this->display_line_item($child_line_item, $options, $line_item);
154
+				}
155
+				$event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0;
156
+				$sub_total += $event_sub_total;
157
+				if ((
158
+						// event subtotals
159
+						$line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1
160
+					)
161
+					|| (
162
+						// pre-tax subtotals
163
+						$line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1
164
+					)
165
+				) {
166
+					$options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total;
167
+					$html .= $this->_sub_total_row($line_item, $text, $options);
168
+				}
169
+				break;
170
+			case EEM_Line_Item::type_tax:
171
+				if ($this->_show_taxes) {
172
+					$this->_taxes_html .= $this->_tax_row($line_item, $options);
173
+				}
174
+				break;
175
+			case EEM_Line_Item::type_tax_sub_total:
176
+				if ($this->_show_taxes) {
177
+					$child_line_items = $line_item->children();
178
+					// loop thru children
179
+					foreach ($child_line_items as $child_line_item) {
180
+						// recursively feed children back into this method
181
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
182
+					}
183
+					if (count($child_line_items) > 1) {
184
+						$this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso'));
185
+					}
186
+				}
187
+				break;
188
+			case EEM_Line_Item::type_total:
189
+				// get all child line items
190
+				$children = $line_item->children();
191
+				// loop thru all non-tax child line items
192
+				foreach ($children as $child_line_item) {
193
+					if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) {
194
+						// recursively feed children back into this method
195
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
196
+					}
197
+				}
198
+				// now loop thru  tax child line items
199
+				foreach ($children as $child_line_item) {
200
+					if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) {
201
+						// recursively feed children back into this method
202
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
203
+					}
204
+				}
205
+				$html .= $this->_taxes_html;
206
+				$html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso'));
207
+				$html .= $this->_payments_and_amount_owing_rows($line_item, $options);
208
+				break;
209
+		}
210
+		return $html;
211
+	}
212
+
213
+
214
+
215
+	/**
216
+	 * _event_row - basically a Heading row displayed once above each event's ticket rows
217
+	 *
218
+	 * @param EE_Line_Item $line_item
219
+	 * @return mixed
220
+	 */
221
+	private function _event_row(EE_Line_Item $line_item)
222
+	{
223
+		// start of row
224
+		$html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd');
225
+		// event name td
226
+		$html .= EEH_HTML::td(
227
+			EEH_HTML::strong($line_item->name()),
228
+			'',
229
+			'event-header',
230
+			'',
231
+			' colspan="4"'
232
+		);
233
+		// end of row
234
+		$html .= EEH_HTML::trx();
235
+		return $html;
236
+	}
237
+
238
+
239
+
240
+	/**
241
+	 * _ticket_row
242
+	 *
243
+	 * @param EE_Line_Item $line_item
244
+	 * @param array        $options
245
+	 * @return mixed
246
+	 * @throws EE_Error
247
+	 */
248
+	private function _ticket_row(EE_Line_Item $line_item, $options = array())
249
+	{
250
+		// start of row
251
+		$row_class = $options['odd'] ? 'item odd' : 'item';
252
+		$html = EEH_HTML::tr('', '', $row_class);
253
+		// name && desc
254
+		$name_and_desc = apply_filters(
255
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
256
+			$line_item->name(),
257
+			$line_item
258
+		);
259
+		$name_and_desc .= apply_filters(
260
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
261
+			(
262
+				$options['show_desc']
263
+					? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
264
+					: ''
265
+			),
266
+			$line_item,
267
+			$options
268
+		);
269
+		$name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
270
+		// name td
271
+		$html .= EEH_HTML::td( /*__FUNCTION__ .*/
272
+			$name_and_desc,
273
+			'',
274
+			'item_l'
275
+		);
276
+		// price td
277
+		$price = apply_filters(
278
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__price',
279
+			$line_item->unit_price_no_code(),
280
+			$line_item
281
+		);
282
+		$html .= EEH_HTML::td($price, '', 'item_c jst-rght');
283
+		// quantity td
284
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
285
+		$this->_total_items += $line_item->quantity();
286
+		// determine total for line item
287
+		$total = apply_filters(
288
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__total',
289
+			$line_item->total(),
290
+			$line_item
291
+		);
292
+		$this->_events[ $options['event_id'] ] += $total;
293
+		// total td
294
+		$html .= EEH_HTML::td(
295
+			EEH_Template::format_currency($total, false, false),
296
+			'',
297
+			'item_r jst-rght'
298
+		);
299
+		// end of row
300
+		$html .= EEH_HTML::trx();
301
+		return $html;
302
+	}
303
+
304
+
305
+
306
+	/**
307
+	 * _item_row
308
+	 *
309
+	 * @param EE_Line_Item $line_item
310
+	 * @param array        $options
311
+	 * @return mixed
312
+	 * @throws EE_Error
313
+	 */
314
+	private function _item_row(EE_Line_Item $line_item, $options = array())
315
+	{
316
+		// start of row
317
+		$row_class = $options['odd'] ? 'item odd' : 'item';
318
+		$html = EEH_HTML::tr('', '', $row_class);
319
+		$obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : '';
320
+		// name && desc
321
+		$name_and_desc = apply_filters(
322
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
323
+			$obj_name . $line_item->name(),
324
+			$line_item
325
+		);
326
+		$name_and_desc .= apply_filters(
327
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
328
+			(
329
+				$options['show_desc']
330
+				? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
331
+				: ''
332
+			),
333
+			$line_item,
334
+			$options
335
+		);
336
+		$name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
337
+		// name td
338
+		$html .= EEH_HTML::td($name_and_desc, '', 'item_l');
339
+		// price td
340
+		if ($line_item->is_percent()) {
341
+			$html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght');
342
+		} else {
343
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
344
+		}
345
+		// quantity td
346
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
347
+		// $total = $line_item->total() * $line_item->quantity();
348
+		$total = $line_item->total();
349
+		if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) {
350
+			$this->_events[ $options['event_id'] ] += $total;
351
+		}
352
+		// total td
353
+		$html .= EEH_HTML::td(
354
+			EEH_Template::format_currency($total, false, false),
355
+			'',
356
+			'item_r jst-rght'
357
+		);
358
+		// end of row
359
+		$html .= EEH_HTML::trx();
360
+		return $html;
361
+	}
362
+
363
+
364
+
365
+	/**
366
+	 * _sub_item_row
367
+	 *
368
+	 * @param EE_Line_Item $line_item
369
+	 * @param array        $options
370
+	 * @param EE_Line_Item $parent_line_item
371
+	 * @return mixed
372
+	 * @throws EE_Error
373
+	 */
374
+	private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null)
375
+	{
376
+		if ($parent_line_item instanceof  EE_Line_Item
377
+			&& $line_item->children() === array()
378
+			&& $line_item->name() === $parent_line_item->name()
379
+			&& apply_filters(
380
+				'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__hide_main_sub_line_item',
381
+				true
382
+			)
383
+		) {
384
+			return '';
385
+		}
386
+		// start of row
387
+		$html = EEH_HTML::tr('', '', 'item sub-item-row');
388
+		// name && desc
389
+		$name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right')
390
+						 . $line_item->name();
391
+		$name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '
392
+												  . $line_item->desc()
393
+												  . '</span>' : '';
394
+		// name td
395
+		$html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item');
396
+		$qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1;
397
+		// discount/surcharge td
398
+		if ($line_item->is_percent()) {
399
+			$html .= EEH_HTML::td(
400
+				EEH_Template::format_currency(
401
+					$line_item->total() / $qty,
402
+					false,
403
+					false
404
+				),
405
+				'',
406
+				'item_c jst-rght'
407
+			);
408
+		} else {
409
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
410
+		}
411
+		// no quantity td
412
+		$html .= EEH_HTML::td();
413
+		// no total td
414
+		$html .= EEH_HTML::td();
415
+		// end of row
416
+		$html .= EEH_HTML::trx();
417
+		$html = apply_filters(
418
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__html',
419
+			$html,
420
+			$line_item,
421
+			$options,
422
+			$parent_line_item
423
+		);
424
+		return $html;
425
+	}
426
+
427
+
428
+
429
+	/**
430
+	 * _tax_row
431
+	 *
432
+	 * @param EE_Line_Item $line_item
433
+	 * @param array        $options
434
+	 * @return mixed
435
+	 * @throws EE_Error
436
+	 */
437
+	private function _tax_row(EE_Line_Item $line_item, $options = array())
438
+	{
439
+		// start of row
440
+		$html = EEH_HTML::tr('', 'item sub-item tax-total');
441
+		// name && desc
442
+		$name_and_desc = $line_item->name();
443
+		$name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
444
+						  . esc_html__(' * taxable items', 'event_espresso') . '</span>';
445
+		$name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : '';
446
+		// name td
447
+		$html .= EEH_HTML::td( /*__FUNCTION__ .*/
448
+			$name_and_desc,
449
+			'',
450
+			'item_l sub-item'
451
+		);
452
+		// percent td
453
+		$html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', '');
454
+		// empty td (price)
455
+		$html .= EEH_HTML::td(EEH_HTML::nbsp());
456
+		// total td
457
+		$html .= EEH_HTML::td(
458
+			EEH_Template::format_currency(
459
+				$line_item->total(),
460
+				false,
461
+				false
462
+			),
463
+			'',
464
+			'item_r jst-rght'
465
+		);
466
+		// end of row
467
+		$html .= EEH_HTML::trx();
468
+		return $html;
469
+	}
470
+
471
+
472
+
473
+	/**
474
+	 * _total_row
475
+	 *
476
+	 * @param EE_Line_Item $line_item
477
+	 * @param string       $text
478
+	 * @return mixed
479
+	 * @throws EE_Error
480
+	 */
481
+	private function _total_tax_row(EE_Line_Item $line_item, $text = '')
482
+	{
483
+		$html = '';
484
+		if ($line_item->total()) {
485
+			// start of row
486
+			$html = EEH_HTML::tr('', '', 'total_tr odd');
487
+			// total td
488
+			$html .= EEH_HTML::td(
489
+				$text,
490
+				'',
491
+				'total_currency total jst-rght',
492
+				'',
493
+				' colspan="2"'
494
+			);
495
+			// empty td (price)
496
+			$html .= EEH_HTML::td(EEH_HTML::nbsp());
497
+			// total td
498
+			$html .= EEH_HTML::td(
499
+				EEH_Template::format_currency($line_item->total(), false, false),
500
+				'',
501
+				'total jst-rght'
502
+			);
503
+			// end of row
504
+			$html .= EEH_HTML::trx();
505
+		}
506
+		return $html;
507
+	}
508
+
509
+
510
+
511
+	/**
512
+	 * _total_row
513
+	 *
514
+	 * @param EE_Line_Item $line_item
515
+	 * @param string       $text
516
+	 * @param array        $options
517
+	 * @return mixed
518
+	 * @throws EE_Error
519
+	 */
520
+	private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array())
521
+	{
522
+		$html = '';
523
+		if ($line_item->total()) {
524
+			// start of row
525
+			$html = EEH_HTML::tr('', '', 'total_tr odd');
526
+			// total td
527
+			$html .= EEH_HTML::td(
528
+				$text,
529
+				'',
530
+				'total_currency total jst-rght',
531
+				'',
532
+				' colspan="3"'
533
+			);
534
+			// total td
535
+			$html .= EEH_HTML::td(
536
+				EEH_Template::format_currency($options['sub_total'], false, false),
537
+				'',
538
+				'total jst-rght'
539
+			);
540
+			// end of row
541
+			$html .= EEH_HTML::trx();
542
+		}
543
+		return $html;
544
+	}
545
+
546
+
547
+
548
+	/**
549
+	 * _total_row
550
+	 *
551
+	 * @param EE_Line_Item $line_item
552
+	 * @param string       $text
553
+	 * @return mixed
554
+	 * @throws EE_Error
555
+	 */
556
+	private function _total_row(EE_Line_Item $line_item, $text = '')
557
+	{
558
+		// start of row
559
+		$html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd');
560
+		// total td
561
+		$html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
562
+		// total td
563
+		$html .= EEH_HTML::td(
564
+			EEH_Template::format_currency($line_item->total(), false, false),
565
+			'',
566
+			'total jst-rght'
567
+		);
568
+		// end of row
569
+		$html .= EEH_HTML::trx();
570
+		return $html;
571
+	}
572
+
573
+
574
+
575
+	/**
576
+	 * _payments_and_amount_owing_rows
577
+	 *
578
+	 * @param EE_Line_Item $line_item
579
+	 * @param array        $options
580
+	 * @return mixed
581
+	 * @throws EE_Error
582
+	 */
583
+	private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array())
584
+	{
585
+		$html = '';
586
+		$owing = $line_item->total();
587
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID());
588
+		if ($transaction instanceof EE_Transaction) {
589
+			$registration_payments = array();
590
+			$registrations = ! empty($options['registrations'])
591
+				? $options['registrations']
592
+				: $transaction->registrations();
593
+			foreach ($registrations as $registration) {
594
+				if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
595
+					$registration_payments += $registration->registration_payments();
596
+				}
597
+			}
598
+			if (! empty($registration_payments)) {
599
+				foreach ($registration_payments as $registration_payment) {
600
+					if ($registration_payment instanceof EE_Registration_Payment) {
601
+						$owing -= $registration_payment->amount();
602
+						$payment = $registration_payment->payment();
603
+						$payment_desc = '';
604
+						if ($payment instanceof EE_Payment) {
605
+							$payment_desc = sprintf(
606
+								esc_html__('Payment%1$s Received: %2$s', 'event_espresso'),
607
+								$payment->txn_id_chq_nmbr() !== ''
608
+									? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> '
609
+									: '',
610
+								$payment->timestamp()
611
+							);
612
+						}
613
+						// start of row
614
+						$html .= EEH_HTML::tr('', '', 'total_tr odd');
615
+						// payment desc
616
+						$html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"');
617
+						// total td
618
+						$html .= EEH_HTML::td(
619
+							EEH_Template::format_currency(
620
+								$registration_payment->amount(),
621
+								false,
622
+								false
623
+							),
624
+							'',
625
+							'total jst-rght'
626
+						);
627
+						// end of row
628
+						$html .= EEH_HTML::trx();
629
+					}
630
+				}
631
+				if ($line_item->total()) {
632
+					// start of row
633
+					$html .= EEH_HTML::tr('', '', 'total_tr odd');
634
+					// total td
635
+					$html .= EEH_HTML::td(
636
+						esc_html__('Amount Owing', 'event_espresso'),
637
+						'',
638
+						'total_currency total jst-rght',
639
+						'',
640
+						' colspan="3"'
641
+					);
642
+					// total td
643
+					$html .= EEH_HTML::td(
644
+						EEH_Template::format_currency($owing, false, false),
645
+						'',
646
+						'total jst-rght'
647
+					);
648
+					// end of row
649
+					$html .= EEH_HTML::trx();
650
+				}
651
+			}
652
+		}
653
+		$this->_grand_total = $owing;
654
+		return $html;
655
+	}
656 656
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         $html = '';
85 85
         // set some default options and merge with incoming
86 86
         $default_options = array(
87
-            'show_desc' => true,  //    true        false
87
+            'show_desc' => true, //    true        false
88 88
             'odd'       => false,
89 89
         );
90 90
         $options = array_merge($default_options, (array) $options);
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                 $text = esc_html__('Sub-Total', 'event_espresso');
119 119
                 if ($line_item->OBJ_type() === 'Event') {
120 120
                     $options['event_id'] = $event_id = $line_item->OBJ_ID();
121
-                    if (! isset($this->_events[ $options['event_id'] ])) {
121
+                    if ( ! isset($this->_events[$options['event_id']])) {
122 122
                         $event = EEM_Event::instance()->get_one_by_ID($options['event_id']);
123 123
                         // if event has default reg status of Not Approved, then don't display info on it
124 124
                         if ($event instanceof EE_Event
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
                             // unless there are registrations for it that are returning to pay
129 129
                             if (isset($options['registrations']) && is_array($options['registrations'])) {
130 130
                                 foreach ($options['registrations'] as $registration) {
131
-                                    if (! $registration instanceof EE_Registration) {
131
+                                    if ( ! $registration instanceof EE_Registration) {
132 132
                                         continue;
133 133
                                     }
134 134
                                     $display_event = $registration->event_ID() === $options['event_id']
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
                                         : $display_event;
138 138
                                 }
139 139
                             }
140
-                            if (! $display_event) {
140
+                            if ( ! $display_event) {
141 141
                                 return '';
142 142
                             }
143 143
                         }
144
-                        $this->_events[ $options['event_id'] ] = 0;
144
+                        $this->_events[$options['event_id']] = 0;
145 145
                         $html .= $this->_event_row($line_item);
146 146
                         $text = esc_html__('Event Sub-Total', 'event_espresso');
147 147
                     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
                     // recursively feed children back into this method
153 153
                     $html .= $this->display_line_item($child_line_item, $options, $line_item);
154 154
                 }
155
-                $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0;
155
+                $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0;
156 156
                 $sub_total += $event_sub_total;
157 157
                 if ((
158 158
                         // event subtotals
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
             'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
261 261
             (
262 262
                 $options['show_desc']
263
-                    ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
263
+                    ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>'
264 264
                     : ''
265 265
             ),
266 266
             $line_item,
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
             $line_item->total(),
290 290
             $line_item
291 291
         );
292
-        $this->_events[ $options['event_id'] ] += $total;
292
+        $this->_events[$options['event_id']] += $total;
293 293
         // total td
294 294
         $html .= EEH_HTML::td(
295 295
             EEH_Template::format_currency($total, false, false),
@@ -316,18 +316,18 @@  discard block
 block discarded – undo
316 316
         // start of row
317 317
         $row_class = $options['odd'] ? 'item odd' : 'item';
318 318
         $html = EEH_HTML::tr('', '', $row_class);
319
-        $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : '';
319
+        $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n().': ' : '';
320 320
         // name && desc
321 321
         $name_and_desc = apply_filters(
322 322
             'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
323
-            $obj_name . $line_item->name(),
323
+            $obj_name.$line_item->name(),
324 324
             $line_item
325 325
         );
326 326
         $name_and_desc .= apply_filters(
327 327
             'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
328 328
             (
329 329
                 $options['show_desc']
330
-                ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
330
+                ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>'
331 331
                 : ''
332 332
             ),
333 333
             $line_item,
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
         $html .= EEH_HTML::td($name_and_desc, '', 'item_l');
339 339
         // price td
340 340
         if ($line_item->is_percent()) {
341
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght');
341
+            $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght');
342 342
         } else {
343 343
             $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
344 344
         }
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
         $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
347 347
         // $total = $line_item->total() * $line_item->quantity();
348 348
         $total = $line_item->total();
349
-        if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) {
350
-            $this->_events[ $options['event_id'] ] += $total;
349
+        if (isset($options['event_id'], $this->_events[$options['event_id']])) {
350
+            $this->_events[$options['event_id']] += $total;
351 351
         }
352 352
         // total td
353 353
         $html .= EEH_HTML::td(
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
         // name && desc
442 442
         $name_and_desc = $line_item->name();
443 443
         $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
444
-                          . esc_html__(' * taxable items', 'event_espresso') . '</span>';
445
-        $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : '';
444
+                          . esc_html__(' * taxable items', 'event_espresso').'</span>';
445
+        $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : '';
446 446
         // name td
447 447
         $html .= EEH_HTML::td( /*__FUNCTION__ .*/
448 448
             $name_and_desc,
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
             'item_l sub-item'
451 451
         );
452 452
         // percent td
453
-        $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', '');
453
+        $html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', '');
454 454
         // empty td (price)
455 455
         $html .= EEH_HTML::td(EEH_HTML::nbsp());
456 456
         // total td
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
                     $registration_payments += $registration->registration_payments();
596 596
                 }
597 597
             }
598
-            if (! empty($registration_payments)) {
598
+            if ( ! empty($registration_payments)) {
599 599
                 foreach ($registration_payments as $registration_payment) {
600 600
                     if ($registration_payment instanceof EE_Registration_Payment) {
601 601
                         $owing -= $registration_payment->amount();
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
                             $payment_desc = sprintf(
606 606
                                 esc_html__('Payment%1$s Received: %2$s', 'event_espresso'),
607 607
                                 $payment->txn_id_chq_nmbr() !== ''
608
-                                    ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> '
608
+                                    ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> '
609 609
                                     : '',
610 610
                                 $payment->timestamp()
611 611
                             );
Please login to merge, or discard this patch.
templates/txn_admin_details_side_meta_box_registrant.template.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,19 +10,19 @@  discard block
 block discarded – undo
10 10
 ?>
11 11
 <div id="admin-side-mbox-primary-registrant-dv" class="admin-side-mbox-dv">
12 12
     <?php
13
-    if (! empty($no_attendee_message)) : ?>
13
+	if (! empty($no_attendee_message)) : ?>
14 14
     <p class="clearfix">
15 15
         <?php echo $no_attendee_message; ?>
16 16
     </p>
17 17
 </div> <!-- end #admin-side-mbox-primary-registrant-dv -->
18 18
 <?php
19
-    else : ?>
19
+	else : ?>
20 20
     <p class="clearfix">
21 21
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left">
22 22
             <?php esc_html_e(
23
-                'Name',
24
-                'event_espresso'
25
-            ); ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>
23
+				'Name',
24
+				'event_espresso'
25
+			); ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>
26 26
     </p>
27 27
     <p class="clearfix">
28 28
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php esc_html_e('Email', 'event_espresso'); ?></span><a
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
     <p class="clearfix">
32 32
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left">
33 33
             <?php esc_html_e(
34
-                'Phone #',
35
-                'event_espresso'
36
-            ); ?>
34
+				'Phone #',
35
+				'event_espresso'
36
+			); ?>
37 37
     </span>
38 38
     <?php if (! empty($prime_reg_phone)) : ?>
39 39
         <a href="tel:<?php echo $prime_reg_phone; ?>">
@@ -50,22 +50,22 @@  discard block
 block discarded – undo
50 50
     </div> <!-- end #admin-side-mbox-primary-registrant-dv -->
51 51
 
52 52
     <?php
53
-    /** only show if logged in user has access */
54
-    if (EE_Registry::instance()->CAP->current_user_can(
55
-        'ee_edit_contact',
56
-        'view_or_edit_contact_button',
57
-        $ATT_ID
58
-    )
59
-    ) : ?>
53
+	/** only show if logged in user has access */
54
+	if (EE_Registry::instance()->CAP->current_user_can(
55
+		'ee_edit_contact',
56
+		'view_or_edit_contact_button',
57
+		$ATT_ID
58
+	)
59
+	) : ?>
60 60
         <p style="text-align:right;">
61 61
             <a class="button button-small" href="<?php echo $edit_attendee_url; ?>"
62 62
                title="<?php esc_attr_e('View details for this contact.', 'event_espresso'); ?>">
63 63
                 <span class="ee-icon ee-icon-user-edit"></span>
64 64
                 <?php _e(
65
-                    'View / Edit this Contact',
66
-                    'event_espresso'
67
-                ); ?>
65
+					'View / Edit this Contact',
66
+					'event_espresso'
67
+				); ?>
68 68
             </a>
69 69
         </p>
70 70
     <?php endif;
71
-    endif;
71
+	endif;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 ?>
11 11
 <div id="admin-side-mbox-primary-registrant-dv" class="admin-side-mbox-dv">
12 12
     <?php
13
-    if (! empty($no_attendee_message)) : ?>
13
+    if ( ! empty($no_attendee_message)) : ?>
14 14
     <p class="clearfix">
15 15
         <?php echo $no_attendee_message; ?>
16 16
     </p>
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
             <?php esc_html_e(
23 23
                 'Name',
24 24
                 'event_espresso'
25
-            ); ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>
25
+            ); ?></span><?php echo $prime_reg_fname.' '.$prime_reg_lname; ?>
26 26
     </p>
27 27
     <p class="clearfix">
28 28
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php esc_html_e('Email', 'event_espresso'); ?></span><a
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
                 'event_espresso'
36 36
             ); ?>
37 37
     </span>
38
-    <?php if (! empty($prime_reg_phone)) : ?>
38
+    <?php if ( ! empty($prime_reg_phone)) : ?>
39 39
         <a href="tel:<?php echo $prime_reg_phone; ?>">
40 40
             <?php echo $prime_reg_phone; ?>
41 41
         </a>
Please login to merge, or discard this patch.
core/db_models/EEM_Transaction.model.php 2 patches
Indentation   +450 added lines, -450 removed lines patch added patch discarded remove patch
@@ -16,230 +16,230 @@  discard block
 block discarded – undo
16 16
 class EEM_Transaction extends EEM_Base
17 17
 {
18 18
 
19
-    // private instance of the Transaction object
20
-    protected static $_instance;
21
-
22
-    /**
23
-     * Status ID(STS_ID on esp_status table) to indicate the transaction is complete,
24
-     * but payment is pending. This is the state for transactions where payment is promised
25
-     * from an offline gateway.
26
-     */
27
-    //  const open_status_code = 'TPN';
28
-
29
-    /**
30
-     * Status ID(STS_ID on esp_status table) to indicate the transaction failed,
31
-     * either due to a technical reason (server or computer crash during registration),
32
-     *  or some other reason that prevent the collection of any useful contact information from any of the registrants
33
-     */
34
-    const failed_status_code = 'TFL';
35
-
36
-    /**
37
-     * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned,
38
-     * either due to a technical reason (server or computer crash during registration),
39
-     * or due to an abandoned cart after registrant chose not to complete the registration process
40
-     * HOWEVER...
41
-     * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one
42
-     * registrant
43
-     */
44
-    const abandoned_status_code = 'TAB';
45
-
46
-    /**
47
-     * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction,
48
-     * meaning that monies are still owing: TXN_paid < TXN_total
49
-     */
50
-    const incomplete_status_code = 'TIN';
51
-
52
-    /**
53
-     * Status ID (STS_ID on esp_status table) to indicate a complete transaction.
54
-     * meaning that NO monies are owing: TXN_paid == TXN_total
55
-     */
56
-    const complete_status_code = 'TCM';
57
-
58
-    /**
59
-     *  Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid.
60
-     *  This is the same as complete, but site admins actually owe clients the moneys!  TXN_paid > TXN_total
61
-     */
62
-    const overpaid_status_code = 'TOP';
63
-
64
-
65
-    /**
66
-     *    private constructor to prevent direct creation
67
-     *
68
-     * @Constructor
69
-     * @access protected
70
-     *
71
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
72
-     *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
73
-     *                         date time model field objects.  Default is NULL (and will be assumed using the set
74
-     *                         timezone in the 'timezone_string' wp option)
75
-     *
76
-     * @return EEM_Transaction
77
-     * @throws \EE_Error
78
-     */
79
-    protected function __construct($timezone)
80
-    {
81
-        $this->singular_item = __('Transaction', 'event_espresso');
82
-        $this->plural_item   = __('Transactions', 'event_espresso');
83
-
84
-        $this->_tables                 = array(
85
-            'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID')
86
-        );
87
-        $this->_fields                 = array(
88
-            'TransactionTable' => array(
89
-                'TXN_ID'           => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')),
90
-                'TXN_timestamp'    => new EE_Datetime_Field(
91
-                    'TXN_timestamp',
92
-                    __('date when transaction was created', 'event_espresso'),
93
-                    false,
94
-                    EE_Datetime_Field::now,
95
-                    $timezone
96
-                ),
97
-                'TXN_total'        => new EE_Money_Field(
98
-                    'TXN_total',
99
-                    __('Total value of Transaction', 'event_espresso'),
100
-                    false,
101
-                    0
102
-                ),
103
-                'TXN_paid'         => new EE_Money_Field(
104
-                    'TXN_paid',
105
-                    __('Amount paid towards transaction to date', 'event_espresso'),
106
-                    false,
107
-                    0
108
-                ),
109
-                'STS_ID'           => new EE_Foreign_Key_String_Field(
110
-                    'STS_ID',
111
-                    __('Status ID', 'event_espresso'),
112
-                    false,
113
-                    EEM_Transaction::failed_status_code,
114
-                    'Status'
115
-                ),
116
-                'TXN_session_data' => new EE_Serialized_Text_Field(
117
-                    'TXN_session_data',
118
-                    __('Serialized session data', 'event_espresso'),
119
-                    true,
120
-                    ''
121
-                ),
122
-                'TXN_hash_salt'    => new EE_Plain_Text_Field(
123
-                    'TXN_hash_salt',
124
-                    __('Transaction Hash Salt', 'event_espresso'),
125
-                    true,
126
-                    ''
127
-                ),
128
-                'PMD_ID'           => new EE_Foreign_Key_Int_Field(
129
-                    'PMD_ID',
130
-                    __("Last Used Payment Method", 'event_espresso'),
131
-                    true,
132
-                    null,
133
-                    'Payment_Method'
134
-                ),
135
-                'TXN_reg_steps'    => new EE_Serialized_Text_Field(
136
-                    'TXN_reg_steps',
137
-                    __('Registration Steps', 'event_espresso'),
138
-                    false,
139
-                    array()
140
-                ),
141
-            )
142
-        );
143
-        $this->_model_relations        = array(
144
-            'Registration'   => new EE_Has_Many_Relation(),
145
-            'Payment'        => new EE_Has_Many_Relation(),
146
-            'Status'         => new EE_Belongs_To_Relation(),
147
-            'Line_Item'      => new EE_Has_Many_Relation(false),
148
-            // you can delete a transaction without needing to delete its line items
149
-            'Payment_Method' => new EE_Belongs_To_Relation(),
150
-            'Message'        => new EE_Has_Many_Relation()
151
-        );
152
-        $this->_model_chain_to_wp_user = 'Registration.Event';
153
-        parent::__construct($timezone);
154
-    }
155
-
156
-
157
-    /**
158
-     *    txn_status_array
159
-     * get list of transaction statuses
160
-     *
161
-     * @access public
162
-     * @return array
163
-     */
164
-    public static function txn_status_array()
165
-    {
166
-        return apply_filters(
167
-            'FHEE__EEM_Transaction__txn_status_array',
168
-            array(
169
-                EEM_Transaction::overpaid_status_code,
170
-                EEM_Transaction::complete_status_code,
171
-                EEM_Transaction::incomplete_status_code,
172
-                EEM_Transaction::abandoned_status_code,
173
-                EEM_Transaction::failed_status_code,
174
-            )
175
-        );
176
-    }
177
-
178
-    /**
179
-     *        get the revenue per day  for the Transaction Admin page Reports Tab
180
-     *
181
-     * @access        public
182
-     *
183
-     * @param string $period
184
-     *
185
-     * @return \stdClass[]
186
-     */
187
-    public function get_revenue_per_day_report($period = '-1 month')
188
-    {
189
-        $sql_date = $this->convert_datetime_for_query(
190
-            'TXN_timestamp',
191
-            date('Y-m-d H:i:s', strtotime($period)),
192
-            'Y-m-d H:i:s',
193
-            'UTC'
194
-        );
195
-
196
-        $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp');
197
-
198
-        return $this->_get_all_wpdb_results(
199
-            array(
200
-                array(
201
-                    'TXN_timestamp' => array('>=', $sql_date)
202
-                ),
203
-                'group_by' => 'txnDate',
204
-                'order_by' => array('TXN_timestamp' => 'ASC')
205
-            ),
206
-            OBJECT,
207
-            array(
208
-                'txnDate' => array('DATE(' . $query_interval . ')', '%s'),
209
-                'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d')
210
-            )
211
-        );
212
-    }
213
-
214
-
215
-    /**
216
-     *        get the revenue per event  for the Transaction Admin page Reports Tab
217
-     *
218
-     * @access        public
219
-     *
220
-     * @param string $period
221
-     *
222
-     * @throws \EE_Error
223
-     * @return mixed
224
-     */
225
-    public function get_revenue_per_event_report($period = '-1 month')
226
-    {
227
-        global $wpdb;
228
-        $transaction_table          = $wpdb->prefix . 'esp_transaction';
229
-        $registration_table         = $wpdb->prefix . 'esp_registration';
230
-        $registration_payment_table = $wpdb->prefix . 'esp_registration_payment';
231
-        $event_table                = $wpdb->posts;
232
-        $payment_table              = $wpdb->prefix . 'esp_payment';
233
-        $sql_date                   = date('Y-m-d H:i:s', strtotime($period));
234
-        $approved_payment_status    = EEM_Payment::status_id_approved;
235
-        $extra_event_on_join        = '';
236
-        // exclude events not authored by user if permissions in effect
237
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
238
-            $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
239
-        }
240
-
241
-        return $wpdb->get_results(
242
-            "SELECT
19
+	// private instance of the Transaction object
20
+	protected static $_instance;
21
+
22
+	/**
23
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction is complete,
24
+	 * but payment is pending. This is the state for transactions where payment is promised
25
+	 * from an offline gateway.
26
+	 */
27
+	//  const open_status_code = 'TPN';
28
+
29
+	/**
30
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction failed,
31
+	 * either due to a technical reason (server or computer crash during registration),
32
+	 *  or some other reason that prevent the collection of any useful contact information from any of the registrants
33
+	 */
34
+	const failed_status_code = 'TFL';
35
+
36
+	/**
37
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned,
38
+	 * either due to a technical reason (server or computer crash during registration),
39
+	 * or due to an abandoned cart after registrant chose not to complete the registration process
40
+	 * HOWEVER...
41
+	 * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one
42
+	 * registrant
43
+	 */
44
+	const abandoned_status_code = 'TAB';
45
+
46
+	/**
47
+	 * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction,
48
+	 * meaning that monies are still owing: TXN_paid < TXN_total
49
+	 */
50
+	const incomplete_status_code = 'TIN';
51
+
52
+	/**
53
+	 * Status ID (STS_ID on esp_status table) to indicate a complete transaction.
54
+	 * meaning that NO monies are owing: TXN_paid == TXN_total
55
+	 */
56
+	const complete_status_code = 'TCM';
57
+
58
+	/**
59
+	 *  Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid.
60
+	 *  This is the same as complete, but site admins actually owe clients the moneys!  TXN_paid > TXN_total
61
+	 */
62
+	const overpaid_status_code = 'TOP';
63
+
64
+
65
+	/**
66
+	 *    private constructor to prevent direct creation
67
+	 *
68
+	 * @Constructor
69
+	 * @access protected
70
+	 *
71
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
72
+	 *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
73
+	 *                         date time model field objects.  Default is NULL (and will be assumed using the set
74
+	 *                         timezone in the 'timezone_string' wp option)
75
+	 *
76
+	 * @return EEM_Transaction
77
+	 * @throws \EE_Error
78
+	 */
79
+	protected function __construct($timezone)
80
+	{
81
+		$this->singular_item = __('Transaction', 'event_espresso');
82
+		$this->plural_item   = __('Transactions', 'event_espresso');
83
+
84
+		$this->_tables                 = array(
85
+			'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID')
86
+		);
87
+		$this->_fields                 = array(
88
+			'TransactionTable' => array(
89
+				'TXN_ID'           => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')),
90
+				'TXN_timestamp'    => new EE_Datetime_Field(
91
+					'TXN_timestamp',
92
+					__('date when transaction was created', 'event_espresso'),
93
+					false,
94
+					EE_Datetime_Field::now,
95
+					$timezone
96
+				),
97
+				'TXN_total'        => new EE_Money_Field(
98
+					'TXN_total',
99
+					__('Total value of Transaction', 'event_espresso'),
100
+					false,
101
+					0
102
+				),
103
+				'TXN_paid'         => new EE_Money_Field(
104
+					'TXN_paid',
105
+					__('Amount paid towards transaction to date', 'event_espresso'),
106
+					false,
107
+					0
108
+				),
109
+				'STS_ID'           => new EE_Foreign_Key_String_Field(
110
+					'STS_ID',
111
+					__('Status ID', 'event_espresso'),
112
+					false,
113
+					EEM_Transaction::failed_status_code,
114
+					'Status'
115
+				),
116
+				'TXN_session_data' => new EE_Serialized_Text_Field(
117
+					'TXN_session_data',
118
+					__('Serialized session data', 'event_espresso'),
119
+					true,
120
+					''
121
+				),
122
+				'TXN_hash_salt'    => new EE_Plain_Text_Field(
123
+					'TXN_hash_salt',
124
+					__('Transaction Hash Salt', 'event_espresso'),
125
+					true,
126
+					''
127
+				),
128
+				'PMD_ID'           => new EE_Foreign_Key_Int_Field(
129
+					'PMD_ID',
130
+					__("Last Used Payment Method", 'event_espresso'),
131
+					true,
132
+					null,
133
+					'Payment_Method'
134
+				),
135
+				'TXN_reg_steps'    => new EE_Serialized_Text_Field(
136
+					'TXN_reg_steps',
137
+					__('Registration Steps', 'event_espresso'),
138
+					false,
139
+					array()
140
+				),
141
+			)
142
+		);
143
+		$this->_model_relations        = array(
144
+			'Registration'   => new EE_Has_Many_Relation(),
145
+			'Payment'        => new EE_Has_Many_Relation(),
146
+			'Status'         => new EE_Belongs_To_Relation(),
147
+			'Line_Item'      => new EE_Has_Many_Relation(false),
148
+			// you can delete a transaction without needing to delete its line items
149
+			'Payment_Method' => new EE_Belongs_To_Relation(),
150
+			'Message'        => new EE_Has_Many_Relation()
151
+		);
152
+		$this->_model_chain_to_wp_user = 'Registration.Event';
153
+		parent::__construct($timezone);
154
+	}
155
+
156
+
157
+	/**
158
+	 *    txn_status_array
159
+	 * get list of transaction statuses
160
+	 *
161
+	 * @access public
162
+	 * @return array
163
+	 */
164
+	public static function txn_status_array()
165
+	{
166
+		return apply_filters(
167
+			'FHEE__EEM_Transaction__txn_status_array',
168
+			array(
169
+				EEM_Transaction::overpaid_status_code,
170
+				EEM_Transaction::complete_status_code,
171
+				EEM_Transaction::incomplete_status_code,
172
+				EEM_Transaction::abandoned_status_code,
173
+				EEM_Transaction::failed_status_code,
174
+			)
175
+		);
176
+	}
177
+
178
+	/**
179
+	 *        get the revenue per day  for the Transaction Admin page Reports Tab
180
+	 *
181
+	 * @access        public
182
+	 *
183
+	 * @param string $period
184
+	 *
185
+	 * @return \stdClass[]
186
+	 */
187
+	public function get_revenue_per_day_report($period = '-1 month')
188
+	{
189
+		$sql_date = $this->convert_datetime_for_query(
190
+			'TXN_timestamp',
191
+			date('Y-m-d H:i:s', strtotime($period)),
192
+			'Y-m-d H:i:s',
193
+			'UTC'
194
+		);
195
+
196
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp');
197
+
198
+		return $this->_get_all_wpdb_results(
199
+			array(
200
+				array(
201
+					'TXN_timestamp' => array('>=', $sql_date)
202
+				),
203
+				'group_by' => 'txnDate',
204
+				'order_by' => array('TXN_timestamp' => 'ASC')
205
+			),
206
+			OBJECT,
207
+			array(
208
+				'txnDate' => array('DATE(' . $query_interval . ')', '%s'),
209
+				'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d')
210
+			)
211
+		);
212
+	}
213
+
214
+
215
+	/**
216
+	 *        get the revenue per event  for the Transaction Admin page Reports Tab
217
+	 *
218
+	 * @access        public
219
+	 *
220
+	 * @param string $period
221
+	 *
222
+	 * @throws \EE_Error
223
+	 * @return mixed
224
+	 */
225
+	public function get_revenue_per_event_report($period = '-1 month')
226
+	{
227
+		global $wpdb;
228
+		$transaction_table          = $wpdb->prefix . 'esp_transaction';
229
+		$registration_table         = $wpdb->prefix . 'esp_registration';
230
+		$registration_payment_table = $wpdb->prefix . 'esp_registration_payment';
231
+		$event_table                = $wpdb->posts;
232
+		$payment_table              = $wpdb->prefix . 'esp_payment';
233
+		$sql_date                   = date('Y-m-d H:i:s', strtotime($period));
234
+		$approved_payment_status    = EEM_Payment::status_id_approved;
235
+		$extra_event_on_join        = '';
236
+		// exclude events not authored by user if permissions in effect
237
+		if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
238
+			$extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
239
+		}
240
+
241
+		return $wpdb->get_results(
242
+			"SELECT
243 243
 			Transaction_Event.event_name AS event_name,
244 244
 			SUM(Transaction_Event.paid) AS revenue
245 245
 			FROM
@@ -267,231 +267,231 @@  discard block
 block discarded – undo
267 267
 					$extra_event_on_join
268 268
 				) AS Transaction_Event
269 269
 			GROUP BY event_name",
270
-            OBJECT
271
-        );
272
-    }
273
-
274
-
275
-    /**
276
-     * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the
277
-     * $_REQUEST global variable. Either way, tries to find the current transaction (through
278
-     * the registration pointed to by reg_url_link), if not returns null
279
-     *
280
-     * @param string $reg_url_link
281
-     *
282
-     * @return EE_Transaction
283
-     */
284
-    public function get_transaction_from_reg_url_link($reg_url_link = '')
285
-    {
286
-        return $this->get_one(array(
287
-            array(
288
-                'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get(
289
-                    'e_reg_url_link',
290
-                    ''
291
-                )
292
-            )
293
-        ));
294
-    }
295
-
296
-
297
-    /**
298
-     * Updates the provided EE_Transaction with all the applicable payments
299
-     * (or fetch the EE_Transaction from its ID)
300
-     *
301
-     * @deprecated
302
-     *
303
-     * @param EE_Transaction|int $transaction_obj_or_id
304
-     * @param boolean            $save_txn whether or not to save the transaction during this function call
305
-     *
306
-     * @return boolean
307
-     * @throws \EE_Error
308
-     */
309
-    public function update_based_on_payments($transaction_obj_or_id, $save_txn = true)
310
-    {
311
-        EE_Error::doing_it_wrong(
312
-            __CLASS__ . '::' . __FUNCTION__,
313
-            sprintf(
314
-                __('This method is deprecated. Please use "%s" instead', 'event_espresso'),
315
-                'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'
316
-            ),
317
-            '4.6.0'
318
-        );
319
-        /** @type EE_Transaction_Processor $transaction_processor */
320
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
321
-
322
-        return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
323
-            $this->ensure_is_obj($transaction_obj_or_id)
324
-        );
325
-    }
326
-
327
-    /**
328
-     * Deletes "junk" transactions that were probably added by bots. There might be TONS
329
-     * of these, so we are very careful to NOT select (which the models do even when deleting),
330
-     * and so we only use wpdb directly and only do minimal joins.
331
-     * Transactions are considered "junk" if they're failed for longer than a week.
332
-     * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on
333
-     * it, it's probably not junk (regardless of what status it has).
334
-     * The downside to this approach is that is addons are listening for object deletions
335
-     * on EEM_Base::delete() they won't be notified of this.  However, there is an action that plugins can hook into
336
-     * to catch these types of deletions.
337
-     *
338
-     * @global WPDB $wpdb
339
-     * @return mixed
340
-     */
341
-    public function delete_junk_transactions()
342
-    {
343
-        /** @type WPDB $wpdb */
344
-        global $wpdb;
345
-        $deleted             = false;
346
-        $time_to_leave_alone = apply_filters(
347
-            'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone',
348
-            WEEK_IN_SECONDS
349
-        );
350
-
351
-
352
-        /**
353
-         * This allows code to filter the query arguments used for retrieving the transaction IDs to delete.
354
-         * Useful for plugins that want to exclude transactions matching certain query parameters.
355
-         * The query parameters should be in the format accepted by the EEM_Base model queries.
356
-         */
357
-        $ids_query = apply_filters(
358
-            'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args',
359
-            array(
360
-                0 => array(
361
-                    'STS_ID'        => EEM_Transaction::failed_status_code,
362
-                    'Payment.PAY_ID' => array( 'IS NULL' ),
363
-                    'TXN_timestamp' => array('<', time() - $time_to_leave_alone)
364
-                )
365
-            ),
366
-            $time_to_leave_alone
367
-        );
368
-
369
-
370
-        /**
371
-         * This filter is for when code needs to filter the list of transaction ids that represent transactions
372
-         * about to be deleted based on some other criteria that isn't easily done via the query args filter.
373
-         */
374
-        $txn_ids = apply_filters(
375
-            'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete',
376
-            EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'),
377
-            $time_to_leave_alone
378
-        );
379
-        // now that we have the ids to delete
380
-        if (! empty($txn_ids) && is_array($txn_ids)) {
381
-            // first, make sure these TXN's are removed the "ee_locked_transactions" array
382
-            EEM_Transaction::unset_locked_transactions($txn_ids);
383
-
384
-            // Create IDs placeholder.
385
-            $placeholders = array_fill(0, count($txn_ids), '%d');
270
+			OBJECT
271
+		);
272
+	}
273
+
274
+
275
+	/**
276
+	 * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the
277
+	 * $_REQUEST global variable. Either way, tries to find the current transaction (through
278
+	 * the registration pointed to by reg_url_link), if not returns null
279
+	 *
280
+	 * @param string $reg_url_link
281
+	 *
282
+	 * @return EE_Transaction
283
+	 */
284
+	public function get_transaction_from_reg_url_link($reg_url_link = '')
285
+	{
286
+		return $this->get_one(array(
287
+			array(
288
+				'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get(
289
+					'e_reg_url_link',
290
+					''
291
+				)
292
+			)
293
+		));
294
+	}
295
+
296
+
297
+	/**
298
+	 * Updates the provided EE_Transaction with all the applicable payments
299
+	 * (or fetch the EE_Transaction from its ID)
300
+	 *
301
+	 * @deprecated
302
+	 *
303
+	 * @param EE_Transaction|int $transaction_obj_or_id
304
+	 * @param boolean            $save_txn whether or not to save the transaction during this function call
305
+	 *
306
+	 * @return boolean
307
+	 * @throws \EE_Error
308
+	 */
309
+	public function update_based_on_payments($transaction_obj_or_id, $save_txn = true)
310
+	{
311
+		EE_Error::doing_it_wrong(
312
+			__CLASS__ . '::' . __FUNCTION__,
313
+			sprintf(
314
+				__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
315
+				'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'
316
+			),
317
+			'4.6.0'
318
+		);
319
+		/** @type EE_Transaction_Processor $transaction_processor */
320
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
321
+
322
+		return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
323
+			$this->ensure_is_obj($transaction_obj_or_id)
324
+		);
325
+	}
326
+
327
+	/**
328
+	 * Deletes "junk" transactions that were probably added by bots. There might be TONS
329
+	 * of these, so we are very careful to NOT select (which the models do even when deleting),
330
+	 * and so we only use wpdb directly and only do minimal joins.
331
+	 * Transactions are considered "junk" if they're failed for longer than a week.
332
+	 * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on
333
+	 * it, it's probably not junk (regardless of what status it has).
334
+	 * The downside to this approach is that is addons are listening for object deletions
335
+	 * on EEM_Base::delete() they won't be notified of this.  However, there is an action that plugins can hook into
336
+	 * to catch these types of deletions.
337
+	 *
338
+	 * @global WPDB $wpdb
339
+	 * @return mixed
340
+	 */
341
+	public function delete_junk_transactions()
342
+	{
343
+		/** @type WPDB $wpdb */
344
+		global $wpdb;
345
+		$deleted             = false;
346
+		$time_to_leave_alone = apply_filters(
347
+			'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone',
348
+			WEEK_IN_SECONDS
349
+		);
350
+
351
+
352
+		/**
353
+		 * This allows code to filter the query arguments used for retrieving the transaction IDs to delete.
354
+		 * Useful for plugins that want to exclude transactions matching certain query parameters.
355
+		 * The query parameters should be in the format accepted by the EEM_Base model queries.
356
+		 */
357
+		$ids_query = apply_filters(
358
+			'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args',
359
+			array(
360
+				0 => array(
361
+					'STS_ID'        => EEM_Transaction::failed_status_code,
362
+					'Payment.PAY_ID' => array( 'IS NULL' ),
363
+					'TXN_timestamp' => array('<', time() - $time_to_leave_alone)
364
+				)
365
+			),
366
+			$time_to_leave_alone
367
+		);
368
+
369
+
370
+		/**
371
+		 * This filter is for when code needs to filter the list of transaction ids that represent transactions
372
+		 * about to be deleted based on some other criteria that isn't easily done via the query args filter.
373
+		 */
374
+		$txn_ids = apply_filters(
375
+			'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete',
376
+			EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'),
377
+			$time_to_leave_alone
378
+		);
379
+		// now that we have the ids to delete
380
+		if (! empty($txn_ids) && is_array($txn_ids)) {
381
+			// first, make sure these TXN's are removed the "ee_locked_transactions" array
382
+			EEM_Transaction::unset_locked_transactions($txn_ids);
383
+
384
+			// Create IDs placeholder.
385
+			$placeholders = array_fill(0, count($txn_ids), '%d');
386 386
             
387
-            // Glue it together to use inside $wpdb->prepare.
388
-            $format = implode(', ', $placeholders);
389
-
390
-            // let's get deletin'...
391
-            // We got the ids from the original query to get them FROM
392
-            // the db (which is sanitized) so no need to prepare them again.
393
-            $query   = $wpdb->prepare("DELETE FROM " . $this->table() . " WHERE TXN_ID IN ( $format )", $txn_ids);
394
-            $deleted = $wpdb->query($query);
395
-        }
396
-        if ($deleted) {
397
-            /**
398
-             * Allows code to do something after the transactions have been deleted.
399
-             */
400
-            do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids);
401
-        }
402
-
403
-        return $deleted;
404
-    }
405
-
406
-
407
-    /**
408
-     * @param array $transaction_IDs
409
-     *
410
-     * @return bool
411
-     */
412
-    public static function unset_locked_transactions(array $transaction_IDs)
413
-    {
414
-        $locked_transactions = get_option('ee_locked_transactions', array());
415
-        $update              = false;
416
-        foreach ($transaction_IDs as $TXN_ID) {
417
-            if (isset($locked_transactions[ $TXN_ID ])) {
418
-                unset($locked_transactions[ $TXN_ID ]);
419
-                $update = true;
420
-            }
421
-        }
422
-        if ($update) {
423
-            update_option('ee_locked_transactions', $locked_transactions);
424
-        }
425
-
426
-        return $update;
427
-    }
428
-
429
-
430
-
431
-    /**
432
-     * returns an array of EE_Transaction objects whose timestamp is greater than
433
-     * the current time minus the session lifespan, which defaults to 60 minutes
434
-     *
435
-     * @return EE_Base_Class[]|EE_Transaction[]
436
-     * @throws EE_Error
437
-     * @throws InvalidArgumentException
438
-     * @throws InvalidDataTypeException
439
-     * @throws InvalidInterfaceException
440
-     */
441
-    public function get_transactions_in_progress()
442
-    {
443
-        return $this->_get_transactions_in_progress();
444
-    }
445
-
446
-
447
-
448
-    /**
449
-     * returns an array of EE_Transaction objects whose timestamp is less than
450
-     * the current time minus the session lifespan, which defaults to 60 minutes
451
-     *
452
-     * @return EE_Base_Class[]|EE_Transaction[]
453
-     * @throws EE_Error
454
-     * @throws InvalidArgumentException
455
-     * @throws InvalidDataTypeException
456
-     * @throws InvalidInterfaceException
457
-     */
458
-    public function get_transactions_not_in_progress()
459
-    {
460
-        return $this->_get_transactions_in_progress('<=');
461
-    }
462
-
463
-
464
-
465
-    /**
466
-     * @param string $comparison
467
-     * @return EE_Base_Class[]|EE_Transaction[]
468
-     * @throws EE_Error
469
-     * @throws InvalidArgumentException
470
-     * @throws InvalidDataTypeException
471
-     * @throws InvalidInterfaceException
472
-     */
473
-    private function _get_transactions_in_progress($comparison = '>=')
474
-    {
475
-        $comparison = $comparison === '>=' || $comparison === '<='
476
-            ? $comparison
477
-            : '>=';
478
-        /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
479
-        $session_lifespan = LoaderFactory::getLoader()->getShared(
480
-            'EventEspresso\core\domain\values\session\SessionLifespan'
481
-        );
482
-        return $this->get_all(
483
-            array(
484
-                array(
485
-                    'TXN_timestamp' => array(
486
-                        $comparison,
487
-                        $session_lifespan->expiration()
488
-                    ),
489
-                    'STS_ID' => array(
490
-                        '!=',
491
-                        EEM_Transaction::complete_status_code
492
-                    ),
493
-                )
494
-            )
495
-        );
496
-    }
387
+			// Glue it together to use inside $wpdb->prepare.
388
+			$format = implode(', ', $placeholders);
389
+
390
+			// let's get deletin'...
391
+			// We got the ids from the original query to get them FROM
392
+			// the db (which is sanitized) so no need to prepare them again.
393
+			$query   = $wpdb->prepare("DELETE FROM " . $this->table() . " WHERE TXN_ID IN ( $format )", $txn_ids);
394
+			$deleted = $wpdb->query($query);
395
+		}
396
+		if ($deleted) {
397
+			/**
398
+			 * Allows code to do something after the transactions have been deleted.
399
+			 */
400
+			do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids);
401
+		}
402
+
403
+		return $deleted;
404
+	}
405
+
406
+
407
+	/**
408
+	 * @param array $transaction_IDs
409
+	 *
410
+	 * @return bool
411
+	 */
412
+	public static function unset_locked_transactions(array $transaction_IDs)
413
+	{
414
+		$locked_transactions = get_option('ee_locked_transactions', array());
415
+		$update              = false;
416
+		foreach ($transaction_IDs as $TXN_ID) {
417
+			if (isset($locked_transactions[ $TXN_ID ])) {
418
+				unset($locked_transactions[ $TXN_ID ]);
419
+				$update = true;
420
+			}
421
+		}
422
+		if ($update) {
423
+			update_option('ee_locked_transactions', $locked_transactions);
424
+		}
425
+
426
+		return $update;
427
+	}
428
+
429
+
430
+
431
+	/**
432
+	 * returns an array of EE_Transaction objects whose timestamp is greater than
433
+	 * the current time minus the session lifespan, which defaults to 60 minutes
434
+	 *
435
+	 * @return EE_Base_Class[]|EE_Transaction[]
436
+	 * @throws EE_Error
437
+	 * @throws InvalidArgumentException
438
+	 * @throws InvalidDataTypeException
439
+	 * @throws InvalidInterfaceException
440
+	 */
441
+	public function get_transactions_in_progress()
442
+	{
443
+		return $this->_get_transactions_in_progress();
444
+	}
445
+
446
+
447
+
448
+	/**
449
+	 * returns an array of EE_Transaction objects whose timestamp is less than
450
+	 * the current time minus the session lifespan, which defaults to 60 minutes
451
+	 *
452
+	 * @return EE_Base_Class[]|EE_Transaction[]
453
+	 * @throws EE_Error
454
+	 * @throws InvalidArgumentException
455
+	 * @throws InvalidDataTypeException
456
+	 * @throws InvalidInterfaceException
457
+	 */
458
+	public function get_transactions_not_in_progress()
459
+	{
460
+		return $this->_get_transactions_in_progress('<=');
461
+	}
462
+
463
+
464
+
465
+	/**
466
+	 * @param string $comparison
467
+	 * @return EE_Base_Class[]|EE_Transaction[]
468
+	 * @throws EE_Error
469
+	 * @throws InvalidArgumentException
470
+	 * @throws InvalidDataTypeException
471
+	 * @throws InvalidInterfaceException
472
+	 */
473
+	private function _get_transactions_in_progress($comparison = '>=')
474
+	{
475
+		$comparison = $comparison === '>=' || $comparison === '<='
476
+			? $comparison
477
+			: '>=';
478
+		/** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
479
+		$session_lifespan = LoaderFactory::getLoader()->getShared(
480
+			'EventEspresso\core\domain\values\session\SessionLifespan'
481
+		);
482
+		return $this->get_all(
483
+			array(
484
+				array(
485
+					'TXN_timestamp' => array(
486
+						$comparison,
487
+						$session_lifespan->expiration()
488
+					),
489
+					'STS_ID' => array(
490
+						'!=',
491
+						EEM_Transaction::complete_status_code
492
+					),
493
+				)
494
+			)
495
+		);
496
+	}
497 497
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
                 ),
141 141
             )
142 142
         );
143
-        $this->_model_relations        = array(
143
+        $this->_model_relations = array(
144 144
             'Registration'   => new EE_Has_Many_Relation(),
145 145
             'Payment'        => new EE_Has_Many_Relation(),
146 146
             'Status'         => new EE_Belongs_To_Relation(),
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
             ),
206 206
             OBJECT,
207 207
             array(
208
-                'txnDate' => array('DATE(' . $query_interval . ')', '%s'),
208
+                'txnDate' => array('DATE('.$query_interval.')', '%s'),
209 209
                 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d')
210 210
             )
211 211
         );
@@ -225,17 +225,17 @@  discard block
 block discarded – undo
225 225
     public function get_revenue_per_event_report($period = '-1 month')
226 226
     {
227 227
         global $wpdb;
228
-        $transaction_table          = $wpdb->prefix . 'esp_transaction';
229
-        $registration_table         = $wpdb->prefix . 'esp_registration';
230
-        $registration_payment_table = $wpdb->prefix . 'esp_registration_payment';
228
+        $transaction_table          = $wpdb->prefix.'esp_transaction';
229
+        $registration_table         = $wpdb->prefix.'esp_registration';
230
+        $registration_payment_table = $wpdb->prefix.'esp_registration_payment';
231 231
         $event_table                = $wpdb->posts;
232
-        $payment_table              = $wpdb->prefix . 'esp_payment';
232
+        $payment_table              = $wpdb->prefix.'esp_payment';
233 233
         $sql_date                   = date('Y-m-d H:i:s', strtotime($period));
234 234
         $approved_payment_status    = EEM_Payment::status_id_approved;
235 235
         $extra_event_on_join        = '';
236 236
         // exclude events not authored by user if permissions in effect
237
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
238
-            $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
237
+        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
238
+            $extra_event_on_join = ' AND Event.post_author = '.get_current_user_id();
239 239
         }
240 240
 
241 241
         return $wpdb->get_results(
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
     public function update_based_on_payments($transaction_obj_or_id, $save_txn = true)
310 310
     {
311 311
         EE_Error::doing_it_wrong(
312
-            __CLASS__ . '::' . __FUNCTION__,
312
+            __CLASS__.'::'.__FUNCTION__,
313 313
             sprintf(
314 314
                 __('This method is deprecated. Please use "%s" instead', 'event_espresso'),
315 315
                 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             array(
360 360
                 0 => array(
361 361
                     'STS_ID'        => EEM_Transaction::failed_status_code,
362
-                    'Payment.PAY_ID' => array( 'IS NULL' ),
362
+                    'Payment.PAY_ID' => array('IS NULL'),
363 363
                     'TXN_timestamp' => array('<', time() - $time_to_leave_alone)
364 364
                 )
365 365
             ),
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
             $time_to_leave_alone
378 378
         );
379 379
         // now that we have the ids to delete
380
-        if (! empty($txn_ids) && is_array($txn_ids)) {
380
+        if ( ! empty($txn_ids) && is_array($txn_ids)) {
381 381
             // first, make sure these TXN's are removed the "ee_locked_transactions" array
382 382
             EEM_Transaction::unset_locked_transactions($txn_ids);
383 383
 
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
             // let's get deletin'...
391 391
             // We got the ids from the original query to get them FROM
392 392
             // the db (which is sanitized) so no need to prepare them again.
393
-            $query   = $wpdb->prepare("DELETE FROM " . $this->table() . " WHERE TXN_ID IN ( $format )", $txn_ids);
393
+            $query   = $wpdb->prepare("DELETE FROM ".$this->table()." WHERE TXN_ID IN ( $format )", $txn_ids);
394 394
             $deleted = $wpdb->query($query);
395 395
         }
396 396
         if ($deleted) {
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
         $locked_transactions = get_option('ee_locked_transactions', array());
415 415
         $update              = false;
416 416
         foreach ($transaction_IDs as $TXN_ID) {
417
-            if (isset($locked_transactions[ $TXN_ID ])) {
418
-                unset($locked_transactions[ $TXN_ID ]);
417
+            if (isset($locked_transactions[$TXN_ID])) {
418
+                unset($locked_transactions[$TXN_ID]);
419 419
                 $update = true;
420 420
             }
421 421
         }
Please login to merge, or discard this patch.
core/domain/services/pue/StatsGatherer.php 2 patches
Indentation   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -16,314 +16,314 @@
 block discarded – undo
16 16
 class StatsGatherer
17 17
 {
18 18
 
19
-    const COUNT_ALL_EVENTS = 'event';
20
-    const COUNT_ACTIVE_EVENTS = 'active_event';
21
-    const COUNT_DATETIMES = 'datetime';
22
-    const COUNT_TICKETS = 'ticket';
23
-    const COUNT_DATETIMES_SOLD = 'datetime_sold';
24
-    const COUNT_TICKETS_FREE = 'free_ticket';
25
-    const COUNT_TICKETS_PAID = 'paid_ticket';
26
-    const COUNT_TICKETS_SOLD = 'ticket_sold';
27
-    const COUNT_REGISTRATIONS_APPROVED = 'registrations_approved';
28
-    const COUNT_REGISTRATIONS_NOT_APPROVED = 'registrations_not_approved';
29
-    const COUNT_REGISTRATIONS_PENDING = 'registrations_pending';
30
-    const COUNT_REGISTRATIONS_INCOMPLETE = 'registrations_incomplete';
31
-    const COUNT_REGISTRATIONS_ALL = 'registrations_all';
32
-    const COUNT_REGISTRATIONS_CANCELLED = 'registrations_cancelled';
33
-    const COUNT_REGISTRATIONS_DECLINED = 'registrations_declined';
34
-    const SUM_TRANSACTIONS_COMPLETE_TOTAL = 'transactions_complete_total_sum';
35
-    const SUM_TRANSACTIONS_ALL_PAID = 'transactions_all_paid';
36
-    const INFO_SITE_CURRENCY = 'site_currency';
19
+	const COUNT_ALL_EVENTS = 'event';
20
+	const COUNT_ACTIVE_EVENTS = 'active_event';
21
+	const COUNT_DATETIMES = 'datetime';
22
+	const COUNT_TICKETS = 'ticket';
23
+	const COUNT_DATETIMES_SOLD = 'datetime_sold';
24
+	const COUNT_TICKETS_FREE = 'free_ticket';
25
+	const COUNT_TICKETS_PAID = 'paid_ticket';
26
+	const COUNT_TICKETS_SOLD = 'ticket_sold';
27
+	const COUNT_REGISTRATIONS_APPROVED = 'registrations_approved';
28
+	const COUNT_REGISTRATIONS_NOT_APPROVED = 'registrations_not_approved';
29
+	const COUNT_REGISTRATIONS_PENDING = 'registrations_pending';
30
+	const COUNT_REGISTRATIONS_INCOMPLETE = 'registrations_incomplete';
31
+	const COUNT_REGISTRATIONS_ALL = 'registrations_all';
32
+	const COUNT_REGISTRATIONS_CANCELLED = 'registrations_cancelled';
33
+	const COUNT_REGISTRATIONS_DECLINED = 'registrations_declined';
34
+	const SUM_TRANSACTIONS_COMPLETE_TOTAL = 'transactions_complete_total_sum';
35
+	const SUM_TRANSACTIONS_ALL_PAID = 'transactions_all_paid';
36
+	const INFO_SITE_CURRENCY = 'site_currency';
37 37
 
38 38
 
39
-    /**
40
-     * @var EEM_Payment_Method
41
-     */
42
-    private $payment_method_model;
39
+	/**
40
+	 * @var EEM_Payment_Method
41
+	 */
42
+	private $payment_method_model;
43 43
 
44 44
 
45
-    /**
46
-     * @var EEM_Event
47
-     */
48
-    private $event_model;
45
+	/**
46
+	 * @var EEM_Event
47
+	 */
48
+	private $event_model;
49 49
 
50
-    /**
51
-     * @var EEM_Datetime
52
-     */
53
-    private $datetime_model;
50
+	/**
51
+	 * @var EEM_Datetime
52
+	 */
53
+	private $datetime_model;
54 54
 
55 55
 
56
-    /**
57
-     * @var EEM_Ticket
58
-     */
59
-    private $ticket_model;
56
+	/**
57
+	 * @var EEM_Ticket
58
+	 */
59
+	private $ticket_model;
60 60
 
61 61
 
62
-    /**
63
-     * @var EEM_Registration
64
-     */
65
-    private $registration_model;
62
+	/**
63
+	 * @var EEM_Registration
64
+	 */
65
+	private $registration_model;
66 66
 
67 67
 
68
-    /**
69
-     * @var EEM_Transaction
70
-     */
71
-    private $transaction_model;
68
+	/**
69
+	 * @var EEM_Transaction
70
+	 */
71
+	private $transaction_model;
72 72
 
73 73
 
74
-    /**
75
-     * @var EE_Config
76
-     */
77
-    private $config;
74
+	/**
75
+	 * @var EE_Config
76
+	 */
77
+	private $config;
78 78
 
79 79
 
80
-    /**
81
-     * StatsGatherer constructor.
82
-     *
83
-     * @param EEM_Payment_Method $payment_method_model
84
-     * @param EEM_Event          $event_model
85
-     * @param EEM_Datetime       $datetime_model
86
-     * @param EEM_Ticket         $ticket_model
87
-     * @param EEM_Registration   $registration_model
88
-     * @param EEM_Transaction    $transaction_model
89
-     * @param EE_Config          $config
90
-     */
91
-    public function __construct(
92
-        EEM_Payment_Method $payment_method_model,
93
-        EEM_Event $event_model,
94
-        EEM_Datetime $datetime_model,
95
-        EEM_Ticket $ticket_model,
96
-        EEM_Registration $registration_model,
97
-        EEM_Transaction $transaction_model,
98
-        EE_Config $config
99
-    ) {
100
-        $this->payment_method_model = $payment_method_model;
101
-        $this->event_model = $event_model;
102
-        $this->datetime_model = $datetime_model;
103
-        $this->ticket_model = $ticket_model;
104
-        $this->registration_model = $registration_model;
105
-        $this->transaction_model = $transaction_model;
106
-        $this->config = $config;
107
-    }
80
+	/**
81
+	 * StatsGatherer constructor.
82
+	 *
83
+	 * @param EEM_Payment_Method $payment_method_model
84
+	 * @param EEM_Event          $event_model
85
+	 * @param EEM_Datetime       $datetime_model
86
+	 * @param EEM_Ticket         $ticket_model
87
+	 * @param EEM_Registration   $registration_model
88
+	 * @param EEM_Transaction    $transaction_model
89
+	 * @param EE_Config          $config
90
+	 */
91
+	public function __construct(
92
+		EEM_Payment_Method $payment_method_model,
93
+		EEM_Event $event_model,
94
+		EEM_Datetime $datetime_model,
95
+		EEM_Ticket $ticket_model,
96
+		EEM_Registration $registration_model,
97
+		EEM_Transaction $transaction_model,
98
+		EE_Config $config
99
+	) {
100
+		$this->payment_method_model = $payment_method_model;
101
+		$this->event_model = $event_model;
102
+		$this->datetime_model = $datetime_model;
103
+		$this->ticket_model = $ticket_model;
104
+		$this->registration_model = $registration_model;
105
+		$this->transaction_model = $transaction_model;
106
+		$this->config = $config;
107
+	}
108 108
 
109 109
 
110
-    /**
111
-     * Return the stats array for PUE UXIP stats.
112
-     *
113
-     * @return array
114
-     */
115
-    public function stats()
116
-    {
117
-        global $wp_version;
118
-        $stats = $this->paymentMethodStats();
119
-        // a-ok so let's setup our stats.
120
-        $stats = array_merge($stats, array(
121
-            'is_multisite'                    => is_multisite() && is_main_site(),
122
-            'active_theme'                    => $this->getActiveThemeStat(),
123
-            'ee4_all_events_count'            => $this->getCountFor(self::COUNT_ALL_EVENTS),
124
-            'ee4_active_events_count'         => $this->getCountFor(self::COUNT_ACTIVE_EVENTS),
125
-            'all_dtts_count'                  => $this->getCountFor(self::COUNT_DATETIMES),
126
-            'dtt_sold'                        => $this->getCountFor(self::COUNT_DATETIMES_SOLD),
127
-            'all_tkt_count'                   => $this->getCountFor(self::COUNT_TICKETS),
128
-            'free_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_FREE),
129
-            'paid_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_PAID),
130
-            'tkt_sold'                        => $this->getCountFor(self::COUNT_TICKETS_SOLD),
131
-            'approve_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_APPROVED),
132
-            'pending_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_PENDING),
133
-            'not_approved_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_NOT_APPROVED),
134
-            'incomplete_registration_count'   => $this->getCountFor(self::COUNT_REGISTRATIONS_INCOMPLETE),
135
-            'cancelled_registration_count'    => $this->getCountFor(self::COUNT_REGISTRATIONS_CANCELLED),
136
-            'declined_registration_count'     => $this->getCountFor(self::COUNT_REGISTRATIONS_DECLINED),
137
-            'all_registration_count'          => $this->getCountFor(self::COUNT_REGISTRATIONS_ALL),
138
-            'completed_transaction_total_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_COMPLETE_TOTAL),
139
-            'all_transaction_paid_sum'        => $this->getCountFor(self::SUM_TRANSACTIONS_ALL_PAID),
140
-            self::INFO_SITE_CURRENCY          => $this->config->currency instanceof EE_Currency_Config
141
-                ? $this->config->currency->code
142
-                : 'unknown',
143
-            'phpversion'                      => implode(
144
-                '.',
145
-                array(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION)
146
-            ),
147
-            'wpversion'                       => $wp_version,
148
-            'active_addons'                   => $this->getActiveAddons(),
149
-        ));
150
-        // remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
151
-        return array_filter($stats, function ($value) {
152
-            return $value !== null;
153
-        });
154
-    }
110
+	/**
111
+	 * Return the stats array for PUE UXIP stats.
112
+	 *
113
+	 * @return array
114
+	 */
115
+	public function stats()
116
+	{
117
+		global $wp_version;
118
+		$stats = $this->paymentMethodStats();
119
+		// a-ok so let's setup our stats.
120
+		$stats = array_merge($stats, array(
121
+			'is_multisite'                    => is_multisite() && is_main_site(),
122
+			'active_theme'                    => $this->getActiveThemeStat(),
123
+			'ee4_all_events_count'            => $this->getCountFor(self::COUNT_ALL_EVENTS),
124
+			'ee4_active_events_count'         => $this->getCountFor(self::COUNT_ACTIVE_EVENTS),
125
+			'all_dtts_count'                  => $this->getCountFor(self::COUNT_DATETIMES),
126
+			'dtt_sold'                        => $this->getCountFor(self::COUNT_DATETIMES_SOLD),
127
+			'all_tkt_count'                   => $this->getCountFor(self::COUNT_TICKETS),
128
+			'free_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_FREE),
129
+			'paid_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_PAID),
130
+			'tkt_sold'                        => $this->getCountFor(self::COUNT_TICKETS_SOLD),
131
+			'approve_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_APPROVED),
132
+			'pending_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_PENDING),
133
+			'not_approved_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_NOT_APPROVED),
134
+			'incomplete_registration_count'   => $this->getCountFor(self::COUNT_REGISTRATIONS_INCOMPLETE),
135
+			'cancelled_registration_count'    => $this->getCountFor(self::COUNT_REGISTRATIONS_CANCELLED),
136
+			'declined_registration_count'     => $this->getCountFor(self::COUNT_REGISTRATIONS_DECLINED),
137
+			'all_registration_count'          => $this->getCountFor(self::COUNT_REGISTRATIONS_ALL),
138
+			'completed_transaction_total_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_COMPLETE_TOTAL),
139
+			'all_transaction_paid_sum'        => $this->getCountFor(self::SUM_TRANSACTIONS_ALL_PAID),
140
+			self::INFO_SITE_CURRENCY          => $this->config->currency instanceof EE_Currency_Config
141
+				? $this->config->currency->code
142
+				: 'unknown',
143
+			'phpversion'                      => implode(
144
+				'.',
145
+				array(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION)
146
+			),
147
+			'wpversion'                       => $wp_version,
148
+			'active_addons'                   => $this->getActiveAddons(),
149
+		));
150
+		// remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
151
+		return array_filter($stats, function ($value) {
152
+			return $value !== null;
153
+		});
154
+	}
155 155
 
156
-    /**
157
-     * @param string $which enum (@see constants prefixed with COUNT)
158
-     * @return int|null
159
-     */
160
-    private function getCountFor($which)
161
-    {
162
-        try {
163
-            switch ($which) {
164
-                case self::COUNT_ALL_EVENTS:
165
-                    $count = $this->event_model->count();
166
-                    break;
167
-                case self::COUNT_TICKETS:
168
-                    $count = $this->ticket_model->count();
169
-                    break;
170
-                case self::COUNT_DATETIMES:
171
-                    $count = $this->datetime_model->count();
172
-                    break;
173
-                case self::COUNT_ACTIVE_EVENTS:
174
-                    $count = $this->event_model->get_active_events(array(), true);
175
-                    break;
176
-                case self::COUNT_DATETIMES_SOLD:
177
-                    $count = $this->datetime_model->sum(array(), 'DTT_sold');
178
-                    break;
179
-                case self::COUNT_TICKETS_FREE:
180
-                    $count = $this->ticket_model->count(array(
181
-                        array(
182
-                            'TKT_price' => 0,
183
-                        ),
184
-                    ));
185
-                    break;
186
-                case self::COUNT_TICKETS_PAID:
187
-                    $count = $this->ticket_model->count(array(
188
-                        array(
189
-                            'TKT_price' => array('>', 0),
190
-                        ),
191
-                    ));
192
-                    break;
193
-                case self::COUNT_TICKETS_SOLD:
194
-                    $count = $this->ticket_model->sum(array(), 'TKT_sold');
195
-                    break;
196
-                case self::COUNT_REGISTRATIONS_ALL:
197
-                    $count = $this->registration_model->count();
198
-                    break;
199
-                case self::COUNT_REGISTRATIONS_CANCELLED:
200
-                    $count = $this->registration_model->count(
201
-                        array(
202
-                            array(
203
-                                'STS_ID' => EEM_Registration::status_id_cancelled,
204
-                            ),
205
-                        )
206
-                    );
207
-                    break;
208
-                case self::COUNT_REGISTRATIONS_INCOMPLETE:
209
-                    $count = $this->registration_model->count(
210
-                        array(
211
-                            array(
212
-                                'STS_ID' => EEM_Registration::status_id_incomplete,
213
-                            ),
214
-                        )
215
-                    );
216
-                    break;
217
-                case self::COUNT_REGISTRATIONS_NOT_APPROVED:
218
-                    $count = $this->registration_model->count(
219
-                        array(
220
-                            array(
221
-                                'STS_ID' => EEM_Registration::status_id_not_approved,
222
-                            ),
223
-                        )
224
-                    );
225
-                    break;
226
-                case self::COUNT_REGISTRATIONS_DECLINED:
227
-                    $count = $this->registration_model->count(
228
-                        array(
229
-                            array(
230
-                                'STS_ID' => EEM_Registration::status_id_declined,
231
-                            ),
232
-                        )
233
-                    );
234
-                    break;
235
-                case self::COUNT_REGISTRATIONS_PENDING:
236
-                    $count = $this->registration_model->count(
237
-                        array(
238
-                            array(
239
-                                'STS_ID' => EEM_Registration::status_id_pending_payment,
240
-                            ),
241
-                        )
242
-                    );
243
-                    break;
244
-                case self::COUNT_REGISTRATIONS_APPROVED:
245
-                    $count = $this->registration_model->count(
246
-                        array(
247
-                            array(
248
-                                'STS_ID' => EEM_Registration::status_id_approved,
249
-                            ),
250
-                        )
251
-                    );
252
-                    break;
253
-                case self::SUM_TRANSACTIONS_COMPLETE_TOTAL:
254
-                    $count = $this->transaction_model->sum(
255
-                        array(
256
-                            array(
257
-                                'STS_ID' => EEM_Transaction::complete_status_code,
258
-                            ),
259
-                        ),
260
-                        'TXN_total'
261
-                    );
262
-                    break;
263
-                case self::SUM_TRANSACTIONS_ALL_PAID:
264
-                    $count = $this->transaction_model->sum(
265
-                        array(),
266
-                        'TXN_paid'
267
-                    );
268
-                    break;
269
-                default:
270
-                    $count = null;
271
-                    break;
272
-            }
273
-        } catch (Exception $e) {
274
-            $count = null;
275
-        }
276
-        return $count;
277
-    }
156
+	/**
157
+	 * @param string $which enum (@see constants prefixed with COUNT)
158
+	 * @return int|null
159
+	 */
160
+	private function getCountFor($which)
161
+	{
162
+		try {
163
+			switch ($which) {
164
+				case self::COUNT_ALL_EVENTS:
165
+					$count = $this->event_model->count();
166
+					break;
167
+				case self::COUNT_TICKETS:
168
+					$count = $this->ticket_model->count();
169
+					break;
170
+				case self::COUNT_DATETIMES:
171
+					$count = $this->datetime_model->count();
172
+					break;
173
+				case self::COUNT_ACTIVE_EVENTS:
174
+					$count = $this->event_model->get_active_events(array(), true);
175
+					break;
176
+				case self::COUNT_DATETIMES_SOLD:
177
+					$count = $this->datetime_model->sum(array(), 'DTT_sold');
178
+					break;
179
+				case self::COUNT_TICKETS_FREE:
180
+					$count = $this->ticket_model->count(array(
181
+						array(
182
+							'TKT_price' => 0,
183
+						),
184
+					));
185
+					break;
186
+				case self::COUNT_TICKETS_PAID:
187
+					$count = $this->ticket_model->count(array(
188
+						array(
189
+							'TKT_price' => array('>', 0),
190
+						),
191
+					));
192
+					break;
193
+				case self::COUNT_TICKETS_SOLD:
194
+					$count = $this->ticket_model->sum(array(), 'TKT_sold');
195
+					break;
196
+				case self::COUNT_REGISTRATIONS_ALL:
197
+					$count = $this->registration_model->count();
198
+					break;
199
+				case self::COUNT_REGISTRATIONS_CANCELLED:
200
+					$count = $this->registration_model->count(
201
+						array(
202
+							array(
203
+								'STS_ID' => EEM_Registration::status_id_cancelled,
204
+							),
205
+						)
206
+					);
207
+					break;
208
+				case self::COUNT_REGISTRATIONS_INCOMPLETE:
209
+					$count = $this->registration_model->count(
210
+						array(
211
+							array(
212
+								'STS_ID' => EEM_Registration::status_id_incomplete,
213
+							),
214
+						)
215
+					);
216
+					break;
217
+				case self::COUNT_REGISTRATIONS_NOT_APPROVED:
218
+					$count = $this->registration_model->count(
219
+						array(
220
+							array(
221
+								'STS_ID' => EEM_Registration::status_id_not_approved,
222
+							),
223
+						)
224
+					);
225
+					break;
226
+				case self::COUNT_REGISTRATIONS_DECLINED:
227
+					$count = $this->registration_model->count(
228
+						array(
229
+							array(
230
+								'STS_ID' => EEM_Registration::status_id_declined,
231
+							),
232
+						)
233
+					);
234
+					break;
235
+				case self::COUNT_REGISTRATIONS_PENDING:
236
+					$count = $this->registration_model->count(
237
+						array(
238
+							array(
239
+								'STS_ID' => EEM_Registration::status_id_pending_payment,
240
+							),
241
+						)
242
+					);
243
+					break;
244
+				case self::COUNT_REGISTRATIONS_APPROVED:
245
+					$count = $this->registration_model->count(
246
+						array(
247
+							array(
248
+								'STS_ID' => EEM_Registration::status_id_approved,
249
+							),
250
+						)
251
+					);
252
+					break;
253
+				case self::SUM_TRANSACTIONS_COMPLETE_TOTAL:
254
+					$count = $this->transaction_model->sum(
255
+						array(
256
+							array(
257
+								'STS_ID' => EEM_Transaction::complete_status_code,
258
+							),
259
+						),
260
+						'TXN_total'
261
+					);
262
+					break;
263
+				case self::SUM_TRANSACTIONS_ALL_PAID:
264
+					$count = $this->transaction_model->sum(
265
+						array(),
266
+						'TXN_paid'
267
+					);
268
+					break;
269
+				default:
270
+					$count = null;
271
+					break;
272
+			}
273
+		} catch (Exception $e) {
274
+			$count = null;
275
+		}
276
+		return $count;
277
+	}
278 278
 
279
-    /**
280
-     * Return the active theme.
281
-     *
282
-     * @return false|string
283
-     */
284
-    private function getActiveThemeStat()
285
-    {
286
-        $theme = wp_get_theme();
287
-        return $theme->get('Name');
288
-    }
279
+	/**
280
+	 * Return the active theme.
281
+	 *
282
+	 * @return false|string
283
+	 */
284
+	private function getActiveThemeStat()
285
+	{
286
+		$theme = wp_get_theme();
287
+		return $theme->get('Name');
288
+	}
289 289
 
290
-    /**
291
-     * @return array
292
-     */
293
-    private function paymentMethodStats()
294
-    {
295
-        $payment_method_stats = array();
296
-        try {
297
-            $active_payment_methods = $this->payment_method_model->get_all_active(
298
-                null,
299
-                array('group_by' => 'PMD_type')
300
-            );
301
-            if ($active_payment_methods) {
302
-                foreach ($active_payment_methods as $payment_method) {
303
-                    $payment_method_stats[ $payment_method->name() . '_active_payment_method' ] = 1;
304
-                }
305
-            }
306
-        } catch (Exception $e) {
307
-            // do nothing just prevents fatals.
308
-        }
309
-        return $payment_method_stats;
310
-    }
290
+	/**
291
+	 * @return array
292
+	 */
293
+	private function paymentMethodStats()
294
+	{
295
+		$payment_method_stats = array();
296
+		try {
297
+			$active_payment_methods = $this->payment_method_model->get_all_active(
298
+				null,
299
+				array('group_by' => 'PMD_type')
300
+			);
301
+			if ($active_payment_methods) {
302
+				foreach ($active_payment_methods as $payment_method) {
303
+					$payment_method_stats[ $payment_method->name() . '_active_payment_method' ] = 1;
304
+				}
305
+			}
306
+		} catch (Exception $e) {
307
+			// do nothing just prevents fatals.
308
+		}
309
+		return $payment_method_stats;
310
+	}
311 311
 
312 312
 
313
-    /**
314
-     * Return a list of active EE add-ons and their versions.
315
-     *
316
-     * @return string
317
-     */
318
-    private function getActiveAddons()
319
-    {
320
-        $activeAddons = [];
321
-        $addOns = EE_Registry::instance()->addons;
322
-        if (! empty($addOns)) {
323
-            foreach ($addOns as $addon) {
324
-                $activeAddons[] = $addon->name() . '@' . $addon->version();
325
-            }
326
-        }
327
-        return implode(',', $activeAddons);
328
-    }
313
+	/**
314
+	 * Return a list of active EE add-ons and their versions.
315
+	 *
316
+	 * @return string
317
+	 */
318
+	private function getActiveAddons()
319
+	{
320
+		$activeAddons = [];
321
+		$addOns = EE_Registry::instance()->addons;
322
+		if (! empty($addOns)) {
323
+			foreach ($addOns as $addon) {
324
+				$activeAddons[] = $addon->name() . '@' . $addon->version();
325
+			}
326
+		}
327
+		return implode(',', $activeAddons);
328
+	}
329 329
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             'active_addons'                   => $this->getActiveAddons(),
149 149
         ));
150 150
         // remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
151
-        return array_filter($stats, function ($value) {
151
+        return array_filter($stats, function($value) {
152 152
             return $value !== null;
153 153
         });
154 154
     }
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
             );
301 301
             if ($active_payment_methods) {
302 302
                 foreach ($active_payment_methods as $payment_method) {
303
-                    $payment_method_stats[ $payment_method->name() . '_active_payment_method' ] = 1;
303
+                    $payment_method_stats[$payment_method->name().'_active_payment_method'] = 1;
304 304
                 }
305 305
             }
306 306
         } catch (Exception $e) {
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
     {
320 320
         $activeAddons = [];
321 321
         $addOns = EE_Registry::instance()->addons;
322
-        if (! empty($addOns)) {
322
+        if ( ! empty($addOns)) {
323 323
             foreach ($addOns as $addon) {
324
-                $activeAddons[] = $addon->name() . '@' . $addon->version();
324
+                $activeAddons[] = $addon->name().'@'.$addon->version();
325 325
             }
326 326
         }
327 327
         return implode(',', $activeAddons);
Please login to merge, or discard this patch.
core/EE_Log.core.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public static function instance()
47 47
     {
48
-        if (! self::$_instance instanceof EE_Log) {
48
+        if ( ! self::$_instance instanceof EE_Log) {
49 49
             self::$_instance = new self();
50 50
         }
51 51
         return self::$_instance;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     private function __construct()
59 59
     {
60 60
 
61
-        if (! EE_Registry::instance()->CFG->admin->use_remote_logging) {
61
+        if ( ! EE_Registry::instance()->CFG->admin->use_remote_logging) {
62 62
             return;
63 63
         }
64 64
 
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
      */
103 103
     private function _format_message($file = '', $function = '', $message = '', $type = '')
104 104
     {
105
-        $msg = '----------------------------------------------------------------------------------------' . PHP_EOL;
106
-        $msg .= '[' . current_time('mysql') . '] ';
105
+        $msg = '----------------------------------------------------------------------------------------'.PHP_EOL;
106
+        $msg .= '['.current_time('mysql').'] ';
107 107
         $msg .= ! empty($file) ? basename($file) : '';
108 108
         $msg .= ! empty($file) && ! empty($function) ? ' -> ' : '';
109
-        $msg .= ! empty($function) ? $function . '()' : '';
109
+        $msg .= ! empty($function) ? $function.'()' : '';
110 110
         $msg .= PHP_EOL;
111 111
         $type = ! empty($type) ? $type : 'log message';
112
-        $msg .= ! empty($message) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : '';
112
+        $msg .= ! empty($message) ? "\t".'['.$type.'] '.$message.PHP_EOL : '';
113 113
         return $msg;
114 114
     }
115 115
 
@@ -159,19 +159,19 @@  discard block
 block discarded – undo
159 159
             return;
160 160
         }
161 161
 
162
-        $data = 'domain=' . $_SERVER['HTTP_HOST'];
163
-        $data .= '&ip=' . $_SERVER['SERVER_ADDR'];
164
-        $data .= '&server_type=' . $_SERVER['SERVER_SOFTWARE'];
165
-        $data .= '&time=' . time();
166
-        $data .= '&remote_log=' . $this->_log;
167
-        $data .= '&request_array=' . json_encode($_REQUEST);
162
+        $data = 'domain='.$_SERVER['HTTP_HOST'];
163
+        $data .= '&ip='.$_SERVER['SERVER_ADDR'];
164
+        $data .= '&server_type='.$_SERVER['SERVER_SOFTWARE'];
165
+        $data .= '&time='.time();
166
+        $data .= '&remote_log='.$this->_log;
167
+        $data .= '&request_array='.json_encode($_REQUEST);
168 168
         $data .= '&action=save';
169 169
 
170 170
         if (defined('EELOGGING_PASS')) {
171
-            $data .= '&pass=' . EELOGGING_PASS;
171
+            $data .= '&pass='.EELOGGING_PASS;
172 172
         }
173 173
         if (defined('EELOGGING_KEY')) {
174
-            $data .= '&key=' . EELOGGING_KEY;
174
+            $data .= '&key='.EELOGGING_KEY;
175 175
         }
176 176
 
177 177
         $c = curl_init($this->_remote_logging_url);
Please login to merge, or discard this patch.
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -17,196 +17,196 @@
 block discarded – undo
17 17
 class EE_Log
18 18
 {
19 19
 
20
-    /**
21
-     * @var string
22
-     */
23
-    private $_log = '';
24
-
25
-    /**
26
-     * Used for remote logging
27
-     *
28
-     * @var string
29
-     */
30
-    private $_remote_logging_url = '';
31
-
32
-    /**
33
-     * @var string
34
-     */
35
-    private $_remote_log = '';
36
-
37
-    /**
38
-     * @var EE_Log
39
-     */
40
-    private static $_instance;
41
-
42
-
43
-    /**
44
-     * @return EE_Log
45
-     */
46
-    public static function instance()
47
-    {
48
-        if (! self::$_instance instanceof EE_Log) {
49
-            self::$_instance = new self();
50
-        }
51
-        return self::$_instance;
52
-    }
53
-
54
-    /**
55
-     * @access private
56
-     * @return EE_Log
57
-     */
58
-    private function __construct()
59
-    {
60
-
61
-        if (! EE_Registry::instance()->CFG->admin->use_remote_logging) {
62
-            return;
63
-        }
64
-
65
-        $this->_remote_logging_url = EE_Registry::instance()->CFG->admin->remote_logging_url;
66
-        $this->_remote_log = '';
67
-
68
-        if (EE_Registry::instance()->CFG->admin->use_remote_logging) {
69
-            add_action('shutdown', array($this, 'send_log'), 9999);
70
-        }
71
-    }
72
-
73
-
74
-    /**
75
-     *    verify_filesystem
76
-     * tests that the required files and folders exist and are writable
77
-     *
78
-     */
79
-    public function verify_filesystem()
80
-    {
81
-        $msg = esc_html__(
82
-            'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.',
83
-            'event_espresso'
84
-        );
85
-        EE_Error::doing_it_wrong(
86
-            __METHOD__,
87
-            $msg,
88
-            '4.10.1.p'
89
-        );
90
-    }
91
-
92
-
93
-    /**
94
-     *    _format_message
95
-     *    makes yer log entries look all purdy
96
-     *
97
-     * @param string $file
98
-     * @param string $function
99
-     * @param string $message
100
-     * @param string $type
101
-     * @return string
102
-     */
103
-    private function _format_message($file = '', $function = '', $message = '', $type = '')
104
-    {
105
-        $msg = '----------------------------------------------------------------------------------------' . PHP_EOL;
106
-        $msg .= '[' . current_time('mysql') . '] ';
107
-        $msg .= ! empty($file) ? basename($file) : '';
108
-        $msg .= ! empty($file) && ! empty($function) ? ' -> ' : '';
109
-        $msg .= ! empty($function) ? $function . '()' : '';
110
-        $msg .= PHP_EOL;
111
-        $type = ! empty($type) ? $type : 'log message';
112
-        $msg .= ! empty($message) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : '';
113
-        return $msg;
114
-    }
115
-
116
-
117
-    /**
118
-     *    log
119
-     * adds content to the EE_Log->_log property which gets written to file during the WP 'shutdown' hookpoint via the
120
-     * EE_Log::write_log() callback
121
-     *
122
-     * @param string $file
123
-     * @param string $function
124
-     * @param string $message
125
-     * @param string $type
126
-     */
127
-    public function log($file = '', $function = '', $message = '', $type = '')
128
-    {
129
-        $this->_log .= $this->_format_message($file, $function, $message, $type);
130
-    }
131
-
132
-
133
-    /**
134
-     * write_log
135
-     * appends the results of the 'AHEE_log' filter to the espresso log file
136
-     */
137
-    public function write_log()
138
-    {
139
-        $msg = esc_html__(
140
-            'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.',
141
-            'event_espresso'
142
-        );
143
-        EE_Error::doing_it_wrong(
144
-            __METHOD__,
145
-            $msg,
146
-            '4.10.1.p'
147
-        );
148
-    }
149
-
150
-
151
-    /**
152
-     * send_log
153
-     * sends the espresso log to a remote URL via a PHP cURL request
154
-     */
155
-    public function send_log()
156
-    {
157
-
158
-        if (empty($this->_remote_logging_url)) {
159
-            return;
160
-        }
161
-
162
-        $data = 'domain=' . $_SERVER['HTTP_HOST'];
163
-        $data .= '&ip=' . $_SERVER['SERVER_ADDR'];
164
-        $data .= '&server_type=' . $_SERVER['SERVER_SOFTWARE'];
165
-        $data .= '&time=' . time();
166
-        $data .= '&remote_log=' . $this->_log;
167
-        $data .= '&request_array=' . json_encode($_REQUEST);
168
-        $data .= '&action=save';
169
-
170
-        if (defined('EELOGGING_PASS')) {
171
-            $data .= '&pass=' . EELOGGING_PASS;
172
-        }
173
-        if (defined('EELOGGING_KEY')) {
174
-            $data .= '&key=' . EELOGGING_KEY;
175
-        }
176
-
177
-        $c = curl_init($this->_remote_logging_url);
178
-        curl_setopt($c, CURLOPT_POST, true);
179
-        curl_setopt($c, CURLOPT_POSTFIELDS, $data);
180
-        curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
181
-        curl_exec($c);
182
-        curl_close($c);
183
-    }
184
-
185
-
186
-    /**
187
-     * write_debug
188
-     * writes the contents of the current request's $_GET and $_POST arrays to a log file.
189
-     * previous entries are overwritten
190
-     */
191
-    public function write_debug()
192
-    {
193
-        $msg = esc_html__(
194
-            'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.',
195
-            'event_espresso'
196
-        );
197
-        EE_Error::doing_it_wrong(
198
-            __METHOD__,
199
-            $msg,
200
-            '4.10.1.p'
201
-        );
202
-    }
203
-
204
-
205
-    /**
206
-     * __clone
207
-     */
208
-    public function __clone()
209
-    {
210
-        trigger_error(__('Clone is not allowed.', 'event_espresso'), E_USER_ERROR);
211
-    }
20
+	/**
21
+	 * @var string
22
+	 */
23
+	private $_log = '';
24
+
25
+	/**
26
+	 * Used for remote logging
27
+	 *
28
+	 * @var string
29
+	 */
30
+	private $_remote_logging_url = '';
31
+
32
+	/**
33
+	 * @var string
34
+	 */
35
+	private $_remote_log = '';
36
+
37
+	/**
38
+	 * @var EE_Log
39
+	 */
40
+	private static $_instance;
41
+
42
+
43
+	/**
44
+	 * @return EE_Log
45
+	 */
46
+	public static function instance()
47
+	{
48
+		if (! self::$_instance instanceof EE_Log) {
49
+			self::$_instance = new self();
50
+		}
51
+		return self::$_instance;
52
+	}
53
+
54
+	/**
55
+	 * @access private
56
+	 * @return EE_Log
57
+	 */
58
+	private function __construct()
59
+	{
60
+
61
+		if (! EE_Registry::instance()->CFG->admin->use_remote_logging) {
62
+			return;
63
+		}
64
+
65
+		$this->_remote_logging_url = EE_Registry::instance()->CFG->admin->remote_logging_url;
66
+		$this->_remote_log = '';
67
+
68
+		if (EE_Registry::instance()->CFG->admin->use_remote_logging) {
69
+			add_action('shutdown', array($this, 'send_log'), 9999);
70
+		}
71
+	}
72
+
73
+
74
+	/**
75
+	 *    verify_filesystem
76
+	 * tests that the required files and folders exist and are writable
77
+	 *
78
+	 */
79
+	public function verify_filesystem()
80
+	{
81
+		$msg = esc_html__(
82
+			'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.',
83
+			'event_espresso'
84
+		);
85
+		EE_Error::doing_it_wrong(
86
+			__METHOD__,
87
+			$msg,
88
+			'4.10.1.p'
89
+		);
90
+	}
91
+
92
+
93
+	/**
94
+	 *    _format_message
95
+	 *    makes yer log entries look all purdy
96
+	 *
97
+	 * @param string $file
98
+	 * @param string $function
99
+	 * @param string $message
100
+	 * @param string $type
101
+	 * @return string
102
+	 */
103
+	private function _format_message($file = '', $function = '', $message = '', $type = '')
104
+	{
105
+		$msg = '----------------------------------------------------------------------------------------' . PHP_EOL;
106
+		$msg .= '[' . current_time('mysql') . '] ';
107
+		$msg .= ! empty($file) ? basename($file) : '';
108
+		$msg .= ! empty($file) && ! empty($function) ? ' -> ' : '';
109
+		$msg .= ! empty($function) ? $function . '()' : '';
110
+		$msg .= PHP_EOL;
111
+		$type = ! empty($type) ? $type : 'log message';
112
+		$msg .= ! empty($message) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : '';
113
+		return $msg;
114
+	}
115
+
116
+
117
+	/**
118
+	 *    log
119
+	 * adds content to the EE_Log->_log property which gets written to file during the WP 'shutdown' hookpoint via the
120
+	 * EE_Log::write_log() callback
121
+	 *
122
+	 * @param string $file
123
+	 * @param string $function
124
+	 * @param string $message
125
+	 * @param string $type
126
+	 */
127
+	public function log($file = '', $function = '', $message = '', $type = '')
128
+	{
129
+		$this->_log .= $this->_format_message($file, $function, $message, $type);
130
+	}
131
+
132
+
133
+	/**
134
+	 * write_log
135
+	 * appends the results of the 'AHEE_log' filter to the espresso log file
136
+	 */
137
+	public function write_log()
138
+	{
139
+		$msg = esc_html__(
140
+			'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.',
141
+			'event_espresso'
142
+		);
143
+		EE_Error::doing_it_wrong(
144
+			__METHOD__,
145
+			$msg,
146
+			'4.10.1.p'
147
+		);
148
+	}
149
+
150
+
151
+	/**
152
+	 * send_log
153
+	 * sends the espresso log to a remote URL via a PHP cURL request
154
+	 */
155
+	public function send_log()
156
+	{
157
+
158
+		if (empty($this->_remote_logging_url)) {
159
+			return;
160
+		}
161
+
162
+		$data = 'domain=' . $_SERVER['HTTP_HOST'];
163
+		$data .= '&ip=' . $_SERVER['SERVER_ADDR'];
164
+		$data .= '&server_type=' . $_SERVER['SERVER_SOFTWARE'];
165
+		$data .= '&time=' . time();
166
+		$data .= '&remote_log=' . $this->_log;
167
+		$data .= '&request_array=' . json_encode($_REQUEST);
168
+		$data .= '&action=save';
169
+
170
+		if (defined('EELOGGING_PASS')) {
171
+			$data .= '&pass=' . EELOGGING_PASS;
172
+		}
173
+		if (defined('EELOGGING_KEY')) {
174
+			$data .= '&key=' . EELOGGING_KEY;
175
+		}
176
+
177
+		$c = curl_init($this->_remote_logging_url);
178
+		curl_setopt($c, CURLOPT_POST, true);
179
+		curl_setopt($c, CURLOPT_POSTFIELDS, $data);
180
+		curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
181
+		curl_exec($c);
182
+		curl_close($c);
183
+	}
184
+
185
+
186
+	/**
187
+	 * write_debug
188
+	 * writes the contents of the current request's $_GET and $_POST arrays to a log file.
189
+	 * previous entries are overwritten
190
+	 */
191
+	public function write_debug()
192
+	{
193
+		$msg = esc_html__(
194
+			'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.',
195
+			'event_espresso'
196
+		);
197
+		EE_Error::doing_it_wrong(
198
+			__METHOD__,
199
+			$msg,
200
+			'4.10.1.p'
201
+		);
202
+	}
203
+
204
+
205
+	/**
206
+	 * __clone
207
+	 */
208
+	public function __clone()
209
+	{
210
+		trigger_error(__('Clone is not allowed.', 'event_espresso'), E_USER_ERROR);
211
+	}
212 212
 }
Please login to merge, or discard this patch.
data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_org_options.dmsstage.php 1 patch
Indentation   +270 added lines, -270 removed lines patch added patch discarded remove patch
@@ -103,286 +103,286 @@
 block discarded – undo
103 103
 class EE_DMS_4_1_0_org_options extends EE_Data_Migration_Script_Stage
104 104
 {
105 105
 
106
-    public function _migration_step($num_items = 50)
107
-    {
106
+	public function _migration_step($num_items = 50)
107
+	{
108 108
 
109
-        $items_actually_migrated = 0;
110
-        $old_org_options = get_option('events_organization_settings');
111
-        foreach ($this->_org_options_we_know_how_to_migrate as $option_name) {
112
-            // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default
113
-            if (isset($old_org_options[ $option_name ])) {
114
-                $this->_handle_org_option($option_name, $old_org_options[ $option_name ]);
115
-            }
116
-            if ($option_name=='surcharge') {
117
-                $this->_insert_new_global_surcharge_price($old_org_options);
118
-            }
119
-            $items_actually_migrated++;
120
-        }
109
+		$items_actually_migrated = 0;
110
+		$old_org_options = get_option('events_organization_settings');
111
+		foreach ($this->_org_options_we_know_how_to_migrate as $option_name) {
112
+			// only bother migrating if there's a setting to migrate. Otherwise we'll just use the default
113
+			if (isset($old_org_options[ $option_name ])) {
114
+				$this->_handle_org_option($option_name, $old_org_options[ $option_name ]);
115
+			}
116
+			if ($option_name=='surcharge') {
117
+				$this->_insert_new_global_surcharge_price($old_org_options);
118
+			}
119
+			$items_actually_migrated++;
120
+		}
121 121
 
122
-        $success = EE_Config::instance()->update_espresso_config(false, true);
123
-        if (! $success) {
124
-            $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false)));
125
-            EE_Error::overwrite_errors();
126
-        }
127
-        EE_Network_Config::instance()->update_config(false, false);
128
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
129
-            // we may have added new pages and this might be necessary
130
-            flush_rewrite_rules();
131
-            $this->set_completed();
132
-        }
133
-        return $items_actually_migrated;
134
-    }
135
-    public function _count_records_to_migrate()
136
-    {
137
-        $count_of_options_to_migrate = count($this->_org_options_we_know_how_to_migrate);
138
-        return $count_of_options_to_migrate;
139
-    }
140
-    public function __construct()
141
-    {
142
-        $this->_pretty_name = __("Organization Options/Config", "event_espresso");
143
-        $this->_org_options_we_know_how_to_migrate = apply_filters('FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', $this->_org_options_we_know_how_to_migrate);
144
-        parent::__construct();
145
-    }
122
+		$success = EE_Config::instance()->update_espresso_config(false, true);
123
+		if (! $success) {
124
+			$this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false)));
125
+			EE_Error::overwrite_errors();
126
+		}
127
+		EE_Network_Config::instance()->update_config(false, false);
128
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
129
+			// we may have added new pages and this might be necessary
130
+			flush_rewrite_rules();
131
+			$this->set_completed();
132
+		}
133
+		return $items_actually_migrated;
134
+	}
135
+	public function _count_records_to_migrate()
136
+	{
137
+		$count_of_options_to_migrate = count($this->_org_options_we_know_how_to_migrate);
138
+		return $count_of_options_to_migrate;
139
+	}
140
+	public function __construct()
141
+	{
142
+		$this->_pretty_name = __("Organization Options/Config", "event_espresso");
143
+		$this->_org_options_we_know_how_to_migrate = apply_filters('FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', $this->_org_options_we_know_how_to_migrate);
144
+		parent::__construct();
145
+	}
146 146
 
147
-    private function _handle_org_option($option_name, $value)
148
-    {
149
-        $c = EE_Config::instance();
150
-        $cn = EE_Network_Config::instance();
151
-        switch ($option_name) {
152
-            case 'organization':
153
-                $c->organization->name = $value;
154
-                break;
155
-            case 'organization_street1':
156
-                $c->organization->address_1 = $value;
157
-                break;
158
-            case 'organization_street2':
159
-                $c->organization->address_2 = $value;
160
-                break;
161
-            case 'organization_city':
162
-                $c->organization->city = $value;
163
-                break;
164
-            case 'organization_state':
165
-                try {
166
-                    $state = $this->get_migration_script()->get_or_create_state($value);
167
-                    $state_id = $state['STA_ID'];
168
-                    $c->organization->STA_ID = $state_id;
169
-                } catch (EE_Error $e) {
170
-                }
171
-                break;
172
-            case 'organization_zip':
173
-                $c->organization->zip = $value;
174
-                break;
175
-            case 'contact_email':
176
-                $c->organization->email = $value;
177
-                break;
178
-            case 'default_payment_status':
179
-                $c->registration->default_STS_ID =  $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value);
180
-                break;
181
-            case 'organization_country':
182
-                $iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value);
183
-                $c->organization->CNT_ISO = $iso;
184
-                $country_row = $this->get_migration_script()->get_or_create_country($iso);
185
-                if (! $country_row) {
186
-                    $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso));
187
-                }
188
-                // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them)
189
-                $c->currency->code = $country_row['CNT_cur_code'];          // currency code: USD, CAD, EUR
190
-                $c->currency->name = $country_row['CNT_cur_single'];    // Dollar
191
-                $c->currency->plural = $country_row['CNT_cur_plural'];  // Dollars
192
-                $c->currency->sign =  $country_row['CNT_cur_sign'];             // currency sign: $
193
-                $c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN);        // currency sign before or after: $TRUE  or  FALSE$
194
-                $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc'];    // decimal places: 2 = 0.00  3 = 0.000
195
-                $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk'];    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
196
-                $c->currency->thsnds = $country_row['CNT_cur_thsnds'];  // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
147
+	private function _handle_org_option($option_name, $value)
148
+	{
149
+		$c = EE_Config::instance();
150
+		$cn = EE_Network_Config::instance();
151
+		switch ($option_name) {
152
+			case 'organization':
153
+				$c->organization->name = $value;
154
+				break;
155
+			case 'organization_street1':
156
+				$c->organization->address_1 = $value;
157
+				break;
158
+			case 'organization_street2':
159
+				$c->organization->address_2 = $value;
160
+				break;
161
+			case 'organization_city':
162
+				$c->organization->city = $value;
163
+				break;
164
+			case 'organization_state':
165
+				try {
166
+					$state = $this->get_migration_script()->get_or_create_state($value);
167
+					$state_id = $state['STA_ID'];
168
+					$c->organization->STA_ID = $state_id;
169
+				} catch (EE_Error $e) {
170
+				}
171
+				break;
172
+			case 'organization_zip':
173
+				$c->organization->zip = $value;
174
+				break;
175
+			case 'contact_email':
176
+				$c->organization->email = $value;
177
+				break;
178
+			case 'default_payment_status':
179
+				$c->registration->default_STS_ID =  $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value);
180
+				break;
181
+			case 'organization_country':
182
+				$iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value);
183
+				$c->organization->CNT_ISO = $iso;
184
+				$country_row = $this->get_migration_script()->get_or_create_country($iso);
185
+				if (! $country_row) {
186
+					$this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso));
187
+				}
188
+				// can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them)
189
+				$c->currency->code = $country_row['CNT_cur_code'];          // currency code: USD, CAD, EUR
190
+				$c->currency->name = $country_row['CNT_cur_single'];    // Dollar
191
+				$c->currency->plural = $country_row['CNT_cur_plural'];  // Dollars
192
+				$c->currency->sign =  $country_row['CNT_cur_sign'];             // currency sign: $
193
+				$c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN);        // currency sign before or after: $TRUE  or  FALSE$
194
+				$c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc'];    // decimal places: 2 = 0.00  3 = 0.000
195
+				$c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk'];    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
196
+				$c->currency->thsnds = $country_row['CNT_cur_thsnds'];  // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
197 197
   //            $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break;
198 198
   //        case 'currency_symbol': ignore the currency symbol. we'll just go by their country.
199 199
   //            $c->currency->sign = $value;break;
200
-            case 'show_pending_payment_options':
201
-                $c->registration->show_pending_payment_options = ($value == 'Y');
202
-                break;
203
-            case 'display_address_in_regform':
204
-                $c->template_settings->display_address_in_regform = ($value == 'Y');
205
-                break;
206
-            case 'default_logo_url':
207
-                $c->organization->logo_url = $value;
208
-                break;
209
-            case 'event_page_id':
210
-                // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
211
-                // to ESPRESSO_THANK_YOU
212
-                $reg_page_post = get_post($value);
213
-                $reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]", "[ESPRESSO_CHECKOUT]", $reg_page_post->post_content);
214
-                wp_update_post($reg_page_post);
215
-                $c->core->reg_page_id = $value;
216
-                break;
217
-            case 'return_url':
218
-                // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
219
-                // to ESPRESSO_THANK_YOU
220
-                $thank_you_page_post = get_post($value);
221
-                $thank_you_page_post->post_content = str_replace("[ESPRESSO_PAYMENTS]", "[ESPRESSO_THANK_YOU]", $thank_you_page_post->post_content);
222
-                wp_update_post($thank_you_page_post);
223
-                $c->core->thank_you_page_id = $value;
224
-                break;
225
-            case 'cancel_return':
226
-                $c->core->cancel_page_id = $value;
200
+			case 'show_pending_payment_options':
201
+				$c->registration->show_pending_payment_options = ($value == 'Y');
202
+				break;
203
+			case 'display_address_in_regform':
204
+				$c->template_settings->display_address_in_regform = ($value == 'Y');
205
+				break;
206
+			case 'default_logo_url':
207
+				$c->organization->logo_url = $value;
208
+				break;
209
+			case 'event_page_id':
210
+				// also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
211
+				// to ESPRESSO_THANK_YOU
212
+				$reg_page_post = get_post($value);
213
+				$reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]", "[ESPRESSO_CHECKOUT]", $reg_page_post->post_content);
214
+				wp_update_post($reg_page_post);
215
+				$c->core->reg_page_id = $value;
216
+				break;
217
+			case 'return_url':
218
+				// also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
219
+				// to ESPRESSO_THANK_YOU
220
+				$thank_you_page_post = get_post($value);
221
+				$thank_you_page_post->post_content = str_replace("[ESPRESSO_PAYMENTS]", "[ESPRESSO_THANK_YOU]", $thank_you_page_post->post_content);
222
+				wp_update_post($thank_you_page_post);
223
+				$c->core->thank_you_page_id = $value;
224
+				break;
225
+			case 'cancel_return':
226
+				$c->core->cancel_page_id = $value;
227 227
 
228
-                break;
229
-            case 'notify_url':
230
-                $c->core->txn_page_id = $value;
231
-                break;
232
-            case 'use_captcha':
233
-                $c->registration->use_captcha = ($value == 'Y');
234
-                break;
235
-            case 'recaptcha_publickey':
236
-                $c->registration->recaptcha_publickey = $value;
237
-                break;
238
-            case 'recaptcha_privatekey':
239
-                $c->registration->recaptcha_privatekey = $value;
240
-                break;
241
-            case 'recaptcha_theme':
242
-                $c->registration->recaptcha_theme = $value;
243
-                break;
244
-            case 'recaptcha_width':
245
-                $c->registration->recaptcha_width = $value;
246
-                break;
247
-            case 'recaptcha_language':
248
-                $c->registration->recaptcha_language = $value;
249
-                break;
250
-            case 'espresso_dashboard_widget':
251
-                $c->admin->use_dashboard_widget = ($value == 'Y');
252
-                break;
253
-            case 'use_personnel_manager':
254
-                $c->admin->use_personnel_manager = ($value == 'Y');
255
-                break;
256
-            case 'use_event_timezones':
257
-                $c->admin->use_event_timezones = ($value == 'Y');
258
-                break;
259
-            case 'affiliate_id':
260
-                $c->admin->affiliate_id = $value;
261
-                break;
262
-            case 'site_license_key':
263
-                $cn->core->site_license_key = $value;
264
-                break;
265
-            default:
266
-                do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value);
267
-        }
268
-    }
228
+				break;
229
+			case 'notify_url':
230
+				$c->core->txn_page_id = $value;
231
+				break;
232
+			case 'use_captcha':
233
+				$c->registration->use_captcha = ($value == 'Y');
234
+				break;
235
+			case 'recaptcha_publickey':
236
+				$c->registration->recaptcha_publickey = $value;
237
+				break;
238
+			case 'recaptcha_privatekey':
239
+				$c->registration->recaptcha_privatekey = $value;
240
+				break;
241
+			case 'recaptcha_theme':
242
+				$c->registration->recaptcha_theme = $value;
243
+				break;
244
+			case 'recaptcha_width':
245
+				$c->registration->recaptcha_width = $value;
246
+				break;
247
+			case 'recaptcha_language':
248
+				$c->registration->recaptcha_language = $value;
249
+				break;
250
+			case 'espresso_dashboard_widget':
251
+				$c->admin->use_dashboard_widget = ($value == 'Y');
252
+				break;
253
+			case 'use_personnel_manager':
254
+				$c->admin->use_personnel_manager = ($value == 'Y');
255
+				break;
256
+			case 'use_event_timezones':
257
+				$c->admin->use_event_timezones = ($value == 'Y');
258
+				break;
259
+			case 'affiliate_id':
260
+				$c->admin->affiliate_id = $value;
261
+				break;
262
+			case 'site_license_key':
263
+				$cn->core->site_license_key = $value;
264
+				break;
265
+			default:
266
+				do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value);
267
+		}
268
+	}
269 269
 
270
-    /**
271
-     * Creates a 4.1 member price discount
272
-     * @global type $wpdb
273
-     * @param type $old_price
274
-     * @return int
275
-     */
276
-    private function _insert_new_global_surcharge_price($org_options)
277
-    {
278
-        $amount = floatval($org_options['surcharge']);
279
-        // dont createa a price if the surcharge is 0
280
-        if ($amount <=.01) {
281
-            return 0;
282
-        }
283
-        if ($org_options['surcharge_type'] == 'flat_rate') {
284
-            $price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge;
285
-        } else {
286
-            $price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge;
287
-        }
288
-        global $wpdb;
289
-        $cols_n_values = array(
290
-            'PRT_ID'=>$price_type,
291
-            'PRC_amount'=>$amount,
292
-            'PRC_name'=>  $org_options['surcharge_text'],
293
-            'PRC_is_default'=>true,
294
-            'PRC_overrides'=>false,
295
-            'PRC_order'=>100,
296
-            'PRC_deleted'=>false,
297
-            'PRC_parent'=>null
270
+	/**
271
+	 * Creates a 4.1 member price discount
272
+	 * @global type $wpdb
273
+	 * @param type $old_price
274
+	 * @return int
275
+	 */
276
+	private function _insert_new_global_surcharge_price($org_options)
277
+	{
278
+		$amount = floatval($org_options['surcharge']);
279
+		// dont createa a price if the surcharge is 0
280
+		if ($amount <=.01) {
281
+			return 0;
282
+		}
283
+		if ($org_options['surcharge_type'] == 'flat_rate') {
284
+			$price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge;
285
+		} else {
286
+			$price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge;
287
+		}
288
+		global $wpdb;
289
+		$cols_n_values = array(
290
+			'PRT_ID'=>$price_type,
291
+			'PRC_amount'=>$amount,
292
+			'PRC_name'=>  $org_options['surcharge_text'],
293
+			'PRC_is_default'=>true,
294
+			'PRC_overrides'=>false,
295
+			'PRC_order'=>100,
296
+			'PRC_deleted'=>false,
297
+			'PRC_parent'=>null
298 298
 
299
-        );
300
-        $datatypes = array(
301
-            '%d',// PRT_ID
302
-            '%f',// PRT_amount
303
-            '%s',// PRC_name
304
-            '%d',// PRC_is_default
305
-            '%d',// PRC_overrides
306
-            '%d',// PRC_order
307
-            '%d',// PRC_deleted
308
-            '%d',// PRC_parent
309
-        );
310
-        $price_table = $wpdb->prefix."esp_price";
311
-        $success = $wpdb->insert($price_table, $cols_n_values, $datatypes);
312
-        if (! $success) {
313
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion(
314
-                'org_options',
315
-                array(
316
-                        'surcharge'=>$org_options['surcharge'],
317
-                        'surcharge_type'=>$org_options['surcharge_type'],
318
-                        'surcharge_text'=>$org_options['surcharge_text']),
319
-                $price_table,
320
-                $cols_n_values,
321
-                $datatypes
322
-            ));
323
-            return 0;
324
-        }
325
-        $new_id = $wpdb->insert_id;
326
-        return $new_id;
327
-    }
299
+		);
300
+		$datatypes = array(
301
+			'%d',// PRT_ID
302
+			'%f',// PRT_amount
303
+			'%s',// PRC_name
304
+			'%d',// PRC_is_default
305
+			'%d',// PRC_overrides
306
+			'%d',// PRC_order
307
+			'%d',// PRC_deleted
308
+			'%d',// PRC_parent
309
+		);
310
+		$price_table = $wpdb->prefix."esp_price";
311
+		$success = $wpdb->insert($price_table, $cols_n_values, $datatypes);
312
+		if (! $success) {
313
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion(
314
+				'org_options',
315
+				array(
316
+						'surcharge'=>$org_options['surcharge'],
317
+						'surcharge_type'=>$org_options['surcharge_type'],
318
+						'surcharge_text'=>$org_options['surcharge_text']),
319
+				$price_table,
320
+				$cols_n_values,
321
+				$datatypes
322
+			));
323
+			return 0;
324
+		}
325
+		$new_id = $wpdb->insert_id;
326
+		return $new_id;
327
+	}
328 328
 
329
-    protected $_org_options_we_know_how_to_migrate = array(
330
-      'organization',
331
-      'organization_street1',
332
-      'organization_street2',
333
-      'organization_city',
334
-      'organization_state',
335
-      'organization_zip',
336
-      'contact_email',
337
-      'default_mail',
338
-      'payment_subject',
339
-      'payment_message',
340
-      'message',
341
-      'default_payment_status',
342
-      'surcharge',// unused?
343
-      'country_id',// unused?
344
-      'organization_country',
329
+	protected $_org_options_we_know_how_to_migrate = array(
330
+	  'organization',
331
+	  'organization_street1',
332
+	  'organization_street2',
333
+	  'organization_city',
334
+	  'organization_state',
335
+	  'organization_zip',
336
+	  'contact_email',
337
+	  'default_mail',
338
+	  'payment_subject',
339
+	  'payment_message',
340
+	  'message',
341
+	  'default_payment_status',
342
+	  'surcharge',// unused?
343
+	  'country_id',// unused?
344
+	  'organization_country',
345 345
 //    'currency_symbol',
346
-      'expire_on_registration_end',
347
-      'email_before_payment',
348
-      'email_fancy_headers',
349
-      'enable_default_style',
350
-      'event_ssl_active',
351
-      'selected_style',
352
-      'show_pending_payment_options',
353
-      'show_reg_footer',
354
-      'skip_confirmation_page',
355
-      'allow_mer_discounts',// no equiv
356
-      'allow_mer_vouchers',// no equiv
357
-      'display_short_description_in_event_list',
358
-      'display_description_on_multi_reg_page',
359
-      'display_address_in_event_list',
360
-      'display_address_in_regform',
361
-      'use_custom_post_types',// no equiv
362
-      'display_ical_download',
363
-      'display_featured_image',
364
-      'themeroller',
365
-      'default_logo_url',
366
-      'event_page_id',
367
-      'return_url',
368
-      'cancel_return',
369
-      'notify_url',
370
-      'events_in_dashboard',
371
-      'use_captcha',
372
-      'recaptcha_publickey',
373
-      'recaptcha_privatekey',
374
-      'recaptcha_theme',
375
-      'recaptcha_width',
376
-      'recaptcha_language',
377
-      'espresso_dashboard_widget',
378
-      'time_reg_limit',
346
+	  'expire_on_registration_end',
347
+	  'email_before_payment',
348
+	  'email_fancy_headers',
349
+	  'enable_default_style',
350
+	  'event_ssl_active',
351
+	  'selected_style',
352
+	  'show_pending_payment_options',
353
+	  'show_reg_footer',
354
+	  'skip_confirmation_page',
355
+	  'allow_mer_discounts',// no equiv
356
+	  'allow_mer_vouchers',// no equiv
357
+	  'display_short_description_in_event_list',
358
+	  'display_description_on_multi_reg_page',
359
+	  'display_address_in_event_list',
360
+	  'display_address_in_regform',
361
+	  'use_custom_post_types',// no equiv
362
+	  'display_ical_download',
363
+	  'display_featured_image',
364
+	  'themeroller',
365
+	  'default_logo_url',
366
+	  'event_page_id',
367
+	  'return_url',
368
+	  'cancel_return',
369
+	  'notify_url',
370
+	  'events_in_dashboard',
371
+	  'use_captcha',
372
+	  'recaptcha_publickey',
373
+	  'recaptcha_privatekey',
374
+	  'recaptcha_theme',
375
+	  'recaptcha_width',
376
+	  'recaptcha_language',
377
+	  'espresso_dashboard_widget',
378
+	  'time_reg_limit',
379 379
 //    'use_attendee_pre_approval', removed in 4.1- instead this is factored into the default reg status
380
-      'use_personnel_manager',// no equiv
381
-      'use_event_timezones',
382
-      'full_logging',
383
-      'surcharge_type',// unused
384
-      'surcharge_text',// unused
385
-      'affiliate_id',
386
-      'site_license_key',
387
-    );
380
+	  'use_personnel_manager',// no equiv
381
+	  'use_event_timezones',
382
+	  'full_logging',
383
+	  'surcharge_type',// unused
384
+	  'surcharge_text',// unused
385
+	  'affiliate_id',
386
+	  'site_license_key',
387
+	);
388 388
 }
Please login to merge, or discard this patch.
admin/extend/general_settings/Extend_General_Settings_Admin_Page.core.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -18,68 +18,68 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    public function __construct($routing = true)
22
-    {
23
-        parent::__construct($routing);
24
-        define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'general_settings/templates/');
25
-    }
21
+	public function __construct($routing = true)
22
+	{
23
+		parent::__construct($routing);
24
+		define('GEN_SET_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'general_settings/templates/');
25
+	}
26 26
 
27 27
 
28
-    protected function _extend_page_config()
29
-    {
28
+	protected function _extend_page_config()
29
+	{
30 30
 
31
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'general_settings';
31
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'general_settings';
32 32
 
33
-        // filters and action hooks here
34
-        add_action('AHEE__admin_option_settings__template__before', array($this, 'debug_logging_options'), 9);
35
-        add_filter(
36
-            'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
37
-            array($this, 'update_debug_logging_options'),
38
-            10,
39
-            1
40
-        );
41
-    }
33
+		// filters and action hooks here
34
+		add_action('AHEE__admin_option_settings__template__before', array($this, 'debug_logging_options'), 9);
35
+		add_filter(
36
+			'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
37
+			array($this, 'update_debug_logging_options'),
38
+			10,
39
+			1
40
+		);
41
+	}
42 42
 
43 43
 
44 44
 
45
-    /*************        Logging Settings        *************/
45
+	/*************        Logging Settings        *************/
46 46
 
47
-    /**
48
-     * debug_logging_options
49
-     *
50
-     * @param array $template_args
51
-     *
52
-     * @return void
53
-     */
54
-    public function debug_logging_options($template_args = array())
55
-    {
56
-        $template_args['use_remote_logging'] = isset(EE_Registry::instance()->CFG->admin->use_remote_logging) ? absint(
57
-            EE_Registry::instance()->CFG->admin->use_remote_logging
58
-        ) : false;
59
-        $template_args['remote_logging_url'] = isset(EE_Registry::instance()->CFG->admin->remote_logging_url)
60
-                                               && ! empty(EE_Registry::instance()->CFG->admin->remote_logging_url)
61
-            ? stripslashes(EE_Registry::instance()->CFG->admin->remote_logging_url) : '';
62
-        $template = GEN_SET_CAF_TEMPLATE_PATH . 'debug_log_settings.template.php';
63
-        EEH_Template::display_template($template, $template_args);
64
-    }
47
+	/**
48
+	 * debug_logging_options
49
+	 *
50
+	 * @param array $template_args
51
+	 *
52
+	 * @return void
53
+	 */
54
+	public function debug_logging_options($template_args = array())
55
+	{
56
+		$template_args['use_remote_logging'] = isset(EE_Registry::instance()->CFG->admin->use_remote_logging) ? absint(
57
+			EE_Registry::instance()->CFG->admin->use_remote_logging
58
+		) : false;
59
+		$template_args['remote_logging_url'] = isset(EE_Registry::instance()->CFG->admin->remote_logging_url)
60
+											   && ! empty(EE_Registry::instance()->CFG->admin->remote_logging_url)
61
+			? stripslashes(EE_Registry::instance()->CFG->admin->remote_logging_url) : '';
62
+		$template = GEN_SET_CAF_TEMPLATE_PATH . 'debug_log_settings.template.php';
63
+		EEH_Template::display_template($template, $template_args);
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * update_debug_logging_options
69
-     *
70
-     * @param array $admin_options
71
-     *
72
-     * @return array
73
-     */
74
-    public function update_debug_logging_options($admin_options = array())
75
-    {
76
-        $admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint(
77
-            $this->_req_data['use_remote_logging']
78
-        ) : $admin_options->use_remote_logging;
79
-        $admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw(
80
-            $this->_req_data['remote_logging_url']
81
-        ) : $admin_options->remote_logging_url;
67
+	/**
68
+	 * update_debug_logging_options
69
+	 *
70
+	 * @param array $admin_options
71
+	 *
72
+	 * @return array
73
+	 */
74
+	public function update_debug_logging_options($admin_options = array())
75
+	{
76
+		$admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint(
77
+			$this->_req_data['use_remote_logging']
78
+		) : $admin_options->use_remote_logging;
79
+		$admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw(
80
+			$this->_req_data['remote_logging_url']
81
+		) : $admin_options->remote_logging_url;
82 82
 
83
-        return $admin_options;
84
-    }
83
+		return $admin_options;
84
+	}
85 85
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/help_tours/Admin_Options_Help_Tour.class.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -15,81 +15,81 @@
 block discarded – undo
15 15
 class Admin_Options_Help_Tour extends EE_Help_Tour
16 16
 {
17 17
 
18
-    protected function _set_tour_properties()
19
-    {
20
-        $this->_label = __('Admin Options Tour', 'event_espresso');
21
-        $this->_slug = 'admin-options-joyride';
22
-    }
18
+	protected function _set_tour_properties()
19
+	{
20
+		$this->_label = __('Admin Options Tour', 'event_espresso');
21
+		$this->_slug = 'admin-options-joyride';
22
+	}
23 23
 
24
-    protected function _set_tour_stops()
25
-    {
26
-        $this->_stops = array(
27
-            10 => array(
28
-                'content' => $this->_start(),
29
-            ),
30
-            30 => array(
31
-                'id'      => 'use_remote_logging',
32
-                'content' => $this->_use_remote_logging_stop(),
33
-                'options' => array(
34
-                    'tipLocation'    => 'right',
35
-                    'tipAdjustmentY' => -50,
36
-                    'tipAdjustmentX' => 15,
37
-                ),
38
-            ),
39
-            40 => array(
40
-                'id'      => 'affiliate_info',
41
-                'content' => $this->_show_reg_footer_stop(),
42
-                'options' => array(
43
-                    'tipLocation'    => 'right',
44
-                    'tipAdjustmentY' => -50,
45
-                    'tipAdjustmentX' => 15,
46
-                ),
47
-            ),
24
+	protected function _set_tour_stops()
25
+	{
26
+		$this->_stops = array(
27
+			10 => array(
28
+				'content' => $this->_start(),
29
+			),
30
+			30 => array(
31
+				'id'      => 'use_remote_logging',
32
+				'content' => $this->_use_remote_logging_stop(),
33
+				'options' => array(
34
+					'tipLocation'    => 'right',
35
+					'tipAdjustmentY' => -50,
36
+					'tipAdjustmentX' => 15,
37
+				),
38
+			),
39
+			40 => array(
40
+				'id'      => 'affiliate_info',
41
+				'content' => $this->_show_reg_footer_stop(),
42
+				'options' => array(
43
+					'tipLocation'    => 'right',
44
+					'tipAdjustmentY' => -50,
45
+					'tipAdjustmentX' => 15,
46
+				),
47
+			),
48 48
 
49
-            60 => array(
50
-                'id'      => 'help_tour_activation',
51
-                'content' => $this->_help_tour_activation_stop(),
52
-                'options' => array(
53
-                    'tipLocation'    => 'right',
54
-                    'tipAdjustmentY' => -50,
55
-                    'tipAdjustmentX' => 15,
56
-                ),
57
-            ),
58
-        );
59
-    }
49
+			60 => array(
50
+				'id'      => 'help_tour_activation',
51
+				'content' => $this->_help_tour_activation_stop(),
52
+				'options' => array(
53
+					'tipLocation'    => 'right',
54
+					'tipAdjustmentY' => -50,
55
+					'tipAdjustmentX' => 15,
56
+				),
57
+			),
58
+		);
59
+	}
60 60
 
61 61
 
62
-    protected function _start()
63
-    {
64
-        $content = '<h3>' . __('Admin Options', 'event_espresso') . '</h3>';
65
-        $content .= '<p>'
66
-                    . __(
67
-                        'This tour of the Admin Options page will go over different areas of the screen to help you understand what they are used for.',
68
-                        'event_espresso'
69
-                    ) . '</p>';
70
-        return $content;
71
-    }
62
+	protected function _start()
63
+	{
64
+		$content = '<h3>' . __('Admin Options', 'event_espresso') . '</h3>';
65
+		$content .= '<p>'
66
+					. __(
67
+						'This tour of the Admin Options page will go over different areas of the screen to help you understand what they are used for.',
68
+						'event_espresso'
69
+					) . '</p>';
70
+		return $content;
71
+	}
72 72
 
73
-    protected function _use_remote_logging_stop()
74
-    {
75
-        return '<p>'
76
-               . __(
77
-                   ' This option sends all Event Espresso debugging data and get / post variables to the specified URL below.',
78
-                   'event_espresso'
79
-               ) . '</p>';
80
-    }
73
+	protected function _use_remote_logging_stop()
74
+	{
75
+		return '<p>'
76
+			   . __(
77
+				   ' This option sends all Event Espresso debugging data and get / post variables to the specified URL below.',
78
+				   'event_espresso'
79
+			   ) . '</p>';
80
+	}
81 81
 
82
-    protected function _show_reg_footer_stop()
83
-    {
84
-        return '<p>'
85
-               . __(
86
-                   'Support us by adding a small link to Event Espresso in your event pages. You can even earn money for yourself by adding your affiliate link there!',
87
-                   'event_espresso'
88
-               ) . '</p>';
89
-    }
82
+	protected function _show_reg_footer_stop()
83
+	{
84
+		return '<p>'
85
+			   . __(
86
+				   'Support us by adding a small link to Event Espresso in your event pages. You can even earn money for yourself by adding your affiliate link there!',
87
+				   'event_espresso'
88
+			   ) . '</p>';
89
+	}
90 90
 
91
-    protected function _help_tour_activation_stop()
92
-    {
93
-        return '<p>' . __('Turn these help tours on / off for Event Espresso pages.', 'event_espresso') . '</p>';
94
-    }
91
+	protected function _help_tour_activation_stop()
92
+	{
93
+		return '<p>' . __('Turn these help tours on / off for Event Espresso pages.', 'event_espresso') . '</p>';
94
+	}
95 95
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 
62 62
     protected function _start()
63 63
     {
64
-        $content = '<h3>' . __('Admin Options', 'event_espresso') . '</h3>';
64
+        $content = '<h3>'.__('Admin Options', 'event_espresso').'</h3>';
65 65
         $content .= '<p>'
66 66
                     . __(
67 67
                         'This tour of the Admin Options page will go over different areas of the screen to help you understand what they are used for.',
68 68
                         'event_espresso'
69
-                    ) . '</p>';
69
+                    ).'</p>';
70 70
         return $content;
71 71
     }
72 72
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
                . __(
77 77
                    ' This option sends all Event Espresso debugging data and get / post variables to the specified URL below.',
78 78
                    'event_espresso'
79
-               ) . '</p>';
79
+               ).'</p>';
80 80
     }
81 81
 
82 82
     protected function _show_reg_footer_stop()
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
                . __(
86 86
                    'Support us by adding a small link to Event Espresso in your event pages. You can even earn money for yourself by adding your affiliate link there!',
87 87
                    'event_espresso'
88
-               ) . '</p>';
88
+               ).'</p>';
89 89
     }
90 90
 
91 91
     protected function _help_tour_activation_stop()
92 92
     {
93
-        return '<p>' . __('Turn these help tours on / off for Event Espresso pages.', 'event_espresso') . '</p>';
93
+        return '<p>'.__('Turn these help tours on / off for Event Espresso pages.', 'event_espresso').'</p>';
94 94
     }
95 95
 }
Please login to merge, or discard this patch.
general_settings/help_tabs/general_settings_admin_options.help_tab.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,12 +32,12 @@
 block discarded – undo
32 32
 <li>
33 33
 <strong><?php esc_html_e('Event Espresso Affiliate ID', 'event_espresso'); ?></strong><br />
34 34
 <?php printf(
35
-    esc_html__(
36
-        'You can also monetize this link by signing up to our %1$saffiliate program%2$s and adding in your affiliate ID here.',
37
-        'event_espresso'
38
-    ),
39
-    '<a href="https://eventespresso.com/affiliates/">',
40
-    '</a>'
35
+	esc_html__(
36
+		'You can also monetize this link by signing up to our %1$saffiliate program%2$s and adding in your affiliate ID here.',
37
+		'event_espresso'
38
+	),
39
+	'<a href="https://eventespresso.com/affiliates/">',
40
+	'</a>'
41 41
 ); ?>
42 42
 </li>
43 43
 </ul>
Please login to merge, or discard this patch.