Completed
Branch dev (22bd0c)
by
unknown
24:44 queued 18:15
created
event_single_caff/templates/admin-event-single-settings.template.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -4,10 +4,10 @@  discard block
 block discarded – undo
4 4
 
5 5
 add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
6 6
 $values = EEH_Form_Fields::prep_answer_options(
7
-    array(
8
-        array('id' => 1, 'text' => esc_html__('Yes', 'event_espresso')),
9
-        array('id' => 0, 'text' => esc_html__('No', 'event_espresso')),
10
-    )
7
+	array(
8
+		array('id' => 1, 'text' => esc_html__('Yes', 'event_espresso')),
9
+		array('id' => 0, 'text' => esc_html__('No', 'event_espresso')),
10
+	)
11 11
 );
12 12
 ?>
13 13
 
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 
16 16
 <h2 class="ee-admin-settings-hdr">
17 17
     <?php esc_html_e(
18
-        'Single Event Pages',
19
-        'event_espresso'
20
-    ); ?><?php // echo EEH_Template::get_help_tab_link('event_single_settings_info');?>
18
+		'Single Event Pages',
19
+		'event_espresso'
20
+	); ?><?php // echo EEH_Template::get_help_tab_link('event_single_settings_info');?>
21 21
 </h2>
22 22
 <table class="form-table">
23 23
     <tbody>
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
         </th>
30 30
         <td>
31 31
             <?php echo EEH_Form_Fields::select(
32
-                'display_status_banner_single',
33
-                $display_status_banner_single,
34
-                $values,
35
-                'display_status_banner_single',
36
-                'display_status_banner_single'
37
-            ); ?>
32
+				'display_status_banner_single',
33
+				$display_status_banner_single,
34
+				$values,
35
+				'display_status_banner_single',
36
+				'display_status_banner_single'
37
+			); ?>
38 38
             <p class="description"><?php
39
-                esc_html_e(
40
-                    'Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the single event page.',
41
-                    'event_espresso'
42
-                ); ?></p>
39
+				esc_html_e(
40
+					'Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the single event page.',
41
+					'event_espresso'
42
+				); ?></p>
43 43
         </td>
44 44
     </tr>
45 45
 
@@ -47,23 +47,23 @@  discard block
 block discarded – undo
47 47
         <th>
48 48
             <label for="display_venue">
49 49
                 <?php esc_html_e('Display Venue Details', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
50
-                    'display_addresses_in_reg_form_info'
51
-                ); ?>
50
+					'display_addresses_in_reg_form_info'
51
+				); ?>
52 52
             </label>
53 53
         </th>
54 54
         <td>
55 55
             <?php echo EEH_Form_Fields::select(
56
-                'display_venue',
57
-                $display_venue,
58
-                $values,
59
-                'display_venue',
60
-                'display_venue'
61
-            ); ?>
56
+				'display_venue',
57
+				$display_venue,
58
+				$values,
59
+				'display_venue',
60
+				'display_venue'
61
+			); ?>
62 62
             <p class="description"><?php
63
-                esc_html_e(
64
-                    'Do not use this if you are using the venue shortcodes in your event description.',
65
-                    'event_espresso'
66
-                ); ?></p>
63
+				esc_html_e(
64
+					'Do not use this if you are using the venue shortcodes in your event description.',
65
+					'event_espresso'
66
+				); ?></p>
67 67
         </td>
68 68
     </tr>
69 69
 
@@ -75,37 +75,37 @@  discard block
 block discarded – undo
75 75
         </th>
76 76
         <td>
77 77
             <?php
78
-            echo EEH_Form_Fields::select(
79
-                'use_sortable_display_order',
80
-                $use_sortable_display_order,
81
-                $values,
82
-                'EED_Events_Single_use_sortable_display_order',
83
-                'EED_Events_Single_use_sortable_display_order'
84
-            );
85
-            ?>
78
+			echo EEH_Form_Fields::select(
79
+				'use_sortable_display_order',
80
+				$use_sortable_display_order,
81
+				$values,
82
+				'EED_Events_Single_use_sortable_display_order',
83
+				'EED_Events_Single_use_sortable_display_order'
84
+			);
85
+			?>
86 86
         </td>
87 87
     </tr>
88 88
 
89 89
     <tr>
90 90
         <th>
91 91
             <?php esc_html_e('Display Order', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
92
-                'display_addresses_in_reg_form_info'
93
-            ); ?>
92
+				'display_addresses_in_reg_form_info'
93
+			); ?>
94 94
         </th>
95 95
         <td>
96 96
 
97 97
             <?php wp_nonce_field(
98
-                'espresso_update_event_single_order',
99
-                'espresso_update_event_single_order_nonce',
100
-                false
101
-            ); ?>
98
+				'espresso_update_event_single_order',
99
+				'espresso_update_event_single_order_nonce',
100
+				false
101
+			); ?>
102 102
             <?php echo wp_kses($event_single_display_order, AllowedTags::getWithFormTags()); ?>
103 103
 
104 104
             <p class="description"><?php
105
-                esc_html_e(
106
-                    'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the single event page.',
107
-                    'event_espresso'
108
-                ); ?></p>
105
+				esc_html_e(
106
+					'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the single event page.',
107
+					'event_espresso'
108
+				); ?></p>
109 109
 
110 110
         </td>
111 111
     </tr>
Please login to merge, or discard this patch.
admin_pages/messages/help_tabs/messages_settings_messengers.help_tab.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -3,79 +3,79 @@
 block discarded – undo
3 3
 </p>
4 4
 <p>
5 5
     <?php esc_html_e(
6
-        'You can select Messengers via the tabs across the top of the settings page. The available messengers you see depends on what version of Event Espresso you have and what addons are installed. Every install include an "Email" messenger tab.  When you click one of those tabs it will display that messenger.',
7
-        'event_espresso'
8
-    ); ?>
6
+		'You can select Messengers via the tabs across the top of the settings page. The available messengers you see depends on what version of Event Espresso you have and what addons are installed. Every install include an "Email" messenger tab.  When you click one of those tabs it will display that messenger.',
7
+		'event_espresso'
8
+	); ?>
9 9
 </p>
10 10
 <p>
11 11
     <?php esc_html_e(
12
-        'There are two ways to determine whether a messenger is active or not.  The first way is via the messenger tab itself.',
13
-        'event_espresso'
14
-    ); ?>
12
+		'There are two ways to determine whether a messenger is active or not.  The first way is via the messenger tab itself.',
13
+		'event_espresso'
14
+	); ?>
15 15
 </p>
16 16
 <p>
17 17
     <?php printf(
18
-        esc_html__(
19
-            'The green colored gear %s indicates that this messenger is currently active.',
20
-            'event_espresso'
21
-        ),
22
-        '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '"'
23
-        . ' alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />'
24
-    );
25
-    printf(
26
-        esc_html__(
27
-            ' The white colored gear %s indicates the messenger is inactive. This is very helpful for seeing at a glance all the messengers that are active when you first view the page.',
28
-            'event_espresso'
29
-        ),
30
-        '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png'
31
-        . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />'
32
-    ); ?>
18
+		esc_html__(
19
+			'The green colored gear %s indicates that this messenger is currently active.',
20
+			'event_espresso'
21
+		),
22
+		'<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '"'
23
+		. ' alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />'
24
+	);
25
+	printf(
26
+		esc_html__(
27
+			' The white colored gear %s indicates the messenger is inactive. This is very helpful for seeing at a glance all the messengers that are active when you first view the page.',
28
+			'event_espresso'
29
+		),
30
+		'<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png'
31
+		. '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />'
32
+	); ?>
33 33
 </p>
34 34
 <p>
35 35
     <?php esc_html_e(
36
-        'The second way to determine whether a messenger is active or not is via the "on/off" button in the top right corner of the active messenger displayed content:',
37
-        'event_espresso'
38
-    ); ?>
36
+		'The second way to determine whether a messenger is active or not is via the "on/off" button in the top right corner of the active messenger displayed content:',
37
+		'event_espresso'
38
+	); ?>
39 39
 </p>
40 40
 <p>
41 41
     <?php printf(
42
-        esc_html__(
43
-            '%1$s means of course that the messenger is active and %2$s means the messenger is inactive.',
44
-            'event_espresso'
45
-        ),
46
-        '<div class="switch">'
47
-        . '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked disabled>'
48
-        . '<label for="ee-on-off-toggle-on"></label>'
49
-        . '</div>',
50
-        '<div class="switch">'
51
-        . '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" disabled>'
52
-        . '<label for="ee-on-off-toggle-on"></label>'
53
-        . '</div>'
54
-    ); ?>
42
+		esc_html__(
43
+			'%1$s means of course that the messenger is active and %2$s means the messenger is inactive.',
44
+			'event_espresso'
45
+		),
46
+		'<div class="switch">'
47
+		. '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked disabled>'
48
+		. '<label for="ee-on-off-toggle-on"></label>'
49
+		. '</div>',
50
+		'<div class="switch">'
51
+		. '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" disabled>'
52
+		. '<label for="ee-on-off-toggle-on"></label>'
53
+		. '</div>'
54
+	); ?>
55 55
 </p>
56 56
 <p>
57 57
     <?php
58
-    esc_html_e(
59
-        'The on/off toggle is also what you use to activate or deactivate a messenger.',
60
-        'event_espresso'
61
-    ); ?>
58
+	esc_html_e(
59
+		'The on/off toggle is also what you use to activate or deactivate a messenger.',
60
+		'event_espresso'
61
+	); ?>
62 62
 </p>
63 63
 <p>
64 64
     <?php esc_html_e(
65
-        'What happens when you click the toggle to activate is the messenger is activated and the system determines what default message types are activated with the messenger.  Then, if there are any default settings for either the messenger or message types those settings are saved.  Next, the system will generate any default templates (if none have been generated before, if there are previously generated templates then they are reactivated).  Finally, you will see the display change to reflect that the messenger is active. If the messenger has settings you can modify them then. Any message types that have settings will also automatically expand so you can see the default settings and make any changes as necessary to fit your needs. Usually the defaults are sufficient however.',
66
-        'event_espresso'
67
-    ); ?>
65
+		'What happens when you click the toggle to activate is the messenger is activated and the system determines what default message types are activated with the messenger.  Then, if there are any default settings for either the messenger or message types those settings are saved.  Next, the system will generate any default templates (if none have been generated before, if there are previously generated templates then they are reactivated).  Finally, you will see the display change to reflect that the messenger is active. If the messenger has settings you can modify them then. Any message types that have settings will also automatically expand so you can see the default settings and make any changes as necessary to fit your needs. Usually the defaults are sufficient however.',
66
+		'event_espresso'
67
+	); ?>
68 68
 </p>
69 69
 <p>
70 70
     <?php esc_html_e(
71
-        'When you deactivate a messenger, the system will first check if there are any custom event templates for that messenger. If there are you will be unable to deactivate the messenger. This is a fail safe to make sure you know that no messages will go out for those specific events so you don\'t accidentally deactivate.  If this check passes, then the system will deactivate any global templates for that messenger (note the templates are not erased, they just become inactive, so if you decide to reactivate the messenger later all your customizations are preserved). Then the display will change to reflect the deactivation.',
72
-        'event_espresso'
73
-    ); ?>
71
+		'When you deactivate a messenger, the system will first check if there are any custom event templates for that messenger. If there are you will be unable to deactivate the messenger. This is a fail safe to make sure you know that no messages will go out for those specific events so you don\'t accidentally deactivate.  If this check passes, then the system will deactivate any global templates for that messenger (note the templates are not erased, they just become inactive, so if you decide to reactivate the messenger later all your customizations are preserved). Then the display will change to reflect the deactivation.',
72
+		'event_espresso'
73
+	); ?>
74 74
 </p>
75 75
 <p>
76 76
     <strong><?php esc_html_e('Important', 'event_espresso'); ?></strong><br />
77 77
     <?php esc_html_e(
78
-        'Although customizations made to global templates are preserved when a messenger is deactivated, any settings for that messenger (or the message types that were attached to it) are lost on deactivation.  Also, once you deactivate a messenger, no more messages will be delivered using that messenger for any of your events.',
79
-        'event_espresso'
80
-    ); ?>
78
+		'Although customizations made to global templates are preserved when a messenger is deactivated, any settings for that messenger (or the message types that were attached to it) are lost on deactivation.  Also, once you deactivate a messenger, no more messages will be delivered using that messenger for any of your events.',
79
+		'event_espresso'
80
+	); ?>
81 81
 </p>
Please login to merge, or discard this patch.
modules/gateways/Invoice/lib/invoice_functions.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -13,36 +13,36 @@  discard block
 block discarded – undo
13 13
  */
14 14
 function espresso_invoice_template_files($class_file)
15 15
 {
16
-    $files = [];
17
-    // read our template dir and build an array of files
18
-    $directory_handle = opendir(dirname($class_file) . '/lib/templates/css/');
19
-    //if we managed to open the directory
20
-    if ($directory_handle) {
21
-        /** @var RequestInterface $request */
22
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
23
-        $skip = [
24
-            '.',
25
-            '..',
26
-            '.DS_Store',
27
-            '.svn',
28
-            'images',
29
-            'index.php',
30
-            'print',
31
-            basename($request->getServerParam('PHP_SELF')),
32
-        ];
33
-        // loop through all of the files
34
-        while (false !== ($fname = readdir($directory_handle))) {
35
-            // if the file is not this file, and does not start with a '.' or '..',
36
-            // then store it for later display
37
-            if (! in_array($fname, $skip, true)) {
38
-                $files[] = $fname;
39
-            }
40
-        }
41
-        // close the directory
42
-        closedir($directory_handle);
43
-    }
16
+	$files = [];
17
+	// read our template dir and build an array of files
18
+	$directory_handle = opendir(dirname($class_file) . '/lib/templates/css/');
19
+	//if we managed to open the directory
20
+	if ($directory_handle) {
21
+		/** @var RequestInterface $request */
22
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
23
+		$skip = [
24
+			'.',
25
+			'..',
26
+			'.DS_Store',
27
+			'.svn',
28
+			'images',
29
+			'index.php',
30
+			'print',
31
+			basename($request->getServerParam('PHP_SELF')),
32
+		];
33
+		// loop through all of the files
34
+		while (false !== ($fname = readdir($directory_handle))) {
35
+			// if the file is not this file, and does not start with a '.' or '..',
36
+			// then store it for later display
37
+			if (! in_array($fname, $skip, true)) {
38
+				$files[] = $fname;
39
+			}
40
+		}
41
+		// close the directory
42
+		closedir($directory_handle);
43
+	}
44 44
 
45
-    return $files;
45
+	return $files;
46 46
 }
47 47
 
48 48
 
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
  */
57 57
 function espresso_invoice_is_selected($input_item, $selected = '')
58 58
 {
59
-    if ($input_item === $selected) {
60
-        return 'selected';
61
-    }
62
-    return '';
59
+	if ($input_item === $selected) {
60
+		return 'selected';
61
+	}
62
+	return '';
63 63
 }
64 64
\ No newline at end of file
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Transaction_Shortcodes.lib.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
                    && isset($this->_extra_data['data'])
270 270
                    && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment
271 271
             : $payment;
272
-        if (! $transaction instanceof EE_Transaction) {
272
+        if ( ! $transaction instanceof EE_Transaction) {
273 273
             return '';
274 274
         }
275 275
         switch ($shortcode) {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
                 $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
288 288
                 return sprintf(
289 289
                     esc_html__('%sClick here for Invoice%s', 'event_espresso'),
290
-                    '<a href="' . $invoice_url . '">',
290
+                    '<a href="'.$invoice_url.'">',
291 291
                     '</a>'
292 292
                 );
293 293
                 break;
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
                 return $this->_data->total_ticket_count;
362 362
                 break;
363 363
             case '[TRANSACTION_ADMIN_URL]':
364
-                require_once EE_CORE . 'admin/EE_Admin_Page.core.php';
364
+                require_once EE_CORE.'admin/EE_Admin_Page.core.php';
365 365
                 $query_args = array(
366 366
                     'page'   => 'espresso_transactions',
367 367
                     'action' => 'view_transaction',
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
             case '[RECEIPT_URL]':
374 374
                 // get primary_registration
375 375
                 $reg = $this->_data->primary_reg_obj;
376
-                if (! $reg instanceof EE_Registration) {
376
+                if ( ! $reg instanceof EE_Registration) {
377 377
                     return '';
378 378
                 }
379 379
                 return $reg->receipt_url();
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
         if (empty($invoice_logo_url)) {
493 493
             return '';
494 494
         }
495
-        if (! $img_tags) {
495
+        if ( ! $img_tags) {
496 496
             return $invoice_logo_url;
497 497
         }
498 498
         // image tags have been requested.
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
         } else {
504 504
             $image_width = $image_size[0];
505 505
         }
506
-        return '<img class="logo screen" src="' . esc_url_raw($invoice_logo_url) . '" width="' . esc_attr($image_width) . '" alt="logo" />';
506
+        return '<img class="logo screen" src="'.esc_url_raw($invoice_logo_url).'" width="'.esc_attr($image_width).'" alt="logo" />';
507 507
     }
508 508
 
509 509
 
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
      */
541 541
     private function _get_invoice_payment_method()
542 542
     {
543
-        if (! $this->_invoice_pm instanceof EE_Payment_Method) {
543
+        if ( ! $this->_invoice_pm instanceof EE_Payment_Method) {
544 544
             $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
545 545
             $transaction = ! $transaction instanceof EE_Transaction
546 546
                            && is_array($this->_extra_data)
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
         $attrs = $this->_get_shortcode_attrs($shortcode);
609 609
         // prefix?
610 610
         $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso');
611
-        return $prefix . $payee_tax_number;
611
+        return $prefix.$payee_tax_number;
612 612
     }
613 613
 
614 614
 
@@ -632,16 +632,16 @@  discard block
 block discarded – undo
632 632
         }
633 633
         if (empty($payee_address)) {
634 634
             $organization = EE_Registry::instance()->CFG->organization;
635
-            $payee_address = $organization->get_pretty('address_1') . '<br>';
635
+            $payee_address = $organization->get_pretty('address_1').'<br>';
636 636
             $payee_address .= ! empty($organization->address_2)
637
-                ? $organization->get_pretty('address_2') . '<br>'
637
+                ? $organization->get_pretty('address_2').'<br>'
638 638
                 : '';
639
-            $payee_address .= $organization->get_pretty('city') . '<br>';
639
+            $payee_address .= $organization->get_pretty('city').'<br>';
640 640
             // state
641 641
             $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
642 642
             $payee_address .= $state instanceof EE_State ? $state->name() : '';
643 643
             // Country
644
-            $payee_address .= ! empty($organization->CNT_ISO) ? ', ' . $organization->CNT_ISO . '<br>' : '';
644
+            $payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : '';
645 645
             $payee_address .= ! empty($organization->zip) ? $organization->zip : '';
646 646
         }
647 647
         return $payee_address;
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
     {
678 678
         $reg = $this->_data->primary_reg_obj;
679 679
         $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : '';
680
-        if (! $reg instanceof EE_Registration || empty($message_type)) {
680
+        if ( ! $reg instanceof EE_Registration || empty($message_type)) {
681 681
             return '';
682 682
         }
683 683
         $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false;
@@ -685,13 +685,13 @@  discard block
 block discarded – undo
685 685
             ? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso');
686 686
         $switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label;
687 687
         $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url();
688
-        if (! $button) {
688
+        if ( ! $button) {
689 689
             return $switch_to_url;
690 690
         }
691
-        if (! empty($switch_to_url)) {
691
+        if ( ! empty($switch_to_url)) {
692 692
             return '
693
-	<form method="post" action="' . $switch_to_url . '" >
694
-		<input class="print_button" type="submit" value="' . $switch_to_label . '" />
693
+	<form method="post" action="' . $switch_to_url.'" >
694
+		<input class="print_button" type="submit" value="' . $switch_to_label.'" />
695 695
 	</form>
696 696
 			';
697 697
         }
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
     private function _get_subtotal($tax = false)
710 710
     {
711 711
         $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null;
712
-        if (! $grand_total instanceof EE_Line_Item) {
712
+        if ( ! $grand_total instanceof EE_Line_Item) {
713 713
             return 0;
714 714
         }
715 715
         return $tax ? $grand_total->get_total_tax() : $grand_total->get_items_total();
@@ -736,11 +736,11 @@  discard block
 block discarded – undo
736 736
             $class = isset($attrs['class']) ? $attrs['class'] : 'callout';
737 737
             $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
738 738
             $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p';
739
-            $opening_tag = ! empty($container_tag) ? '<' . $container_tag : '';
740
-            $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="' . $class . '"' : $opening_tag;
739
+            $opening_tag = ! empty($container_tag) ? '<'.$container_tag : '';
740
+            $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag;
741 741
             $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag;
742
-            $closing_tag = ! empty($container_tag) ? '</' . $container_tag . '>' : '';
743
-            $content = $opening_tag . sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>') . $closing_tag;
742
+            $closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : '';
743
+            $content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag;
744 744
             // we need to re run this string through the parser to catch any shortcodes that are in it.
745 745
             $owing_content = $this->_shortcode_helper->parse_message_template(
746 746
                 $content,
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
         try {
783 783
             if ($transaction_created instanceof DateTime) {
784 784
                 $date_due = $transaction_created->add(
785
-                    new DateInterval('P' . $days_until_due . 'D')
785
+                    new DateInterval('P'.$days_until_due.'D')
786 786
                 )->format($format);
787 787
             } else {
788 788
                 throw new Exception();
@@ -794,6 +794,6 @@  discard block
 block discarded – undo
794 794
                 'event_espresso'
795 795
             );
796 796
         }
797
-        return $prefix_text . $date_due;
797
+        return $prefix_text.$date_due;
798 798
     }
799 799
 }
Please login to merge, or discard this patch.
Indentation   +775 added lines, -775 removed lines patch added patch discarded remove patch
@@ -16,783 +16,783 @@
 block discarded – undo
16 16
  */
17 17
 class EE_Transaction_Shortcodes extends EE_Shortcodes
18 18
 {
19
-    /**
20
-     * @var EE_Payment_Method $_invoice_pm the invoice payment method for use in invoices etc
21
-     */
22
-    protected $_invoice_pm;
23
-
24
-
25
-    protected function _init_props()
26
-    {
27
-        $this->label = esc_html__('Transaction Shortcodes', 'event_espresso');
28
-        $this->description = esc_html__('All shortcodes specific to transaction related data', 'event_espresso');
29
-        $this->_shortcodes = array(
30
-            '[TXN_ID]'                          => esc_html__('The transaction id for the purchase.', 'event_espresso'),
31
-            '[PAYMENT_URL]'                     => esc_html__(
32
-                'This is a link to make a payment for the event',
33
-                'event_espresso'
34
-            ),
35
-            '[PAYMENT_LINK_IF_NEEDED_*]'        => esc_html__(
36
-                'This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:',
37
-                'event_espresso'
38
-            )
39
-                                                   . '<ul>'
40
-                                                   . '<li>'
41
-                                                   . sprintf(
42
-                                                       esc_html__(
43
-                                                           '%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").',
44
-                                                           'event_espresso'
45
-                                                       ),
46
-                                                       '<strong>',
47
-                                                       '</strong>'
48
-                                                   )
49
-                                                   . '</li>'
50
-                                                   . '<li>'
51
-                                                   . sprintf(
52
-                                                       esc_html__(
53
-                                                           '%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)',
54
-                                                           'event_espresso'
55
-                                                       ),
56
-                                                       '<strong>',
57
-                                                       '</strong>'
58
-                                                   )
59
-                                                   . '</li>'
60
-                                                   . '<li>'
61
-                                                   . sprintf(
62
-                                                       esc_html__(
63
-                                                           '%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").',
64
-                                                           'event_espresso'
65
-                                                       ),
66
-                                                       '<strong>',
67
-                                                       '</strong>'
68
-                                                   )
69
-                                                   . '</li>'
70
-                                                   . '</ul>',
71
-            '[PAYMENT_DUE_DATE_*]'              => esc_html__(
72
-                'This is a special dynamic shortcode that allows one to output a payment due date.  It will only result in a date shown if there is money owing.  Three parameters are available on this shortcode:',
73
-                'event_espresso'
74
-            )
75
-                                                   . '<ul>'
76
-                                                   . '<li>'
77
-                                                   . sprintf(
78
-                                                       esc_html__(
79
-                                                           '%sformat:%s This is used to indicate what format the date is in.  Default is whatever is set as date formats for your website.',
80
-                                                           'event_espresso'
81
-                                                       ),
82
-                                                       '<strong>',
83
-                                                       '</strong>'
84
-                                                   )
85
-                                                   . '</li>'
86
-                                                   . '<li>'
87
-                                                   . sprintf(
88
-                                                       esc_html__(
89
-                                                           '%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due.  Defaults to 30.',
90
-                                                           'event_espresso'
91
-                                                       ),
92
-                                                       '<strong>',
93
-                                                       '</strong>'
94
-                                                   )
95
-                                                   . '</li>'
96
-                                                   . '<li>'
97
-                                                   . sprintf(
98
-                                                       esc_html__(
99
-                                                           '%sprefix_text:%s You can use this to indicate what text will prefix the date string.  Defaults to "Payment in full due by:"',
100
-                                                           'event_espresso'
101
-                                                       ),
102
-                                                       '<strong>',
103
-                                                       '</strong>'
104
-                                                   )
105
-                                                   . '</li>',
106
-            '[INVOICE_LINK]'                    => esc_html__(
107
-                'This is a full html link to the invoice',
108
-                'event_espresso'
109
-            ),
110
-            '[INVOICE_URL]'                     => esc_html__(
111
-                'This is just the url for the invoice',
112
-                'event_espresso'
113
-            ),
114
-            '[INVOICE_LOGO_URL]'                => esc_html__(
115
-                'This returns the url for the logo uploaded via the invoice settings page.',
116
-                'event_espresso'
117
-            ),
118
-            '[INVOICE_LOGO]'                    => esc_html__(
119
-                'This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.',
120
-                'event_espresso'
121
-            ),
122
-            '[INVOICE_PAYEE_NAME]'              => esc_html__(
123
-                'This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.',
124
-                'event_espresso'
125
-            ),
126
-            '[INVOICE_PAYEE_ADDRESS]'           => esc_html__(
127
-                'This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.',
128
-                'event_espresso'
129
-            ),
130
-            '[INVOICE_PAYMENT_INSTRUCTIONS]'    => esc_html__(
131
-                'This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page',
132
-                'event_espresso'
133
-            ),
134
-            '[INVOICE_PAYEE_EMAIL]'             => esc_html__(
135
-                'This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.',
136
-                'event_espresso'
137
-            ),
138
-            '[INVOICE_PAYEE_TAX_NUMBER_*]'      => sprintf(
139
-                esc_html__(
140
-                    'This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number.  It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56.  If you have no tax number in your settings, then no prefix will be output either.',
141
-                    'event_espresso'
142
-                ),
143
-                '<code>',
144
-                '</code>'
145
-            ),
146
-            '[TOTAL_COST]'                      => esc_html__('The total cost for the transaction', 'event_espresso'),
147
-            '[TXN_STATUS]'                      => esc_html__(
148
-                'The transaction status for the transaction.',
149
-                'event_espresso'
150
-            ),
151
-            '[TXN_STATUS_ID]'                   => esc_html__(
152
-                'The ID representing the transaction status as saved in the db.  This tends to be useful for including with css classes for styling certain statuses differently from others.',
153
-                'event_espresso'
154
-            ),
155
-            '[PAYMENT_STATUS]'                  => esc_html__(
156
-                'The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.',
157
-                'event_espresso'
158
-            ),
159
-            '[PAYMENT_GATEWAY]'                 => esc_html__(
160
-                'The payment gateway used for the transaction',
161
-                'event_espresso'
162
-            ),
163
-            '[AMOUNT_PAID]'                     => esc_html__(
164
-                'The amount paid or refunded.  This will only have a value if there was a payment or refund at the time of generating the message.',
165
-                'event_espresso'
166
-            ),
167
-            '[LAST_AMOUNT_PAID]'                => esc_html__(
168
-                'This is the last payment or refund made on the transaction related to the message being generated.',
169
-                'event_espresso'
170
-            ),
171
-            '[TOTAL_AMOUNT_PAID]'               => esc_html__(
172
-                'This parses to the total amount paid over all payments',
173
-                'event_espresso'
174
-            ),
175
-            '[TOTAL_OWING]'                     => esc_html__(
176
-                'The total owing on a transaction with no attributes.',
177
-                'event_espresso'
178
-            ),
179
-            '[TXN_SUBTOTAL]'                    => esc_html__('The subtotal for all txn line items.', 'event_espresso'),
180
-            '[TXN_TAX_SUBTOTAL]'                => esc_html__('The subtotal for all tax line items.', 'event_espresso'),
181
-            '[OWING_STATUS_MESSAGE_*]'          => esc_html__(
182
-                'A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:',
183
-                'event_espresso'
184
-            )
185
-                                                   . '<p></ul>'
186
-                                                   . '<li><strong>still_owing</strong>:'
187
-                                                   . esc_html__(
188
-                                                       'If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:',
189
-                                                       'event_espresso'
190
-                                                   )
191
-                                                   . sprintf(
192
-                                                       esc_html__('%sPlease make a payment.%s', 'event_espresso'),
193
-                                                       '<a href="[PAYMENT_URL]" class="noPrint">',
194
-                                                       '</a>'
195
-                                                   )
196
-                                                   . '</li>'
197
-                                                   .
198
-                                                   '<li><strong>none_owing</strong>:'
199
-                                                   . esc_html__(
200
-                                                       'If the transaction is paid in full, then you can indicate how this gets displayed.  Note, that it defaults to just be the total owing.',
201
-                                                       'event_espresso'
202
-                                                   )
203
-                                                   . '</li></ul></p>',
204
-            '[TXN_TOTAL_TICKETS]'               => esc_html__(
205
-                'The total number of all tickets purchased in a transaction',
206
-                'event_espresso'
207
-            ),
208
-            '[TKT_QTY_PURCHASED]'               => sprintf(
209
-                esc_html__(
210
-                    'The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s',
211
-                    'event_espresso'
212
-                ),
213
-                '<strong>',
214
-                '</strong>'
215
-            ),
216
-            '[TRANSACTION_ADMIN_URL]'           => esc_html__(
217
-                'The url to the admin page for this transaction',
218
-                'event_espresso'
219
-            ),
220
-            '[RECEIPT_URL]'                     => esc_html__(
221
-                'This parses to the generated url for retrieving the receipt for the transaction',
222
-                'event_espresso'
223
-            ),
224
-            '[INVOICE_RECEIPT_SWITCHER_URL]'    => esc_html__(
225
-                'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active  then will parse to an empty string.',
226
-                'event_espresso'
227
-            ),
228
-            '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(
229
-                esc_html__(
230
-                    'The same as %1$s%2$s except this returns the html for a button linked to the invoice or receipt.',
231
-                    'event_espresso'
232
-                ),
233
-                '<code>[INVOICE_RECEIPT_SWITCHER_URL]',
234
-                '</code>'
235
-            ),
236
-            '[LAST_PAYMENT_TRANSACTION_ID]'     => esc_html__(
237
-                'This will output the value of the payment transaction id for the last payment made on the transaction. Note, if a specific payment was included for message generation, that will be used when parsing the shortcode.',
238
-                'event_espresso'
239
-            ),
240
-        );
241
-    }
242
-
243
-
244
-    /**
245
-     * @param  string $shortcode the shortcode to be parsed.
246
-     * @return string parsed shortcode
247
-     * @throws EE_Error
248
-     * @throws InvalidArgumentException
249
-     * @throws ReflectionException
250
-     * @throws InvalidDataTypeException
251
-     * @throws InvalidInterfaceException
252
-     */
253
-    protected function _parser($shortcode)
254
-    {
255
-        // attempt to get the transaction.  Since this is potentially used in more fields, we may have to look in the
256
-        // _extra_data for the transaction.
257
-        $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
258
-        $transaction = ! $transaction instanceof EE_Transaction
259
-                       && is_array($this->_extra_data)
260
-                       && isset($this->_extra_data['data'])
261
-                       && $this->_extra_data['data'] instanceof EE_Messages_Addressee
262
-            ? $this->_extra_data['data']->txn
263
-            : $transaction;
264
-        // payment
265
-        $payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null;
266
-        $payment = ! $payment instanceof EE_Payment
267
-                   && is_array($this->_extra_data)
268
-                   && isset($this->_extra_data['data'])
269
-                   && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment
270
-            : $payment;
271
-        if (! $transaction instanceof EE_Transaction) {
272
-            return '';
273
-        }
274
-        switch ($shortcode) {
275
-            case '[TXN_ID]':
276
-                return $transaction->ID();
277
-                break;
278
-            case '[PAYMENT_URL]':
279
-                $payment_url = $transaction->payment_overview_url();
280
-                return empty($payment_url)
281
-                    ? esc_html__('http://dummypaymenturlforpreview.com', 'event_espresso')
282
-                    : $payment_url;
283
-                break;
284
-            case '[INVOICE_LINK]':
285
-                $invoice_url = $transaction->invoice_url();
286
-                $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
287
-                return sprintf(
288
-                    esc_html__('%sClick here for Invoice%s', 'event_espresso'),
289
-                    '<a href="' . $invoice_url . '">',
290
-                    '</a>'
291
-                );
292
-                break;
293
-            case '[INVOICE_URL]':
294
-                $invoice_url = $transaction->invoice_url();
295
-                return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
296
-                break;
297
-            case '[INVOICE_LOGO_URL]':
298
-                return $this->_get_invoice_logo();
299
-                break;
300
-            case '[INVOICE_LOGO]':
301
-                return $this->_get_invoice_logo(true);
302
-                break;
303
-            case '[INVOICE_PAYEE_NAME]':
304
-                return $this->_get_invoice_payee_name();
305
-                break;
306
-            case '[INVOICE_PAYEE_ADDRESS]':
307
-                return $this->_get_invoice_payee_address();
308
-                break;
309
-            case '[INVOICE_PAYMENT_INSTRUCTIONS]':
310
-                return $this->_get_invoice_payment_instructions();
311
-                break;
312
-            case '[INVOICE_PAYEE_EMAIL]':
313
-                return $this->_get_invoice_payee_email();
314
-                break;
315
-            case '[TOTAL_COST]':
316
-                $total = $transaction->total();
317
-                return ! empty($total) ? EEH_Template::format_currency($total) : '';
318
-                break;
319
-            case '[PAYMENT_STATUS]':
320
-                $status = $transaction->pretty_status();
321
-                return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso');
322
-                break; /**/
323
-            // note the [payment_status] shortcode is kind of misleading because payment status might be different
324
-            // from txn status so I'm adding this here for clarity.
325
-            case '[TXN_STATUS]':
326
-                $status = $transaction->pretty_status();
327
-                return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso');
328
-                break;
329
-            case '[TXN_STATUS_ID]':
330
-                return $transaction->status_ID();
331
-                break;
332
-            case '[PAYMENT_GATEWAY]':
333
-                return $this->_get_payment_gateway($transaction);
334
-                break;
335
-            case '[AMOUNT_PAID]':
336
-                return $payment instanceof EE_Payment
337
-                    ? EEH_Template::format_currency($payment->amount())
338
-                    : EEH_Template::format_currency(0);
339
-                break;
340
-            case '[LAST_AMOUNT_PAID]':
341
-                $last_payment = $transaction->last_payment();
342
-                return $last_payment instanceof EE_Payment
343
-                    ? EEH_Template::format_currency($last_payment->amount())
344
-                    : EEH_Template::format_currency(0);
345
-            case '[TOTAL_AMOUNT_PAID]':
346
-                return EEH_Template::format_currency($transaction->paid());
347
-                break;
348
-            case '[TOTAL_OWING]':
349
-                $total_owing = $transaction->remaining();
350
-                return EEH_Template::format_currency($total_owing);
351
-                break;
352
-            case '[TXN_SUBTOTAL]':
353
-                return EEH_Template::format_currency($this->_get_subtotal());
354
-                break;
355
-            case '[TXN_TAX_SUBTOTAL]':
356
-                return EEH_Template::format_currency($this->_get_subtotal(true));
357
-                break;
358
-            case '[TKT_QTY_PURCHASED]':
359
-            case '[TXN_TOTAL_TICKETS]':
360
-                return $this->_data->total_ticket_count;
361
-                break;
362
-            case '[TRANSACTION_ADMIN_URL]':
363
-                require_once EE_CORE . 'admin/EE_Admin_Page.core.php';
364
-                $query_args = array(
365
-                    'page'   => 'espresso_transactions',
366
-                    'action' => 'view_transaction',
367
-                    'TXN_ID' => $transaction->ID(),
368
-                );
369
-                $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php'));
370
-                return $url;
371
-                break;
372
-            case '[RECEIPT_URL]':
373
-                // get primary_registration
374
-                $reg = $this->_data->primary_reg_obj;
375
-                if (! $reg instanceof EE_Registration) {
376
-                    return '';
377
-                }
378
-                return $reg->receipt_url();
379
-                break;
380
-            case '[INVOICE_RECEIPT_SWITCHER_URL]':
381
-                return $this->_get_invoice_receipt_switcher(false);
382
-                break;
383
-            case '[INVOICE_RECEIPT_SWITCHER_BUTTON]':
384
-                return $this->_get_invoice_receipt_switcher();
385
-                break;
386
-            case '[LAST_PAYMENT_TRANSACTION_ID]':
387
-                $id = '';
388
-                $payment = $payment instanceof EE_Payment && $payment->ID() !== 0
389
-                    ? $payment
390
-                    : $transaction->last_payment();
391
-                if ($payment instanceof EE_Payment) {
392
-                    $id = $payment->txn_id_chq_nmbr();
393
-                }
394
-                return $id;
395
-                break;
396
-        }
397
-        if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== false) {
398
-            return $this->_get_custom_total_owing($shortcode);
399
-        }
400
-        if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== false) {
401
-            return $this->_get_invoice_payee_tax_number($shortcode);
402
-        }
403
-        if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== false) {
404
-            return $this->_get_payment_link_if_needed($shortcode);
405
-        }
406
-        if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) {
407
-            return $this->_get_payment_due_date($shortcode, $transaction);
408
-        }
409
-        return '';
410
-    }
411
-
412
-
413
-    /**
414
-     * parser for the [OWING_STATUS_MESSAGE_*] attribute type shortcode
415
-     *
416
-     * @since 4.5.0
417
-     * @param string $shortcode the incoming shortcode
418
-     * @return string parsed.
419
-     * @throws EE_Error
420
-     */
421
-    private function _get_custom_total_owing($shortcode)
422
-    {
423
-        $valid_shortcodes = array('transaction');
424
-        $attrs = $this->_get_shortcode_attrs($shortcode);
425
-        // ensure default is set.
426
-        $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
427
-        $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction
428
-            ? $addressee->txn->remaining() : 0;
429
-        if ($total_owing > 0) {
430
-            $owing_content = ! empty($attrs['still_owing'])
431
-                ? $attrs['still_owing']
432
-                : sprintf(
433
-                    esc_html__('%sPlease make a payment.%s', 'event_espresso'),
434
-                    '<a href="[PAYMENT_URL]" class="noPrint">',
435
-                    '</a>'
436
-                );
437
-            $owing_content = $this->_shortcode_helper->parse_message_template(
438
-                $owing_content,
439
-                $addressee,
440
-                $valid_shortcodes,
441
-                $this->_message_type,
442
-                $this->_messenger,
443
-                $this->_message
444
-            );
445
-        } else {
446
-            $owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : '';
447
-        }
448
-        return $owing_content;
449
-    }
450
-
451
-
452
-    /**
453
-     * @param EE_Transaction $transaction
454
-     * @return string
455
-     * @throws EE_Error
456
-     */
457
-    private function _get_payment_gateway($transaction)
458
-    {
459
-        if ($transaction instanceof EE_Transaction) {
460
-            $pm = $transaction->payment_method();
461
-        } else {
462
-            $pm = null;
463
-        }
464
-        return $pm instanceof EE_Payment_Method ? $pm->name() : '';
465
-    }
466
-
467
-
468
-    /**
469
-     * This retrieves a logo to be used for the invoice from whatever is set on the invoice logo settings page.  If its
470
-     * not present then the organization logo is used if its found (set on the organization settings page).
471
-     *
472
-     * @since 4.5.0
473
-     * @param bool $img_tags TRUE means to return with the img tag wrappers.  False just returns the url to the image.
474
-     * @return string url or html
475
-     * @throws EE_Error
476
-     * @throws InvalidArgumentException
477
-     * @throws InvalidDataTypeException
478
-     * @throws InvalidInterfaceException
479
-     */
480
-    private function _get_invoice_logo($img_tags = false)
481
-    {
482
-        $invoice_logo_url = '';
483
-        // try to get the invoice payment method's logo for this transaction image first
484
-        $pm = $this->_get_invoice_payment_method();
485
-        if ($pm instanceof EE_Payment_Method) {
486
-            $invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', true);
487
-        }
488
-        if (empty($invoice_logo_url)) {
489
-            $invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url;
490
-        }
491
-        if (empty($invoice_logo_url)) {
492
-            return '';
493
-        }
494
-        if (! $img_tags) {
495
-            return $invoice_logo_url;
496
-        }
497
-        // image tags have been requested.
498
-        $image_size = getimagesize($invoice_logo_url);
499
-        // if image is wider than 300px, set the width to 300
500
-        if ($image_size[0] > 300) {
501
-            $image_width = 300;
502
-        } else {
503
-            $image_width = $image_size[0];
504
-        }
505
-        return '<img class="logo screen" src="' . esc_url_raw($invoice_logo_url) . '" width="' . esc_attr($image_width) . '" alt="logo" />';
506
-    }
507
-
508
-
509
-    /**
510
-     * Used to retrieve the appropriate content for the invoice payee name shortcode
511
-     *
512
-     * @since 4.5.0
513
-     * @return string
514
-     * @throws EE_Error
515
-     * @throws InvalidArgumentException
516
-     * @throws InvalidDataTypeException
517
-     * @throws InvalidInterfaceException
518
-     */
519
-    private function _get_invoice_payee_name()
520
-    {
521
-        $payee_name = null;
522
-        $pm = $this->_get_invoice_payment_method();
523
-        if ($pm instanceof EE_Payment_Method) {
524
-            $payee_name = $pm->get_extra_meta('pdf_payee_name', true);
525
-        }
526
-        $payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name;
527
-        return $payee_name;
528
-    }
529
-
530
-
531
-    /**
532
-     * gets the default invoice payment method, but has a filter so it can be overridden
533
-     *
534
-     * @return EE_Payment_Method|null
535
-     * @throws EE_Error
536
-     * @throws InvalidArgumentException
537
-     * @throws InvalidDataTypeException
538
-     * @throws InvalidInterfaceException
539
-     */
540
-    private function _get_invoice_payment_method()
541
-    {
542
-        if (! $this->_invoice_pm instanceof EE_Payment_Method) {
543
-            $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
544
-            $transaction = ! $transaction instanceof EE_Transaction
545
-                           && is_array($this->_extra_data)
546
-                           && isset($this->_extra_data['data'])
547
-                           && $this->_extra_data['data'] instanceof EE_Messages_Addressee
548
-                ? $this->_extra_data['data']->txn : $transaction;
549
-            // get the invoice payment method, and remember it for the next call too
550
-            $this->_invoice_pm = apply_filters(
551
-                'FHEE__EE_Transaction_Shortcodes__get_payment_method__default',
552
-                EEM_Payment_Method::instance()->get_one_of_type('Invoice'),
553
-                $transaction
554
-            );
555
-        }
556
-        return $this->_invoice_pm;
557
-    }
558
-
559
-
560
-    /**
561
-     * Used to retrieve the appropriate content for the invoice payee email shortcode
562
-     *
563
-     * @since 4.5.0
564
-     * @return string
565
-     * @throws EE_Error
566
-     * @throws InvalidArgumentException
567
-     * @throws InvalidDataTypeException
568
-     * @throws InvalidInterfaceException
569
-     */
570
-    private function _get_invoice_payee_email()
571
-    {
572
-        $payee_email = null;
573
-        $pm = $this->_get_invoice_payment_method();
574
-        if ($pm instanceof EE_Payment_Method) {
575
-            $payee_email = $pm->get_extra_meta('pdf_payee_email', true);
576
-        }
577
-        $payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email')
578
-            : $payee_email;
579
-        return $payee_email;
580
-    }
581
-
582
-
583
-    /**
584
-     * Used to retrieve the appropriate content for the invoice payee tax number shortcode
585
-     *
586
-     * @since 4.5.0
587
-     * @param string $shortcode
588
-     * @return string
589
-     * @throws EE_Error
590
-     * @throws InvalidArgumentException
591
-     * @throws InvalidDataTypeException
592
-     * @throws InvalidInterfaceException
593
-     */
594
-    private function _get_invoice_payee_tax_number($shortcode)
595
-    {
596
-        $payee_tax_number = null;
597
-        $pm = $this->_get_invoice_payment_method();
598
-        if ($pm instanceof EE_Payment_Method) {
599
-            $payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', true);
600
-        }
601
-        $payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat
602
-            : $payee_tax_number;
603
-        if (empty($payee_tax_number)) {
604
-            return '';
605
-        }
606
-        // any attributes?
607
-        $attrs = $this->_get_shortcode_attrs($shortcode);
608
-        // prefix?
609
-        $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso');
610
-        return $prefix . $payee_tax_number;
611
-    }
612
-
613
-
614
-    /**
615
-     * Used to retrieve the appropriate content for the invoice payee address shortcode.
616
-     *
617
-     * @since 4.5.0
618
-     * @return string
619
-     * @throws EE_Error
620
-     * @throws InvalidArgumentException
621
-     * @throws ReflectionException
622
-     * @throws InvalidDataTypeException
623
-     * @throws InvalidInterfaceException
624
-     */
625
-    private function _get_invoice_payee_address()
626
-    {
627
-        $payee_address = null;
628
-        $pm = $this->_get_invoice_payment_method();
629
-        if ($pm instanceof EE_Payment_Method) {
630
-            $payee_address = $pm->get_extra_meta('pdf_payee_address', true);
631
-        }
632
-        if (empty($payee_address)) {
633
-            $organization = EE_Registry::instance()->CFG->organization;
634
-            $payee_address = $organization->get_pretty('address_1') . '<br>';
635
-            $payee_address .= ! empty($organization->address_2)
636
-                ? $organization->get_pretty('address_2') . '<br>'
637
-                : '';
638
-            $payee_address .= $organization->get_pretty('city') . '<br>';
639
-            // state
640
-            $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
641
-            $payee_address .= $state instanceof EE_State ? $state->name() : '';
642
-            // Country
643
-            $payee_address .= ! empty($organization->CNT_ISO) ? ', ' . $organization->CNT_ISO . '<br>' : '';
644
-            $payee_address .= ! empty($organization->zip) ? $organization->zip : '';
645
-        }
646
-        return $payee_address;
647
-    }
648
-
649
-
650
-    /**
651
-     * Used to retrieve the appropriate content for the invoice payment instructions shortcode.
652
-     *
653
-     * @since 4.5.0
654
-     * @return string
655
-     * @throws EE_Error
656
-     * @throws InvalidArgumentException
657
-     * @throws InvalidDataTypeException
658
-     * @throws InvalidInterfaceException
659
-     */
660
-    private function _get_invoice_payment_instructions()
661
-    {
662
-        $instructions = null;
663
-        $pm = $this->_get_invoice_payment_method();
664
-        return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', true) : '';
665
-    }
666
-
667
-
668
-    /**
669
-     * get invoice/receipt switch button or url.
670
-     *
671
-     * @param bool $button true (default) returns the html for a button, false just returns the url.
672
-     * @return string
673
-     * @throws EE_Error
674
-     */
675
-    protected function _get_invoice_receipt_switcher($button = true)
676
-    {
677
-        $reg = $this->_data->primary_reg_obj;
678
-        $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : '';
679
-        if (! $reg instanceof EE_Registration || empty($message_type)) {
680
-            return '';
681
-        }
682
-        $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false;
683
-        $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type
684
-            ? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso');
685
-        $switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label;
686
-        $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url();
687
-        if (! $button) {
688
-            return $switch_to_url;
689
-        }
690
-        if (! empty($switch_to_url)) {
691
-            return '
19
+	/**
20
+	 * @var EE_Payment_Method $_invoice_pm the invoice payment method for use in invoices etc
21
+	 */
22
+	protected $_invoice_pm;
23
+
24
+
25
+	protected function _init_props()
26
+	{
27
+		$this->label = esc_html__('Transaction Shortcodes', 'event_espresso');
28
+		$this->description = esc_html__('All shortcodes specific to transaction related data', 'event_espresso');
29
+		$this->_shortcodes = array(
30
+			'[TXN_ID]'                          => esc_html__('The transaction id for the purchase.', 'event_espresso'),
31
+			'[PAYMENT_URL]'                     => esc_html__(
32
+				'This is a link to make a payment for the event',
33
+				'event_espresso'
34
+			),
35
+			'[PAYMENT_LINK_IF_NEEDED_*]'        => esc_html__(
36
+				'This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:',
37
+				'event_espresso'
38
+			)
39
+												   . '<ul>'
40
+												   . '<li>'
41
+												   . sprintf(
42
+													   esc_html__(
43
+														   '%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").',
44
+														   'event_espresso'
45
+													   ),
46
+													   '<strong>',
47
+													   '</strong>'
48
+												   )
49
+												   . '</li>'
50
+												   . '<li>'
51
+												   . sprintf(
52
+													   esc_html__(
53
+														   '%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)',
54
+														   'event_espresso'
55
+													   ),
56
+													   '<strong>',
57
+													   '</strong>'
58
+												   )
59
+												   . '</li>'
60
+												   . '<li>'
61
+												   . sprintf(
62
+													   esc_html__(
63
+														   '%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").',
64
+														   'event_espresso'
65
+													   ),
66
+													   '<strong>',
67
+													   '</strong>'
68
+												   )
69
+												   . '</li>'
70
+												   . '</ul>',
71
+			'[PAYMENT_DUE_DATE_*]'              => esc_html__(
72
+				'This is a special dynamic shortcode that allows one to output a payment due date.  It will only result in a date shown if there is money owing.  Three parameters are available on this shortcode:',
73
+				'event_espresso'
74
+			)
75
+												   . '<ul>'
76
+												   . '<li>'
77
+												   . sprintf(
78
+													   esc_html__(
79
+														   '%sformat:%s This is used to indicate what format the date is in.  Default is whatever is set as date formats for your website.',
80
+														   'event_espresso'
81
+													   ),
82
+													   '<strong>',
83
+													   '</strong>'
84
+												   )
85
+												   . '</li>'
86
+												   . '<li>'
87
+												   . sprintf(
88
+													   esc_html__(
89
+														   '%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due.  Defaults to 30.',
90
+														   'event_espresso'
91
+													   ),
92
+													   '<strong>',
93
+													   '</strong>'
94
+												   )
95
+												   . '</li>'
96
+												   . '<li>'
97
+												   . sprintf(
98
+													   esc_html__(
99
+														   '%sprefix_text:%s You can use this to indicate what text will prefix the date string.  Defaults to "Payment in full due by:"',
100
+														   'event_espresso'
101
+													   ),
102
+													   '<strong>',
103
+													   '</strong>'
104
+												   )
105
+												   . '</li>',
106
+			'[INVOICE_LINK]'                    => esc_html__(
107
+				'This is a full html link to the invoice',
108
+				'event_espresso'
109
+			),
110
+			'[INVOICE_URL]'                     => esc_html__(
111
+				'This is just the url for the invoice',
112
+				'event_espresso'
113
+			),
114
+			'[INVOICE_LOGO_URL]'                => esc_html__(
115
+				'This returns the url for the logo uploaded via the invoice settings page.',
116
+				'event_espresso'
117
+			),
118
+			'[INVOICE_LOGO]'                    => esc_html__(
119
+				'This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.',
120
+				'event_espresso'
121
+			),
122
+			'[INVOICE_PAYEE_NAME]'              => esc_html__(
123
+				'This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.',
124
+				'event_espresso'
125
+			),
126
+			'[INVOICE_PAYEE_ADDRESS]'           => esc_html__(
127
+				'This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.',
128
+				'event_espresso'
129
+			),
130
+			'[INVOICE_PAYMENT_INSTRUCTIONS]'    => esc_html__(
131
+				'This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page',
132
+				'event_espresso'
133
+			),
134
+			'[INVOICE_PAYEE_EMAIL]'             => esc_html__(
135
+				'This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.',
136
+				'event_espresso'
137
+			),
138
+			'[INVOICE_PAYEE_TAX_NUMBER_*]'      => sprintf(
139
+				esc_html__(
140
+					'This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number.  It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56.  If you have no tax number in your settings, then no prefix will be output either.',
141
+					'event_espresso'
142
+				),
143
+				'<code>',
144
+				'</code>'
145
+			),
146
+			'[TOTAL_COST]'                      => esc_html__('The total cost for the transaction', 'event_espresso'),
147
+			'[TXN_STATUS]'                      => esc_html__(
148
+				'The transaction status for the transaction.',
149
+				'event_espresso'
150
+			),
151
+			'[TXN_STATUS_ID]'                   => esc_html__(
152
+				'The ID representing the transaction status as saved in the db.  This tends to be useful for including with css classes for styling certain statuses differently from others.',
153
+				'event_espresso'
154
+			),
155
+			'[PAYMENT_STATUS]'                  => esc_html__(
156
+				'The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.',
157
+				'event_espresso'
158
+			),
159
+			'[PAYMENT_GATEWAY]'                 => esc_html__(
160
+				'The payment gateway used for the transaction',
161
+				'event_espresso'
162
+			),
163
+			'[AMOUNT_PAID]'                     => esc_html__(
164
+				'The amount paid or refunded.  This will only have a value if there was a payment or refund at the time of generating the message.',
165
+				'event_espresso'
166
+			),
167
+			'[LAST_AMOUNT_PAID]'                => esc_html__(
168
+				'This is the last payment or refund made on the transaction related to the message being generated.',
169
+				'event_espresso'
170
+			),
171
+			'[TOTAL_AMOUNT_PAID]'               => esc_html__(
172
+				'This parses to the total amount paid over all payments',
173
+				'event_espresso'
174
+			),
175
+			'[TOTAL_OWING]'                     => esc_html__(
176
+				'The total owing on a transaction with no attributes.',
177
+				'event_espresso'
178
+			),
179
+			'[TXN_SUBTOTAL]'                    => esc_html__('The subtotal for all txn line items.', 'event_espresso'),
180
+			'[TXN_TAX_SUBTOTAL]'                => esc_html__('The subtotal for all tax line items.', 'event_espresso'),
181
+			'[OWING_STATUS_MESSAGE_*]'          => esc_html__(
182
+				'A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:',
183
+				'event_espresso'
184
+			)
185
+												   . '<p></ul>'
186
+												   . '<li><strong>still_owing</strong>:'
187
+												   . esc_html__(
188
+													   'If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:',
189
+													   'event_espresso'
190
+												   )
191
+												   . sprintf(
192
+													   esc_html__('%sPlease make a payment.%s', 'event_espresso'),
193
+													   '<a href="[PAYMENT_URL]" class="noPrint">',
194
+													   '</a>'
195
+												   )
196
+												   . '</li>'
197
+												   .
198
+												   '<li><strong>none_owing</strong>:'
199
+												   . esc_html__(
200
+													   'If the transaction is paid in full, then you can indicate how this gets displayed.  Note, that it defaults to just be the total owing.',
201
+													   'event_espresso'
202
+												   )
203
+												   . '</li></ul></p>',
204
+			'[TXN_TOTAL_TICKETS]'               => esc_html__(
205
+				'The total number of all tickets purchased in a transaction',
206
+				'event_espresso'
207
+			),
208
+			'[TKT_QTY_PURCHASED]'               => sprintf(
209
+				esc_html__(
210
+					'The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s',
211
+					'event_espresso'
212
+				),
213
+				'<strong>',
214
+				'</strong>'
215
+			),
216
+			'[TRANSACTION_ADMIN_URL]'           => esc_html__(
217
+				'The url to the admin page for this transaction',
218
+				'event_espresso'
219
+			),
220
+			'[RECEIPT_URL]'                     => esc_html__(
221
+				'This parses to the generated url for retrieving the receipt for the transaction',
222
+				'event_espresso'
223
+			),
224
+			'[INVOICE_RECEIPT_SWITCHER_URL]'    => esc_html__(
225
+				'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active  then will parse to an empty string.',
226
+				'event_espresso'
227
+			),
228
+			'[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(
229
+				esc_html__(
230
+					'The same as %1$s%2$s except this returns the html for a button linked to the invoice or receipt.',
231
+					'event_espresso'
232
+				),
233
+				'<code>[INVOICE_RECEIPT_SWITCHER_URL]',
234
+				'</code>'
235
+			),
236
+			'[LAST_PAYMENT_TRANSACTION_ID]'     => esc_html__(
237
+				'This will output the value of the payment transaction id for the last payment made on the transaction. Note, if a specific payment was included for message generation, that will be used when parsing the shortcode.',
238
+				'event_espresso'
239
+			),
240
+		);
241
+	}
242
+
243
+
244
+	/**
245
+	 * @param  string $shortcode the shortcode to be parsed.
246
+	 * @return string parsed shortcode
247
+	 * @throws EE_Error
248
+	 * @throws InvalidArgumentException
249
+	 * @throws ReflectionException
250
+	 * @throws InvalidDataTypeException
251
+	 * @throws InvalidInterfaceException
252
+	 */
253
+	protected function _parser($shortcode)
254
+	{
255
+		// attempt to get the transaction.  Since this is potentially used in more fields, we may have to look in the
256
+		// _extra_data for the transaction.
257
+		$transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
258
+		$transaction = ! $transaction instanceof EE_Transaction
259
+					   && is_array($this->_extra_data)
260
+					   && isset($this->_extra_data['data'])
261
+					   && $this->_extra_data['data'] instanceof EE_Messages_Addressee
262
+			? $this->_extra_data['data']->txn
263
+			: $transaction;
264
+		// payment
265
+		$payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null;
266
+		$payment = ! $payment instanceof EE_Payment
267
+				   && is_array($this->_extra_data)
268
+				   && isset($this->_extra_data['data'])
269
+				   && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment
270
+			: $payment;
271
+		if (! $transaction instanceof EE_Transaction) {
272
+			return '';
273
+		}
274
+		switch ($shortcode) {
275
+			case '[TXN_ID]':
276
+				return $transaction->ID();
277
+				break;
278
+			case '[PAYMENT_URL]':
279
+				$payment_url = $transaction->payment_overview_url();
280
+				return empty($payment_url)
281
+					? esc_html__('http://dummypaymenturlforpreview.com', 'event_espresso')
282
+					: $payment_url;
283
+				break;
284
+			case '[INVOICE_LINK]':
285
+				$invoice_url = $transaction->invoice_url();
286
+				$invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
287
+				return sprintf(
288
+					esc_html__('%sClick here for Invoice%s', 'event_espresso'),
289
+					'<a href="' . $invoice_url . '">',
290
+					'</a>'
291
+				);
292
+				break;
293
+			case '[INVOICE_URL]':
294
+				$invoice_url = $transaction->invoice_url();
295
+				return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
296
+				break;
297
+			case '[INVOICE_LOGO_URL]':
298
+				return $this->_get_invoice_logo();
299
+				break;
300
+			case '[INVOICE_LOGO]':
301
+				return $this->_get_invoice_logo(true);
302
+				break;
303
+			case '[INVOICE_PAYEE_NAME]':
304
+				return $this->_get_invoice_payee_name();
305
+				break;
306
+			case '[INVOICE_PAYEE_ADDRESS]':
307
+				return $this->_get_invoice_payee_address();
308
+				break;
309
+			case '[INVOICE_PAYMENT_INSTRUCTIONS]':
310
+				return $this->_get_invoice_payment_instructions();
311
+				break;
312
+			case '[INVOICE_PAYEE_EMAIL]':
313
+				return $this->_get_invoice_payee_email();
314
+				break;
315
+			case '[TOTAL_COST]':
316
+				$total = $transaction->total();
317
+				return ! empty($total) ? EEH_Template::format_currency($total) : '';
318
+				break;
319
+			case '[PAYMENT_STATUS]':
320
+				$status = $transaction->pretty_status();
321
+				return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso');
322
+				break; /**/
323
+			// note the [payment_status] shortcode is kind of misleading because payment status might be different
324
+			// from txn status so I'm adding this here for clarity.
325
+			case '[TXN_STATUS]':
326
+				$status = $transaction->pretty_status();
327
+				return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso');
328
+				break;
329
+			case '[TXN_STATUS_ID]':
330
+				return $transaction->status_ID();
331
+				break;
332
+			case '[PAYMENT_GATEWAY]':
333
+				return $this->_get_payment_gateway($transaction);
334
+				break;
335
+			case '[AMOUNT_PAID]':
336
+				return $payment instanceof EE_Payment
337
+					? EEH_Template::format_currency($payment->amount())
338
+					: EEH_Template::format_currency(0);
339
+				break;
340
+			case '[LAST_AMOUNT_PAID]':
341
+				$last_payment = $transaction->last_payment();
342
+				return $last_payment instanceof EE_Payment
343
+					? EEH_Template::format_currency($last_payment->amount())
344
+					: EEH_Template::format_currency(0);
345
+			case '[TOTAL_AMOUNT_PAID]':
346
+				return EEH_Template::format_currency($transaction->paid());
347
+				break;
348
+			case '[TOTAL_OWING]':
349
+				$total_owing = $transaction->remaining();
350
+				return EEH_Template::format_currency($total_owing);
351
+				break;
352
+			case '[TXN_SUBTOTAL]':
353
+				return EEH_Template::format_currency($this->_get_subtotal());
354
+				break;
355
+			case '[TXN_TAX_SUBTOTAL]':
356
+				return EEH_Template::format_currency($this->_get_subtotal(true));
357
+				break;
358
+			case '[TKT_QTY_PURCHASED]':
359
+			case '[TXN_TOTAL_TICKETS]':
360
+				return $this->_data->total_ticket_count;
361
+				break;
362
+			case '[TRANSACTION_ADMIN_URL]':
363
+				require_once EE_CORE . 'admin/EE_Admin_Page.core.php';
364
+				$query_args = array(
365
+					'page'   => 'espresso_transactions',
366
+					'action' => 'view_transaction',
367
+					'TXN_ID' => $transaction->ID(),
368
+				);
369
+				$url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php'));
370
+				return $url;
371
+				break;
372
+			case '[RECEIPT_URL]':
373
+				// get primary_registration
374
+				$reg = $this->_data->primary_reg_obj;
375
+				if (! $reg instanceof EE_Registration) {
376
+					return '';
377
+				}
378
+				return $reg->receipt_url();
379
+				break;
380
+			case '[INVOICE_RECEIPT_SWITCHER_URL]':
381
+				return $this->_get_invoice_receipt_switcher(false);
382
+				break;
383
+			case '[INVOICE_RECEIPT_SWITCHER_BUTTON]':
384
+				return $this->_get_invoice_receipt_switcher();
385
+				break;
386
+			case '[LAST_PAYMENT_TRANSACTION_ID]':
387
+				$id = '';
388
+				$payment = $payment instanceof EE_Payment && $payment->ID() !== 0
389
+					? $payment
390
+					: $transaction->last_payment();
391
+				if ($payment instanceof EE_Payment) {
392
+					$id = $payment->txn_id_chq_nmbr();
393
+				}
394
+				return $id;
395
+				break;
396
+		}
397
+		if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== false) {
398
+			return $this->_get_custom_total_owing($shortcode);
399
+		}
400
+		if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== false) {
401
+			return $this->_get_invoice_payee_tax_number($shortcode);
402
+		}
403
+		if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== false) {
404
+			return $this->_get_payment_link_if_needed($shortcode);
405
+		}
406
+		if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) {
407
+			return $this->_get_payment_due_date($shortcode, $transaction);
408
+		}
409
+		return '';
410
+	}
411
+
412
+
413
+	/**
414
+	 * parser for the [OWING_STATUS_MESSAGE_*] attribute type shortcode
415
+	 *
416
+	 * @since 4.5.0
417
+	 * @param string $shortcode the incoming shortcode
418
+	 * @return string parsed.
419
+	 * @throws EE_Error
420
+	 */
421
+	private function _get_custom_total_owing($shortcode)
422
+	{
423
+		$valid_shortcodes = array('transaction');
424
+		$attrs = $this->_get_shortcode_attrs($shortcode);
425
+		// ensure default is set.
426
+		$addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
427
+		$total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction
428
+			? $addressee->txn->remaining() : 0;
429
+		if ($total_owing > 0) {
430
+			$owing_content = ! empty($attrs['still_owing'])
431
+				? $attrs['still_owing']
432
+				: sprintf(
433
+					esc_html__('%sPlease make a payment.%s', 'event_espresso'),
434
+					'<a href="[PAYMENT_URL]" class="noPrint">',
435
+					'</a>'
436
+				);
437
+			$owing_content = $this->_shortcode_helper->parse_message_template(
438
+				$owing_content,
439
+				$addressee,
440
+				$valid_shortcodes,
441
+				$this->_message_type,
442
+				$this->_messenger,
443
+				$this->_message
444
+			);
445
+		} else {
446
+			$owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : '';
447
+		}
448
+		return $owing_content;
449
+	}
450
+
451
+
452
+	/**
453
+	 * @param EE_Transaction $transaction
454
+	 * @return string
455
+	 * @throws EE_Error
456
+	 */
457
+	private function _get_payment_gateway($transaction)
458
+	{
459
+		if ($transaction instanceof EE_Transaction) {
460
+			$pm = $transaction->payment_method();
461
+		} else {
462
+			$pm = null;
463
+		}
464
+		return $pm instanceof EE_Payment_Method ? $pm->name() : '';
465
+	}
466
+
467
+
468
+	/**
469
+	 * This retrieves a logo to be used for the invoice from whatever is set on the invoice logo settings page.  If its
470
+	 * not present then the organization logo is used if its found (set on the organization settings page).
471
+	 *
472
+	 * @since 4.5.0
473
+	 * @param bool $img_tags TRUE means to return with the img tag wrappers.  False just returns the url to the image.
474
+	 * @return string url or html
475
+	 * @throws EE_Error
476
+	 * @throws InvalidArgumentException
477
+	 * @throws InvalidDataTypeException
478
+	 * @throws InvalidInterfaceException
479
+	 */
480
+	private function _get_invoice_logo($img_tags = false)
481
+	{
482
+		$invoice_logo_url = '';
483
+		// try to get the invoice payment method's logo for this transaction image first
484
+		$pm = $this->_get_invoice_payment_method();
485
+		if ($pm instanceof EE_Payment_Method) {
486
+			$invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', true);
487
+		}
488
+		if (empty($invoice_logo_url)) {
489
+			$invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url;
490
+		}
491
+		if (empty($invoice_logo_url)) {
492
+			return '';
493
+		}
494
+		if (! $img_tags) {
495
+			return $invoice_logo_url;
496
+		}
497
+		// image tags have been requested.
498
+		$image_size = getimagesize($invoice_logo_url);
499
+		// if image is wider than 300px, set the width to 300
500
+		if ($image_size[0] > 300) {
501
+			$image_width = 300;
502
+		} else {
503
+			$image_width = $image_size[0];
504
+		}
505
+		return '<img class="logo screen" src="' . esc_url_raw($invoice_logo_url) . '" width="' . esc_attr($image_width) . '" alt="logo" />';
506
+	}
507
+
508
+
509
+	/**
510
+	 * Used to retrieve the appropriate content for the invoice payee name shortcode
511
+	 *
512
+	 * @since 4.5.0
513
+	 * @return string
514
+	 * @throws EE_Error
515
+	 * @throws InvalidArgumentException
516
+	 * @throws InvalidDataTypeException
517
+	 * @throws InvalidInterfaceException
518
+	 */
519
+	private function _get_invoice_payee_name()
520
+	{
521
+		$payee_name = null;
522
+		$pm = $this->_get_invoice_payment_method();
523
+		if ($pm instanceof EE_Payment_Method) {
524
+			$payee_name = $pm->get_extra_meta('pdf_payee_name', true);
525
+		}
526
+		$payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name;
527
+		return $payee_name;
528
+	}
529
+
530
+
531
+	/**
532
+	 * gets the default invoice payment method, but has a filter so it can be overridden
533
+	 *
534
+	 * @return EE_Payment_Method|null
535
+	 * @throws EE_Error
536
+	 * @throws InvalidArgumentException
537
+	 * @throws InvalidDataTypeException
538
+	 * @throws InvalidInterfaceException
539
+	 */
540
+	private function _get_invoice_payment_method()
541
+	{
542
+		if (! $this->_invoice_pm instanceof EE_Payment_Method) {
543
+			$transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
544
+			$transaction = ! $transaction instanceof EE_Transaction
545
+						   && is_array($this->_extra_data)
546
+						   && isset($this->_extra_data['data'])
547
+						   && $this->_extra_data['data'] instanceof EE_Messages_Addressee
548
+				? $this->_extra_data['data']->txn : $transaction;
549
+			// get the invoice payment method, and remember it for the next call too
550
+			$this->_invoice_pm = apply_filters(
551
+				'FHEE__EE_Transaction_Shortcodes__get_payment_method__default',
552
+				EEM_Payment_Method::instance()->get_one_of_type('Invoice'),
553
+				$transaction
554
+			);
555
+		}
556
+		return $this->_invoice_pm;
557
+	}
558
+
559
+
560
+	/**
561
+	 * Used to retrieve the appropriate content for the invoice payee email shortcode
562
+	 *
563
+	 * @since 4.5.0
564
+	 * @return string
565
+	 * @throws EE_Error
566
+	 * @throws InvalidArgumentException
567
+	 * @throws InvalidDataTypeException
568
+	 * @throws InvalidInterfaceException
569
+	 */
570
+	private function _get_invoice_payee_email()
571
+	{
572
+		$payee_email = null;
573
+		$pm = $this->_get_invoice_payment_method();
574
+		if ($pm instanceof EE_Payment_Method) {
575
+			$payee_email = $pm->get_extra_meta('pdf_payee_email', true);
576
+		}
577
+		$payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email')
578
+			: $payee_email;
579
+		return $payee_email;
580
+	}
581
+
582
+
583
+	/**
584
+	 * Used to retrieve the appropriate content for the invoice payee tax number shortcode
585
+	 *
586
+	 * @since 4.5.0
587
+	 * @param string $shortcode
588
+	 * @return string
589
+	 * @throws EE_Error
590
+	 * @throws InvalidArgumentException
591
+	 * @throws InvalidDataTypeException
592
+	 * @throws InvalidInterfaceException
593
+	 */
594
+	private function _get_invoice_payee_tax_number($shortcode)
595
+	{
596
+		$payee_tax_number = null;
597
+		$pm = $this->_get_invoice_payment_method();
598
+		if ($pm instanceof EE_Payment_Method) {
599
+			$payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', true);
600
+		}
601
+		$payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat
602
+			: $payee_tax_number;
603
+		if (empty($payee_tax_number)) {
604
+			return '';
605
+		}
606
+		// any attributes?
607
+		$attrs = $this->_get_shortcode_attrs($shortcode);
608
+		// prefix?
609
+		$prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso');
610
+		return $prefix . $payee_tax_number;
611
+	}
612
+
613
+
614
+	/**
615
+	 * Used to retrieve the appropriate content for the invoice payee address shortcode.
616
+	 *
617
+	 * @since 4.5.0
618
+	 * @return string
619
+	 * @throws EE_Error
620
+	 * @throws InvalidArgumentException
621
+	 * @throws ReflectionException
622
+	 * @throws InvalidDataTypeException
623
+	 * @throws InvalidInterfaceException
624
+	 */
625
+	private function _get_invoice_payee_address()
626
+	{
627
+		$payee_address = null;
628
+		$pm = $this->_get_invoice_payment_method();
629
+		if ($pm instanceof EE_Payment_Method) {
630
+			$payee_address = $pm->get_extra_meta('pdf_payee_address', true);
631
+		}
632
+		if (empty($payee_address)) {
633
+			$organization = EE_Registry::instance()->CFG->organization;
634
+			$payee_address = $organization->get_pretty('address_1') . '<br>';
635
+			$payee_address .= ! empty($organization->address_2)
636
+				? $organization->get_pretty('address_2') . '<br>'
637
+				: '';
638
+			$payee_address .= $organization->get_pretty('city') . '<br>';
639
+			// state
640
+			$state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
641
+			$payee_address .= $state instanceof EE_State ? $state->name() : '';
642
+			// Country
643
+			$payee_address .= ! empty($organization->CNT_ISO) ? ', ' . $organization->CNT_ISO . '<br>' : '';
644
+			$payee_address .= ! empty($organization->zip) ? $organization->zip : '';
645
+		}
646
+		return $payee_address;
647
+	}
648
+
649
+
650
+	/**
651
+	 * Used to retrieve the appropriate content for the invoice payment instructions shortcode.
652
+	 *
653
+	 * @since 4.5.0
654
+	 * @return string
655
+	 * @throws EE_Error
656
+	 * @throws InvalidArgumentException
657
+	 * @throws InvalidDataTypeException
658
+	 * @throws InvalidInterfaceException
659
+	 */
660
+	private function _get_invoice_payment_instructions()
661
+	{
662
+		$instructions = null;
663
+		$pm = $this->_get_invoice_payment_method();
664
+		return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', true) : '';
665
+	}
666
+
667
+
668
+	/**
669
+	 * get invoice/receipt switch button or url.
670
+	 *
671
+	 * @param bool $button true (default) returns the html for a button, false just returns the url.
672
+	 * @return string
673
+	 * @throws EE_Error
674
+	 */
675
+	protected function _get_invoice_receipt_switcher($button = true)
676
+	{
677
+		$reg = $this->_data->primary_reg_obj;
678
+		$message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : '';
679
+		if (! $reg instanceof EE_Registration || empty($message_type)) {
680
+			return '';
681
+		}
682
+		$switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false;
683
+		$switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type
684
+			? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso');
685
+		$switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label;
686
+		$switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url();
687
+		if (! $button) {
688
+			return $switch_to_url;
689
+		}
690
+		if (! empty($switch_to_url)) {
691
+			return '
692 692
 	<form method="post" action="' . $switch_to_url . '" >
693 693
 		<input class="print_button" type="submit" value="' . $switch_to_label . '" />
694 694
 	</form>
695 695
 			';
696
-        }
697
-        return '';
698
-    }
699
-
700
-
701
-    /**
702
-     * This returns a subtotal.
703
-     *
704
-     * @param bool $tax if true then return the subtotal for tax otherwise return subtotal.
705
-     * @return int
706
-     * @throws EE_Error
707
-     */
708
-    private function _get_subtotal($tax = false)
709
-    {
710
-        $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null;
711
-        if (! $grand_total instanceof EE_Line_Item) {
712
-            return 0;
713
-        }
714
-        return $tax ? $grand_total->get_total_tax() : $grand_total->get_items_total();
715
-    }
716
-
717
-
718
-    /**
719
-     * parser for the [PAYMENT_LINK_IF_NEEDED_*] attribute type shortcode
720
-     *
721
-     * @since 4.7.0
722
-     * @param string $shortcode the incoming shortcode
723
-     * @return string parsed.
724
-     * @throws EE_Error
725
-     */
726
-    private function _get_payment_link_if_needed($shortcode)
727
-    {
728
-        $valid_shortcodes = array('transaction');
729
-        $attrs = $this->_get_shortcode_attrs($shortcode);
730
-        // ensure default is set.
731
-        $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
732
-        $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction
733
-            ? $addressee->txn->remaining() : 0;
734
-        if ($total_owing > 0) {
735
-            $class = isset($attrs['class']) ? $attrs['class'] : 'callout';
736
-            $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
737
-            $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p';
738
-            $opening_tag = ! empty($container_tag) ? '<' . $container_tag : '';
739
-            $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="' . $class . '"' : $opening_tag;
740
-            $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag;
741
-            $closing_tag = ! empty($container_tag) ? '</' . $container_tag . '>' : '';
742
-            $content = $opening_tag . sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>') . $closing_tag;
743
-            // we need to re run this string through the parser to catch any shortcodes that are in it.
744
-            $owing_content = $this->_shortcode_helper->parse_message_template(
745
-                $content,
746
-                $addressee,
747
-                $valid_shortcodes,
748
-                $this->_message_type,
749
-                $this->_messenger,
750
-                $this->_message
751
-            );
752
-        } else {
753
-            return '';
754
-        }
755
-        return $owing_content;
756
-    }
757
-
758
-
759
-    /**
760
-     * Parser for the [PAYMENT_DUE_DATE_*] attribute type shortcode
761
-     *
762
-     * @since 4.8.28.rc.011
763
-     * @param string         $shortcode The shortcode being parsed.
764
-     * @param EE_Transaction $transaction
765
-     * @return string
766
-     * @throws EE_Error
767
-     */
768
-    protected function _get_payment_due_date($shortcode, EE_Transaction $transaction)
769
-    {
770
-        // if transaction is paid in full then we can just return an empty string
771
-        if ($transaction->remaining() === 0) {
772
-            return '';
773
-        }
774
-        $attrs = $this->_get_shortcode_attrs($shortcode);
775
-        $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format');
776
-        $days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30;
777
-        $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text']
778
-            : esc_html__('Payment in full due by: ', 'event_espresso');
779
-        $transaction_created = $transaction->get_DateTime_object('TXN_timestamp');
780
-        // setup date due:
781
-        try {
782
-            if ($transaction_created instanceof DateTime) {
783
-                $date_due = $transaction_created->add(
784
-                    new DateInterval('P' . $days_until_due . 'D')
785
-                )->format($format);
786
-            } else {
787
-                throw new Exception();
788
-            }
789
-        } catch (Exception $e) {
790
-            // format was likely invalid.
791
-            $date_due = esc_html__(
792
-                'Unable to calculate date due, likely the format string is invalid.',
793
-                'event_espresso'
794
-            );
795
-        }
796
-        return $prefix_text . $date_due;
797
-    }
696
+		}
697
+		return '';
698
+	}
699
+
700
+
701
+	/**
702
+	 * This returns a subtotal.
703
+	 *
704
+	 * @param bool $tax if true then return the subtotal for tax otherwise return subtotal.
705
+	 * @return int
706
+	 * @throws EE_Error
707
+	 */
708
+	private function _get_subtotal($tax = false)
709
+	{
710
+		$grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null;
711
+		if (! $grand_total instanceof EE_Line_Item) {
712
+			return 0;
713
+		}
714
+		return $tax ? $grand_total->get_total_tax() : $grand_total->get_items_total();
715
+	}
716
+
717
+
718
+	/**
719
+	 * parser for the [PAYMENT_LINK_IF_NEEDED_*] attribute type shortcode
720
+	 *
721
+	 * @since 4.7.0
722
+	 * @param string $shortcode the incoming shortcode
723
+	 * @return string parsed.
724
+	 * @throws EE_Error
725
+	 */
726
+	private function _get_payment_link_if_needed($shortcode)
727
+	{
728
+		$valid_shortcodes = array('transaction');
729
+		$attrs = $this->_get_shortcode_attrs($shortcode);
730
+		// ensure default is set.
731
+		$addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
732
+		$total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction
733
+			? $addressee->txn->remaining() : 0;
734
+		if ($total_owing > 0) {
735
+			$class = isset($attrs['class']) ? $attrs['class'] : 'callout';
736
+			$custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
737
+			$container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p';
738
+			$opening_tag = ! empty($container_tag) ? '<' . $container_tag : '';
739
+			$opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="' . $class . '"' : $opening_tag;
740
+			$opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag;
741
+			$closing_tag = ! empty($container_tag) ? '</' . $container_tag . '>' : '';
742
+			$content = $opening_tag . sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>') . $closing_tag;
743
+			// we need to re run this string through the parser to catch any shortcodes that are in it.
744
+			$owing_content = $this->_shortcode_helper->parse_message_template(
745
+				$content,
746
+				$addressee,
747
+				$valid_shortcodes,
748
+				$this->_message_type,
749
+				$this->_messenger,
750
+				$this->_message
751
+			);
752
+		} else {
753
+			return '';
754
+		}
755
+		return $owing_content;
756
+	}
757
+
758
+
759
+	/**
760
+	 * Parser for the [PAYMENT_DUE_DATE_*] attribute type shortcode
761
+	 *
762
+	 * @since 4.8.28.rc.011
763
+	 * @param string         $shortcode The shortcode being parsed.
764
+	 * @param EE_Transaction $transaction
765
+	 * @return string
766
+	 * @throws EE_Error
767
+	 */
768
+	protected function _get_payment_due_date($shortcode, EE_Transaction $transaction)
769
+	{
770
+		// if transaction is paid in full then we can just return an empty string
771
+		if ($transaction->remaining() === 0) {
772
+			return '';
773
+		}
774
+		$attrs = $this->_get_shortcode_attrs($shortcode);
775
+		$format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format');
776
+		$days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30;
777
+		$prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text']
778
+			: esc_html__('Payment in full due by: ', 'event_espresso');
779
+		$transaction_created = $transaction->get_DateTime_object('TXN_timestamp');
780
+		// setup date due:
781
+		try {
782
+			if ($transaction_created instanceof DateTime) {
783
+				$date_due = $transaction_created->add(
784
+					new DateInterval('P' . $days_until_due . 'D')
785
+				)->format($format);
786
+			} else {
787
+				throw new Exception();
788
+			}
789
+		} catch (Exception $e) {
790
+			// format was likely invalid.
791
+			$date_due = esc_html__(
792
+				'Unable to calculate date due, likely the format string is invalid.',
793
+				'event_espresso'
794
+			);
795
+		}
796
+		return $prefix_text . $date_due;
797
+	}
798 798
 }
Please login to merge, or discard this patch.
modules/gateways/Invoice/lib/templates/invoice_body.template.php 2 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -76,20 +76,20 @@  discard block
 block discarded – undo
76 76
         </thead>
77 77
         <tbody>
78 78
         <?php
79
-        /**
80
-         * Recursive function for traversing all the sub-items of each line item
81
-         * and displaying them in the table
82
-         *
83
-         * @param EE_Line_Item $line_item
84
-         * @param boolean      $odd for indicating whether to style this line item as an 'odd' or 'even'
85
-         */
86
-        function ee_invoice_display_line_item(EE_Line_Item $line_item, $show_line_item_description, $odd = false)
87
-        {
88
-            switch ($line_item->type()) {
89
-                case EEM_Line_Item::type_total:
90
-                    foreach ($line_item->children() as $child_line_item) {
91
-                        ee_invoice_display_line_item($child_line_item, $show_line_item_description);
92
-                    } ?>
79
+		/**
80
+		 * Recursive function for traversing all the sub-items of each line item
81
+		 * and displaying them in the table
82
+		 *
83
+		 * @param EE_Line_Item $line_item
84
+		 * @param boolean      $odd for indicating whether to style this line item as an 'odd' or 'even'
85
+		 */
86
+		function ee_invoice_display_line_item(EE_Line_Item $line_item, $show_line_item_description, $odd = false)
87
+		{
88
+			switch ($line_item->type()) {
89
+				case EEM_Line_Item::type_total:
90
+					foreach ($line_item->children() as $child_line_item) {
91
+						ee_invoice_display_line_item($child_line_item, $show_line_item_description);
92
+					} ?>
93 93
                     <tr>
94 94
                         <td colspan="<?php echo ($show_line_item_description ? 5 : 4) ?>">
95 95
                             <hr>
@@ -101,50 +101,50 @@  discard block
 block discarded – undo
101 101
                         <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td>
102 102
                     </tr>
103 103
                     <?php
104
-                    break;
104
+					break;
105 105
 
106 106
 
107
-                case EEM_Line_Item::type_sub_total:
108
-                    foreach ($line_item->children() as $child_line_item) {
109
-                        // $odd = !$odd;
110
-                        ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd);
111
-                    } ?>
107
+				case EEM_Line_Item::type_sub_total:
108
+					foreach ($line_item->children() as $child_line_item) {
109
+						// $odd = !$odd;
110
+						ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd);
111
+					} ?>
112 112
                     <tr class="total_tr odd">
113 113
                         <td colspan="<?php echo ($show_line_item_description ? 2 : 1) ?>">&nbsp;</td>
114 114
                         <td colspan="2" class="total" id="total_currency">
115 115
                             <?php esc_html_e(
116
-                                'Sub-Total',
117
-                                'event_espresso'
118
-                            ); ?></td>
116
+								'Sub-Total',
117
+								'event_espresso'
118
+							); ?></td>
119 119
                         <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td>
120 120
                     </tr>
121 121
                     <?php
122
-                    break;
122
+					break;
123 123
 
124 124
 
125
-                case EEM_Line_Item::type_tax_sub_total:
126
-                    foreach ($line_item->children() as $child_line_item) {
127
-                        $odd = ! $odd;
128
-                        ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd);
129
-                    } ?>
125
+				case EEM_Line_Item::type_tax_sub_total:
126
+					foreach ($line_item->children() as $child_line_item) {
127
+						$odd = ! $odd;
128
+						ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd);
129
+					} ?>
130 130
                     <tr class="total_tr odd">
131 131
                         <td colspan="<?php echo ($show_line_item_description ? 2 : 1) ?>">&nbsp;</td>
132 132
                         <td colspan="2" class="total" id="total_currency">
133 133
                             <?php esc_html_e(
134
-                                'Tax Total',
135
-                                'event_espresso'
136
-                            ); ?></td>
134
+								'Tax Total',
135
+								'event_espresso'
136
+							); ?></td>
137 137
                         <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td>
138 138
                     </tr>
139 139
                     <?php
140
-                    break;
140
+					break;
141 141
 
142 142
 
143
-                case EEM_Line_Item::type_line_item:
144
-                    $subitems = $line_item->children();
145
-                    $has_subitems = count($subitems) > 1;
146
-                    if ($has_subitems) {
147
-                        ?>
143
+				case EEM_Line_Item::type_line_item:
144
+					$subitems = $line_item->children();
145
+					$has_subitems = count($subitems) > 1;
146
+					if ($has_subitems) {
147
+						?>
148 148
                         <tr class="item <?php echo ($odd ? 'odd' : ''); ?>">
149 149
                             <td class="item_l"><?php echo esc_html($line_item->name()) ?></td>
150 150
                             <?php if ($show_line_item_description) { ?>
@@ -155,18 +155,18 @@  discard block
 block discarded – undo
155 155
                             <td class="item_c"><?php echo esc_html($line_item->unit_price_no_code()) ?></td>
156 156
 
157 157
                             <td class="item_r"> <?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags());
158
-                                echo ($line_item->is_taxable() ? '*' : ''); ?> </td>
158
+								echo ($line_item->is_taxable() ? '*' : ''); ?> </td>
159 159
                             <?php // <td class="item_l"><?php  $datetimes_strings = array(); foreach($datetimes as $datetime){ $datetimes_strings[]= $datetime->start_date_and_time();} echo implode(", ",$datetimes_strings);
160
-                            ?>
160
+							?>
161 161
                         </tr>
162 162
                         <?php
163
-                        if ($has_subitems) {
164
-                            foreach ($line_item->children() as $child_line_item) {
165
-                                ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd);
166
-                            }
167
-                        }
168
-                    } else {// no subitems - just show this line item
169
-                        ?>
163
+						if ($has_subitems) {
164
+							foreach ($line_item->children() as $child_line_item) {
165
+								ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd);
166
+							}
167
+						}
168
+					} else {// no subitems - just show this line item
169
+						?>
170 170
                         <tr class="item <?php echo ($odd ? 'odd' : ''); ?>">
171 171
                             <td class="item_l"><?php echo esc_html($line_item->name()); ?></td>
172 172
                             <?php if ($show_line_item_description) { ?>
@@ -175,15 +175,15 @@  discard block
 block discarded – undo
175 175
                             <td class="item_l"><?php echo esc_html($line_item->quantity()); ?></td>
176 176
                             <td class="item_c"><?php echo wp_kses($line_item->unit_price_no_code(), AllowedTags::getAllowedTags()); ?></td>
177 177
                             <td class="item_r"> <?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags());
178
-                                echo ($line_item->is_taxable() ? '*' : ''); ?> </td>
178
+								echo ($line_item->is_taxable() ? '*' : ''); ?> </td>
179 179
                             <?php // <td class="item_l"><?php  $datetimes_strings = array(); foreach($datetimes as $datetime){ $datetimes_strings[]= $datetime->start_date_and_time();} echo implode(", ",$datetimes_strings);
180
-                            ?>
180
+							?>
181 181
                         </tr>
182 182
                     <?php }
183 183
 
184
-                    break;
185
-                case EEM_Line_Item::type_sub_line_item:
186
-                    ?>
184
+					break;
185
+				case EEM_Line_Item::type_sub_line_item:
186
+					?>
187 187
                     <tr class="item subitem-row">
188 188
                         <td class="item_l subitem"><?php echo esc_html($line_item->name()); ?></td>
189 189
                         <?php if ($show_line_item_description) { ?>
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
                         <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td>
200 200
                     </tr>
201 201
                     <?php
202
-                    break;
203
-                case EEM_Line_Item::type_tax:
204
-                    ?>
202
+					break;
203
+				case EEM_Line_Item::type_tax:
204
+					?>
205 205
                     <tr class="item sub-item tax-total">
206 206
                     <td class="item_l"><?php echo esc_html($line_item->name()); ?></td>
207 207
                     <?php if ($show_line_item_description) { ?>
@@ -211,15 +211,15 @@  discard block
 block discarded – undo
211 211
 
212 212
                     <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td>
213 213
                     </tr><?php
214
-                    break;
215
-            }
216
-        }
214
+					break;
215
+			}
216
+		}
217 217
 
218
-        $c = false;
219
-        /* @var $transaction EE_Transaction */
220
-        $total_line_item = $transaction->total_line_item();
221
-        ee_invoice_display_line_item($total_line_item, $show_line_item_description);
222
-        /* foreach($transaction->registrations() as $registration){
218
+		$c = false;
219
+		/* @var $transaction EE_Transaction */
220
+		$total_line_item = $transaction->total_line_item();
221
+		ee_invoice_display_line_item($total_line_item, $show_line_item_description);
222
+		/* foreach($transaction->registrations() as $registration){
223 223
              ?>
224 224
             <tr class="item <?php echo ($c = !$c) ? ' odd' : ''; ?>">
225 225
                 <td class="item_l">1</td>
@@ -248,11 +248,11 @@  discard block
 block discarded – undo
248 248
         </thead>
249 249
         <tbody>
250 250
         <?php
251
-        $c = false;
252
-        if (! empty($payments)) {
253
-            foreach ($payments as $payment) {
254
-                /* @var $payment EE_Payment */
255
-                ?>
251
+		$c = false;
252
+		if (! empty($payments)) {
253
+			foreach ($payments as $payment) {
254
+				/* @var $payment EE_Payment */
255
+				?>
256 256
                 <tr class='item <?php echo(($c = ! $c) ? ' odd' : '') ?>'>
257 257
                     <td><?php $payment->e('PAY_gateway') ?></td>
258 258
                     <td><?php echo esc_html($payment->timestamp('D M j, Y')); ?></td>
@@ -262,17 +262,17 @@  discard block
 block discarded – undo
262 262
                     <td class='item_r'><?php echo EEH_Template::format_currency($payment->amount()); ?></td>
263 263
                 </tr>
264 264
             <?php }
265
-        } else {
266
-            ?>
265
+		} else {
266
+			?>
267 267
             <tr class='item'>
268 268
                 <td class='aln-cntr' colspan=6>
269 269
                     <?php esc_html_e(
270
-                        "No approved payments have been received",
271
-                        'event_espresso'
272
-                    ) ?></td>
270
+						"No approved payments have been received",
271
+						'event_espresso'
272
+					) ?></td>
273 273
             </tr>
274 274
         <?php }
275
-        ?>
275
+		?>
276 276
         </tbody>
277 277
         <tfoot>
278 278
         <tr class='total_tr'>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         <div class="fn">[name]</div>
55 55
         <div class="adr">
56 56
             <div class="street-address"><?php echo wp_kses($attendee_address, AllowedTags::getAllowedTags()); ?></div>
57
-            <div class="locality"><?php echo wp_kses($attendee_city . ' ' . $attendee_state, AllowedTags::getAllowedTags()); ?></div>
57
+            <div class="locality"><?php echo wp_kses($attendee_city.' '.$attendee_state, AllowedTags::getAllowedTags()); ?></div>
58 58
             <div id="client-postcode"><?php echo wp_kses($attendee_zip, AllowedTags::getAllowedTags()); ?></div>
59 59
         </div>
60 60
     </div>
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         <tbody>
250 250
         <?php
251 251
         $c = false;
252
-        if (! empty($payments)) {
252
+        if ( ! empty($payments)) {
253 253
             foreach ($payments as $payment) {
254 254
                 /* @var $payment EE_Payment */
255 255
                 ?>
Please login to merge, or discard this patch.
modules/gateways/Invoice/lib/Invoice.class.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
             7 => "union.css",
98 98
         ];
99 99
         // Get the CSS file
100
-        if (isset($themes[ $theme_requested ])) {
101
-            $template_args['invoice_css'] = $themes[ $theme_requested ];
100
+        if (isset($themes[$theme_requested])) {
101
+            $template_args['invoice_css'] = $themes[$theme_requested];
102 102
         } else {
103 103
             $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
104 104
                 'legacy_invoice_css',
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
             );
108 108
         }
109 109
 
110
-        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
111
-            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
110
+        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) {
111
+            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL.'Invoice/lib/templates/';
112 112
         } else {
113
-            $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
113
+            $template_args['base_url'] = EE_GATEWAYS.'/Invoice/lib/templates/';
114 114
         }
115 115
         $primary_attendee = $this->transaction->primary_registration()->attendee();
116 116
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             //      $this->session_data['cart']['REG']['sub_total']
170 170
             // );
171 171
             $tax_items = $this->transaction->tax_items();
172
-            if (! empty($tax_items)) {
172
+            if ( ! empty($tax_items)) {
173 173
                 foreach ($tax_items as $tax) {
174 174
                     $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
175 175
                 }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
                 html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES)
191 191
             )
192 192
         );
193
-        $template_args['shameless_plug']                = apply_filters(
193
+        $template_args['shameless_plug'] = apply_filters(
194 194
             'FHEE_Invoice__send_invoice__shameless_plug',
195 195
             true
196 196
         );
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
                 $line_items_for_this_event                = EEM_Line_Item::instance()->get_all(
208 208
                     [['Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()]]
209 209
                 );
210
-                $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
210
+                $ticket_line_items_per_event[$event_id] = $line_items_for_this_event;
211 211
                 foreach ($line_items_for_this_event as $line_item_id => $line_item) {
212
-                    if (! $line_item instanceof EE_Line_Item) {
212
+                    if ( ! $line_item instanceof EE_Line_Item) {
213 213
                         continue;
214 214
                     }
215 215
                     $ticket                                       = $line_item->ticket();
216 216
                     $registrations_for_this_ticket                = EEM_Registration::instance()->get_all(
217 217
                         [['TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()]]
218 218
                     );
219
-                    $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
219
+                    $registrations_per_line_item[$line_item_id] = $registrations_for_this_ticket;
220 220
                 }
221 221
                 if ($event instanceof EE_Event) {
222 222
                     $venues_for_events += $event->venues();
@@ -248,24 +248,24 @@  discard block
 block discarded – undo
248 248
         // Get the HTML as an object
249 249
         $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
250 250
         $template_header         = EEH_Template::locate_template(
251
-            $templates_relative_path . 'invoice_header.template.php',
251
+            $templates_relative_path.'invoice_header.template.php',
252 252
             $template_args
253 253
         );
254 254
         if ($receipt) {
255 255
             $template_body = EEH_Template::locate_template(
256
-                $templates_relative_path . 'receipt_body.template.php',
256
+                $templates_relative_path.'receipt_body.template.php',
257 257
                 $template_args
258 258
             );
259 259
         } else {
260 260
             $template_body = EEH_Template::locate_template(
261
-                $templates_relative_path . 'invoice_body.template.php',
261
+                $templates_relative_path.'invoice_body.template.php',
262 262
                 $template_args
263 263
             );
264 264
         }
265 265
 
266 266
 
267 267
         $template_footer = EEH_Template::locate_template(
268
-            $templates_relative_path . 'invoice_footer.template.php',
268
+            $templates_relative_path.'invoice_footer.template.php',
269 269
             $template_args
270 270
         );
271 271
 
@@ -282,18 +282,18 @@  discard block
 block discarded – undo
282 282
             echo wp_kses($content, AllowedTags::getWithFormTags());
283 283
             exit(0);
284 284
         }
285
-        $invoice_name = $template_args['organization'] . ' ';
285
+        $invoice_name = $template_args['organization'].' ';
286 286
         $invoice_name .= esc_html__('Invoice #', 'event_espresso');
287 287
         $invoice_name .= $template_args['registration_code'];
288
-        $invoice_name .= esc_html__(' for ', 'event_espresso') . $template_args['name'];
288
+        $invoice_name .= esc_html__(' for ', 'event_espresso').$template_args['name'];
289 289
         $invoice_name = str_replace(' ', '_', $invoice_name);
290 290
         // Create the PDF
291 291
         if ($request->requestParamIsSet('html')) {
292 292
             echo wp_kses($content, AllowedTags::getWithFormTags());
293 293
         } else {
294 294
             // only load dompdf if nobody else has yet...
295
-            if (! class_exists('Dompdf\Dompdf')) {
296
-                require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
295
+            if ( ! class_exists('Dompdf\Dompdf')) {
296
+                require_once(EE_THIRD_PARTY.'dompdf/src/Autoloader.php');
297 297
                 Dompdf\Autoloader::register();
298 298
             }
299 299
             $options = new Dompdf\Options();
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
             $dompdf = new Dompdf\Dompdf($options);
307 307
             $dompdf->loadHtml($content);
308 308
             $dompdf->render();
309
-            $dompdf->stream($invoice_name . ".pdf", ['Attachment' => $download]);
309
+            $dompdf->stream($invoice_name.".pdf", ['Attachment' => $download]);
310 310
         }
311 311
         exit(0);
312 312
     }
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
             true,
356 356
             $EE->CFG->organization->logo_url
357 357
         );
358
-        if (! empty($invoice_logo_url)) {
358
+        if ( ! empty($invoice_logo_url)) {
359 359
             $image_size         = getimagesize($invoice_logo_url);
360 360
             $invoice_logo_image =
361
-                '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
361
+                '<img class="logo screen" src="'.$invoice_logo_url.'" '.$image_size[3].' alt="logo" /> ';
362 362
         } else {
363 363
             $invoice_logo_image = '';
364 364
         }
365
-        $SearchValues     = [
365
+        $SearchValues = [
366 366
             "[organization]",
367 367
             "[registration_code]",
368 368
             "[transaction_id]",
@@ -391,15 +391,15 @@  discard block
 block discarded – undo
391 391
             $this->registration->reg_code(),
392 392
             $this->transaction->ID(),
393 393
             $primary_attendee->full_name(),
394
-            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice'))
394
+            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice'))
395 395
                 ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
396
-                : EE_GATEWAYS_URL . 'Invoice/lib/templates/',
396
+                : EE_GATEWAYS_URL.'Invoice/lib/templates/',
397 397
             $this->registration->invoice_url(),
398 398
             // home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
399 399
             $invoice_logo_image,
400 400
             empty($EE->CFG->organization->address_2)
401 401
                 ? $EE->CFG->organization->get_pretty('address_1')
402
-                : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
402
+                : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty(
403 403
                     'address_2'
404 404
                 ),
405 405
             $EE->CFG->organization->get_pretty('city'),
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
         $find    = [' '];
437 437
         $replace = ['-'];
438 438
         $row_id  = strtolower(str_replace($find, $replace, $text));
439
-        $html    .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
440
-        $html    .= '<td class="item_r">' . $text . '</td>';
441
-        $html    .= '<td class="item_r">' . $total_cost . '</td>';
439
+        $html    .= '<tr id="'.$row_id.'-tr"><td colspan="4">&nbsp;</td>';
440
+        $html    .= '<td class="item_r">'.$text.'</td>';
441
+        $html    .= '<td class="item_r">'.$total_cost.'</td>';
442 442
         $html    .= '</tr>';
443 443
         return $html;
444 444
     }
Please login to merge, or discard this patch.
Indentation   +430 added lines, -430 removed lines patch added patch discarded remove patch
@@ -12,434 +12,434 @@
 block discarded – undo
12 12
  */
13 13
 class Invoice
14 14
 {
15
-    /**
16
-     *
17
-     * @var EE_Registration
18
-     */
19
-    private $registration;
20
-
21
-    /**
22
-     *
23
-     * @var EE_Transaction
24
-     */
25
-    private $transaction;
26
-
27
-    /**
28
-     *
29
-     * @var EE_Payment_Method
30
-     */
31
-    private $invoice_payment_method;
32
-
33
-
34
-    /**
35
-     * Invoice constructor.
36
-     *
37
-     * @param int $url_link
38
-     * @throws EE_Error
39
-     * @throws ReflectionException
40
-     * @deprecated 4.9.13
41
-     */
42
-    public function __construct($url_link = 0)
43
-    {
44
-        EE_Error::doing_it_wrong(
45
-            __CLASS__,
46
-            esc_html__(
47
-                'This class has been deprecated and replaced by the new Messages library.',
48
-                'event_espresso'
49
-            ),
50
-            '4.9.12',
51
-            '5.0.0'
52
-        );
53
-        /** @var EEM_Registration $reg_model */
54
-        $reg_model = EE_Registry::instance()->load_model('Registration');
55
-        $this->registration = $reg_model->get_registration_for_reg_url_link($url_link);
56
-        if ($this->registration instanceof EE_Registration) {
57
-            $this->transaction = $this->registration->transaction();
58
-            EE_Config::instance()->gateway->payment_settings;
59
-            $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice');
60
-        } else {
61
-            EE_Error::add_error(
62
-                esc_html__(
63
-                    'Your request appears to be missing some required data, and no information for your transaction could be retrieved.',
64
-                    'event_espresso'
65
-                ),
66
-                __FILE__,
67
-                __FUNCTION__,
68
-                __LINE__
69
-            );
70
-        }
71
-    }
72
-
73
-
74
-    /**
75
-     * @param false $download
76
-     * @throws EE_Error
77
-     * @throws ReflectionException
78
-     */
79
-    public function send_invoice($download = false)
80
-    {
81
-        $template_args = [];
82
-        $EE            = EE_Registry::instance();
83
-        /** @var RequestInterface $request */
84
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
85
-        $theme   = $request->getRequestParam('theme', 0, 'int');
86
-        // allow the request to override the default theme defined in the invoice settings
87
-        $theme_requested = $theme > 0 && $theme < 8
88
-                ? $theme
89
-                : null;
90
-        $themes          = [
91
-            1 => "simple.css",
92
-            2 => "bauhaus.css",
93
-            3 => "ejs.css",
94
-            4 => "horizon.css",
95
-            5 => "lola.css",
96
-            6 => "tranquility.css",
97
-            7 => "union.css",
98
-        ];
99
-        // Get the CSS file
100
-        if (isset($themes[ $theme_requested ])) {
101
-            $template_args['invoice_css'] = $themes[ $theme_requested ];
102
-        } else {
103
-            $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
104
-                'legacy_invoice_css',
105
-                true,
106
-                'simple.css'
107
-            );
108
-        }
109
-
110
-        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
111
-            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
112
-        } else {
113
-            $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
114
-        }
115
-        $primary_attendee = $this->transaction->primary_registration()->attendee();
116
-
117
-        $template_args['organization'] = $EE->CFG->organization->get_pretty('name');
118
-        $template_args['street']       = empty($EE->CFG->organization->address_2)
119
-                ? $EE->CFG->organization->get_pretty('address_1')
120
-                : $EE->CFG->organization->get_pretty('address_1')
121
-                  . '<br>'
122
-                  . $EE->CFG->organization->get_pretty('address_2');
123
-        $template_args['city']         = $EE->CFG->organization->get_pretty('city');
124
-        $template_args['state']        = EE_Registry::instance()->load_model('State')->get_one_by_ID(
125
-            $EE->CFG->organization->STA_ID
126
-        );
127
-        $template_args['country']      = EE_Registry::instance()->load_model('Country')->get_one_by_ID(
128
-            $EE->CFG->organization->CNT_ISO
129
-        );
130
-        $template_args['zip']          = $EE->CFG->organization->get_pretty('zip');
131
-        $template_args['email']        = $EE->CFG->organization->get_pretty('email');
132
-
133
-        $template_args['registration_code'] = $this->registration->reg_code();
134
-        $template_args['registration_date'] = $this->registration->date();
135
-        $template_args['name']              = $primary_attendee->full_name();
136
-        $template_args['attendee_address']  = $primary_attendee->address();
137
-        $template_args['attendee_address2'] = $primary_attendee->address2();
138
-        $template_args['attendee_city']     = $primary_attendee->city();
139
-        $attendee_state                     = $primary_attendee->state_obj();
140
-        if ($attendee_state) {
141
-            $attendee_state_name = $attendee_state->name();
142
-        } else {
143
-            $attendee_state_name = '';
144
-        }
145
-        $template_args['attendee_state'] = $attendee_state_name;
146
-        $template_args['attendee_zip']   = $primary_attendee->zip();
147
-
148
-        $template_args['ship_name']    = $template_args['name'];
149
-        $template_args['ship_address'] = $template_args['attendee_address'];
150
-        $template_args['ship_city']    = $template_args['attendee_city'];
151
-        $template_args['ship_state']   = $template_args['attendee_state'];
152
-        $template_args['ship_zip']     = $template_args['attendee_zip'];
153
-
154
-        $template_args['total_cost']                 = number_format($this->transaction->total(), 2, '.', '');
155
-        $template_args['transaction']                = $this->transaction;
156
-        $template_args['amount_pd']                  = $this->transaction->paid();
157
-        $template_args['amount_owed']                = $this->transaction->total() - $this->transaction->paid();
158
-        $template_args['payments']                   = $this->transaction->approved_payments();
159
-        $template_args['net_total']                  = '';
160
-        $template_args['edit_reg_info_url']          = $this->registration->edit_attendee_information_url();
161
-        $template_args['retry_payment_url']          = $this->registration->payment_overview_url();
162
-        $template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description(
163
-            $this->transaction->total_line_item()
164
-        );
165
-        if ($template_args['amount_pd'] != $template_args['total_cost']) {
166
-            // $template_args['net_total'] = $this->espressoInvoiceTotals(
167
-            //      esc_html__('SubTotal', 'event_espresso'),
168
-            //      $this->transaction->total());
169
-            //      $this->session_data['cart']['REG']['sub_total']
170
-            // );
171
-            $tax_items = $this->transaction->tax_items();
172
-            if (! empty($tax_items)) {
173
-                foreach ($tax_items as $tax) {
174
-                    $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
175
-                }
176
-            }
177
-
178
-            $difference = $template_args['amount_pd'] - $template_args['total_cost'];
179
-            if ($difference < 0) {
180
-                $text = esc_html__('Discount', 'event_espresso');
181
-            } else {
182
-                $text = esc_html__('Extra', 'event_espresso');
183
-            }
184
-            $template_args['discount'] = $this->espressoInvoiceTotals($text, $difference);
185
-        }
186
-
187
-        $template_args['currency_symbol']               = $EE->CFG->currency->sign;
188
-        $template_args['template_payment_instructions'] = wpautop(
189
-            stripslashes_deep(
190
-                html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES)
191
-            )
192
-        );
193
-        $template_args['shameless_plug']                = apply_filters(
194
-            'FHEE_Invoice__send_invoice__shameless_plug',
195
-            true
196
-        );
197
-        $receipt = $request->getRequestParam('receipt');
198
-        if ($receipt) {
199
-            // receipt-specific stuff
200
-            $events_for_txn              = EEM_Event::instance()->get_all(
201
-                [['Registration.TXN_ID' => $this->transaction->ID()]]
202
-            );
203
-            $ticket_line_items_per_event = [];
204
-            $registrations_per_line_item = [];
205
-            $venues_for_events           = [];
206
-            foreach ($events_for_txn as $event_id => $event) {
207
-                $line_items_for_this_event                = EEM_Line_Item::instance()->get_all(
208
-                    [['Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()]]
209
-                );
210
-                $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
211
-                foreach ($line_items_for_this_event as $line_item_id => $line_item) {
212
-                    if (! $line_item instanceof EE_Line_Item) {
213
-                        continue;
214
-                    }
215
-                    $ticket                                       = $line_item->ticket();
216
-                    $registrations_for_this_ticket                = EEM_Registration::instance()->get_all(
217
-                        [['TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()]]
218
-                    );
219
-                    $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
220
-                }
221
-                if ($event instanceof EE_Event) {
222
-                    $venues_for_events += $event->venues();
223
-                }
224
-            }
225
-            $tax_total_line_item = EEM_Line_Item::instance()->get_one(
226
-                [['TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total]]
227
-            );
228
-            $questions_to_skip   = [
229
-                EEM_Attendee::system_question_fname,
230
-                EEM_Attendee::system_question_lname,
231
-                EEM_Attendee::system_question_email,
232
-            ];
233
-
234
-
235
-            $template_args['events_for_txn']              = $events_for_txn;
236
-            $template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event;
237
-            $template_args['registrations_per_line_item'] = $registrations_per_line_item;
238
-            $template_args['venues_for_events']           = $venues_for_events;
239
-            $template_args['tax_total_line_item']         = $tax_total_line_item;
240
-            $template_args['questions_to_skip']           = $questions_to_skip;
241
-            // d($template_args);
242
-            $template_args['download_link'] = $this->registration->receipt_url('download');
243
-        } else {
244
-            // it's just an invoice we're accessing
245
-            $template_args['download_link'] = $this->registration->invoice_url('download');
246
-        }
247
-
248
-        // Get the HTML as an object
249
-        $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
250
-        $template_header         = EEH_Template::locate_template(
251
-            $templates_relative_path . 'invoice_header.template.php',
252
-            $template_args
253
-        );
254
-        if ($receipt) {
255
-            $template_body = EEH_Template::locate_template(
256
-                $templates_relative_path . 'receipt_body.template.php',
257
-                $template_args
258
-            );
259
-        } else {
260
-            $template_body = EEH_Template::locate_template(
261
-                $templates_relative_path . 'invoice_body.template.php',
262
-                $template_args
263
-            );
264
-        }
265
-
266
-
267
-        $template_footer = EEH_Template::locate_template(
268
-            $templates_relative_path . 'invoice_footer.template.php',
269
-            $template_args
270
-        );
271
-
272
-        $copies = $request->getRequestParam('copies', 1, 'int');
273
-
274
-        $content = $this->espresso_replace_invoice_shortcodes($template_header);
275
-        for ($x = 1; $x <= $copies; $x++) {
276
-            $content .= $this->espresso_replace_invoice_shortcodes($template_body);
277
-        }
278
-        $content .= $this->espresso_replace_invoice_shortcodes($template_footer);
279
-
280
-        // Check if debugging or mobile is set
281
-        if ($request->getRequestParam('html')) {
282
-            echo wp_kses($content, AllowedTags::getWithFormTags());
283
-            exit(0);
284
-        }
285
-        $invoice_name = $template_args['organization'] . ' ';
286
-        $invoice_name .= esc_html__('Invoice #', 'event_espresso');
287
-        $invoice_name .= $template_args['registration_code'];
288
-        $invoice_name .= esc_html__(' for ', 'event_espresso') . $template_args['name'];
289
-        $invoice_name = str_replace(' ', '_', $invoice_name);
290
-        // Create the PDF
291
-        if ($request->requestParamIsSet('html')) {
292
-            echo wp_kses($content, AllowedTags::getWithFormTags());
293
-        } else {
294
-            // only load dompdf if nobody else has yet...
295
-            if (! class_exists('Dompdf\Dompdf')) {
296
-                require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
297
-                Dompdf\Autoloader::register();
298
-            }
299
-            $options = new Dompdf\Options();
300
-            $options->set('isRemoteEnabled', true);
301
-            $options->set('isJavascriptEnabled', false);
302
-            if (defined('DOMPDF_FONT_DIR')) {
303
-                $options->setFontDir(DOMPDF_FONT_DIR);
304
-                $options->setFontCache(DOMPDF_FONT_DIR);
305
-            }
306
-            $dompdf = new Dompdf\Dompdf($options);
307
-            $dompdf->loadHtml($content);
308
-            $dompdf->render();
309
-            $dompdf->stream($invoice_name . ".pdf", ['Attachment' => $download]);
310
-        }
311
-        exit(0);
312
-    }
313
-
314
-
315
-    /**
316
-     * Checks if this line item, or any of its children, actually has a description.
317
-     * If none do, then the template can decide to not show any description column
318
-     *
319
-     * @param EE_Line_Item $line_item
320
-     * @return boolean
321
-     * @throws EE_Error
322
-     * @throws ReflectionException
323
-     */
324
-    public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item)
325
-    {
326
-        if ($line_item->desc()) {
327
-            return true;
328
-        } else {
329
-            foreach ($line_item->children() as $child_line_item) {
330
-                if ($this->check_if_any_line_items_have_a_description($child_line_item)) {
331
-                    return true;
332
-                }
333
-            }
334
-            // well, if I and my children don't have descriptions, I guess not
335
-            return false;
336
-        }
337
-    }
338
-
339
-
340
-    /**
341
-     * Perform the shortcode replacement
342
-     *
343
-     * @param $content
344
-     * @return array|string|string[]
345
-     * @throws EE_Error
346
-     * @throws ReflectionException
347
-     */
348
-    public function espresso_replace_invoice_shortcodes($content)
349
-    {
350
-
351
-        $EE = EE_Registry::instance();
352
-        // Create the logo
353
-        $invoice_logo_url = $this->invoice_payment_method->get_extra_meta(
354
-            'pdf_logo_image',
355
-            true,
356
-            $EE->CFG->organization->logo_url
357
-        );
358
-        if (! empty($invoice_logo_url)) {
359
-            $image_size         = getimagesize($invoice_logo_url);
360
-            $invoice_logo_image =
361
-                '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
362
-        } else {
363
-            $invoice_logo_image = '';
364
-        }
365
-        $SearchValues     = [
366
-            "[organization]",
367
-            "[registration_code]",
368
-            "[transaction_id]",
369
-            "[name]",
370
-            "[base_url]",
371
-            "[download_link]",
372
-            "[invoice_logo_image]",
373
-            "[street]",
374
-            "[city]",
375
-            "[state]",
376
-            "[zip]",
377
-            "[email]",
378
-            "[vat]",
379
-            "[registration_date]",
380
-            "[instructions]",
381
-        ];
382
-        $primary_attendee = $this->transaction->primary_registration()->attendee();
383
-        $org_state        = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID);
384
-        if ($org_state) {
385
-            $org_state_name = $org_state->name();
386
-        } else {
387
-            $org_state_name = '';
388
-        }
389
-        $ReplaceValues = [
390
-            $EE->CFG->organization->get_pretty('name'),
391
-            $this->registration->reg_code(),
392
-            $this->transaction->ID(),
393
-            $primary_attendee->full_name(),
394
-            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice'))
395
-                ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
396
-                : EE_GATEWAYS_URL . 'Invoice/lib/templates/',
397
-            $this->registration->invoice_url(),
398
-            // home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
399
-            $invoice_logo_image,
400
-            empty($EE->CFG->organization->address_2)
401
-                ? $EE->CFG->organization->get_pretty('address_1')
402
-                : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
403
-                    'address_2'
404
-                ),
405
-            $EE->CFG->organization->get_pretty('city'),
406
-            $org_state_name,
407
-            $EE->CFG->organization->get_pretty('zip'),
408
-            $EE->CFG->organization->get_pretty('email'),
409
-            $EE->CFG->organization->vat,
410
-            $this->registration->get_i18n_datetime('REG_date', get_option('date_format')),
411
-            $this->invoice_payment_method->get_extra_meta('pdf_instructions', true),
412
-        ];
413
-
414
-        return str_replace($SearchValues, $ReplaceValues, $content);
415
-    }
416
-
417
-
418
-    public function espressoLoadData($items)
419
-    {
420
-        $lines = $items;
421
-        $data  = [];
422
-        foreach ($lines as $line) {
423
-            $data[] = explode(';', chop($line));
424
-        }
425
-
426
-        return $data;
427
-    }
428
-
429
-
430
-    public function espressoInvoiceTotals($text, $total_cost)
431
-    {
432
-        $html = '';
433
-        if ($total_cost < 0) {
434
-            $total_cost = (-1) * $total_cost;
435
-        }
436
-        $find    = [' '];
437
-        $replace = ['-'];
438
-        $row_id  = strtolower(str_replace($find, $replace, $text));
439
-        $html    .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
440
-        $html    .= '<td class="item_r">' . $text . '</td>';
441
-        $html    .= '<td class="item_r">' . $total_cost . '</td>';
442
-        $html    .= '</tr>';
443
-        return $html;
444
-    }
15
+	/**
16
+	 *
17
+	 * @var EE_Registration
18
+	 */
19
+	private $registration;
20
+
21
+	/**
22
+	 *
23
+	 * @var EE_Transaction
24
+	 */
25
+	private $transaction;
26
+
27
+	/**
28
+	 *
29
+	 * @var EE_Payment_Method
30
+	 */
31
+	private $invoice_payment_method;
32
+
33
+
34
+	/**
35
+	 * Invoice constructor.
36
+	 *
37
+	 * @param int $url_link
38
+	 * @throws EE_Error
39
+	 * @throws ReflectionException
40
+	 * @deprecated 4.9.13
41
+	 */
42
+	public function __construct($url_link = 0)
43
+	{
44
+		EE_Error::doing_it_wrong(
45
+			__CLASS__,
46
+			esc_html__(
47
+				'This class has been deprecated and replaced by the new Messages library.',
48
+				'event_espresso'
49
+			),
50
+			'4.9.12',
51
+			'5.0.0'
52
+		);
53
+		/** @var EEM_Registration $reg_model */
54
+		$reg_model = EE_Registry::instance()->load_model('Registration');
55
+		$this->registration = $reg_model->get_registration_for_reg_url_link($url_link);
56
+		if ($this->registration instanceof EE_Registration) {
57
+			$this->transaction = $this->registration->transaction();
58
+			EE_Config::instance()->gateway->payment_settings;
59
+			$this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice');
60
+		} else {
61
+			EE_Error::add_error(
62
+				esc_html__(
63
+					'Your request appears to be missing some required data, and no information for your transaction could be retrieved.',
64
+					'event_espresso'
65
+				),
66
+				__FILE__,
67
+				__FUNCTION__,
68
+				__LINE__
69
+			);
70
+		}
71
+	}
72
+
73
+
74
+	/**
75
+	 * @param false $download
76
+	 * @throws EE_Error
77
+	 * @throws ReflectionException
78
+	 */
79
+	public function send_invoice($download = false)
80
+	{
81
+		$template_args = [];
82
+		$EE            = EE_Registry::instance();
83
+		/** @var RequestInterface $request */
84
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
85
+		$theme   = $request->getRequestParam('theme', 0, 'int');
86
+		// allow the request to override the default theme defined in the invoice settings
87
+		$theme_requested = $theme > 0 && $theme < 8
88
+				? $theme
89
+				: null;
90
+		$themes          = [
91
+			1 => "simple.css",
92
+			2 => "bauhaus.css",
93
+			3 => "ejs.css",
94
+			4 => "horizon.css",
95
+			5 => "lola.css",
96
+			6 => "tranquility.css",
97
+			7 => "union.css",
98
+		];
99
+		// Get the CSS file
100
+		if (isset($themes[ $theme_requested ])) {
101
+			$template_args['invoice_css'] = $themes[ $theme_requested ];
102
+		} else {
103
+			$template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
104
+				'legacy_invoice_css',
105
+				true,
106
+				'simple.css'
107
+			);
108
+		}
109
+
110
+		if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
111
+			$template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
112
+		} else {
113
+			$template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
114
+		}
115
+		$primary_attendee = $this->transaction->primary_registration()->attendee();
116
+
117
+		$template_args['organization'] = $EE->CFG->organization->get_pretty('name');
118
+		$template_args['street']       = empty($EE->CFG->organization->address_2)
119
+				? $EE->CFG->organization->get_pretty('address_1')
120
+				: $EE->CFG->organization->get_pretty('address_1')
121
+				  . '<br>'
122
+				  . $EE->CFG->organization->get_pretty('address_2');
123
+		$template_args['city']         = $EE->CFG->organization->get_pretty('city');
124
+		$template_args['state']        = EE_Registry::instance()->load_model('State')->get_one_by_ID(
125
+			$EE->CFG->organization->STA_ID
126
+		);
127
+		$template_args['country']      = EE_Registry::instance()->load_model('Country')->get_one_by_ID(
128
+			$EE->CFG->organization->CNT_ISO
129
+		);
130
+		$template_args['zip']          = $EE->CFG->organization->get_pretty('zip');
131
+		$template_args['email']        = $EE->CFG->organization->get_pretty('email');
132
+
133
+		$template_args['registration_code'] = $this->registration->reg_code();
134
+		$template_args['registration_date'] = $this->registration->date();
135
+		$template_args['name']              = $primary_attendee->full_name();
136
+		$template_args['attendee_address']  = $primary_attendee->address();
137
+		$template_args['attendee_address2'] = $primary_attendee->address2();
138
+		$template_args['attendee_city']     = $primary_attendee->city();
139
+		$attendee_state                     = $primary_attendee->state_obj();
140
+		if ($attendee_state) {
141
+			$attendee_state_name = $attendee_state->name();
142
+		} else {
143
+			$attendee_state_name = '';
144
+		}
145
+		$template_args['attendee_state'] = $attendee_state_name;
146
+		$template_args['attendee_zip']   = $primary_attendee->zip();
147
+
148
+		$template_args['ship_name']    = $template_args['name'];
149
+		$template_args['ship_address'] = $template_args['attendee_address'];
150
+		$template_args['ship_city']    = $template_args['attendee_city'];
151
+		$template_args['ship_state']   = $template_args['attendee_state'];
152
+		$template_args['ship_zip']     = $template_args['attendee_zip'];
153
+
154
+		$template_args['total_cost']                 = number_format($this->transaction->total(), 2, '.', '');
155
+		$template_args['transaction']                = $this->transaction;
156
+		$template_args['amount_pd']                  = $this->transaction->paid();
157
+		$template_args['amount_owed']                = $this->transaction->total() - $this->transaction->paid();
158
+		$template_args['payments']                   = $this->transaction->approved_payments();
159
+		$template_args['net_total']                  = '';
160
+		$template_args['edit_reg_info_url']          = $this->registration->edit_attendee_information_url();
161
+		$template_args['retry_payment_url']          = $this->registration->payment_overview_url();
162
+		$template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description(
163
+			$this->transaction->total_line_item()
164
+		);
165
+		if ($template_args['amount_pd'] != $template_args['total_cost']) {
166
+			// $template_args['net_total'] = $this->espressoInvoiceTotals(
167
+			//      esc_html__('SubTotal', 'event_espresso'),
168
+			//      $this->transaction->total());
169
+			//      $this->session_data['cart']['REG']['sub_total']
170
+			// );
171
+			$tax_items = $this->transaction->tax_items();
172
+			if (! empty($tax_items)) {
173
+				foreach ($tax_items as $tax) {
174
+					$template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
175
+				}
176
+			}
177
+
178
+			$difference = $template_args['amount_pd'] - $template_args['total_cost'];
179
+			if ($difference < 0) {
180
+				$text = esc_html__('Discount', 'event_espresso');
181
+			} else {
182
+				$text = esc_html__('Extra', 'event_espresso');
183
+			}
184
+			$template_args['discount'] = $this->espressoInvoiceTotals($text, $difference);
185
+		}
186
+
187
+		$template_args['currency_symbol']               = $EE->CFG->currency->sign;
188
+		$template_args['template_payment_instructions'] = wpautop(
189
+			stripslashes_deep(
190
+				html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES)
191
+			)
192
+		);
193
+		$template_args['shameless_plug']                = apply_filters(
194
+			'FHEE_Invoice__send_invoice__shameless_plug',
195
+			true
196
+		);
197
+		$receipt = $request->getRequestParam('receipt');
198
+		if ($receipt) {
199
+			// receipt-specific stuff
200
+			$events_for_txn              = EEM_Event::instance()->get_all(
201
+				[['Registration.TXN_ID' => $this->transaction->ID()]]
202
+			);
203
+			$ticket_line_items_per_event = [];
204
+			$registrations_per_line_item = [];
205
+			$venues_for_events           = [];
206
+			foreach ($events_for_txn as $event_id => $event) {
207
+				$line_items_for_this_event                = EEM_Line_Item::instance()->get_all(
208
+					[['Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()]]
209
+				);
210
+				$ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
211
+				foreach ($line_items_for_this_event as $line_item_id => $line_item) {
212
+					if (! $line_item instanceof EE_Line_Item) {
213
+						continue;
214
+					}
215
+					$ticket                                       = $line_item->ticket();
216
+					$registrations_for_this_ticket                = EEM_Registration::instance()->get_all(
217
+						[['TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()]]
218
+					);
219
+					$registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
220
+				}
221
+				if ($event instanceof EE_Event) {
222
+					$venues_for_events += $event->venues();
223
+				}
224
+			}
225
+			$tax_total_line_item = EEM_Line_Item::instance()->get_one(
226
+				[['TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total]]
227
+			);
228
+			$questions_to_skip   = [
229
+				EEM_Attendee::system_question_fname,
230
+				EEM_Attendee::system_question_lname,
231
+				EEM_Attendee::system_question_email,
232
+			];
233
+
234
+
235
+			$template_args['events_for_txn']              = $events_for_txn;
236
+			$template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event;
237
+			$template_args['registrations_per_line_item'] = $registrations_per_line_item;
238
+			$template_args['venues_for_events']           = $venues_for_events;
239
+			$template_args['tax_total_line_item']         = $tax_total_line_item;
240
+			$template_args['questions_to_skip']           = $questions_to_skip;
241
+			// d($template_args);
242
+			$template_args['download_link'] = $this->registration->receipt_url('download');
243
+		} else {
244
+			// it's just an invoice we're accessing
245
+			$template_args['download_link'] = $this->registration->invoice_url('download');
246
+		}
247
+
248
+		// Get the HTML as an object
249
+		$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
250
+		$template_header         = EEH_Template::locate_template(
251
+			$templates_relative_path . 'invoice_header.template.php',
252
+			$template_args
253
+		);
254
+		if ($receipt) {
255
+			$template_body = EEH_Template::locate_template(
256
+				$templates_relative_path . 'receipt_body.template.php',
257
+				$template_args
258
+			);
259
+		} else {
260
+			$template_body = EEH_Template::locate_template(
261
+				$templates_relative_path . 'invoice_body.template.php',
262
+				$template_args
263
+			);
264
+		}
265
+
266
+
267
+		$template_footer = EEH_Template::locate_template(
268
+			$templates_relative_path . 'invoice_footer.template.php',
269
+			$template_args
270
+		);
271
+
272
+		$copies = $request->getRequestParam('copies', 1, 'int');
273
+
274
+		$content = $this->espresso_replace_invoice_shortcodes($template_header);
275
+		for ($x = 1; $x <= $copies; $x++) {
276
+			$content .= $this->espresso_replace_invoice_shortcodes($template_body);
277
+		}
278
+		$content .= $this->espresso_replace_invoice_shortcodes($template_footer);
279
+
280
+		// Check if debugging or mobile is set
281
+		if ($request->getRequestParam('html')) {
282
+			echo wp_kses($content, AllowedTags::getWithFormTags());
283
+			exit(0);
284
+		}
285
+		$invoice_name = $template_args['organization'] . ' ';
286
+		$invoice_name .= esc_html__('Invoice #', 'event_espresso');
287
+		$invoice_name .= $template_args['registration_code'];
288
+		$invoice_name .= esc_html__(' for ', 'event_espresso') . $template_args['name'];
289
+		$invoice_name = str_replace(' ', '_', $invoice_name);
290
+		// Create the PDF
291
+		if ($request->requestParamIsSet('html')) {
292
+			echo wp_kses($content, AllowedTags::getWithFormTags());
293
+		} else {
294
+			// only load dompdf if nobody else has yet...
295
+			if (! class_exists('Dompdf\Dompdf')) {
296
+				require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
297
+				Dompdf\Autoloader::register();
298
+			}
299
+			$options = new Dompdf\Options();
300
+			$options->set('isRemoteEnabled', true);
301
+			$options->set('isJavascriptEnabled', false);
302
+			if (defined('DOMPDF_FONT_DIR')) {
303
+				$options->setFontDir(DOMPDF_FONT_DIR);
304
+				$options->setFontCache(DOMPDF_FONT_DIR);
305
+			}
306
+			$dompdf = new Dompdf\Dompdf($options);
307
+			$dompdf->loadHtml($content);
308
+			$dompdf->render();
309
+			$dompdf->stream($invoice_name . ".pdf", ['Attachment' => $download]);
310
+		}
311
+		exit(0);
312
+	}
313
+
314
+
315
+	/**
316
+	 * Checks if this line item, or any of its children, actually has a description.
317
+	 * If none do, then the template can decide to not show any description column
318
+	 *
319
+	 * @param EE_Line_Item $line_item
320
+	 * @return boolean
321
+	 * @throws EE_Error
322
+	 * @throws ReflectionException
323
+	 */
324
+	public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item)
325
+	{
326
+		if ($line_item->desc()) {
327
+			return true;
328
+		} else {
329
+			foreach ($line_item->children() as $child_line_item) {
330
+				if ($this->check_if_any_line_items_have_a_description($child_line_item)) {
331
+					return true;
332
+				}
333
+			}
334
+			// well, if I and my children don't have descriptions, I guess not
335
+			return false;
336
+		}
337
+	}
338
+
339
+
340
+	/**
341
+	 * Perform the shortcode replacement
342
+	 *
343
+	 * @param $content
344
+	 * @return array|string|string[]
345
+	 * @throws EE_Error
346
+	 * @throws ReflectionException
347
+	 */
348
+	public function espresso_replace_invoice_shortcodes($content)
349
+	{
350
+
351
+		$EE = EE_Registry::instance();
352
+		// Create the logo
353
+		$invoice_logo_url = $this->invoice_payment_method->get_extra_meta(
354
+			'pdf_logo_image',
355
+			true,
356
+			$EE->CFG->organization->logo_url
357
+		);
358
+		if (! empty($invoice_logo_url)) {
359
+			$image_size         = getimagesize($invoice_logo_url);
360
+			$invoice_logo_image =
361
+				'<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
362
+		} else {
363
+			$invoice_logo_image = '';
364
+		}
365
+		$SearchValues     = [
366
+			"[organization]",
367
+			"[registration_code]",
368
+			"[transaction_id]",
369
+			"[name]",
370
+			"[base_url]",
371
+			"[download_link]",
372
+			"[invoice_logo_image]",
373
+			"[street]",
374
+			"[city]",
375
+			"[state]",
376
+			"[zip]",
377
+			"[email]",
378
+			"[vat]",
379
+			"[registration_date]",
380
+			"[instructions]",
381
+		];
382
+		$primary_attendee = $this->transaction->primary_registration()->attendee();
383
+		$org_state        = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID);
384
+		if ($org_state) {
385
+			$org_state_name = $org_state->name();
386
+		} else {
387
+			$org_state_name = '';
388
+		}
389
+		$ReplaceValues = [
390
+			$EE->CFG->organization->get_pretty('name'),
391
+			$this->registration->reg_code(),
392
+			$this->transaction->ID(),
393
+			$primary_attendee->full_name(),
394
+			(is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice'))
395
+				? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
396
+				: EE_GATEWAYS_URL . 'Invoice/lib/templates/',
397
+			$this->registration->invoice_url(),
398
+			// home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
399
+			$invoice_logo_image,
400
+			empty($EE->CFG->organization->address_2)
401
+				? $EE->CFG->organization->get_pretty('address_1')
402
+				: $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
403
+					'address_2'
404
+				),
405
+			$EE->CFG->organization->get_pretty('city'),
406
+			$org_state_name,
407
+			$EE->CFG->organization->get_pretty('zip'),
408
+			$EE->CFG->organization->get_pretty('email'),
409
+			$EE->CFG->organization->vat,
410
+			$this->registration->get_i18n_datetime('REG_date', get_option('date_format')),
411
+			$this->invoice_payment_method->get_extra_meta('pdf_instructions', true),
412
+		];
413
+
414
+		return str_replace($SearchValues, $ReplaceValues, $content);
415
+	}
416
+
417
+
418
+	public function espressoLoadData($items)
419
+	{
420
+		$lines = $items;
421
+		$data  = [];
422
+		foreach ($lines as $line) {
423
+			$data[] = explode(';', chop($line));
424
+		}
425
+
426
+		return $data;
427
+	}
428
+
429
+
430
+	public function espressoInvoiceTotals($text, $total_cost)
431
+	{
432
+		$html = '';
433
+		if ($total_cost < 0) {
434
+			$total_cost = (-1) * $total_cost;
435
+		}
436
+		$find    = [' '];
437
+		$replace = ['-'];
438
+		$row_id  = strtolower(str_replace($find, $replace, $text));
439
+		$html    .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
440
+		$html    .= '<td class="item_r">' . $text . '</td>';
441
+		$html    .= '<td class="item_r">' . $total_cost . '</td>';
442
+		$html    .= '</tr>';
443
+		return $html;
444
+	}
445 445
 }
Please login to merge, or discard this patch.
modules/ticket_selector/templates/simple_ticket_selector.template.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 if ($ticket instanceof EE_Ticket) {
28 28
     do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event);
29 29
     $ticket_description .= ! empty($ticket_description)
30
-        ? '<br />' . $ticket_status_display
30
+        ? '<br />'.$ticket_status_display
31 31
         : $ticket_status_display;
32 32
     if (strpos($ticket_description, '<div') === false) {
33 33
         $ticket_description = "<p>{$ticket_description}</p>";
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 <div id="no-tkt-slctr-ticket-dv-<?php echo esc_attr($EVT_ID); ?>" class="no-tkt-slctr-ticket-dv">
37 37
     <div class="no-tkt-slctr-ticket-content-dv">
38 38
         <h5><?php echo esc_html($ticket->name()); ?></h5>
39
-        <?php if (! empty($ticket_description)) { ?>
39
+        <?php if ( ! empty($ticket_description)) { ?>
40 40
             <?php echo wp_kses($ticket_description, AllowedTags::getAllowedTags()); ?>
41 41
         <?php } ?>
42 42
     </div><!-- .no-tkt-slctr-ticket-content-dv -->
Please login to merge, or discard this patch.
modules/ticket_selector/templates/ticket_details.template.php 2 patches
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -21,28 +21,28 @@  discard block
 block discarded – undo
21 21
 use EventEspresso\modules\ticket_selector\TicketDetails;
22 22
 
23 23
 $event_date_label = apply_filters(
24
-    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date',
25
-    esc_html__('Event Date ', 'event_espresso')
24
+	'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date',
25
+	esc_html__('Event Date ', 'event_espresso')
26 26
 );
27 27
 
28 28
 $sold_label = apply_filters(
29
-    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold',
30
-    esc_html__('Sold', 'event_espresso')
29
+	'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold',
30
+	esc_html__('Sold', 'event_espresso')
31 31
 );
32 32
 
33 33
 $remaining_label = apply_filters(
34
-    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left',
35
-    esc_html__('Remaining', 'event_espresso')
34
+	'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left',
35
+	esc_html__('Remaining', 'event_espresso')
36 36
 );
37 37
 
38 38
 $total_sold_label = apply_filters(
39
-    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold',
40
-    esc_html__('Total Sold', 'event_espresso')
39
+	'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold',
40
+	esc_html__('Total Sold', 'event_espresso')
41 41
 );
42 42
 
43 43
 $spaces_left_label = apply_filters(
44
-    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left',
45
-    esc_html__('Total Spaces Left', 'event_espresso')
44
+	'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left',
45
+	esc_html__('Total Spaces Left', 'event_espresso')
46 46
 );
47 47
 
48 48
 ?>
@@ -56,32 +56,32 @@  discard block
 block discarded – undo
56 56
                     <p><?php echo wp_kses($ticket->description(), AllowedTags::getAllowedTags()); ?></p>
57 57
 
58 58
                     <?php
59
-                    do_action(
60
-                        'AHEE__ticket_selector_chart_template__ticket_details__after_description',
61
-                        $ticket,
62
-                        $ticket_price,
63
-                        $display_ticket_price
64
-                    );
65
-                    ?>
59
+					do_action(
60
+						'AHEE__ticket_selector_chart_template__ticket_details__after_description',
61
+						$ticket,
62
+						$ticket_price,
63
+						$display_ticket_price
64
+					);
65
+					?>
66 66
                     <section class="tckt-slctr-tkt-sale-dates-sctn">
67 67
                         <h5>
68 68
                             <?php echo apply_filters(
69
-                                'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading',
70
-                                esc_html__('Sale Dates', 'event_espresso')
71
-                            ); ?>
69
+								'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading',
70
+								esc_html__('Sale Dates', 'event_espresso')
71
+							); ?>
72 72
                         </h5>
73 73
                         <span class="drk-grey-text small-text no-bold"> -
74 74
                             <?php echo apply_filters(
75
-                                'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message',
76
-                                esc_html__('The dates when this option is available for purchase.', 'event_espresso')
77
-                            ); ?>
75
+								'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message',
76
+								esc_html__('The dates when this option is available for purchase.', 'event_espresso')
77
+							); ?>
78 78
                         </span>
79 79
                         <br />
80 80
                         <span class="ticket-details-label-spn drk-grey-text">
81 81
                             <?php echo apply_filters(
82
-                                'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale',
83
-                                esc_html__('Goes On Sale:', 'event_espresso')
84
-                            ); ?>
82
+								'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale',
83
+								esc_html__('Goes On Sale:', 'event_espresso')
84
+							); ?>
85 85
                         </span>
86 86
                         <span class="dashicons dashicons-calendar"></span>
87 87
                         <?php echo esc_html($ticket->get_i18n_datetime('TKT_start_date', $date_format)) . ' &nbsp; '; ?>
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
                         <br />
91 91
                         <span class="ticket-details-label-spn drk-grey-text">
92 92
                             <?php echo apply_filters(
93
-                                'FHEE__ticket_selector_chart_template__ticket_details_sales_end',
94
-                                esc_html__('Sales End:', 'event_espresso')
95
-                            ); ?>
93
+								'FHEE__ticket_selector_chart_template__ticket_details_sales_end',
94
+								esc_html__('Sales End:', 'event_espresso')
95
+							); ?>
96 96
                         </span>
97 97
                         <span class="dashicons dashicons-calendar"></span>
98 98
                         <?php echo esc_html($ticket->get_i18n_datetime('TKT_end_date', $date_format)) . ' &nbsp; '; ?>
@@ -108,53 +108,53 @@  discard block
 block discarded – undo
108 108
                         <section class="tckt-slctr-tkt-quantities-sctn">
109 109
                             <h5>
110 110
                                 <?php echo apply_filters(
111
-                                    'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading',
112
-                                    esc_html__('Purchasable Quantities', 'event_espresso')
113
-                                ); ?>
111
+									'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading',
112
+									esc_html__('Purchasable Quantities', 'event_espresso')
113
+								); ?>
114 114
                             </h5>
115 115
                             <span class="drk-grey-text small-text no-bold"> -
116 116
                                 <?php echo apply_filters(
117
-                                    'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message',
118
-                                    esc_html__(
119
-                                        'The number of tickets that can be purchased per transaction (if available).',
120
-                                        'event_espresso'
121
-                                    )
122
-                                ); ?>
117
+									'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message',
118
+									esc_html__(
119
+										'The number of tickets that can be purchased per transaction (if available).',
120
+										'event_espresso'
121
+									)
122
+								); ?>
123 123
                             </span>
124 124
                             <br />
125 125
                             <span class="ticket-details-label-spn drk-grey-text">
126 126
                                 <?php echo apply_filters(
127
-                                    'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty',
128
-                                    esc_html__('Minimum Qty:', 'event_espresso')
129
-                                ); ?>
127
+									'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty',
128
+									esc_html__('Minimum Qty:', 'event_espresso')
129
+								); ?>
130 130
                             </span>
131 131
                             <?php
132
-                            echo ($ticket->min() > 0 ? $ticket->min() : 0);
132
+							echo ($ticket->min() > 0 ? $ticket->min() : 0);
133 133
 
134
-                            if ($ticket->min() > $remaining) {
135
-                                ?> &nbsp;
134
+							if ($ticket->min() > $remaining) {
135
+								?> &nbsp;
136 136
                                 <span class="important-notice small-text">
137 137
                                 <?php echo apply_filters(
138
-                                    'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message',
139
-                                    esc_html__(
140
-                                        'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining',
141
-                                        'event_espresso'
142
-                                    )
143
-                                ); ?>
138
+									'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message',
139
+									esc_html__(
140
+										'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining',
141
+										'event_espresso'
142
+									)
143
+								); ?>
144 144
                                 </span>
145 145
                             <?php } ?>
146 146
                             <br />
147 147
                             <?php // $max = min( $max, $max_atndz );?>
148 148
                             <span class="ticket-details-label-spn drk-grey-text">
149 149
                                 <?php echo apply_filters(
150
-                                    'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty',
151
-                                    esc_html__('Maximum Qty:', 'event_espresso')
152
-                                ); ?>
150
+									'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty',
151
+									esc_html__('Maximum Qty:', 'event_espresso')
152
+								); ?>
153 153
                             </span>
154 154
                             <?php echo ($ticket->max() === EE_INF
155
-                                ? esc_html__('no limit', 'event_espresso')
156
-                                : max($ticket->max(), 1));
157
-                            ?>
155
+								? esc_html__('no limit', 'event_espresso')
156
+								: max($ticket->max(), 1));
157
+							?>
158 158
                             <br />
159 159
                         </section>
160 160
                         <br />
@@ -164,31 +164,31 @@  discard block
 block discarded – undo
164 164
                         <section class="tckt-slctr-tkt-uses-sctn">
165 165
                             <h5>
166 166
                                 <?php echo apply_filters(
167
-                                    'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading',
168
-                                    esc_html__('Event Date Ticket Uses', 'event_espresso')
169
-                                ); ?>
167
+									'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading',
168
+									esc_html__('Event Date Ticket Uses', 'event_espresso')
169
+								); ?>
170 170
                             </h5>
171 171
                             <span class="drk-grey-text small-text no-bold"> -
172 172
                                 <?php echo apply_filters(
173
-                                    'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message',
174
-                                    sprintf(
175
-                                        esc_html__(
176
-                                            'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s',
177
-                                            'event_espresso'
178
-                                        ),
179
-                                        '<br/>',
180
-                                        '<strong>',
181
-                                        '</strong>'
182
-                                    )
183
-                                );
184
-                                ?>
173
+									'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message',
174
+									sprintf(
175
+										esc_html__(
176
+											'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s',
177
+											'event_espresso'
178
+										),
179
+										'<br/>',
180
+										'<strong>',
181
+										'</strong>'
182
+									)
183
+								);
184
+								?>
185 185
                             </span>
186 186
                             <br />
187 187
                             <span class="ticket-details-label-spn drk-grey-text">
188 188
                                 <?php echo apply_filters(
189
-                                    'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes',
190
-                                    esc_html__('# Datetimes:', 'event_espresso')
191
-                                ); ?>
189
+									'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes',
190
+									esc_html__('# Datetimes:', 'event_espresso')
191
+								); ?>
192 192
                             </span>
193 193
                             <?php echo wp_kses($ticket->uses(), AllowedTags::getAllowedTags()); ?>
194 194
                             <br />
@@ -196,24 +196,24 @@  discard block
 block discarded – undo
196 196
                     <?php } ?>
197 197
 
198 198
                     <?php
199
-                    $datetimes          = $ticket->datetimes_ordered($event_is_expired, false);
200
-                    $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width';
201
-                    if (! empty($datetimes)) { ?>
199
+					$datetimes          = $ticket->datetimes_ordered($event_is_expired, false);
200
+					$chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width';
201
+					if (! empty($datetimes)) { ?>
202 202
                         <section class="tckt-slctr-tkt-datetimes-sctn">
203 203
                             <h5>
204 204
                                 <?php echo apply_filters(
205
-                                    'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading',
206
-                                    esc_html__('Access', 'event_espresso')
207
-                                ); ?>
205
+									'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading',
206
+									esc_html__('Access', 'event_espresso')
207
+								); ?>
208 208
                             </h5>
209 209
                             <span class="drk-grey-text small-text no-bold"> -
210 210
                                 <?php echo apply_filters(
211
-                                    'FHEE__ticket_selector_chart_template__ticket_details_event_access_message',
212
-                                    esc_html__(
213
-                                        'This option allows access to the following dates and times.',
214
-                                        'event_espresso'
215
-                                    )
216
-                                ); ?>
211
+									'FHEE__ticket_selector_chart_template__ticket_details_event_access_message',
212
+									esc_html__(
213
+										'This option allows access to the following dates and times.',
214
+										'event_espresso'
215
+									)
216
+								); ?>
217 217
                             </span>
218 218
                         <div class="tckt-slctr-tkt-details-tbl-wrap-dv">
219 219
                             <table class="tckt-slctr-tkt-details-tbl">
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
                                             <span class="dashicons dashicons-calendar"></span>
224 224
                                             <span class="small-text">
225 225
                                             <?php echo apply_filters(
226
-                                                'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date',
227
-                                                esc_html__('Date ', 'event_espresso')
228
-                                            ); ?>
226
+												'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date',
227
+												esc_html__('Date ', 'event_espresso')
228
+											); ?>
229 229
                                         </span>
230 230
                                         </th>
231 231
                                         <th class="tckt-slctr-tkt-details-time-th <?php echo esc_attr($chart_column_width); ?>">
@@ -238,33 +238,33 @@  discard block
 block discarded – undo
238 238
                                         <th class="tckt-slctr-tkt-details-this-ticket-sold-th ee-fourth-width cntr">
239 239
                                             <span class="smaller-text">
240 240
                                                 <?php echo apply_filters(
241
-                                                    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold',
242
-                                                    sprintf(esc_html__('Sold', 'event_espresso'), '<br/>')
243
-                                                ); ?>
241
+													'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold',
242
+													sprintf(esc_html__('Sold', 'event_espresso'), '<br/>')
243
+												); ?>
244 244
                                             </span>
245 245
                                         </th>
246 246
                                         <th class="tckt-slctr-tkt-details-this-ticket-left-th ee-fourth-width cntr">
247 247
                                             <span class="smaller-text">
248 248
                                                 <?php echo apply_filters(
249
-                                                    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left',
250
-                                                    sprintf(esc_html__('Remaining', 'event_espresso'), '<br/>')
251
-                                                ); ?>
249
+													'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left',
250
+													sprintf(esc_html__('Remaining', 'event_espresso'), '<br/>')
251
+												); ?>
252 252
                                             </span>
253 253
                                         </th>
254 254
                                         <th class="tckt-slctr-tkt-details-total-tickets-sold-th ee-fourth-width cntr">
255 255
                                             <span class="smaller-text">
256 256
                                                 <?php echo apply_filters(
257
-                                                    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold',
258
-                                                    sprintf(esc_html__('Total%sSold', 'event_espresso'), '<br/>')
259
-                                                ); ?>
257
+													'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold',
258
+													sprintf(esc_html__('Total%sSold', 'event_espresso'), '<br/>')
259
+												); ?>
260 260
                                             </span>
261 261
                                         </th>
262 262
                                         <th class="tckt-slctr-tkt-details-total-tickets-left-th ee-fourth-width cntr">
263 263
                                             <span class="smaller-text">
264 264
                                                 <?php echo apply_filters(
265
-                                                    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left',
266
-                                                    sprintf(esc_html__('Total Spaces%sLeft', 'event_espresso'), '<br/>')
267
-                                                ); ?>
265
+													'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left',
266
+													sprintf(esc_html__('Total Spaces%sLeft', 'event_espresso'), '<br/>')
267
+												); ?>
268 268
                                             </span>
269 269
                                         </th>
270 270
                                         <?php endif; // end $show_ticket_sale_columns conditional ?>
@@ -272,25 +272,25 @@  discard block
 block discarded – undo
272 272
                                 </thead>
273 273
                                 <tbody>
274 274
                                 <?php foreach ($datetimes as $datetime) {
275
-                                    if ($datetime instanceof EE_Datetime) { ?>
275
+									if ($datetime instanceof EE_Datetime) { ?>
276 276
                                     <tr>
277 277
                                         <td data-th="<?php echo esc_attr($event_date_label); ?>" class="small-text">
278 278
                                             <?php $datetime_name = $datetime->name(); ?>
279 279
                                             <?php echo ! empty($datetime_name)
280
-                                            ? '<b>' . esc_html($datetime_name) . '</b><br/>'
281
-                                            : ''; ?>
280
+											? '<b>' . esc_html($datetime_name) . '</b><br/>'
281
+											: ''; ?>
282 282
                                             <?php echo esc_html($datetime->date_range(
283
-                                                $date_format,
284
-                                                esc_html__(' to  ', 'event_espresso')
285
-                                            )); ?>
283
+												$date_format,
284
+												esc_html__(' to  ', 'event_espresso')
285
+											)); ?>
286 286
                                         </td>
287 287
                                         <td data-th="<?php esc_html_e('Time ', 'event_espresso'); ?>"
288 288
                                             class="cntr small-text"
289 289
                                         >
290 290
                                             <?php echo esc_html($datetime->time_range(
291
-                                                $time_format,
292
-                                                esc_html__(' to  ', 'event_espresso')
293
-                                            )); ?>
291
+												$time_format,
292
+												esc_html__(' to  ', 'event_espresso')
293
+											)); ?>
294 294
                                         </td>
295 295
                                         <?php if ($show_ticket_sale_columns) : ?>
296 296
                                         <td data-th="<?php echo esc_attr($sold_label); ?>" class="cntr small-text">
@@ -298,25 +298,25 @@  discard block
 block discarded – undo
298 298
                                         </td>
299 299
                                         <td data-th="<?php echo esc_attr($remaining_label); ?>" class="cntr small-text">
300 300
                                             <?php echo ($remaining === EE_INF
301
-                                                ? '<span class="smaller-text">'
302
-                                                  . esc_html__('unlimited ', 'event_espresso')
303
-                                                  . '</span>'
304
-                                                : $remaining); ?>
301
+												? '<span class="smaller-text">'
302
+												  . esc_html__('unlimited ', 'event_espresso')
303
+												  . '</span>'
304
+												: $remaining); ?>
305 305
                                         </td>
306 306
                                         <td data-th="<?php echo esc_attr($total_sold_label); ?>" class="cntr small-text">
307 307
                                             <?php echo esc_html($datetime->sold()); ?>
308 308
                                         </td>
309 309
                                             <?php $tkts_left = $datetime->sold_out()
310
-                                                ? '<span class="sold-out smaller-text">'
311
-                                                  . esc_html__('Sold&nbsp;Out', 'event_espresso')
312
-                                                  . '</span>'
313
-                                                : $datetime->spaces_remaining(); ?>
310
+												? '<span class="sold-out smaller-text">'
311
+												  . esc_html__('Sold&nbsp;Out', 'event_espresso')
312
+												  . '</span>'
313
+												: $datetime->spaces_remaining(); ?>
314 314
                                         <td data-th="<?php echo esc_attr($spaces_left_label); ?>" class="cntr small-text">
315 315
                                             <?php echo ($tkts_left === EE_INF
316
-                                                ? '<span class="smaller-text">'
317
-                                                  . esc_html__('unlimited ', 'event_espresso')
318
-                                                  . '</span>'
319
-                                                : $tkts_left); ?>
316
+												? '<span class="smaller-text">'
317
+												  . esc_html__('unlimited ', 'event_espresso')
318
+												  . '</span>'
319
+												: $tkts_left); ?>
320 320
                                         </td>
321 321
                                         <?php endif; // end $show_ticket_sale_columns conditional ?>
322 322
                                     </tr>
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                             ); ?>
85 85
                         </span>
86 86
                         <span class="dashicons dashicons-calendar"></span>
87
-                        <?php echo esc_html($ticket->get_i18n_datetime('TKT_start_date', $date_format)) . ' &nbsp; '; ?>
87
+                        <?php echo esc_html($ticket->get_i18n_datetime('TKT_start_date', $date_format)).' &nbsp; '; ?>
88 88
                         <span class="dashicons dashicons-clock"></span>
89 89
                         <?php echo esc_html($ticket->get_i18n_datetime('TKT_start_date', $time_format)); ?>
90 90
                         <br />
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
                             ); ?>
96 96
                         </span>
97 97
                         <span class="dashicons dashicons-calendar"></span>
98
-                        <?php echo esc_html($ticket->get_i18n_datetime('TKT_end_date', $date_format)) . ' &nbsp; '; ?>
98
+                        <?php echo esc_html($ticket->get_i18n_datetime('TKT_end_date', $date_format)).' &nbsp; '; ?>
99 99
                         <span class="dashicons dashicons-clock"></span>
100 100
                         <?php echo esc_html($ticket->get_i18n_datetime('TKT_end_date', $time_format)); ?>
101 101
                         <br />
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                         <br />
161 161
                     <?php } ?>
162 162
 
163
-                    <?php if ((! defined('EE_DECAF') || EE_DECAF !== true) && $ticket->uses() !== EE_INF) { ?>
163
+                    <?php if (( ! defined('EE_DECAF') || EE_DECAF !== true) && $ticket->uses() !== EE_INF) { ?>
164 164
                         <section class="tckt-slctr-tkt-uses-sctn">
165 165
                             <h5>
166 166
                                 <?php echo apply_filters(
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
                     <?php
199 199
                     $datetimes          = $ticket->datetimes_ordered($event_is_expired, false);
200 200
                     $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width';
201
-                    if (! empty($datetimes)) { ?>
201
+                    if ( ! empty($datetimes)) { ?>
202 202
                         <section class="tckt-slctr-tkt-datetimes-sctn">
203 203
                             <h5>
204 204
                                 <?php echo apply_filters(
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                                         <td data-th="<?php echo esc_attr($event_date_label); ?>" class="small-text">
278 278
                                             <?php $datetime_name = $datetime->name(); ?>
279 279
                                             <?php echo ! empty($datetime_name)
280
-                                            ? '<b>' . esc_html($datetime_name) . '</b><br/>'
280
+                                            ? '<b>'.esc_html($datetime_name).'</b><br/>'
281 281
                                             : ''; ?>
282 282
                                             <?php echo esc_html($datetime->date_range(
283 283
                                                 $date_format,
@@ -334,4 +334,4 @@  discard block
 block discarded – undo
334 334
             </div>
335 335
         </td>
336 336
     </tr>
337
-<?php endif;  // end template_settings->show_ticket_details check
337
+<?php endif; // end template_settings->show_ticket_details check
Please login to merge, or discard this patch.
modules/bot_trap/EED_Bot_Trap.module.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public static function set_trap()
60 60
     {
61
-        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/');
61
+        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).'/');
62 62
         add_action(
63 63
             'AHEE__ticket_selector_chart__template__after_ticket_selector',
64 64
             array('EED_Bot_Trap', 'generate_bot_trap'),
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
     {
124 124
         $time = microtime(true);
125 125
         $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
126
-        $html .= '<label for="tkt-slctr-request-processor-email-' . esc_attr($time) . '">' . esc_html__('please do not enter anything in this input', 'event_espresso') . '</label>';
126
+        $html .= '<label for="tkt-slctr-request-processor-email-'.esc_attr($time).'">'.esc_html__('please do not enter anything in this input', 'event_espresso').'</label>';
127 127
         $html .= '<input type="email" id="tkt-slctr-request-processor-email-';
128
-        $html .= esc_attr($time) . '" name="tkt-slctr-request-processor-email" value=""/>';
128
+        $html .= esc_attr($time).'" name="tkt-slctr-request-processor-email" value=""/>';
129 129
         $html .= '</div>';
130 130
         echo wp_kses($html, AllowedTags::getWithFormTags());
131 131
     }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             return;
151 151
         }
152 152
         // check the given callback is valid first before executing
153
-        if (! is_callable($triggered_trap_callback)) {
153
+        if ( ! is_callable($triggered_trap_callback)) {
154 154
             // invalid callback so lets just sub in our default.
155 155
             $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
156 156
         }
Please login to merge, or discard this patch.
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -17,305 +17,305 @@
 block discarded – undo
17 17
  */
18 18
 class EED_Bot_Trap extends EED_Module
19 19
 {
20
-    /**
21
-     * @return EED_Module|EED_Bot_Trap
22
-     * @throws EE_Error
23
-     * @throws ReflectionException
24
-     */
25
-    public static function instance()
26
-    {
27
-        return parent::get_instance(__CLASS__);
28
-    }
20
+	/**
21
+	 * @return EED_Module|EED_Bot_Trap
22
+	 * @throws EE_Error
23
+	 * @throws ReflectionException
24
+	 */
25
+	public static function instance()
26
+	{
27
+		return parent::get_instance(__CLASS__);
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * set_hooks - for hooking into EE Core, other modules, etc
33
-     *
34
-     * @return void
35
-     */
36
-    public static function set_hooks()
37
-    {
38
-        if (
39
-            apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) &&
40
-            EE_Registry::instance()->CFG->registration->use_bot_trap
41
-        ) {
42
-            EED_Bot_Trap::set_trap();
43
-            // redirect bots to bogus success page
44
-            EE_Config::register_route(
45
-                'ticket_selection_received',
46
-                'EED_Bot_Trap',
47
-                'display_bot_trap_success'
48
-            );
49
-        }
50
-    }
31
+	/**
32
+	 * set_hooks - for hooking into EE Core, other modules, etc
33
+	 *
34
+	 * @return void
35
+	 */
36
+	public static function set_hooks()
37
+	{
38
+		if (
39
+			apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) &&
40
+			EE_Registry::instance()->CFG->registration->use_bot_trap
41
+		) {
42
+			EED_Bot_Trap::set_trap();
43
+			// redirect bots to bogus success page
44
+			EE_Config::register_route(
45
+				'ticket_selection_received',
46
+				'EED_Bot_Trap',
47
+				'display_bot_trap_success'
48
+			);
49
+		}
50
+	}
51 51
 
52 52
 
53
-    /**
54
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
55
-     *
56
-     * @return void
57
-     */
58
-    public static function set_trap()
59
-    {
60
-        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/');
61
-        add_action(
62
-            'AHEE__ticket_selector_chart__template__after_ticket_selector',
63
-            array('EED_Bot_Trap', 'generate_bot_trap'),
64
-            10,
65
-            2
66
-        );
67
-        add_action(
68
-            'EED_Ticket_Selector__process_ticket_selections__before',
69
-            array('EED_Bot_Trap', 'process_bot_trap'),
70
-            1,
71
-            2
72
-        );
73
-    }
53
+	/**
54
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
55
+	 *
56
+	 * @return void
57
+	 */
58
+	public static function set_trap()
59
+	{
60
+		define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/');
61
+		add_action(
62
+			'AHEE__ticket_selector_chart__template__after_ticket_selector',
63
+			array('EED_Bot_Trap', 'generate_bot_trap'),
64
+			10,
65
+			2
66
+		);
67
+		add_action(
68
+			'EED_Ticket_Selector__process_ticket_selections__before',
69
+			array('EED_Bot_Trap', 'process_bot_trap'),
70
+			1,
71
+			2
72
+		);
73
+	}
74 74
 
75 75
 
76
-    /**
77
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
78
-     *
79
-     * @return void
80
-     */
81
-    public static function set_hooks_admin()
82
-    {
83
-        if (
84
-            EED_Bot_Trap::getRequest()->isAjax()
85
-            && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true)
86
-            && EE_Registry::instance()->CFG->registration->use_bot_trap
87
-        ) {
88
-            EED_Bot_Trap::set_trap();
89
-        }
90
-        add_action(
91
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
92
-            array('EED_Bot_Trap', 'bot_trap_settings_form'),
93
-            5
94
-        );
95
-        add_filter(
96
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
97
-            array('EED_Bot_Trap', 'update_bot_trap_settings_form'),
98
-            10,
99
-            1
100
-        );
101
-    }
76
+	/**
77
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
78
+	 *
79
+	 * @return void
80
+	 */
81
+	public static function set_hooks_admin()
82
+	{
83
+		if (
84
+			EED_Bot_Trap::getRequest()->isAjax()
85
+			&& apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true)
86
+			&& EE_Registry::instance()->CFG->registration->use_bot_trap
87
+		) {
88
+			EED_Bot_Trap::set_trap();
89
+		}
90
+		add_action(
91
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
92
+			array('EED_Bot_Trap', 'bot_trap_settings_form'),
93
+			5
94
+		);
95
+		add_filter(
96
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
97
+			array('EED_Bot_Trap', 'update_bot_trap_settings_form'),
98
+			10,
99
+			1
100
+		);
101
+	}
102 102
 
103 103
 
104
-    /**
105
-     * run - initial module setup
106
-     *
107
-     * @param WP $WP
108
-     * @return void
109
-     */
110
-    public function run($WP)
111
-    {
112
-    }
104
+	/**
105
+	 * run - initial module setup
106
+	 *
107
+	 * @param WP $WP
108
+	 * @return void
109
+	 */
110
+	public function run($WP)
111
+	{
112
+	}
113 113
 
114 114
 
115
-    /**
116
-     * generate_bot_trap
117
-     *
118
-     * @return void
119
-     * @throws RuntimeException
120
-     */
121
-    public static function generate_bot_trap()
122
-    {
123
-        $time = microtime(true);
124
-        $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
125
-        $html .= '<label for="tkt-slctr-request-processor-email-' . esc_attr($time) . '">' . esc_html__('please do not enter anything in this input', 'event_espresso') . '</label>';
126
-        $html .= '<input type="email" id="tkt-slctr-request-processor-email-';
127
-        $html .= esc_attr($time) . '" name="tkt-slctr-request-processor-email" value=""/>';
128
-        $html .= '</div>';
129
-        echo wp_kses($html, AllowedTags::getWithFormTags());
130
-    }
115
+	/**
116
+	 * generate_bot_trap
117
+	 *
118
+	 * @return void
119
+	 * @throws RuntimeException
120
+	 */
121
+	public static function generate_bot_trap()
122
+	{
123
+		$time = microtime(true);
124
+		$html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
125
+		$html .= '<label for="tkt-slctr-request-processor-email-' . esc_attr($time) . '">' . esc_html__('please do not enter anything in this input', 'event_espresso') . '</label>';
126
+		$html .= '<input type="email" id="tkt-slctr-request-processor-email-';
127
+		$html .= esc_attr($time) . '" name="tkt-slctr-request-processor-email" value=""/>';
128
+		$html .= '</div>';
129
+		echo wp_kses($html, AllowedTags::getWithFormTags());
130
+	}
131 131
 
132 132
 
133
-    /**
134
-     * process_bot_trap
135
-     *
136
-     * @param array|string $triggered_trap_callback Callback that will be executed for handling the
137
-     *                                              response if the bot trap is triggered.
138
-     *                                              It should receive one argument: a boolean indicating
139
-     *                                              whether the trap was triggered by suspicious timing or not.
140
-     * @throws RuntimeException
141
-     */
142
-    public static function process_bot_trap($triggered_trap_callback = array())
143
-    {
144
-        // what's your email address Mr. Bot ?
145
-        $empty_trap = EED_Bot_Trap::getRequest()->getRequestParam('tkt-slctr-request-processor-email') === '';
146
-        // are we human ?
147
-        if ($empty_trap) {
148
-            do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
149
-            return;
150
-        }
151
-        // check the given callback is valid first before executing
152
-        if (! is_callable($triggered_trap_callback)) {
153
-            // invalid callback so lets just sub in our default.
154
-            $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
155
-        }
156
-        call_user_func($triggered_trap_callback);
157
-    }
133
+	/**
134
+	 * process_bot_trap
135
+	 *
136
+	 * @param array|string $triggered_trap_callback Callback that will be executed for handling the
137
+	 *                                              response if the bot trap is triggered.
138
+	 *                                              It should receive one argument: a boolean indicating
139
+	 *                                              whether the trap was triggered by suspicious timing or not.
140
+	 * @throws RuntimeException
141
+	 */
142
+	public static function process_bot_trap($triggered_trap_callback = array())
143
+	{
144
+		// what's your email address Mr. Bot ?
145
+		$empty_trap = EED_Bot_Trap::getRequest()->getRequestParam('tkt-slctr-request-processor-email') === '';
146
+		// are we human ?
147
+		if ($empty_trap) {
148
+			do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
149
+			return;
150
+		}
151
+		// check the given callback is valid first before executing
152
+		if (! is_callable($triggered_trap_callback)) {
153
+			// invalid callback so lets just sub in our default.
154
+			$triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
155
+		}
156
+		call_user_func($triggered_trap_callback);
157
+	}
158 158
 
159 159
 
160
-    /**
161
-     * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response.
162
-     *
163
-     * @throws InvalidArgumentException
164
-     * @throws InvalidDataTypeException
165
-     * @throws InvalidInterfaceException
166
-     */
167
-    public static function triggered_trap_response()
168
-    {
169
-        // UH OH...
170
-        $redirect_url = apply_filters(
171
-            'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url',
172
-            add_query_arg(
173
-                array('ee' => 'ticket_selection_received'),
174
-                EE_Registry::instance()->CFG->core->reg_page_url()
175
-            )
176
-        );
177
-        // if AJAX, return the redirect URL
178
-        if (EED_Bot_Trap::getRequest()->isAjax()) {
179
-            echo wp_json_encode(
180
-                array_merge(
181
-                    EE_Error::get_notices(false),
182
-                    array(
183
-                        'redirect_url' => $redirect_url,
184
-                    )
185
-                )
186
-            );
187
-            exit();
188
-        }
189
-        wp_safe_redirect($redirect_url);
190
-        exit();
191
-    }
160
+	/**
161
+	 * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response.
162
+	 *
163
+	 * @throws InvalidArgumentException
164
+	 * @throws InvalidDataTypeException
165
+	 * @throws InvalidInterfaceException
166
+	 */
167
+	public static function triggered_trap_response()
168
+	{
169
+		// UH OH...
170
+		$redirect_url = apply_filters(
171
+			'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url',
172
+			add_query_arg(
173
+				array('ee' => 'ticket_selection_received'),
174
+				EE_Registry::instance()->CFG->core->reg_page_url()
175
+			)
176
+		);
177
+		// if AJAX, return the redirect URL
178
+		if (EED_Bot_Trap::getRequest()->isAjax()) {
179
+			echo wp_json_encode(
180
+				array_merge(
181
+					EE_Error::get_notices(false),
182
+					array(
183
+						'redirect_url' => $redirect_url,
184
+					)
185
+				)
186
+			);
187
+			exit();
188
+		}
189
+		wp_safe_redirect($redirect_url);
190
+		exit();
191
+	}
192 192
 
193 193
 
194
-    /**
195
-     * display_bot_trap_success
196
-     * shows a "success" screen to bots so that they (ie: the ppl managing them)
197
-     * think the form was submitted successfully
198
-     *
199
-     * @return void
200
-     */
201
-    public static function display_bot_trap_success()
202
-    {
203
-        add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false');
204
-        $bot_notice = EED_Bot_Trap::getRequest()->getRequestParam(
205
-            'ee-notice',
206
-            esc_html__(
207
-                'Thank you so much. Your ticket selections have been received for consideration.',
208
-                'event_espresso'
209
-            )
210
-        );
211
-        EED_Bot_Trap::getResponse()->addOutput(EEH_HTML::div($bot_notice, '', 'ee-attention'));
212
-    }
194
+	/**
195
+	 * display_bot_trap_success
196
+	 * shows a "success" screen to bots so that they (ie: the ppl managing them)
197
+	 * think the form was submitted successfully
198
+	 *
199
+	 * @return void
200
+	 */
201
+	public static function display_bot_trap_success()
202
+	{
203
+		add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false');
204
+		$bot_notice = EED_Bot_Trap::getRequest()->getRequestParam(
205
+			'ee-notice',
206
+			esc_html__(
207
+				'Thank you so much. Your ticket selections have been received for consideration.',
208
+				'event_espresso'
209
+			)
210
+		);
211
+		EED_Bot_Trap::getResponse()->addOutput(EEH_HTML::div($bot_notice, '', 'ee-attention'));
212
+	}
213 213
 
214 214
 
215 215
 
216
-    /***********************************    ADMIN    **********************************/
216
+	/***********************************    ADMIN    **********************************/
217 217
 
218 218
 
219
-    /**
220
-     * bot_trap_settings_form
221
-     *
222
-     * @return void
223
-     * @throws EE_Error
224
-     * @throws InvalidArgumentException
225
-     * @throws InvalidDataTypeException
226
-     * @throws InvalidInterfaceException
227
-     */
228
-    public static function bot_trap_settings_form()
229
-    {
230
-        EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js();
231
-        echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); // already escaped
232
-    }
219
+	/**
220
+	 * bot_trap_settings_form
221
+	 *
222
+	 * @return void
223
+	 * @throws EE_Error
224
+	 * @throws InvalidArgumentException
225
+	 * @throws InvalidDataTypeException
226
+	 * @throws InvalidInterfaceException
227
+	 */
228
+	public static function bot_trap_settings_form()
229
+	{
230
+		EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js();
231
+		echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); // already escaped
232
+	}
233 233
 
234 234
 
235
-    /**
236
-     * _bot_trap_settings_form
237
-     *
238
-     * @return EE_Form_Section_Proper
239
-     * @throws EE_Error
240
-     */
241
-    protected static function _bot_trap_settings_form()
242
-    {
243
-        return new EE_Form_Section_Proper(
244
-            array(
245
-                'name'            => 'bot_trap_settings',
246
-                'html_id'         => 'bot_trap_settings',
247
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
248
-                'subsections'     => array(
249
-                    'bot_trap_hdr' => new EE_Form_Section_HTML(
250
-                        EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))
251
-                    ),
252
-                    'use_bot_trap' => new EE_Yes_No_Input(
253
-                        array(
254
-                            'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'),
255
-                            'html_help_text'  => esc_html__(
256
-                                'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.',
257
-                                'event_espresso'
258
-                            ),
259
-                            'default'         => EE_Registry::instance()->CFG->registration->use_bot_trap !== null
260
-                                ? EE_Registry::instance()->CFG->registration->use_bot_trap
261
-                                : true,
262
-                            'required'        => false,
263
-                        )
264
-                    ),
265
-                ),
266
-            )
267
-        );
268
-    }
235
+	/**
236
+	 * _bot_trap_settings_form
237
+	 *
238
+	 * @return EE_Form_Section_Proper
239
+	 * @throws EE_Error
240
+	 */
241
+	protected static function _bot_trap_settings_form()
242
+	{
243
+		return new EE_Form_Section_Proper(
244
+			array(
245
+				'name'            => 'bot_trap_settings',
246
+				'html_id'         => 'bot_trap_settings',
247
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
248
+				'subsections'     => array(
249
+					'bot_trap_hdr' => new EE_Form_Section_HTML(
250
+						EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))
251
+					),
252
+					'use_bot_trap' => new EE_Yes_No_Input(
253
+						array(
254
+							'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'),
255
+							'html_help_text'  => esc_html__(
256
+								'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.',
257
+								'event_espresso'
258
+							),
259
+							'default'         => EE_Registry::instance()->CFG->registration->use_bot_trap !== null
260
+								? EE_Registry::instance()->CFG->registration->use_bot_trap
261
+								: true,
262
+							'required'        => false,
263
+						)
264
+					),
265
+				),
266
+			)
267
+		);
268
+	}
269 269
 
270 270
 
271
-    /**
272
-     * update_bot_trap_settings_form
273
-     *
274
-     * @param EE_Registration_Config $EE_Registration_Config
275
-     * @return EE_Registration_Config
276
-     * @throws EE_Error
277
-     * @throws InvalidArgumentException
278
-     * @throws ReflectionException
279
-     * @throws InvalidDataTypeException
280
-     * @throws InvalidInterfaceException
281
-     */
282
-    public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config)
283
-    {
284
-        try {
285
-            $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form();
286
-            // if not displaying a form, then check for form submission
287
-            if ($bot_trap_settings_form->was_submitted()) {
288
-                // capture form data
289
-                $bot_trap_settings_form->receive_form_submission();
290
-                // validate form data
291
-                if ($bot_trap_settings_form->is_valid()) {
292
-                    // grab validated data from form
293
-                    $valid_data = $bot_trap_settings_form->valid_data();
294
-                    if (isset($valid_data['use_bot_trap'])) {
295
-                        $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap'];
296
-                    } else {
297
-                        EE_Error::add_error(
298
-                            esc_html__(
299
-                                'Invalid or missing Bot Trap settings. Please refresh the form and try again.',
300
-                                'event_espresso'
301
-                            ),
302
-                            __FILE__,
303
-                            __FUNCTION__,
304
-                            __LINE__
305
-                        );
306
-                    }
307
-                } elseif ($bot_trap_settings_form->submission_error_message() !== '') {
308
-                    EE_Error::add_error(
309
-                        $bot_trap_settings_form->submission_error_message(),
310
-                        __FILE__,
311
-                        __FUNCTION__,
312
-                        __LINE__
313
-                    );
314
-                }
315
-            }
316
-        } catch (EE_Error $e) {
317
-            $e->get_error();
318
-        }
319
-        return $EE_Registration_Config;
320
-    }
271
+	/**
272
+	 * update_bot_trap_settings_form
273
+	 *
274
+	 * @param EE_Registration_Config $EE_Registration_Config
275
+	 * @return EE_Registration_Config
276
+	 * @throws EE_Error
277
+	 * @throws InvalidArgumentException
278
+	 * @throws ReflectionException
279
+	 * @throws InvalidDataTypeException
280
+	 * @throws InvalidInterfaceException
281
+	 */
282
+	public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config)
283
+	{
284
+		try {
285
+			$bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form();
286
+			// if not displaying a form, then check for form submission
287
+			if ($bot_trap_settings_form->was_submitted()) {
288
+				// capture form data
289
+				$bot_trap_settings_form->receive_form_submission();
290
+				// validate form data
291
+				if ($bot_trap_settings_form->is_valid()) {
292
+					// grab validated data from form
293
+					$valid_data = $bot_trap_settings_form->valid_data();
294
+					if (isset($valid_data['use_bot_trap'])) {
295
+						$EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap'];
296
+					} else {
297
+						EE_Error::add_error(
298
+							esc_html__(
299
+								'Invalid or missing Bot Trap settings. Please refresh the form and try again.',
300
+								'event_espresso'
301
+							),
302
+							__FILE__,
303
+							__FUNCTION__,
304
+							__LINE__
305
+						);
306
+					}
307
+				} elseif ($bot_trap_settings_form->submission_error_message() !== '') {
308
+					EE_Error::add_error(
309
+						$bot_trap_settings_form->submission_error_message(),
310
+						__FILE__,
311
+						__FUNCTION__,
312
+						__LINE__
313
+					);
314
+				}
315
+			}
316
+		} catch (EE_Error $e) {
317
+			$e->get_error();
318
+		}
319
+		return $EE_Registration_Config;
320
+	}
321 321
 }
Please login to merge, or discard this patch.