Completed
Branch FET-10486-add-timestamp-checki... (611b15)
by
unknown
105:07 queued 90:18
created
thank_you_page/templates/thank-you-page-payment-details.template.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,30 +1,30 @@  discard block
 block discarded – undo
1 1
 <h2 class="section-heading display-box-heading">
2 2
 	<?php _e('Payment Overview', 'event_espresso'); ?>
3 3
 </h2>
4
-<?php  do_action( 'AHEE__thank_you_page_payment_details_template__after_heading' ); ?>
4
+<?php  do_action('AHEE__thank_you_page_payment_details_template__after_heading'); ?>
5 5
 
6 6
 <div id="espresso-thank-you-page-payment-details-dv">
7
-<?php if ( ! empty( $payments )){	 ?>
7
+<?php if ( ! empty($payments)) {	 ?>
8 8
 	<table class="ee-table">
9 9
 		<thead>
10 10
 			<tr>
11 11
 				<th width="35%" class="jst-left">
12
-					<?php _e('Payment Date','event_espresso')?>
12
+					<?php _e('Payment Date', 'event_espresso')?>
13 13
 				</th>
14 14
 				<th width="17.5%" class="jst-left">
15
-					<?php _e('Type','event_espresso');?>
15
+					<?php _e('Type', 'event_espresso'); ?>
16 16
 				</th>
17 17
 				<th width="17.5%" class="jst-rght">
18
-					<?php _e('Amount','event_espresso');?>
18
+					<?php _e('Amount', 'event_espresso'); ?>
19 19
 				</th>
20 20
 				<th width="30%" class="jst-rght">
21
-					<?php _e('Status','event_espresso');?>
21
+					<?php _e('Status', 'event_espresso'); ?>
22 22
 				</th>
23 23
 			</tr>
24 24
 		</thead>
25 25
 		<tbody>
26 26
 		<?php
27
-			foreach ( $payments as $payment ) {
27
+			foreach ($payments as $payment) {
28 28
 				echo $payment;
29 29
 			}
30 30
 		?>
@@ -33,38 +33,38 @@  discard block
 block discarded – undo
33 33
 <?php
34 34
 	} else {
35 35
 
36
-		if ( $transaction->total() ){
36
+		if ($transaction->total()) {
37 37
 
38 38
 			echo apply_filters(
39 39
 				'FHEE__payment_overview_template__no_payments_made',
40
-				sprintf (
41
-					__('%sNo payments towards this transaction have been received.%s', 'event_espresso' ),
40
+				sprintf(
41
+					__('%sNo payments towards this transaction have been received.%s', 'event_espresso'),
42 42
 					'<p class="important-notice">',
43 43
 					'</p>'
44 44
 				)
45 45
 			);
46
-			do_action( 'AHEE__thank_you_page_payment_details_template__no_payments_made', $transaction );
46
+			do_action('AHEE__thank_you_page_payment_details_template__no_payments_made', $transaction);
47 47
 
48 48
 		} else {
49 49
 
50 50
 			echo apply_filters(
51 51
 				'FHEE__payment_overview_template__no_payment_required',
52
-				sprintf (
53
-					__('%sNo payment is required for this transaction.%s', 'event_espresso' ),
52
+				sprintf(
53
+					__('%sNo payment is required for this transaction.%s', 'event_espresso'),
54 54
 					'<p>',
55 55
 					'</p>'
56 56
 				)
57 57
 			);
58
-			do_action( 'AHEE__thank_you_page_payment_details_template__no_payment_required' );
58
+			do_action('AHEE__thank_you_page_payment_details_template__no_payment_required');
59 59
 
60 60
 		 }
61 61
 
62 62
 	}
63 63
 	echo $gateway_content;
64
-	do_action( 'AHEE__thank_you_page_payment_details_template__after_gateway_content', $gateway_content );
64
+	do_action('AHEE__thank_you_page_payment_details_template__after_gateway_content', $gateway_content);
65 65
 
66 66
 ?>
67 67
 
68 68
 	<br/>
69
-	<?php  do_action( 'AHEE__thank_you_page_payment_details_template__after_payment_details' ); ?>
69
+	<?php  do_action('AHEE__thank_you_page_payment_details_template__after_payment_details'); ?>
70 70
 
Please login to merge, or discard this patch.
modules/thank_you_page/templates/thank-you-page-overview.template.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@  discard block
 block discarded – undo
3 3
 /** @var boolean $revisit */
4 4
 /** @var string $order_conf_desc */
5 5
 
6
-do_action( 'AHEE__thank_you_page_overview_template__top', $transaction );
6
+do_action('AHEE__thank_you_page_overview_template__top', $transaction);
7 7
 
8 8
 ?>
9 9
 
10 10
 <div id="espresso-thank-you-page-overview-dv" class="width-100" >
11 11
 
12
-	<?php if ( ! $revisit ) : ?>
12
+	<?php if ( ! $revisit) : ?>
13 13
 	<div class="ee-attention">
14 14
 		<div class="extra-padding-sides">
15 15
 			<?php echo apply_filters(
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 					'<br />'
22 22
 				)
23 23
 			);
24
-			if ( ! empty( $TXN_receipt_url )) : ?>
24
+			if ( ! empty($TXN_receipt_url)) : ?>
25 25
 			<br/>
26 26
 			<div class="jst-rght">
27
-				<a class="ee-button ee-roundish indented-text big-text" href="<?php echo $TXN_receipt_url;?>"><span class="ee-icon ee-icon-PDF-file-type"></span><?php echo apply_filters( 'FHEE__thank_you_page_overview_template__order_conf_button_text', __( 'View Full Order Confirmation Receipt', 'event_espresso' )); ?></a>
27
+				<a class="ee-button ee-roundish indented-text big-text" href="<?php echo $TXN_receipt_url; ?>"><span class="ee-icon ee-icon-PDF-file-type"></span><?php echo apply_filters('FHEE__thank_you_page_overview_template__order_conf_button_text', __('View Full Order Confirmation Receipt', 'event_espresso')); ?></a>
28 28
 			</div>
29 29
 			<?php endif; ?>
30 30
 		</div>
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	<?php endif; ?>
34 34
 	<br/>
35 35
 
36
-	<?php  do_action( 'AHEE__thank_you_page_overview_template__content', $transaction ); ?>
36
+	<?php  do_action('AHEE__thank_you_page_overview_template__content', $transaction); ?>
37 37
 
38 38
 </div>
39 39
 <!-- end of espresso-thank-you-page-overview-dv -->
40 40
 
41
-<?php  do_action( 'AHEE__thank_you_page_overview_template__bottom', $transaction ); ?>
41
+<?php  do_action('AHEE__thank_you_page_overview_template__bottom', $transaction); ?>
Please login to merge, or discard this patch.
thank_you_page/templates/thank-you-page-transaction-details.template.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <h3><?php _e('Transaction Details', 'event_espresso'); ?></h3>
2
-<?php  do_action( 'AHEE__thank_you_page_transaction_details_template__after_heading' ); ?>
2
+<?php  do_action('AHEE__thank_you_page_transaction_details_template__after_heading'); ?>
3 3
 
4 4
 <div id="espresso-thank-you-page-transaction-details-dv">
5 5
 	<table class='ee-table'>
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 					<label><?php _e('Total Cost: ', 'event_espresso'); ?></label>
10 10
 				</td>
11 11
 				<td>
12
-					<?php echo EEH_Template::format_currency( $transaction->total() ); ?>
12
+					<?php echo EEH_Template::format_currency($transaction->total()); ?>
13 13
 				</td>
14 14
 			</tr>
15 15
 			<tr>
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 					<label><?php _e('Amount Owing: ', 'event_espresso'); ?></label>
18 18
 				</td>
19 19
 				<td class="<?php echo ($transaction->paid() == $transaction->total()) ? 'ee-transaction-paid' : 'ee-transaction-unpaid' ?>">
20
-					<?php echo EEH_Template::format_currency( $transaction->remaining() ); ?>
20
+					<?php echo EEH_Template::format_currency($transaction->remaining()); ?>
21 21
 				</td>
22 22
 			</tr>
23 23
 			<tr>
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 					<label><?php _e('Transaction Status: ', 'event_espresso'); ?></label>
26 26
 				</td>
27 27
 				<td>
28
-					<?php $transaction->e_pretty_status( TRUE );
29
-					if ( $show_try_pay_again_link && ! $transaction->is_completed() ) { ?>
28
+					<?php $transaction->e_pretty_status(TRUE);
29
+					if ($show_try_pay_again_link && ! $transaction->is_completed()) { ?>
30 30
 					 &nbsp; <span class="small-text"><a href='<?php echo $SPCO_payment_options_url?>'><?php _e('View Payment Options', 'event_espresso'); ?></a></span>
31 31
 					<?php } ?>
32 32
 				</td>
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 					<?php  echo $primary_registrant_name; ?>
40 40
 				</td>
41 41
 			</tr>
42
-            <?php  do_action( 'AHEE__thank_you_page_transaction_details_template__after_transaction_table_row', $transaction ); ?>
42
+            <?php  do_action('AHEE__thank_you_page_transaction_details_template__after_transaction_table_row', $transaction); ?>
43 43
 		</tbody>
44 44
 	</table>
45 45
 
46
-<?php if ( $show_try_pay_again_link && ! $transaction->is_completed() ) { ?>
46
+<?php if ($show_try_pay_again_link && ! $transaction->is_completed()) { ?>
47 47
 	<p class="small-text jst-rght">
48 48
 		<a href='<?php echo $SPCO_payment_options_url?>'><?php _e("Click here to view Payment Options", 'event_espresso'); ?></a>
49 49
 	</p>
@@ -52,6 +52,6 @@  discard block
 block discarded – undo
52 52
 
53 53
 <?php }?>
54 54
 
55
-    <?php  do_action( 'AHEE__thank_you_page_transaction_details_template__after_transaction_details' ); ?>
55
+    <?php  do_action('AHEE__thank_you_page_transaction_details_template__after_transaction_details'); ?>
56 56
 
57 57
 </div>
Please login to merge, or discard this patch.
thank_you_page/templates/thank-you-page-registration-details.template.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -5,81 +5,81 @@  discard block
 block discarded – undo
5 5
 /** @type string $SPCO_attendee_information_url */
6 6
 ?>
7 7
 <h3 class="ee-registration-details-h3"><?php _e('Registration Details', 'event_espresso'); ?></h3>
8
-<?php  do_action( 'AHEE__thank_you_page_registration_details_template__after_heading' ); ?>
8
+<?php  do_action('AHEE__thank_you_page_registration_details_template__after_heading'); ?>
9 9
 
10 10
 <div class="ee-registration-details-dv">
11 11
 <?php
12 12
 $registrations = $transaction->registrations();
13
-$registrations = is_array( $registrations ) ? $registrations : array();
14
-$reg_count = count( $registrations );
13
+$registrations = is_array($registrations) ? $registrations : array();
14
+$reg_count = count($registrations);
15 15
 $reg_cntr = 0;
16 16
 $event_name = '';
17 17
 $wait_list = false;
18
-foreach ( $registrations as $registration ) {
19
-	if ( $registration instanceof EE_Registration ) {
20
-		if ( $event_name != $registration->event_name() && ! empty( $event_name )) { ?>
18
+foreach ($registrations as $registration) {
19
+	if ($registration instanceof EE_Registration) {
20
+		if ($event_name != $registration->event_name() && ! empty($event_name)) { ?>
21 21
 		</tbody>
22 22
 	</table>
23 23
 		<?php
24 24
 		}
25 25
 		$reg_cntr++;
26
-		if ( $event_name != $registration->event_name() ) {
26
+		if ($event_name != $registration->event_name()) {
27 27
 	?>
28 28
 	<h5>
29
-		<span class="smaller-text grey-text"><?php _e('for','event_espresso');?>: </span> <?php echo htmlentities( $registration->event_name(), ENT_QUOTES, 'UTF-8' );?>
29
+		<span class="smaller-text grey-text"><?php _e('for', 'event_espresso'); ?>: </span> <?php echo htmlentities($registration->event_name(), ENT_QUOTES, 'UTF-8'); ?>
30 30
 	</h5>
31 31
 	<table class='ee-table ee-registrations-list'>
32 32
 		<thead>
33 33
 			<tr>
34 34
 				<th width="40%">
35
-					<?php _e("Registrant Name",'event_espresso')?>
35
+					<?php _e("Registrant Name", 'event_espresso')?>
36 36
 				</th>
37 37
 				<th width="25%" class="jst-left">
38
-					<?php _e("REG Code",'event_espresso');?>
38
+					<?php _e("REG Code", 'event_espresso'); ?>
39 39
 				</th>
40 40
 				<th width="35%" class="jst-left">
41
-					<?php _e("REG Status",'event_espresso');?>
41
+					<?php _e("REG Status", 'event_espresso'); ?>
42 42
 				</th>
43 43
 			</tr>
44 44
 		</thead>
45 45
 		<tbody>
46 46
 	<?php
47 47
 		}
48
-		if ( $is_primary || ( ! $is_primary && $reg_url_link == $registration->reg_url_link() )) { ?>
48
+		if ($is_primary || ( ! $is_primary && $reg_url_link == $registration->reg_url_link())) { ?>
49 49
 			<tr>
50 50
 				<td width="40%">
51 51
 				<?php
52
-					if ( $registration->attendee() instanceof EE_Attendee ) {
53
-						echo $registration->attendee()->full_name( TRUE );
52
+					if ($registration->attendee() instanceof EE_Attendee) {
53
+						echo $registration->attendee()->full_name(TRUE);
54 54
 					}
55 55
 				?>
56 56
 					<p class="tiny-text" style="margin: .75em 0 0;">
57 57
 					<?php
58
-					if ( $registration->count_question_groups() ) {
58
+					if ($registration->count_question_groups()) {
59 59
 					?>
60
-						<a class="ee-icon-only-lnk" href="<?php echo $registration->edit_attendee_information_url();?>" title="<?php esc_attr_e('Click here to edit Attendee Information', 'event_espresso');?>"><span class="ee-icon ee-icon-user-edit"></span><?php _e('edit info', 'event_espresso');?></a>
60
+						<a class="ee-icon-only-lnk" href="<?php echo $registration->edit_attendee_information_url(); ?>" title="<?php esc_attr_e('Click here to edit Attendee Information', 'event_espresso'); ?>"><span class="ee-icon ee-icon-user-edit"></span><?php _e('edit info', 'event_espresso'); ?></a>
61 61
 					<?php } ?>
62
-						<a class="ee-resend-reg-confirmation-email ee-icon-only-lnk" href="<?php echo add_query_arg( array( 'token'=>$registration->reg_url_link(), 'resend_reg_confirmation' => 'true' ), EE_Registry::instance()->CFG->core->thank_you_page_url() );?>" title="<?php esc_attr_e('Click here to resend the Registration Confirmation email', 'event_espresso');?>" rel="<?php echo $registration->reg_url_link();?>"><span class="dashicons dashicons-email-alt"></span><?php _e('resend email', 'event_espresso');?></a>
62
+						<a class="ee-resend-reg-confirmation-email ee-icon-only-lnk" href="<?php echo add_query_arg(array('token'=>$registration->reg_url_link(), 'resend_reg_confirmation' => 'true'), EE_Registry::instance()->CFG->core->thank_you_page_url()); ?>" title="<?php esc_attr_e('Click here to resend the Registration Confirmation email', 'event_espresso'); ?>" rel="<?php echo $registration->reg_url_link(); ?>"><span class="dashicons dashicons-email-alt"></span><?php _e('resend email', 'event_espresso'); ?></a>
63 63
 					</p>
64 64
 				</td>
65 65
 				<td width="25%" class="jst-left">
66 66
 					<?php $registration->e('REG_code') ?>
67 67
 				</td>
68 68
 				<td width="35%" class="jst-left">
69
-					<?php $registration->e_pretty_status( TRUE )?>
69
+					<?php $registration->e_pretty_status(TRUE)?>
70 70
 					<?php
71
-						if ( $registration->status_ID() === EEM_Registration::status_id_wait_list ) {
71
+						if ($registration->status_ID() === EEM_Registration::status_id_wait_list) {
72 72
 							$wait_list = true;
73 73
 						}
74 74
 					?>
75 75
 				</td>
76 76
 			</tr>
77
-            <?php  do_action( 'AHEE__thank_you_page_registration_details_template__after_registration_table_row', $registration ); ?>
77
+            <?php  do_action('AHEE__thank_you_page_registration_details_template__after_registration_table_row', $registration); ?>
78 78
         <?php
79 79
 			$event_name = $registration->event_name();
80 80
 
81 81
 		}
82
-		if ( $reg_cntr >= $reg_count ) {
82
+		if ($reg_cntr >= $reg_count) {
83 83
 			?>
84 84
 			</tbody>
85 85
 			</table>
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 	}
89 89
 }
90 90
 ?>
91
-<?php if ( $is_primary && $SPCO_attendee_information_url ) { ?>
91
+<?php if ($is_primary && $SPCO_attendee_information_url) { ?>
92 92
 	<p class="small-text jst-rght">
93 93
 		<a href='<?php echo $SPCO_attendee_information_url?>'><?php _e("Click here to edit All Attendee Information", 'event_espresso'); ?></a>
94 94
 	</p>
95 95
 <?php } ?>
96
-	<?php if ( $wait_list ) { ?>
96
+	<?php if ($wait_list) { ?>
97 97
 
98 98
 			<?php
99 99
 			echo apply_filters(
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	<?php } ?>
114 114
 
115 115
 
116
-	<?php  do_action( 'AHEE__thank_you_page_registration_details_template__after_registration_details' ); ?>
116
+	<?php  do_action('AHEE__thank_you_page_registration_details_template__after_registration_details'); ?>
117 117
 
118 118
 </div>
119 119
 <!-- end of .registration-details -->
Please login to merge, or discard this patch.
modules/thank_you_page/EED_Thank_You_Page.module.php 2 patches
Indentation   +915 added lines, -915 removed lines patch added patch discarded remove patch
@@ -14,756 +14,756 @@  discard block
 block discarded – undo
14 14
 class EED_Thank_You_Page extends EED_Module
15 15
 {
16 16
 
17
-    /**
18
-     * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes )
19
-     */
20
-    const IPN_wait_time = 1200;
21
-
22
-    /**
23
-     * The transaction specified by the reg_url_link passed from the Request, or from the Session
24
-     *
25
-     * @var EE_Transaction $_current_txn
26
-     */
27
-    private $_current_txn;
28
-
29
-    /**
30
-     * @var EE_Registration $_primary_registrant
31
-     */
32
-    private $_primary_registrant;
33
-
34
-    /**
35
-     * The reg_url_link passed from the Request, or from the Session
36
-     *
37
-     * @var string $_reg_url_link
38
-     */
39
-    private $_reg_url_link;
40
-
41
-    /**
42
-     * whether the incoming reg_url_link is for the primary registrant or not
43
-     *
44
-     * @var boolean $_is_primary
45
-     */
46
-    private $_is_primary;
47
-
48
-    /**
49
-     * The URL for revisiting the SPCO attendee information step
50
-     *
51
-     * @var string $_SPCO_attendee_information_url
52
-     */
53
-    private $_SPCO_attendee_information_url;
54
-
55
-    /**
56
-     * The URL for revisiting the SPCO payment options step
57
-     *
58
-     * @var string $_SPCO_payment_options_url
59
-     */
60
-    private $_SPCO_payment_options_url;
61
-
62
-    /**
63
-     * whether to display the Payment Options link
64
-     *
65
-     * @var boolean $_show_try_pay_again_link
66
-     */
67
-    private $_show_try_pay_again_link = false;
68
-
69
-    /**
70
-     * whether payments are allowed at this time
71
-     *
72
-     * @var boolean $_payments_closed
73
-     */
74
-    private $_payments_closed = false;
75
-
76
-    /**
77
-     * whether the selected payment method is Bank, Check , Invoice, etc
78
-     *
79
-     * @var boolean $_is_offline_payment_method
80
-     */
81
-    private $_is_offline_payment_method = true;
82
-
83
-
84
-
85
-    /**
86
-     * @return EED_Module|EED_Thank_You_Page
87
-     */
88
-    public static function instance()
89
-    {
90
-        return parent::get_instance(__CLASS__);
91
-    }
92
-
93
-
94
-    /**
95
-     * set_hooks - for hooking into EE Core, modules, etc
96
-     *
97
-     * @return void
98
-     */
99
-    public static function set_hooks()
100
-    {
101
-        add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2);
102
-    }
103
-
104
-
105
-
106
-    /**
107
-     * set_hooks_admin - for hooking into EE Admin Core, modules, etc
108
-     *
109
-     * @return void
110
-     */
111
-    public static function set_hooks_admin()
112
-    {
113
-        // AJAX for IPN monitoring
114
-        add_filter('heartbeat_received', array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'), 10, 3);
115
-        add_filter(
116
-            'heartbeat_nopriv_received',
117
-            array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'),
118
-            10,
119
-            3
120
-        );
121
-        add_action(
122
-            'wp_ajax_espresso_resend_reg_confirmation_email',
123
-            array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
124
-            10,
125
-            2
126
-        );
127
-        add_action(
128
-            'wp_ajax_nopriv_espresso_resend_reg_confirmation_email',
129
-            array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
130
-            10,
131
-            2
132
-        );
133
-    }
134
-
135
-
136
-
137
-    /**
138
-     * set_definitions
139
-     *
140
-     * @return void
141
-     */
142
-    public static function set_definitions()
143
-    {
144
-        define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
145
-        define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
146
-    }
147
-
148
-
149
-
150
-    /**
151
-     * get_txn
152
-     *
153
-     * @return EE_Transaction
154
-     */
155
-    public function get_txn()
156
-    {
157
-        if ($this->_current_txn instanceof EE_Transaction) {
158
-            return $this->_current_txn;
159
-        }
160
-        $TXN_model = EE_Registry::instance()->load_model('Transaction');
161
-        if ( ! $TXN_model instanceof EEM_Transaction) {
162
-            EE_Error::add_error(
163
-                __('The transaction model could not be established.', 'event_espresso'),
164
-                __FILE__,
165
-                __FUNCTION__,
166
-                __LINE__
167
-            );
168
-            return null;
169
-        }
170
-        //get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request
171
-        $this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link);
172
-        // verify TXN
173
-        if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) {
174
-            EE_Error::add_error(
175
-                __(
176
-                    'No transaction information could be retrieved or the transaction data is not of the correct type.',
177
-                    'event_espresso'
178
-                ),
179
-                __FILE__,
180
-                __FUNCTION__,
181
-                __LINE__
182
-            );
183
-            return null;
184
-        }
185
-        return $this->_current_txn;
186
-    }
187
-
188
-
189
-
190
-    /**
191
-     * get_txn_payments
192
-     *
193
-     * @param int $since
194
-     * @return mixed array of EE_Payment || FALSE
195
-     * @throws \EE_Error
196
-     */
197
-    public function get_txn_payments($since = 0)
198
-    {
199
-        if ( ! $this->get_txn()) {
200
-            return false;
201
-        }
202
-        $args = array('order_by' => array('PAY_timestamp' => 'ASC'));
203
-        if ($since > 0) {
204
-            $args[0] = array('PAY_timestamp' => array('>', $since));
205
-        }
206
-        // get array of payments with most recent first
207
-        return $this->_current_txn->payments($args);
208
-    }
209
-
210
-
211
-
212
-    /**
213
-     * get_reg_url_link
214
-     *
215
-     * @return void
216
-     */
217
-    private function _get_reg_url_link()
218
-    {
219
-        if ( ! empty($this->_reg_url_link)) {
220
-            return;
221
-        }
222
-        // only do thank you page stuff if we have a REG_url_link in the url
223
-        if (WP_DEBUG && ! EE_Registry::instance()->REQ->is_set('e_reg_url_link')) {
224
-            EE_Error::add_error(
225
-                __(
226
-                    'No transaction information could be retrieved because the registration URL link is missing or invalid.',
227
-                    'event_espresso'
228
-                ),
229
-                __FILE__,
230
-                __FUNCTION__,
231
-                __LINE__
232
-            );
233
-            return;
234
-        }
235
-        // check for reg_url_link
236
-        $this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link');
237
-    }
238
-
239
-
240
-
241
-    /**
242
-     * set_reg_url_link
243
-     *
244
-     * @param string $reg_url_link
245
-     */
246
-    public function set_reg_url_link($reg_url_link = null)
247
-    {
248
-        $this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link;
249
-    }
250
-
251
-
252
-
253
-    /**
254
-     * run - initial module setup
255
-     * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
256
-     *
257
-     * @param WP $WP
258
-     * @return void
259
-     * @throws \EE_Error
260
-     */
261
-    public function run($WP)
262
-    {
263
-
264
-    }
265
-
266
-
267
-
268
-    /**
269
-     * load_resources
270
-     *
271
-     * @return void
272
-     * @throws \EE_Error
273
-     */
274
-    public function load_resources() {
275
-        $this->_get_reg_url_link();
276
-        // resend_reg_confirmation_email ?
277
-        if (EE_Registry::instance()->REQ->is_set('resend')) {
278
-            EED_Thank_You_Page::resend_reg_confirmation_email();
279
-        }
280
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
281
-        $this->_translate_strings();
282
-        // load assets
283
-        add_action('wp_enqueue_scripts', array($this, 'load_js'), 10);
284
-    }
285
-
286
-
287
-
288
-    /**
289
-     * load_js
290
-     *
291
-     * @return void
292
-     */
293
-    protected function _translate_strings()
294
-    {
295
-        EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link;
296
-        EE_Registry::$i18n_js_strings['initial_access'] = time();
297
-        EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time;
298
-        EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code;
299
-        EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code;
300
-        EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __(
301
-            'checking for new payments...',
302
-            'event_espresso'
303
-        );
304
-        EE_Registry::$i18n_js_strings['loading_payment_info'] = __(
305
-            'loading payment information...',
306
-            'event_espresso'
307
-        );
308
-        EE_Registry::$i18n_js_strings['server_error'] = __(
309
-            'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.',
310
-            'event_espresso'
311
-        );
312
-        EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters(
313
-            'EED_Thank_You_Page__load_js__slow_IPN',
314
-            sprintf(
315
-                __(
316
-                    '%sThe Payment Notification appears to be taking longer than usual to arrive. Maybe check back later or just wait for your payment and registration confirmation results to be sent to you via email. We apologize for any inconvenience this may have caused.%s',
317
-                    'event_espresso'
318
-                ),
319
-                '<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">',
320
-                '</div>'
321
-            )
322
-        );
323
-    }
324
-
325
-
326
-
327
-    /**
328
-     * load_js
329
-     *
330
-     * @return void
331
-     */
332
-    public function load_js()
333
-    {
334
-        wp_register_script(
335
-            'thank_you_page',
336
-            THANK_YOU_ASSETS_URL . 'thank_you_page.js',
337
-            array('espresso_core', 'heartbeat'),
338
-            EVENT_ESPRESSO_VERSION,
339
-            true
340
-        );
341
-        wp_enqueue_script('thank_you_page');
342
-    }
343
-
344
-
345
-
346
-    /**
347
-     * init
348
-     *
349
-     * @return void
350
-     * @throws \EE_Error
351
-     */
352
-    public function init()
353
-    {
354
-        $this->_get_reg_url_link();
355
-        if ( ! $this->get_txn()) {
356
-            echo EEH_HTML::div(
357
-                EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') .
358
-                sprintf(
359
-                    __(
360
-                        'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s',
361
-                        'event_espresso'
362
-                    ),
363
-                    '<br/>'
364
-                ),
365
-                '',
366
-                'ee-attention'
367
-            );
368
-            return null;
369
-        }
370
-        // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete"
371
-        if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) {
372
-            $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code);
373
-            $this->_current_txn->save();
374
-        }
375
-        $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration
376
-            ? $this->_current_txn->primary_registration()
377
-            : null;
378
-        $this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link ? true : false;
379
-        $show_try_pay_again_link_default = apply_filters(
380
-            'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default',
381
-            true
382
-        );
383
-        $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
384
-        // txn status ?
385
-        if ($this->_current_txn->is_completed()) {
386
-            $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
387
-        } else if (
388
-            $this->_current_txn->is_incomplete()
389
-            && ($this->_primary_registrant->is_approved()
390
-                || $this->_primary_registrant->is_pending_payment())
391
-        ) {
392
-            $this->_show_try_pay_again_link = true;
393
-        } else if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) {
394
-            // its pending
395
-            $this->_show_try_pay_again_link = isset(
396
-                                                  EE_Registry::instance()->CFG->registration->show_pending_payment_options
397
-                                              )
398
-                                              && EE_Registry::instance()->CFG->registration->show_pending_payment_options
399
-                ? true
400
-                : $show_try_pay_again_link_default;
401
-        }
402
-        $this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method
403
-            ? true
404
-            : false;
405
-        $this->_is_offline_payment_method = false;
406
-        if (
407
-            // if payment method is unknown
408
-            ! $this->_current_txn->payment_method() instanceof EE_Payment_Method
409
-            || (
410
-                // or is an offline payment method
411
-                $this->_current_txn->payment_method() instanceof EE_Payment_Method
412
-                && $this->_current_txn->payment_method()->is_off_line()
413
-            )
414
-        ) {
415
-            $this->_is_offline_payment_method = true;
416
-        }
417
-        // link to SPCO
418
-        $revisit_spco_url = add_query_arg(
419
-            array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link),
420
-            EE_Registry::instance()->CFG->core->reg_page_url()
421
-        );
422
-        // link to SPCO payment_options
423
-        $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration
424
-            ? $this->_primary_registrant->payment_overview_url()
425
-            : add_query_arg(
426
-                array('step' => 'payment_options'),
427
-                $revisit_spco_url
428
-            );
429
-        // link to SPCO attendee_information
430
-        $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration
431
-            ? $this->_primary_registrant->edit_attendee_information_url()
432
-            : false;
433
-        do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn);
434
-        // set no cache headers and constants
435
-        EE_System::do_not_cache();
436
-    }
437
-
438
-
439
-
440
-    /**
441
-     * display_thank_you_page_results
442
-     *
443
-     * @return string
444
-     * @throws \EE_Error
445
-     */
446
-    public function thank_you_page_results()
447
-    {
448
-        $this->init();
449
-        if ( ! $this->_current_txn instanceof EE_Transaction) {
450
-            return EE_Error::get_notices();
451
-        }
452
-        // link to receipt
453
-        $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html');
454
-        if ( ! empty($template_args['TXN_receipt_url'])) {
455
-            $template_args['order_conf_desc'] = __(
456
-                '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.',
457
-                'event_espresso'
458
-            );
459
-        } else {
460
-            $template_args['order_conf_desc'] = __(
461
-                '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.',
462
-                'event_espresso'
463
-            );
464
-        }
465
-        $template_args['transaction'] = $this->_current_txn;
466
-        $template_args['revisit'] = EE_Registry::instance()->REQ->get('revisit', false);
467
-        add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details'));
468
-        if ($this->_is_primary && ! $this->_current_txn->is_free()) {
469
-            add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content'));
470
-        }
471
-        return EEH_Template::locate_template(
472
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php',
473
-            $template_args,
474
-            true,
475
-            true
476
-        );
477
-    }
478
-
479
-
480
-
481
-    /**
482
-     * thank_you_page_IPN_monitor
483
-     * this basically just pulls the TXN based on the reg_url_link sent from the server,
484
-     * then checks that the TXN status is not failed, and that no other errors have been generated.
485
-     * it also calculates the IPN wait time since the Thank You page was first loaded
486
-     *
487
-     * @param array $response
488
-     * @param array $data
489
-     * @return array
490
-     * @throws \EE_Error
491
-     */
492
-    public static function thank_you_page_IPN_monitor($response = array(), $data = array())
493
-    {
494
-        // does this heartbeat contain our data ?
495
-        if ( ! isset($data['espresso_thank_you_page'])) {
496
-            return $response;
497
-        }
498
-        // check for reg_url_link in the incoming heartbeat data
499
-        if ( ! isset($data['espresso_thank_you_page']['e_reg_url_link'])) {
500
-            $response['espresso_thank_you_page'] = array(
501
-                'errors' => ! empty($notices['errors'])
502
-                    ? $notices['errors']
503
-                    : __(
504
-                        'No transaction information could be retrieved because the registration URL link is missing or invalid.',
505
-                        'event_espresso'
506
-                    )
507
-            );
508
-            return $response;
509
-        }
510
-        // kk heartbeat has our data
511
-        $response['espresso_thank_you_page'] = array();
512
-        // set_definitions, instantiate the thank you page class, and get the ball rolling
513
-        EED_Thank_You_Page::set_definitions();
514
-        /** @var $espresso_thank_you_page EED_Thank_You_Page */
515
-        $espresso_thank_you_page = EED_Thank_You_Page::instance();
516
-        $espresso_thank_you_page->set_reg_url_link($data['espresso_thank_you_page']['e_reg_url_link']);
517
-        $espresso_thank_you_page->init();
518
-        //get TXN
519
-        $TXN = $espresso_thank_you_page->get_txn();
520
-        // no TXN? then get out
521
-        if ( ! $TXN instanceof EE_Transaction) {
522
-            $notices = EE_Error::get_notices();
523
-            $response['espresso_thank_you_page'] = array(
524
-                'errors' => ! empty($notices['errors'])
525
-                    ? $notices['errors']
526
-                    : sprintf(
527
-                        __(
528
-                            'The information for your transaction could not be retrieved from the server or the transaction data received was invalid because of a technical reason. (%s)',
529
-                            'event_espresso'
530
-                        ),
531
-                        __LINE__
532
-                    )
533
-            );
534
-            return $response;
535
-        }
536
-        // grab transient of TXN's status
537
-        $txn_status = isset($data['espresso_thank_you_page']['txn_status'])
538
-            ? $data['espresso_thank_you_page']['txn_status']
539
-            : null;
540
-        // has the TXN status changed since we last checked (or empty because this is the first time running through this code)?
541
-        if ($txn_status !== $TXN->status_ID()) {
542
-            // switch between two possible basic outcomes
543
-            switch ($TXN->status_ID()) {
544
-                // TXN has been updated in some way
545
-                case EEM_Transaction::overpaid_status_code:
546
-                case EEM_Transaction::complete_status_code:
547
-                case EEM_Transaction::incomplete_status_code:
548
-                    // send updated TXN results back to client,
549
-                    $response['espresso_thank_you_page'] = array(
550
-                        'transaction_details' => $espresso_thank_you_page->get_transaction_details(),
551
-                        'txn_status'          => $TXN->status_ID()
552
-                    );
553
-                    break;
554
-                // or we have a bad TXN, or really slow IPN, so calculate the wait time and send that back...
555
-                case EEM_Transaction::failed_status_code:
556
-                default:
557
-                    // keep on waiting...
558
-                    return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']);
559
-            }
560
-            // or is the TXN still failed (never been updated) ???
561
-        } else if ($TXN->failed()) {
562
-            // keep on waiting...
563
-            return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']);
564
-        }
565
-        // TXN is happening so let's get the payments now
566
-        // if we've already gotten payments then the heartbeat data will contain the timestamp of the last time we checked
567
-        $since = isset($data['espresso_thank_you_page']['get_payments_since'])
568
-            ? $data['espresso_thank_you_page']['get_payments_since']
569
-            : 0;
570
-        // then check for payments
571
-        $payments = $espresso_thank_you_page->get_txn_payments($since);
572
-        // has a payment been processed ?
573
-        if ( ! empty($payments) || $espresso_thank_you_page->_is_offline_payment_method) {
574
-            if ($since) {
575
-                $response['espresso_thank_you_page'] = array(
576
-                    'new_payments'        => $espresso_thank_you_page->get_new_payments($payments),
577
-                    'transaction_details' => $espresso_thank_you_page->get_transaction_details(),
578
-                    'txn_status'          => $TXN->status_ID()
579
-                );
580
-            } else {
581
-                $response['espresso_thank_you_page']['payment_details'] = $espresso_thank_you_page->get_payment_details(
582
-                    $payments
583
-                );
584
-            }
585
-            // reset time to check for payments
586
-            $response['espresso_thank_you_page']['get_payments_since'] = time();
587
-        } else {
588
-            $response['espresso_thank_you_page']['get_payments_since'] = $since;
589
-        }
590
-        return $response;
591
-    }
592
-
593
-
594
-
595
-    /**
596
-     * _update_server_wait_time
597
-     *
598
-     * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data
599
-     * @return array
600
-     * @throws \EE_Error
601
-     */
602
-    private function _update_server_wait_time($thank_you_page_data = array())
603
-    {
604
-        $response['espresso_thank_you_page'] = array(
605
-            'still_waiting' => isset($thank_you_page_data['initial_access'])
606
-                ? time() - $thank_you_page_data['initial_access']
607
-                : 0,
608
-            'txn_status'    => $this->_current_txn->status_ID()
609
-        );
610
-        return $response;
611
-    }
612
-
613
-
614
-
615
-    /**
616
-     * get_registration_details
617
-     *
618
-     * @throws \EE_Error
619
-     */
620
-    public function get_registration_details()
621
-    {
622
-        //prepare variables for displaying
623
-        $template_args = array();
624
-        $template_args['transaction'] = $this->_current_txn;
625
-        $template_args['reg_url_link'] = $this->_reg_url_link;
626
-        $template_args['is_primary'] = $this->_is_primary;
627
-        $template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url;
628
-        $template_args['resend_reg_confirmation_url'] = add_query_arg(
629
-            array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'),
630
-            EE_Registry::instance()->CFG->core->thank_you_page_url()
631
-        );
632
-        // verify template arguments
633
-        EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
634
-        EEH_Template_Validator::verify_isnt_null(
635
-            $template_args['SPCO_attendee_information_url'],
636
-            '$SPCO_attendee_information_url'
637
-        );
638
-        echo EEH_Template::locate_template(
639
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php',
640
-            $template_args,
641
-            true,
642
-            true
643
-        );
644
-    }
645
-
646
-
647
-
648
-    /**
649
-     * resend_reg_confirmation_email
650
-     *
651
-     * @throws \EE_Error
652
-     */
653
-    public static function resend_reg_confirmation_email()
654
-    {
655
-        EE_Registry::instance()->load_core('Request_Handler');
656
-        $reg_url_link = EE_Registry::instance()->REQ->get('token');
657
-        // was a REG_ID passed ?
658
-        if ($reg_url_link) {
659
-            $registration = EE_Registry::instance()->load_model('Registration')->get_one(
660
-                array(array('REG_url_link' => $reg_url_link))
661
-            );
662
-            if ($registration instanceof EE_Registration) {
663
-                // resend email
664
-                EED_Messages::process_resend(array('_REG_ID' => $registration->ID()));
665
-            } else {
666
-                EE_Error::add_error(
667
-                    __(
668
-                        'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.',
669
-                        'event_espresso'
670
-                    ),
671
-                    __FILE__,
672
-                    __FUNCTION__,
673
-                    __LINE__
674
-                );
675
-            }
676
-        } else {
677
-            EE_Error::add_error(
678
-                __(
679
-                    'The Registration Confirmation email could not be sent because a registration token is missing or invalid.',
680
-                    'event_espresso'
681
-                ),
682
-                __FILE__,
683
-                __FUNCTION__,
684
-                __LINE__
685
-            );
686
-        }
687
-        // request sent via AJAX ?
688
-        if (EE_FRONT_AJAX) {
689
-            echo wp_json_encode(EE_Error::get_notices(false));
690
-            die();
691
-            // or was JS disabled ?
692
-        } else {
693
-            // save errors so that they get picked up on the next request
694
-            EE_Error::get_notices(true, true);
695
-            wp_safe_redirect(
696
-                add_query_arg(
697
-                    array('e_reg_url_link' => $reg_url_link),
698
-                    EE_Registry::instance()->CFG->core->thank_you_page_url()
699
-                )
700
-            );
701
-        }
702
-    }
703
-
704
-
705
-
706
-    /**
707
-     * get_ajax_content
708
-     *
709
-     * @return void
710
-     * @throws \EE_Error
711
-     */
712
-    public function get_ajax_content()
713
-    {
714
-        if ( ! $this->get_txn()) {
715
-            return;
716
-        }
717
-        // first determine which event(s) require pre-approval or not
718
-        $events = array();
719
-        $events_requiring_pre_approval = array();
720
-        foreach ($this->_current_txn->registrations() as $registration) {
721
-            if ($registration instanceof EE_Registration) {
722
-                $event = $registration->event();
723
-                if ($event instanceof EE_Event) {
724
-                    if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) {
725
-                        $events_requiring_pre_approval[$event->ID()] = $event;
726
-                    } else {
727
-                        $events[$event->ID()] = $event;
728
-                    }
729
-                }
730
-            }
731
-        }
732
-        $this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval);
733
-        $this->display_details_for_events($events);
734
-    }
735
-
736
-
737
-
738
-    /**
739
-     * display_details_for_events
740
-     *
741
-     * @param EE_Event[] $events
742
-     * @return void
743
-     */
744
-    public function display_details_for_events($events = array())
745
-    {
746
-        if ( ! empty($events)) {
747
-            ?>
17
+	/**
18
+	 * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes )
19
+	 */
20
+	const IPN_wait_time = 1200;
21
+
22
+	/**
23
+	 * The transaction specified by the reg_url_link passed from the Request, or from the Session
24
+	 *
25
+	 * @var EE_Transaction $_current_txn
26
+	 */
27
+	private $_current_txn;
28
+
29
+	/**
30
+	 * @var EE_Registration $_primary_registrant
31
+	 */
32
+	private $_primary_registrant;
33
+
34
+	/**
35
+	 * The reg_url_link passed from the Request, or from the Session
36
+	 *
37
+	 * @var string $_reg_url_link
38
+	 */
39
+	private $_reg_url_link;
40
+
41
+	/**
42
+	 * whether the incoming reg_url_link is for the primary registrant or not
43
+	 *
44
+	 * @var boolean $_is_primary
45
+	 */
46
+	private $_is_primary;
47
+
48
+	/**
49
+	 * The URL for revisiting the SPCO attendee information step
50
+	 *
51
+	 * @var string $_SPCO_attendee_information_url
52
+	 */
53
+	private $_SPCO_attendee_information_url;
54
+
55
+	/**
56
+	 * The URL for revisiting the SPCO payment options step
57
+	 *
58
+	 * @var string $_SPCO_payment_options_url
59
+	 */
60
+	private $_SPCO_payment_options_url;
61
+
62
+	/**
63
+	 * whether to display the Payment Options link
64
+	 *
65
+	 * @var boolean $_show_try_pay_again_link
66
+	 */
67
+	private $_show_try_pay_again_link = false;
68
+
69
+	/**
70
+	 * whether payments are allowed at this time
71
+	 *
72
+	 * @var boolean $_payments_closed
73
+	 */
74
+	private $_payments_closed = false;
75
+
76
+	/**
77
+	 * whether the selected payment method is Bank, Check , Invoice, etc
78
+	 *
79
+	 * @var boolean $_is_offline_payment_method
80
+	 */
81
+	private $_is_offline_payment_method = true;
82
+
83
+
84
+
85
+	/**
86
+	 * @return EED_Module|EED_Thank_You_Page
87
+	 */
88
+	public static function instance()
89
+	{
90
+		return parent::get_instance(__CLASS__);
91
+	}
92
+
93
+
94
+	/**
95
+	 * set_hooks - for hooking into EE Core, modules, etc
96
+	 *
97
+	 * @return void
98
+	 */
99
+	public static function set_hooks()
100
+	{
101
+		add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2);
102
+	}
103
+
104
+
105
+
106
+	/**
107
+	 * set_hooks_admin - for hooking into EE Admin Core, modules, etc
108
+	 *
109
+	 * @return void
110
+	 */
111
+	public static function set_hooks_admin()
112
+	{
113
+		// AJAX for IPN monitoring
114
+		add_filter('heartbeat_received', array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'), 10, 3);
115
+		add_filter(
116
+			'heartbeat_nopriv_received',
117
+			array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'),
118
+			10,
119
+			3
120
+		);
121
+		add_action(
122
+			'wp_ajax_espresso_resend_reg_confirmation_email',
123
+			array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
124
+			10,
125
+			2
126
+		);
127
+		add_action(
128
+			'wp_ajax_nopriv_espresso_resend_reg_confirmation_email',
129
+			array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
130
+			10,
131
+			2
132
+		);
133
+	}
134
+
135
+
136
+
137
+	/**
138
+	 * set_definitions
139
+	 *
140
+	 * @return void
141
+	 */
142
+	public static function set_definitions()
143
+	{
144
+		define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
145
+		define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
146
+	}
147
+
148
+
149
+
150
+	/**
151
+	 * get_txn
152
+	 *
153
+	 * @return EE_Transaction
154
+	 */
155
+	public function get_txn()
156
+	{
157
+		if ($this->_current_txn instanceof EE_Transaction) {
158
+			return $this->_current_txn;
159
+		}
160
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
161
+		if ( ! $TXN_model instanceof EEM_Transaction) {
162
+			EE_Error::add_error(
163
+				__('The transaction model could not be established.', 'event_espresso'),
164
+				__FILE__,
165
+				__FUNCTION__,
166
+				__LINE__
167
+			);
168
+			return null;
169
+		}
170
+		//get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request
171
+		$this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link);
172
+		// verify TXN
173
+		if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) {
174
+			EE_Error::add_error(
175
+				__(
176
+					'No transaction information could be retrieved or the transaction data is not of the correct type.',
177
+					'event_espresso'
178
+				),
179
+				__FILE__,
180
+				__FUNCTION__,
181
+				__LINE__
182
+			);
183
+			return null;
184
+		}
185
+		return $this->_current_txn;
186
+	}
187
+
188
+
189
+
190
+	/**
191
+	 * get_txn_payments
192
+	 *
193
+	 * @param int $since
194
+	 * @return mixed array of EE_Payment || FALSE
195
+	 * @throws \EE_Error
196
+	 */
197
+	public function get_txn_payments($since = 0)
198
+	{
199
+		if ( ! $this->get_txn()) {
200
+			return false;
201
+		}
202
+		$args = array('order_by' => array('PAY_timestamp' => 'ASC'));
203
+		if ($since > 0) {
204
+			$args[0] = array('PAY_timestamp' => array('>', $since));
205
+		}
206
+		// get array of payments with most recent first
207
+		return $this->_current_txn->payments($args);
208
+	}
209
+
210
+
211
+
212
+	/**
213
+	 * get_reg_url_link
214
+	 *
215
+	 * @return void
216
+	 */
217
+	private function _get_reg_url_link()
218
+	{
219
+		if ( ! empty($this->_reg_url_link)) {
220
+			return;
221
+		}
222
+		// only do thank you page stuff if we have a REG_url_link in the url
223
+		if (WP_DEBUG && ! EE_Registry::instance()->REQ->is_set('e_reg_url_link')) {
224
+			EE_Error::add_error(
225
+				__(
226
+					'No transaction information could be retrieved because the registration URL link is missing or invalid.',
227
+					'event_espresso'
228
+				),
229
+				__FILE__,
230
+				__FUNCTION__,
231
+				__LINE__
232
+			);
233
+			return;
234
+		}
235
+		// check for reg_url_link
236
+		$this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link');
237
+	}
238
+
239
+
240
+
241
+	/**
242
+	 * set_reg_url_link
243
+	 *
244
+	 * @param string $reg_url_link
245
+	 */
246
+	public function set_reg_url_link($reg_url_link = null)
247
+	{
248
+		$this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link;
249
+	}
250
+
251
+
252
+
253
+	/**
254
+	 * run - initial module setup
255
+	 * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
256
+	 *
257
+	 * @param WP $WP
258
+	 * @return void
259
+	 * @throws \EE_Error
260
+	 */
261
+	public function run($WP)
262
+	{
263
+
264
+	}
265
+
266
+
267
+
268
+	/**
269
+	 * load_resources
270
+	 *
271
+	 * @return void
272
+	 * @throws \EE_Error
273
+	 */
274
+	public function load_resources() {
275
+		$this->_get_reg_url_link();
276
+		// resend_reg_confirmation_email ?
277
+		if (EE_Registry::instance()->REQ->is_set('resend')) {
278
+			EED_Thank_You_Page::resend_reg_confirmation_email();
279
+		}
280
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
281
+		$this->_translate_strings();
282
+		// load assets
283
+		add_action('wp_enqueue_scripts', array($this, 'load_js'), 10);
284
+	}
285
+
286
+
287
+
288
+	/**
289
+	 * load_js
290
+	 *
291
+	 * @return void
292
+	 */
293
+	protected function _translate_strings()
294
+	{
295
+		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link;
296
+		EE_Registry::$i18n_js_strings['initial_access'] = time();
297
+		EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time;
298
+		EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code;
299
+		EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code;
300
+		EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __(
301
+			'checking for new payments...',
302
+			'event_espresso'
303
+		);
304
+		EE_Registry::$i18n_js_strings['loading_payment_info'] = __(
305
+			'loading payment information...',
306
+			'event_espresso'
307
+		);
308
+		EE_Registry::$i18n_js_strings['server_error'] = __(
309
+			'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.',
310
+			'event_espresso'
311
+		);
312
+		EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters(
313
+			'EED_Thank_You_Page__load_js__slow_IPN',
314
+			sprintf(
315
+				__(
316
+					'%sThe Payment Notification appears to be taking longer than usual to arrive. Maybe check back later or just wait for your payment and registration confirmation results to be sent to you via email. We apologize for any inconvenience this may have caused.%s',
317
+					'event_espresso'
318
+				),
319
+				'<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">',
320
+				'</div>'
321
+			)
322
+		);
323
+	}
324
+
325
+
326
+
327
+	/**
328
+	 * load_js
329
+	 *
330
+	 * @return void
331
+	 */
332
+	public function load_js()
333
+	{
334
+		wp_register_script(
335
+			'thank_you_page',
336
+			THANK_YOU_ASSETS_URL . 'thank_you_page.js',
337
+			array('espresso_core', 'heartbeat'),
338
+			EVENT_ESPRESSO_VERSION,
339
+			true
340
+		);
341
+		wp_enqueue_script('thank_you_page');
342
+	}
343
+
344
+
345
+
346
+	/**
347
+	 * init
348
+	 *
349
+	 * @return void
350
+	 * @throws \EE_Error
351
+	 */
352
+	public function init()
353
+	{
354
+		$this->_get_reg_url_link();
355
+		if ( ! $this->get_txn()) {
356
+			echo EEH_HTML::div(
357
+				EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') .
358
+				sprintf(
359
+					__(
360
+						'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s',
361
+						'event_espresso'
362
+					),
363
+					'<br/>'
364
+				),
365
+				'',
366
+				'ee-attention'
367
+			);
368
+			return null;
369
+		}
370
+		// if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete"
371
+		if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) {
372
+			$this->_current_txn->set_status(EEM_Transaction::incomplete_status_code);
373
+			$this->_current_txn->save();
374
+		}
375
+		$this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration
376
+			? $this->_current_txn->primary_registration()
377
+			: null;
378
+		$this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link ? true : false;
379
+		$show_try_pay_again_link_default = apply_filters(
380
+			'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default',
381
+			true
382
+		);
383
+		$this->_show_try_pay_again_link = $show_try_pay_again_link_default;
384
+		// txn status ?
385
+		if ($this->_current_txn->is_completed()) {
386
+			$this->_show_try_pay_again_link = $show_try_pay_again_link_default;
387
+		} else if (
388
+			$this->_current_txn->is_incomplete()
389
+			&& ($this->_primary_registrant->is_approved()
390
+				|| $this->_primary_registrant->is_pending_payment())
391
+		) {
392
+			$this->_show_try_pay_again_link = true;
393
+		} else if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) {
394
+			// its pending
395
+			$this->_show_try_pay_again_link = isset(
396
+												  EE_Registry::instance()->CFG->registration->show_pending_payment_options
397
+											  )
398
+											  && EE_Registry::instance()->CFG->registration->show_pending_payment_options
399
+				? true
400
+				: $show_try_pay_again_link_default;
401
+		}
402
+		$this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method
403
+			? true
404
+			: false;
405
+		$this->_is_offline_payment_method = false;
406
+		if (
407
+			// if payment method is unknown
408
+			! $this->_current_txn->payment_method() instanceof EE_Payment_Method
409
+			|| (
410
+				// or is an offline payment method
411
+				$this->_current_txn->payment_method() instanceof EE_Payment_Method
412
+				&& $this->_current_txn->payment_method()->is_off_line()
413
+			)
414
+		) {
415
+			$this->_is_offline_payment_method = true;
416
+		}
417
+		// link to SPCO
418
+		$revisit_spco_url = add_query_arg(
419
+			array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link),
420
+			EE_Registry::instance()->CFG->core->reg_page_url()
421
+		);
422
+		// link to SPCO payment_options
423
+		$this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration
424
+			? $this->_primary_registrant->payment_overview_url()
425
+			: add_query_arg(
426
+				array('step' => 'payment_options'),
427
+				$revisit_spco_url
428
+			);
429
+		// link to SPCO attendee_information
430
+		$this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration
431
+			? $this->_primary_registrant->edit_attendee_information_url()
432
+			: false;
433
+		do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn);
434
+		// set no cache headers and constants
435
+		EE_System::do_not_cache();
436
+	}
437
+
438
+
439
+
440
+	/**
441
+	 * display_thank_you_page_results
442
+	 *
443
+	 * @return string
444
+	 * @throws \EE_Error
445
+	 */
446
+	public function thank_you_page_results()
447
+	{
448
+		$this->init();
449
+		if ( ! $this->_current_txn instanceof EE_Transaction) {
450
+			return EE_Error::get_notices();
451
+		}
452
+		// link to receipt
453
+		$template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html');
454
+		if ( ! empty($template_args['TXN_receipt_url'])) {
455
+			$template_args['order_conf_desc'] = __(
456
+				'%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.',
457
+				'event_espresso'
458
+			);
459
+		} else {
460
+			$template_args['order_conf_desc'] = __(
461
+				'%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.',
462
+				'event_espresso'
463
+			);
464
+		}
465
+		$template_args['transaction'] = $this->_current_txn;
466
+		$template_args['revisit'] = EE_Registry::instance()->REQ->get('revisit', false);
467
+		add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details'));
468
+		if ($this->_is_primary && ! $this->_current_txn->is_free()) {
469
+			add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content'));
470
+		}
471
+		return EEH_Template::locate_template(
472
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php',
473
+			$template_args,
474
+			true,
475
+			true
476
+		);
477
+	}
478
+
479
+
480
+
481
+	/**
482
+	 * thank_you_page_IPN_monitor
483
+	 * this basically just pulls the TXN based on the reg_url_link sent from the server,
484
+	 * then checks that the TXN status is not failed, and that no other errors have been generated.
485
+	 * it also calculates the IPN wait time since the Thank You page was first loaded
486
+	 *
487
+	 * @param array $response
488
+	 * @param array $data
489
+	 * @return array
490
+	 * @throws \EE_Error
491
+	 */
492
+	public static function thank_you_page_IPN_monitor($response = array(), $data = array())
493
+	{
494
+		// does this heartbeat contain our data ?
495
+		if ( ! isset($data['espresso_thank_you_page'])) {
496
+			return $response;
497
+		}
498
+		// check for reg_url_link in the incoming heartbeat data
499
+		if ( ! isset($data['espresso_thank_you_page']['e_reg_url_link'])) {
500
+			$response['espresso_thank_you_page'] = array(
501
+				'errors' => ! empty($notices['errors'])
502
+					? $notices['errors']
503
+					: __(
504
+						'No transaction information could be retrieved because the registration URL link is missing or invalid.',
505
+						'event_espresso'
506
+					)
507
+			);
508
+			return $response;
509
+		}
510
+		// kk heartbeat has our data
511
+		$response['espresso_thank_you_page'] = array();
512
+		// set_definitions, instantiate the thank you page class, and get the ball rolling
513
+		EED_Thank_You_Page::set_definitions();
514
+		/** @var $espresso_thank_you_page EED_Thank_You_Page */
515
+		$espresso_thank_you_page = EED_Thank_You_Page::instance();
516
+		$espresso_thank_you_page->set_reg_url_link($data['espresso_thank_you_page']['e_reg_url_link']);
517
+		$espresso_thank_you_page->init();
518
+		//get TXN
519
+		$TXN = $espresso_thank_you_page->get_txn();
520
+		// no TXN? then get out
521
+		if ( ! $TXN instanceof EE_Transaction) {
522
+			$notices = EE_Error::get_notices();
523
+			$response['espresso_thank_you_page'] = array(
524
+				'errors' => ! empty($notices['errors'])
525
+					? $notices['errors']
526
+					: sprintf(
527
+						__(
528
+							'The information for your transaction could not be retrieved from the server or the transaction data received was invalid because of a technical reason. (%s)',
529
+							'event_espresso'
530
+						),
531
+						__LINE__
532
+					)
533
+			);
534
+			return $response;
535
+		}
536
+		// grab transient of TXN's status
537
+		$txn_status = isset($data['espresso_thank_you_page']['txn_status'])
538
+			? $data['espresso_thank_you_page']['txn_status']
539
+			: null;
540
+		// has the TXN status changed since we last checked (or empty because this is the first time running through this code)?
541
+		if ($txn_status !== $TXN->status_ID()) {
542
+			// switch between two possible basic outcomes
543
+			switch ($TXN->status_ID()) {
544
+				// TXN has been updated in some way
545
+				case EEM_Transaction::overpaid_status_code:
546
+				case EEM_Transaction::complete_status_code:
547
+				case EEM_Transaction::incomplete_status_code:
548
+					// send updated TXN results back to client,
549
+					$response['espresso_thank_you_page'] = array(
550
+						'transaction_details' => $espresso_thank_you_page->get_transaction_details(),
551
+						'txn_status'          => $TXN->status_ID()
552
+					);
553
+					break;
554
+				// or we have a bad TXN, or really slow IPN, so calculate the wait time and send that back...
555
+				case EEM_Transaction::failed_status_code:
556
+				default:
557
+					// keep on waiting...
558
+					return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']);
559
+			}
560
+			// or is the TXN still failed (never been updated) ???
561
+		} else if ($TXN->failed()) {
562
+			// keep on waiting...
563
+			return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']);
564
+		}
565
+		// TXN is happening so let's get the payments now
566
+		// if we've already gotten payments then the heartbeat data will contain the timestamp of the last time we checked
567
+		$since = isset($data['espresso_thank_you_page']['get_payments_since'])
568
+			? $data['espresso_thank_you_page']['get_payments_since']
569
+			: 0;
570
+		// then check for payments
571
+		$payments = $espresso_thank_you_page->get_txn_payments($since);
572
+		// has a payment been processed ?
573
+		if ( ! empty($payments) || $espresso_thank_you_page->_is_offline_payment_method) {
574
+			if ($since) {
575
+				$response['espresso_thank_you_page'] = array(
576
+					'new_payments'        => $espresso_thank_you_page->get_new_payments($payments),
577
+					'transaction_details' => $espresso_thank_you_page->get_transaction_details(),
578
+					'txn_status'          => $TXN->status_ID()
579
+				);
580
+			} else {
581
+				$response['espresso_thank_you_page']['payment_details'] = $espresso_thank_you_page->get_payment_details(
582
+					$payments
583
+				);
584
+			}
585
+			// reset time to check for payments
586
+			$response['espresso_thank_you_page']['get_payments_since'] = time();
587
+		} else {
588
+			$response['espresso_thank_you_page']['get_payments_since'] = $since;
589
+		}
590
+		return $response;
591
+	}
592
+
593
+
594
+
595
+	/**
596
+	 * _update_server_wait_time
597
+	 *
598
+	 * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data
599
+	 * @return array
600
+	 * @throws \EE_Error
601
+	 */
602
+	private function _update_server_wait_time($thank_you_page_data = array())
603
+	{
604
+		$response['espresso_thank_you_page'] = array(
605
+			'still_waiting' => isset($thank_you_page_data['initial_access'])
606
+				? time() - $thank_you_page_data['initial_access']
607
+				: 0,
608
+			'txn_status'    => $this->_current_txn->status_ID()
609
+		);
610
+		return $response;
611
+	}
612
+
613
+
614
+
615
+	/**
616
+	 * get_registration_details
617
+	 *
618
+	 * @throws \EE_Error
619
+	 */
620
+	public function get_registration_details()
621
+	{
622
+		//prepare variables for displaying
623
+		$template_args = array();
624
+		$template_args['transaction'] = $this->_current_txn;
625
+		$template_args['reg_url_link'] = $this->_reg_url_link;
626
+		$template_args['is_primary'] = $this->_is_primary;
627
+		$template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url;
628
+		$template_args['resend_reg_confirmation_url'] = add_query_arg(
629
+			array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'),
630
+			EE_Registry::instance()->CFG->core->thank_you_page_url()
631
+		);
632
+		// verify template arguments
633
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
634
+		EEH_Template_Validator::verify_isnt_null(
635
+			$template_args['SPCO_attendee_information_url'],
636
+			'$SPCO_attendee_information_url'
637
+		);
638
+		echo EEH_Template::locate_template(
639
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php',
640
+			$template_args,
641
+			true,
642
+			true
643
+		);
644
+	}
645
+
646
+
647
+
648
+	/**
649
+	 * resend_reg_confirmation_email
650
+	 *
651
+	 * @throws \EE_Error
652
+	 */
653
+	public static function resend_reg_confirmation_email()
654
+	{
655
+		EE_Registry::instance()->load_core('Request_Handler');
656
+		$reg_url_link = EE_Registry::instance()->REQ->get('token');
657
+		// was a REG_ID passed ?
658
+		if ($reg_url_link) {
659
+			$registration = EE_Registry::instance()->load_model('Registration')->get_one(
660
+				array(array('REG_url_link' => $reg_url_link))
661
+			);
662
+			if ($registration instanceof EE_Registration) {
663
+				// resend email
664
+				EED_Messages::process_resend(array('_REG_ID' => $registration->ID()));
665
+			} else {
666
+				EE_Error::add_error(
667
+					__(
668
+						'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.',
669
+						'event_espresso'
670
+					),
671
+					__FILE__,
672
+					__FUNCTION__,
673
+					__LINE__
674
+				);
675
+			}
676
+		} else {
677
+			EE_Error::add_error(
678
+				__(
679
+					'The Registration Confirmation email could not be sent because a registration token is missing or invalid.',
680
+					'event_espresso'
681
+				),
682
+				__FILE__,
683
+				__FUNCTION__,
684
+				__LINE__
685
+			);
686
+		}
687
+		// request sent via AJAX ?
688
+		if (EE_FRONT_AJAX) {
689
+			echo wp_json_encode(EE_Error::get_notices(false));
690
+			die();
691
+			// or was JS disabled ?
692
+		} else {
693
+			// save errors so that they get picked up on the next request
694
+			EE_Error::get_notices(true, true);
695
+			wp_safe_redirect(
696
+				add_query_arg(
697
+					array('e_reg_url_link' => $reg_url_link),
698
+					EE_Registry::instance()->CFG->core->thank_you_page_url()
699
+				)
700
+			);
701
+		}
702
+	}
703
+
704
+
705
+
706
+	/**
707
+	 * get_ajax_content
708
+	 *
709
+	 * @return void
710
+	 * @throws \EE_Error
711
+	 */
712
+	public function get_ajax_content()
713
+	{
714
+		if ( ! $this->get_txn()) {
715
+			return;
716
+		}
717
+		// first determine which event(s) require pre-approval or not
718
+		$events = array();
719
+		$events_requiring_pre_approval = array();
720
+		foreach ($this->_current_txn->registrations() as $registration) {
721
+			if ($registration instanceof EE_Registration) {
722
+				$event = $registration->event();
723
+				if ($event instanceof EE_Event) {
724
+					if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) {
725
+						$events_requiring_pre_approval[$event->ID()] = $event;
726
+					} else {
727
+						$events[$event->ID()] = $event;
728
+					}
729
+				}
730
+			}
731
+		}
732
+		$this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval);
733
+		$this->display_details_for_events($events);
734
+	}
735
+
736
+
737
+
738
+	/**
739
+	 * display_details_for_events
740
+	 *
741
+	 * @param EE_Event[] $events
742
+	 * @return void
743
+	 */
744
+	public function display_details_for_events($events = array())
745
+	{
746
+		if ( ! empty($events)) {
747
+			?>
748 748
             <div id="espresso-thank-you-page-ajax-content-dv">
749 749
                 <div id="espresso-thank-you-page-ajax-transaction-dv"></div>
750 750
                 <div id="espresso-thank-you-page-ajax-payment-dv"></div>
751 751
                 <div id="espresso-thank-you-page-ajax-loading-dv">
752 752
                     <div id="ee-ajax-loading-dv" class="float-left lt-blue-text">
753 753
                         <span class="dashicons dashicons-upload"></span><span id="ee-ajax-loading-msg-spn"><?php _e(
754
-                                'loading transaction and payment information...',
755
-                                'event_espresso'
756
-                            ); ?></span>
754
+								'loading transaction and payment information...',
755
+								'event_espresso'
756
+							); ?></span>
757 757
                     </div>
758 758
                     <?php if ( ! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?>
759 759
                         <p id="ee-ajax-loading-pg" class="highlight-bg small-text clear">
760 760
                             <?php echo apply_filters(
761
-                                'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg',
762
-                                __(
763
-                                    'Some payment gateways can take 15 minutes or more to return their payment notification, so please be patient if you require payment confirmation as soon as possible. Please note that as soon as everything is finalized, we will send your full payment and registration confirmation results to you via email.',
764
-                                    'event_espresso'
765
-                                )
766
-                            ); ?>
761
+								'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg',
762
+								__(
763
+									'Some payment gateways can take 15 minutes or more to return their payment notification, so please be patient if you require payment confirmation as soon as possible. Please note that as soon as everything is finalized, we will send your full payment and registration confirmation results to you via email.',
764
+									'event_espresso'
765
+								)
766
+							); ?>
767 767
                             <br/>
768 768
                             <span class="jst-rght ee-block small-text lt-grey-text">
769 769
 								<?php _e('current wait time ', 'event_espresso'); ?>
@@ -774,120 +774,120 @@  discard block
 block discarded – undo
774 774
                 <div class="clear"></div>
775 775
             </div>
776 776
             <?php
777
-        }
778
-    }
777
+		}
778
+	}
779 779
 
780 780
 
781 781
 
782
-    /**
783
-     * display_details_for_events_requiring_pre_approval
784
-     *
785
-     * @param EE_Event[] $events
786
-     * @return void
787
-     */
788
-    public function display_details_for_events_requiring_pre_approval($events = array())
789
-    {
790
-        if ( ! empty($events)) {
791
-            ?>
782
+	/**
783
+	 * display_details_for_events_requiring_pre_approval
784
+	 *
785
+	 * @param EE_Event[] $events
786
+	 * @return void
787
+	 */
788
+	public function display_details_for_events_requiring_pre_approval($events = array())
789
+	{
790
+		if ( ! empty($events)) {
791
+			?>
792 792
             <div id="espresso-thank-you-page-not-approved-message-dv">
793 793
                 <h4 class="orange-text"><?php _e('Important Notice:', 'event_espresso'); ?></h4>
794 794
                 <p id="events-requiring-pre-approval-pg" class="small-text">
795 795
                     <?php echo apply_filters(
796
-                        'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message',
797
-                        __(
798
-                            'The following Event(s) you have registered for do not require payment at this time and will not be billed for during this transaction. Billing will only occur after all attendees have been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.',
799
-                            'event_espresso'
800
-                        )
801
-                    ); ?>
796
+						'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message',
797
+						__(
798
+							'The following Event(s) you have registered for do not require payment at this time and will not be billed for during this transaction. Billing will only occur after all attendees have been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.',
799
+							'event_espresso'
800
+						)
801
+					); ?>
802 802
                 </p>
803 803
                 <ul class="events-requiring-pre-approval-ul">
804 804
                     <?php foreach ($events as $event) {
805
-                        if ($event instanceof EE_Event) {
806
-                            echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>',
807
-                            $event->name(),
808
-                            '</li>';
809
-                        }
810
-                    } ?>
805
+						if ($event instanceof EE_Event) {
806
+							echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>',
807
+							$event->name(),
808
+							'</li>';
809
+						}
810
+					} ?>
811 811
                 </ul>
812 812
                 <div class="clear"></div>
813 813
             </div>
814 814
             <?php
815
-        }
816
-    }
817
-
818
-
819
-
820
-    /**
821
-     * get_transaction_details
822
-     *
823
-     * @return string
824
-     * @throws \EE_Error
825
-     */
826
-    public function get_transaction_details()
827
-    {
828
-        //prepare variables for displaying
829
-        $template_args = array();
830
-        $template_args['transaction'] = $this->_current_txn;
831
-        $template_args['reg_url_link'] = $this->_reg_url_link;
832
-        $template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true);
833
-        // link to SPCO payment_options
834
-        $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
835
-        $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
836
-        // verify template arguments
837
-        EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
838
-        EEH_Template_Validator::verify_isnt_null(
839
-            $template_args['show_try_pay_again_link'],
840
-            '$show_try_pay_again_link'
841
-        );
842
-        EEH_Template_Validator::verify_isnt_null(
843
-            $template_args['SPCO_payment_options_url'],
844
-            '$SPCO_payment_options_url'
845
-        );
846
-        return EEH_Template::locate_template(
847
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php',
848
-            $template_args,
849
-            true,
850
-            true
851
-        );
852
-    }
853
-
854
-
855
-
856
-    /**
857
-     * get_payment_row_html
858
-     *
859
-     * @param EE_Payment $payment
860
-     * @return string
861
-     * @throws \EE_Error
862
-     */
863
-    public function get_payment_row_html($payment = null)
864
-    {
865
-        $html = '';
866
-        if ($payment instanceof EE_Payment) {
867
-            if (
868
-                $payment->payment_method() instanceof EE_Payment_Method
869
-                && $payment->status() === EEM_Payment::status_id_failed
870
-                && $payment->payment_method()->is_off_site()
871
-            ) {
872
-                // considering the registrant has made it to the Thank You page,
873
-                // any failed payments may actually be pending and the IPN is just slow
874
-                // so let's
875
-                $payment->set_status(EEM_Payment::status_id_pending);
876
-            }
877
-            $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined
878
-                ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>'
879
-                : '';
880
-            $html .= '
815
+		}
816
+	}
817
+
818
+
819
+
820
+	/**
821
+	 * get_transaction_details
822
+	 *
823
+	 * @return string
824
+	 * @throws \EE_Error
825
+	 */
826
+	public function get_transaction_details()
827
+	{
828
+		//prepare variables for displaying
829
+		$template_args = array();
830
+		$template_args['transaction'] = $this->_current_txn;
831
+		$template_args['reg_url_link'] = $this->_reg_url_link;
832
+		$template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true);
833
+		// link to SPCO payment_options
834
+		$template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
835
+		$template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
836
+		// verify template arguments
837
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
838
+		EEH_Template_Validator::verify_isnt_null(
839
+			$template_args['show_try_pay_again_link'],
840
+			'$show_try_pay_again_link'
841
+		);
842
+		EEH_Template_Validator::verify_isnt_null(
843
+			$template_args['SPCO_payment_options_url'],
844
+			'$SPCO_payment_options_url'
845
+		);
846
+		return EEH_Template::locate_template(
847
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php',
848
+			$template_args,
849
+			true,
850
+			true
851
+		);
852
+	}
853
+
854
+
855
+
856
+	/**
857
+	 * get_payment_row_html
858
+	 *
859
+	 * @param EE_Payment $payment
860
+	 * @return string
861
+	 * @throws \EE_Error
862
+	 */
863
+	public function get_payment_row_html($payment = null)
864
+	{
865
+		$html = '';
866
+		if ($payment instanceof EE_Payment) {
867
+			if (
868
+				$payment->payment_method() instanceof EE_Payment_Method
869
+				&& $payment->status() === EEM_Payment::status_id_failed
870
+				&& $payment->payment_method()->is_off_site()
871
+			) {
872
+				// considering the registrant has made it to the Thank You page,
873
+				// any failed payments may actually be pending and the IPN is just slow
874
+				// so let's
875
+				$payment->set_status(EEM_Payment::status_id_pending);
876
+			}
877
+			$payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined
878
+				? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>'
879
+				: '';
880
+			$html .= '
881 881
 				<tr>
882 882
 					<td>
883 883
 						' . $payment->timestamp() . '
884 884
 					</td>
885 885
 					<td>
886 886
 						' . (
887
-                $payment->payment_method() instanceof EE_Payment_Method
888
-                    ? $payment->payment_method()->name()
889
-                    : __('Unknown', 'event_espresso')
890
-                ) . '
887
+				$payment->payment_method() instanceof EE_Payment_Method
888
+					? $payment->payment_method()->name()
889
+					: __('Unknown', 'event_espresso')
890
+				) . '
891 891
 					</td>
892 892
 					<td class="jst-rght">
893 893
 						' . EEH_Template::format_currency($payment->amount()) . '
@@ -896,87 +896,87 @@  discard block
 block discarded – undo
896 896
 						' . $payment->pretty_status(true) . $payment_declined_msg . '
897 897
 					</td>
898 898
 				</tr>';
899
-            do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment);
900
-        }
901
-        return $html;
902
-    }
903
-
904
-
905
-
906
-    /**
907
-     * get_payment_details
908
-     *
909
-     * @param array $payments
910
-     * @return string
911
-     * @throws \EE_Error
912
-     */
913
-    public function get_payment_details($payments = array())
914
-    {
915
-        //prepare variables for displaying
916
-        $template_args = array();
917
-        $template_args['transaction'] = $this->_current_txn;
918
-        $template_args['reg_url_link'] = $this->_reg_url_link;
919
-        $template_args['payments'] = array();
920
-        foreach ($payments as $payment) {
921
-            $template_args['payments'][] = $this->get_payment_row_html($payment);
922
-        }
923
-        //create a hacky payment object, but dont save it
924
-        $payment = EE_Payment::new_instance(
925
-            array(
926
-                'TXN_ID'        => $this->_current_txn->ID(),
927
-                'STS_ID'        => EEM_Payment::status_id_pending,
928
-                'PAY_timestamp' => time(),
929
-                'PAY_amount'    => $this->_current_txn->total(),
930
-                'PMD_ID'        => $this->_current_txn->payment_method_ID()
931
-            )
932
-        );
933
-        $payment_method = $this->_current_txn->payment_method();
934
-        if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) {
935
-            $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment);
936
-        } else {
937
-            $template_args['gateway_content'] = '';
938
-        }
939
-        // link to SPCO payment_options
940
-        $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
941
-        $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
942
-        // verify template arguments
943
-        EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
944
-        EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments');
945
-        EEH_Template_Validator::verify_isnt_null(
946
-            $template_args['show_try_pay_again_link'],
947
-            '$show_try_pay_again_link'
948
-        );
949
-        EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content');
950
-        EEH_Template_Validator::verify_isnt_null(
951
-            $template_args['SPCO_payment_options_url'],
952
-            '$SPCO_payment_options_url'
953
-        );
954
-        return EEH_Template::locate_template(
955
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php',
956
-            $template_args,
957
-            true,
958
-            true
959
-        );
960
-    }
961
-
962
-
963
-
964
-    /**
965
-     * get_payment_details
966
-     *
967
-     * @param array $payments
968
-     * @return string
969
-     * @throws \EE_Error
970
-     */
971
-    public function get_new_payments($payments = array())
972
-    {
973
-        $payments_html = '';
974
-        //prepare variables for displaying
975
-        foreach ($payments as $payment) {
976
-            $payments_html .= $this->get_payment_row_html($payment);
977
-        }
978
-        return $payments_html;
979
-    }
899
+			do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment);
900
+		}
901
+		return $html;
902
+	}
903
+
904
+
905
+
906
+	/**
907
+	 * get_payment_details
908
+	 *
909
+	 * @param array $payments
910
+	 * @return string
911
+	 * @throws \EE_Error
912
+	 */
913
+	public function get_payment_details($payments = array())
914
+	{
915
+		//prepare variables for displaying
916
+		$template_args = array();
917
+		$template_args['transaction'] = $this->_current_txn;
918
+		$template_args['reg_url_link'] = $this->_reg_url_link;
919
+		$template_args['payments'] = array();
920
+		foreach ($payments as $payment) {
921
+			$template_args['payments'][] = $this->get_payment_row_html($payment);
922
+		}
923
+		//create a hacky payment object, but dont save it
924
+		$payment = EE_Payment::new_instance(
925
+			array(
926
+				'TXN_ID'        => $this->_current_txn->ID(),
927
+				'STS_ID'        => EEM_Payment::status_id_pending,
928
+				'PAY_timestamp' => time(),
929
+				'PAY_amount'    => $this->_current_txn->total(),
930
+				'PMD_ID'        => $this->_current_txn->payment_method_ID()
931
+			)
932
+		);
933
+		$payment_method = $this->_current_txn->payment_method();
934
+		if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) {
935
+			$template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment);
936
+		} else {
937
+			$template_args['gateway_content'] = '';
938
+		}
939
+		// link to SPCO payment_options
940
+		$template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
941
+		$template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
942
+		// verify template arguments
943
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
944
+		EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments');
945
+		EEH_Template_Validator::verify_isnt_null(
946
+			$template_args['show_try_pay_again_link'],
947
+			'$show_try_pay_again_link'
948
+		);
949
+		EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content');
950
+		EEH_Template_Validator::verify_isnt_null(
951
+			$template_args['SPCO_payment_options_url'],
952
+			'$SPCO_payment_options_url'
953
+		);
954
+		return EEH_Template::locate_template(
955
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php',
956
+			$template_args,
957
+			true,
958
+			true
959
+		);
960
+	}
961
+
962
+
963
+
964
+	/**
965
+	 * get_payment_details
966
+	 *
967
+	 * @param array $payments
968
+	 * @return string
969
+	 * @throws \EE_Error
970
+	 */
971
+	public function get_new_payments($payments = array())
972
+	{
973
+		$payments_html = '';
974
+		//prepare variables for displaying
975
+		foreach ($payments as $payment) {
976
+			$payments_html .= $this->get_payment_row_html($payment);
977
+		}
978
+		return $payments_html;
979
+	}
980 980
 
981 981
 
982 982
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public static function set_definitions()
143 143
     {
144
-        define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
145
-        define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
144
+        define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
145
+        define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
146 146
     }
147 147
 
148 148
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
     {
334 334
         wp_register_script(
335 335
             'thank_you_page',
336
-            THANK_YOU_ASSETS_URL . 'thank_you_page.js',
336
+            THANK_YOU_ASSETS_URL.'thank_you_page.js',
337 337
             array('espresso_core', 'heartbeat'),
338 338
             EVENT_ESPRESSO_VERSION,
339 339
             true
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
         $this->_get_reg_url_link();
355 355
         if ( ! $this->get_txn()) {
356 356
             echo EEH_HTML::div(
357
-                EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') .
357
+                EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '').
358 358
                 sprintf(
359 359
                     __(
360 360
                         'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s',
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
             add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content'));
470 470
         }
471 471
         return EEH_Template::locate_template(
472
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php',
472
+            THANK_YOU_TEMPLATES_PATH.'thank-you-page-overview.template.php',
473 473
             $template_args,
474 474
             true,
475 475
             true
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
             '$SPCO_attendee_information_url'
637 637
         );
638 638
         echo EEH_Template::locate_template(
639
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php',
639
+            THANK_YOU_TEMPLATES_PATH.'thank-you-page-registration-details.template.php',
640 640
             $template_args,
641 641
             true,
642 642
             true
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
             '$SPCO_payment_options_url'
845 845
         );
846 846
         return EEH_Template::locate_template(
847
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php',
847
+            THANK_YOU_TEMPLATES_PATH.'thank-you-page-transaction-details.template.php',
848 848
             $template_args,
849 849
             true,
850 850
             true
@@ -875,25 +875,25 @@  discard block
 block discarded – undo
875 875
                 $payment->set_status(EEM_Payment::status_id_pending);
876 876
             }
877 877
             $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined
878
-                ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>'
878
+                ? '<br /><span class="small-text">'.$payment->gateway_response().'</span>'
879 879
                 : '';
880 880
             $html .= '
881 881
 				<tr>
882 882
 					<td>
883
-						' . $payment->timestamp() . '
883
+						' . $payment->timestamp().'
884 884
 					</td>
885 885
 					<td>
886 886
 						' . (
887 887
                 $payment->payment_method() instanceof EE_Payment_Method
888 888
                     ? $payment->payment_method()->name()
889 889
                     : __('Unknown', 'event_espresso')
890
-                ) . '
890
+                ).'
891 891
 					</td>
892 892
 					<td class="jst-rght">
893
-						' . EEH_Template::format_currency($payment->amount()) . '
893
+						' . EEH_Template::format_currency($payment->amount()).'
894 894
 					</td>
895 895
 					<td class="jst-rght" style="line-height:1;">
896
-						' . $payment->pretty_status(true) . $payment_declined_msg . '
896
+						' . $payment->pretty_status(true).$payment_declined_msg.'
897 897
 					</td>
898 898
 				</tr>';
899 899
             do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment);
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
             '$SPCO_payment_options_url'
953 953
         );
954 954
         return EEH_Template::locate_template(
955
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php',
955
+            THANK_YOU_TEMPLATES_PATH.'thank-you-page-payment-details.template.php',
956 956
             $template_args,
957 957
             true,
958 958
             true
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoThankYou.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
             return;
53 53
         }
54 54
         $post = reset($wp_query->posts);
55
-        if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id ) {
55
+        if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id) {
56 56
             return;
57 57
         }
58 58
         $this->is_thank_you_page = true;
Please login to merge, or discard this patch.
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -20,74 +20,74 @@
 block discarded – undo
20 20
 class EspressoThankYou extends EspressoShortcode
21 21
 {
22 22
 
23
-    /**
24
-     * @var boolean $is_thank_you_page
25
-     */
26
-    private $is_thank_you_page = false;
27
-
28
-    /**
29
-     * the actual shortcode tag that gets registered with WordPress
30
-     *
31
-     * @return string
32
-     */
33
-    public function getTag()
34
-    {
35
-        return 'ESPRESSO_THANK_YOU';
36
-    }
37
-
38
-
39
-
40
-    /**
41
-     * the time in seconds to cache the results of the processShortcode() method
42
-     * 0 means the processShortcode() results will NOT be cached at all
43
-     *
44
-     * @return int
45
-     */
46
-    public function cacheExpiration()
47
-    {
48
-        return 0;
49
-    }
50
-
51
-
52
-    /**
53
-     * a place for adding any initialization code that needs to run prior to wp_header().
54
-     * this may be required for shortcodes that utilize a corresponding module,
55
-     * and need to enqueue assets for that module
56
-     *
57
-     * @return void
58
-     * @throws \EE_Error
59
-     */
60
-    public function initializeShortcode()
61
-    {
62
-        global $wp_query;
63
-        if (empty($wp_query->posts) || count($wp_query->posts) > 1) {
64
-            return;
65
-        }
66
-        $post = reset($wp_query->posts);
67
-        if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id ) {
68
-            return;
69
-        }
70
-        $this->is_thank_you_page = true;
71
-        \EED_Thank_You_Page::instance()->load_resources();
72
-    }
73
-
74
-
75
-
76
-    /**
77
-     * callback that runs when the shortcode is encountered in post content.
78
-     * IMPORTANT !!!
79
-     * remember that shortcode content should be RETURNED and NOT echoed out
80
-     *
81
-     * @param array $attributes
82
-     * @return string
83
-     * @throws \EE_Error
84
-     */
85
-    public function processShortcode($attributes = array())
86
-    {
87
-        return $this->is_thank_you_page
88
-            ? \EED_Thank_You_Page::instance()->thank_you_page_results()
89
-            : '';
90
-    }
23
+	/**
24
+	 * @var boolean $is_thank_you_page
25
+	 */
26
+	private $is_thank_you_page = false;
27
+
28
+	/**
29
+	 * the actual shortcode tag that gets registered with WordPress
30
+	 *
31
+	 * @return string
32
+	 */
33
+	public function getTag()
34
+	{
35
+		return 'ESPRESSO_THANK_YOU';
36
+	}
37
+
38
+
39
+
40
+	/**
41
+	 * the time in seconds to cache the results of the processShortcode() method
42
+	 * 0 means the processShortcode() results will NOT be cached at all
43
+	 *
44
+	 * @return int
45
+	 */
46
+	public function cacheExpiration()
47
+	{
48
+		return 0;
49
+	}
50
+
51
+
52
+	/**
53
+	 * a place for adding any initialization code that needs to run prior to wp_header().
54
+	 * this may be required for shortcodes that utilize a corresponding module,
55
+	 * and need to enqueue assets for that module
56
+	 *
57
+	 * @return void
58
+	 * @throws \EE_Error
59
+	 */
60
+	public function initializeShortcode()
61
+	{
62
+		global $wp_query;
63
+		if (empty($wp_query->posts) || count($wp_query->posts) > 1) {
64
+			return;
65
+		}
66
+		$post = reset($wp_query->posts);
67
+		if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id ) {
68
+			return;
69
+		}
70
+		$this->is_thank_you_page = true;
71
+		\EED_Thank_You_Page::instance()->load_resources();
72
+	}
73
+
74
+
75
+
76
+	/**
77
+	 * callback that runs when the shortcode is encountered in post content.
78
+	 * IMPORTANT !!!
79
+	 * remember that shortcode content should be RETURNED and NOT echoed out
80
+	 *
81
+	 * @param array $attributes
82
+	 * @return string
83
+	 * @throws \EE_Error
84
+	 */
85
+	public function processShortcode($attributes = array())
86
+	{
87
+		return $this->is_thank_you_page
88
+			? \EED_Thank_You_Page::instance()->thank_you_page_results()
89
+			: '';
90
+	}
91 91
 
92 92
 
93 93
 
Please login to merge, or discard this patch.
core/domain/services/capabilities/CapCheck.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 
39 39
 
40 40
     /**
41
-     * @param string|array $capability   - the capability to be checked, like: 'ee_edit_registrations',
41
+     * @param string $capability   - the capability to be checked, like: 'ee_edit_registrations',
42 42
      *                                   or an array of capability strings
43 43
      * @param string       $context      - what the user is attempting to do, like: 'Edit Registration'
44 44
      * @param int          $ID           - (optional) ID for item where current_user_can is being called from
Please login to merge, or discard this patch.
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\exceptions\InvalidDataTypeException;
5 5
 
6 6
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
-    exit('No direct script access allowed');
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -20,72 +20,72 @@  discard block
 block discarded – undo
20 20
 class CapCheck implements CapCheckInterface
21 21
 {
22 22
 
23
-    /**
24
-     * @var string|array $capability
25
-     */
26
-    private $capability;
27
-
28
-    /**
29
-     * @var string $context
30
-     */
31
-    private $context;
32
-
33
-    /**
34
-     * @var int|string $ID
35
-     */
36
-    private $ID;
37
-
38
-
39
-
40
-    /**
41
-     * @param string|array $capability   - the capability to be checked, like: 'ee_edit_registrations',
42
-     *                                   or an array of capability strings
43
-     * @param string       $context      - what the user is attempting to do, like: 'Edit Registration'
44
-     * @param int          $ID           - (optional) ID for item where current_user_can is being called from
45
-     * @throws InvalidDataTypeException
46
-     */
47
-    public function __construct($capability, $context, $ID = 0)
48
-    {
49
-        if ( ! is_string($capability)) {
50
-            throw new InvalidDataTypeException('$capability', $capability, 'string');
51
-        }
52
-        if ( ! is_string($context)) {
53
-            throw new InvalidDataTypeException('$context', $context, 'string');
54
-        }
55
-        $this->capability = $capability;
56
-        $this->context = strtolower(str_replace(' ', '_', $context));
57
-        $this->ID = $ID;
58
-    }
59
-
60
-
61
-
62
-    /**
63
-     * @return string|array
64
-     */
65
-    public function capability()
66
-    {
67
-        return $this->capability;
68
-    }
69
-
70
-
71
-
72
-    /**
73
-     * @return string
74
-     */
75
-    public function context()
76
-    {
77
-        return $this->context;
78
-    }
79
-
80
-
81
-
82
-    /**
83
-     * @return int|string
84
-     */
85
-    public function ID()
86
-    {
87
-        return $this->ID;
88
-    }
23
+	/**
24
+	 * @var string|array $capability
25
+	 */
26
+	private $capability;
27
+
28
+	/**
29
+	 * @var string $context
30
+	 */
31
+	private $context;
32
+
33
+	/**
34
+	 * @var int|string $ID
35
+	 */
36
+	private $ID;
37
+
38
+
39
+
40
+	/**
41
+	 * @param string|array $capability   - the capability to be checked, like: 'ee_edit_registrations',
42
+	 *                                   or an array of capability strings
43
+	 * @param string       $context      - what the user is attempting to do, like: 'Edit Registration'
44
+	 * @param int          $ID           - (optional) ID for item where current_user_can is being called from
45
+	 * @throws InvalidDataTypeException
46
+	 */
47
+	public function __construct($capability, $context, $ID = 0)
48
+	{
49
+		if ( ! is_string($capability)) {
50
+			throw new InvalidDataTypeException('$capability', $capability, 'string');
51
+		}
52
+		if ( ! is_string($context)) {
53
+			throw new InvalidDataTypeException('$context', $context, 'string');
54
+		}
55
+		$this->capability = $capability;
56
+		$this->context = strtolower(str_replace(' ', '_', $context));
57
+		$this->ID = $ID;
58
+	}
59
+
60
+
61
+
62
+	/**
63
+	 * @return string|array
64
+	 */
65
+	public function capability()
66
+	{
67
+		return $this->capability;
68
+	}
69
+
70
+
71
+
72
+	/**
73
+	 * @return string
74
+	 */
75
+	public function context()
76
+	{
77
+		return $this->context;
78
+	}
79
+
80
+
81
+
82
+	/**
83
+	 * @return int|string
84
+	 */
85
+	public function ID()
86
+	{
87
+		return $this->ID;
88
+	}
89 89
 
90 90
 
91 91
 }
Please login to merge, or discard this patch.
admin/extend/registrations/Extend_Registrations_Admin_Page.core.php 2 patches
Indentation   +1141 added lines, -1141 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -17,1145 +17,1145 @@  discard block
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * This is used to hold the reports template data which is setup early in the request.
22
-     *
23
-     * @type array
24
-     */
25
-    protected $_reports_template_data = array();
26
-
27
-
28
-
29
-    /**
30
-     * Extend_Registrations_Admin_Page constructor.
31
-     *
32
-     * @param bool $routing
33
-     */
34
-    public function __construct($routing = true)
35
-    {
36
-        parent::__construct($routing);
37
-        if ( ! defined('REG_CAF_TEMPLATE_PATH')) {
38
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
39
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
40
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
41
-        }
42
-    }
43
-
44
-
45
-
46
-    protected function _extend_page_config()
47
-    {
48
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50
-            ? $this->_req_data['_REG_ID']
51
-            : 0;
52
-        // $att_id = ! empty( $this->_req_data['ATT_ID'] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0;
53
-        // $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] )
54
-        // 	? $this->_req_data['post'] : $att_id;
55
-        $new_page_routes = array(
56
-            'reports'                  => array(
57
-                'func'       => '_registration_reports',
58
-                'capability' => 'ee_read_registrations',
59
-            ),
60
-            'registration_checkins'    => array(
61
-                'func'       => '_registration_checkin_list_table',
62
-                'capability' => 'ee_read_checkins',
63
-            ),
64
-            'newsletter_selected_send' => array(
65
-                'func'       => '_newsletter_selected_send',
66
-                'noheader'   => true,
67
-                'capability' => 'ee_send_message',
68
-            ),
69
-            'delete_checkin_rows'      => array(
70
-                'func'       => '_delete_checkin_rows',
71
-                'noheader'   => true,
72
-                'capability' => 'ee_delete_checkins',
73
-            ),
74
-            'delete_checkin_row'       => array(
75
-                'func'       => '_delete_checkin_row',
76
-                'noheader'   => true,
77
-                'capability' => 'ee_delete_checkin',
78
-                'obj_id'     => $reg_id,
79
-            ),
80
-            'toggle_checkin_status'    => array(
81
-                'func'       => '_toggle_checkin_status',
82
-                'noheader'   => true,
83
-                'capability' => 'ee_edit_checkin',
84
-                'obj_id'     => $reg_id,
85
-            ),
86
-            'event_registrations'      => array(
87
-                'func'       => '_event_registrations_list_table',
88
-                'capability' => 'ee_read_checkins',
89
-            ),
90
-            'registrations_checkin_report' => array(
91
-                'func'       => '_registrations_checkin_report',
92
-                'noheader'   => true,
93
-                'capability' => 'ee_read_registrations',
94
-            ),
95
-        );
96
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
97
-        $new_page_config = array(
98
-            'reports'               => array(
99
-                'nav'           => array(
100
-                    'label' => __('Reports', 'event_espresso'),
101
-                    'order' => 30,
102
-                ),
103
-                'help_tabs'     => array(
104
-                    'registrations_reports_help_tab' => array(
105
-                        'title'    => __('Registration Reports', 'event_espresso'),
106
-                        'filename' => 'registrations_reports',
107
-                    ),
108
-                ),
109
-                /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/
110
-                'require_nonce' => false,
111
-            ),
112
-            'event_registrations'   => array(
113
-                'nav'           => array(
114
-                    'label'      => __('Event Check-In', 'event_espresso'),
115
-                    'order'      => 10,
116
-                    'persistent' => true,
117
-                ),
118
-                'help_tabs'     => array(
119
-                    'registrations_event_checkin_help_tab'                       => array(
120
-                        'title'    => __('Registrations Event Check-In', 'event_espresso'),
121
-                        'filename' => 'registrations_event_checkin',
122
-                    ),
123
-                    'registrations_event_checkin_table_column_headings_help_tab' => array(
124
-                        'title'    => __('Event Check-In Table Column Headings', 'event_espresso'),
125
-                        'filename' => 'registrations_event_checkin_table_column_headings',
126
-                    ),
127
-                    'registrations_event_checkin_filters_help_tab'               => array(
128
-                        'title'    => __('Event Check-In Filters', 'event_espresso'),
129
-                        'filename' => 'registrations_event_checkin_filters',
130
-                    ),
131
-                    'registrations_event_checkin_views_help_tab'                 => array(
132
-                        'title'    => __('Event Check-In Views', 'event_espresso'),
133
-                        'filename' => 'registrations_event_checkin_views',
134
-                    ),
135
-                    'registrations_event_checkin_other_help_tab'                 => array(
136
-                        'title'    => __('Event Check-In Other', 'event_espresso'),
137
-                        'filename' => 'registrations_event_checkin_other',
138
-                    ),
139
-                ),
140
-                'help_tour'     => array('Event_Checkin_Help_Tour'),
141
-                'qtips'         => array('Registration_List_Table_Tips'),
142
-                'list_table'    => 'EE_Event_Registrations_List_Table',
143
-                'metaboxes'     => array(),
144
-                'require_nonce' => false,
145
-            ),
146
-            'registration_checkins' => array(
147
-                'nav'           => array(
148
-                    'label'      => __('Check-In Records', 'event_espresso'),
149
-                    'order'      => 15,
150
-                    'persistent' => false,
151
-                ),
152
-                'list_table'    => 'EE_Registration_CheckIn_List_Table',
153
-                //'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ),
154
-                'metaboxes'     => array(),
155
-                'require_nonce' => false,
156
-            ),
157
-        );
158
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
159
-        $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
160
-        $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
161
-    }
162
-
163
-
164
-
165
-    protected function _ajax_hooks()
166
-    {
167
-        parent::_ajax_hooks();
168
-        add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
169
-    }
170
-
171
-
172
-
173
-    public function load_scripts_styles()
174
-    {
175
-        parent::load_scripts_styles();
176
-        //if newsletter message type is active then let's add filter and load js for it.
177
-        if (EEH_MSG_Template::is_mt_active('newsletter')) {
178
-            //enqueue newsletter js
179
-            wp_enqueue_script(
180
-                'ee-newsletter-trigger',
181
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
182
-                array('ee-dialog'),
183
-                EVENT_ESPRESSO_VERSION,
184
-                true
185
-            );
186
-            wp_enqueue_style(
187
-                'ee-newsletter-trigger-css',
188
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
189
-                array(),
190
-                EVENT_ESPRESSO_VERSION
191
-            );
192
-            //hook in buttons for newsletter message type trigger.
193
-            add_action(
194
-                'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
195
-                array($this, 'add_newsletter_action_buttons'),
196
-                10
197
-            );
198
-        }
199
-    }
200
-
201
-
202
-
203
-    public function load_scripts_styles_reports()
204
-    {
205
-        wp_register_script(
206
-            'ee-reg-reports-js',
207
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
208
-            array('google-charts'),
209
-            EVENT_ESPRESSO_VERSION,
210
-            true
211
-        );
212
-        wp_enqueue_script('ee-reg-reports-js');
213
-        $this->_registration_reports_js_setup();
214
-    }
215
-
216
-
217
-
218
-    protected function _add_screen_options_event_registrations()
219
-    {
220
-        $this->_per_page_screen_option();
221
-    }
222
-
223
-
224
-
225
-    protected function _add_screen_options_registration_checkins()
226
-    {
227
-        $page_title = $this->_admin_page_title;
228
-        $this->_admin_page_title = __('Check-In Records', 'event_espresso');
229
-        $this->_per_page_screen_option();
230
-        $this->_admin_page_title = $page_title;
231
-    }
232
-
233
-
234
-
235
-    protected function _set_list_table_views_event_registrations()
236
-    {
237
-        $this->_views = array(
238
-            'all' => array(
239
-                'slug'        => 'all',
240
-                'label'       => __('All', 'event_espresso'),
241
-                'count'       => 0,
242
-                'bulk_action' => ! isset($this->_req_data['event_id'])
243
-                    ? array()
244
-                    : array(
245
-                        'toggle_checkin_status' => __('Toggle Check-In', 'event_espresso'),
246
-                        //'trash_registrations' => __('Trash Registrations', 'event_espresso')
247
-                    ),
248
-            ),
249
-        );
250
-    }
251
-
252
-
253
-
254
-    protected function _set_list_table_views_registration_checkins()
255
-    {
256
-        $this->_views = array(
257
-            'all' => array(
258
-                'slug'        => 'all',
259
-                'label'       => __('All', 'event_espresso'),
260
-                'count'       => 0,
261
-                'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')),
262
-            ),
263
-        );
264
-    }
265
-
266
-
267
-
268
-    /**
269
-     * callback for ajax action.
270
-     *
271
-     * @since 4.3.0
272
-     * @return void (JSON)
273
-     * @throws \EE_Error
274
-     */
275
-    public function get_newsletter_form_content()
276
-    {
277
-        //do a nonce check cause we're not coming in from an normal route here.
278
-        $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
279
-            $this->_req_data['get_newsletter_form_content_nonce']
280
-        ) : '';
281
-        $nonce_ref = 'get_newsletter_form_content_nonce';
282
-        $this->_verify_nonce($nonce, $nonce_ref);
283
-        //let's get the mtp for the incoming MTP_ ID
284
-        if ( ! isset($this->_req_data['GRP_ID'])) {
285
-            EE_Error::add_error(
286
-                __(
287
-                    'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
288
-                    'event_espresso'
289
-                ),
290
-                __FILE__,
291
-                __FUNCTION__,
292
-                __LINE__
293
-            );
294
-            $this->_template_args['success'] = false;
295
-            $this->_template_args['error'] = true;
296
-            $this->_return_json();
297
-        }
298
-        $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
299
-        if ( ! $MTPG instanceof EE_Message_Template_Group) {
300
-            EE_Error::add_error(
301
-                sprintf(
302
-                    __(
303
-                        'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
304
-                        'event_espresso'
305
-                    ),
306
-                    $this->_req_data['GRP_ID']
307
-                ),
308
-                __FILE__,
309
-                __FUNCTION__,
310
-                __LINE__
311
-            );
312
-            $this->_template_args['success'] = false;
313
-            $this->_template_args['error'] = true;
314
-            $this->_return_json();
315
-        }
316
-        $MTPs = $MTPG->context_templates();
317
-        $MTPs = $MTPs['attendee'];
318
-        $template_fields = array();
319
-        /** @var EE_Message_Template $MTP */
320
-        foreach ($MTPs as $MTP) {
321
-            $field = $MTP->get('MTP_template_field');
322
-            if ($field === 'content') {
323
-                $content = $MTP->get('MTP_content');
324
-                if ( ! empty($content['newsletter_content'])) {
325
-                    $template_fields['newsletter_content'] = $content['newsletter_content'];
326
-                }
327
-                continue;
328
-            }
329
-            $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content');
330
-        }
331
-        $this->_template_args['success'] = true;
332
-        $this->_template_args['error'] = false;
333
-        $this->_template_args['data'] = array(
334
-            'batch_message_from'    => isset($template_fields['from'])
335
-                ? $template_fields['from']
336
-                : '',
337
-            'batch_message_subject' => isset($template_fields['subject'])
338
-                ? $template_fields['subject']
339
-                : '',
340
-            'batch_message_content' => isset($template_fields['newsletter_content'])
341
-                ? $template_fields['newsletter_content']
342
-                : '',
343
-        );
344
-        $this->_return_json();
345
-    }
346
-
347
-
348
-
349
-    /**
350
-     * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
351
-     *
352
-     * @since 4.3.0
353
-     * @param EE_Admin_List_Table $list_table
354
-     * @return void
355
-     */
356
-    public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
357
-    {
358
-        if ( ! EE_Registry::instance()->CAP->current_user_can(
359
-            'ee_send_message',
360
-            'espresso_registrations_newsletter_selected_send'
361
-        )
362
-        ) {
363
-            return;
364
-        }
365
-        $routes_to_add_to = array(
366
-            'contact_list',
367
-            'event_registrations',
368
-            'default',
369
-        );
370
-        if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
371
-            if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
372
-                || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
373
-            ) {
374
-                echo '';
375
-            } else {
376
-                $button_text = sprintf(
377
-                    __('Send Batch Message (%s selected)', 'event_espresso'),
378
-                    '<span class="send-selected-newsletter-count">0</span>'
379
-                );
380
-                echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>'
381
-                     . $button_text
382
-                     . '</button>';
383
-                add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
384
-            }
385
-        }
386
-    }
387
-
388
-
389
-
390
-    public function newsletter_send_form_skeleton()
391
-    {
392
-        $list_table = $this->_list_table_object;
393
-        $codes = array();
394
-        //need to templates for the newsletter message type for the template selector.
395
-        $values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0);
396
-        $mtps = EEM_Message_Template_Group::instance()->get_all(
397
-            array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
398
-        );
399
-        foreach ($mtps as $mtp) {
400
-            $name = $mtp->name();
401
-            $values[] = array(
402
-                'text' => empty($name) ? __('Global', 'event_espresso') : $name,
403
-                'id'   => $mtp->ID(),
404
-            );
405
-        }
406
-        //need to get a list of shortcodes that are available for the newsletter message type.
407
-        $shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', false);
408
-        foreach ($shortcodes as $field => $shortcode_array) {
409
-            $codes[$field] = implode(', ', array_keys($shortcode_array));
410
-        }
411
-        $shortcodes = $codes;
412
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
413
-        $form_template_args = array(
414
-            'form_action'       => admin_url('admin.php?page=espresso_registrations'),
415
-            'form_route'        => 'newsletter_selected_send',
416
-            'form_nonce_name'   => 'newsletter_selected_send_nonce',
417
-            'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
418
-            'redirect_back_to'  => $this->_req_action,
419
-            'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
420
-            'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
421
-            'shortcodes'        => $shortcodes,
422
-            'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
423
-        );
424
-        EEH_Template::display_template($form_template, $form_template_args);
425
-    }
426
-
427
-
428
-
429
-    /**
430
-     * Handles sending selected registrations/contacts a newsletter.
431
-     *
432
-     * @since  4.3.0
433
-     * @return void
434
-     * @throws \EE_Error
435
-     */
436
-    protected function _newsletter_selected_send()
437
-    {
438
-        $success = true;
439
-        //first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
440
-        if (empty($this->_req_data['newsletter_mtp_selected'])) {
441
-            EE_Error::add_error(
442
-                __(
443
-                    'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
444
-                    'event_espresso'
445
-                ),
446
-                __FILE__,
447
-                __FUNCTION__,
448
-                __LINE__
449
-            );
450
-            $success = false;
451
-        }
452
-        if ($success) {
453
-            //update Message template in case there are any changes
454
-            $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
455
-                $this->_req_data['newsletter_mtp_selected']
456
-            );
457
-            $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
458
-                ? $Message_Template_Group->context_templates()
459
-                : array();
460
-            if (empty($Message_Templates)) {
461
-                EE_Error::add_error(
462
-                    __(
463
-                        'Unable to retrieve message template fields from the db. Messages not sent.',
464
-                        'event_espresso'
465
-                    ),
466
-                    __FILE__,
467
-                    __FUNCTION__,
468
-                    __LINE__
469
-                );
470
-            }
471
-            //let's just update the specific fields
472
-            foreach ($Message_Templates['attendee'] as $Message_Template) {
473
-                if ($Message_Template instanceof EE_Message_Template) {
474
-                    $field = $Message_Template->get('MTP_template_field');
475
-                    $content = $Message_Template->get('MTP_content');
476
-                    $new_content = $content;
477
-                    switch ($field) {
478
-                        case 'from' :
479
-                            $new_content = ! empty($this->_req_data['batch_message']['from'])
480
-                                ? $this->_req_data['batch_message']['from']
481
-                                : $content;
482
-                            break;
483
-                        case 'subject' :
484
-                            $new_content = ! empty($this->_req_data['batch_message']['subject'])
485
-                                ? $this->_req_data['batch_message']['subject']
486
-                                : $content;
487
-                            break;
488
-                        case 'content' :
489
-                            $new_content = $content;
490
-                            $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
491
-                                ? $this->_req_data['batch_message']['content']
492
-                                : $content['newsletter_content'];
493
-                            break;
494
-                        default :
495
-                            //continue the foreach loop, we don't want to set $new_content nor save.
496
-                            continue 2;
497
-                    }
498
-                    $Message_Template->set('MTP_content', $new_content);
499
-                    $Message_Template->save();
500
-                }
501
-            }
502
-            //great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
503
-            $id_type = ! empty($this->_req_data['batch_message']['id_type'])
504
-                ? $this->_req_data['batch_message']['id_type']
505
-                : 'registration';
506
-            //id_type will affect how we assemble the ids.
507
-            $ids = ! empty($this->_req_data['batch_message']['ids'])
508
-                ? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
509
-                : array();
510
-            $registrations_used_for_contact_data = array();
511
-            //using switch because eventually we'll have other contexts that will be used for generating messages.
512
-            switch ($id_type) {
513
-                case 'registration' :
514
-                    $registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
515
-                        array(
516
-                            array(
517
-                                'REG_ID' => array('IN', $ids),
518
-                            ),
519
-                        )
520
-                    );
521
-                    break;
522
-                case 'contact' :
523
-                    $registrations_used_for_contact_data = EEM_Registration::instance()
524
-                                                                           ->get_latest_registration_for_each_of_given_contacts($ids);
525
-                    break;
526
-            }
527
-            do_action(
528
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
529
-                $registrations_used_for_contact_data,
530
-                $Message_Template_Group->ID()
531
-            );
532
-            //kept for backward compat, internally we no longer use this action.
533
-            //@deprecated 4.8.36.rc.002
534
-            $contacts = $id_type === 'registration'
535
-                ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
536
-                : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
537
-            do_action(
538
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
539
-                $contacts,
540
-                $Message_Template_Group->ID()
541
-            );
542
-        }
543
-        $query_args = array(
544
-            'action' => ! empty($this->_req_data['redirect_back_to'])
545
-                ? $this->_req_data['redirect_back_to']
546
-                : 'default',
547
-        );
548
-        $this->_redirect_after_action(false, '', '', $query_args, true);
549
-    }
550
-
551
-
552
-
553
-    /**
554
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
555
-     * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
556
-     */
557
-    protected function _registration_reports_js_setup()
558
-    {
559
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
560
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
561
-    }
562
-
563
-
564
-
565
-    /**
566
-     *        generates Business Reports regarding Registrations
567
-     *
568
-     * @access protected
569
-     * @return void
570
-     */
571
-    protected function _registration_reports()
572
-    {
573
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
574
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
575
-            $template_path,
576
-            $this->_reports_template_data,
577
-            true
578
-        );
579
-        // the final template wrapper
580
-        $this->display_admin_page_with_no_sidebar();
581
-    }
582
-
583
-
584
-
585
-    /**
586
-     * Generates Business Report showing total registrations per day.
587
-     *
588
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
589
-     * @return string
590
-     */
591
-    private function _registrations_per_day_report($period = '-1 month')
592
-    {
593
-        $report_ID = 'reg-admin-registrations-per-day-report-dv';
594
-        $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
595
-        $results = (array)$results;
596
-        $regs = array();
597
-        $subtitle = '';
598
-        if ($results) {
599
-            $column_titles = array();
600
-            $tracker = 0;
601
-            foreach ($results as $result) {
602
-                $report_column_values = array();
603
-                foreach ($result as $property_name => $property_value) {
604
-                    $property_value = $property_name === 'Registration_REG_date' ? $property_value
605
-                        : (int)$property_value;
606
-                    $report_column_values[] = $property_value;
607
-                    if ($tracker === 0) {
608
-                        if ($property_name === 'Registration_REG_date') {
609
-                            $column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso');
610
-                        } else {
611
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
612
-                        }
613
-                    }
614
-                }
615
-                $tracker++;
616
-                $regs[] = $report_column_values;
617
-            }
618
-            //make sure the column_titles is pushed to the beginning of the array
619
-            array_unshift($regs, $column_titles);
620
-            //setup the date range.
621
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
622
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
623
-            $ending_date = new DateTime("now", $DateTimeZone);
624
-            $subtitle = sprintf(
625
-                _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
626
-                $beginning_date->format('Y-m-d'),
627
-                $ending_date->format('Y-m-d')
628
-            );
629
-        }
630
-        $report_title = __('Total Registrations per Day', 'event_espresso');
631
-        $report_params = array(
632
-            'title'     => $report_title,
633
-            'subtitle'  => $subtitle,
634
-            'id'        => $report_ID,
635
-            'regs'      => $regs,
636
-            'noResults' => empty($regs),
637
-            'noRegsMsg' => sprintf(
638
-                __(
639
-                    '%sThere are currently no registration records in the last month for this report.%s',
640
-                    'event_espresso'
641
-                ),
642
-                '<h2>' . $report_title . '</h2><p>',
643
-                '</p>'
644
-            ),
645
-        );
646
-        wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
647
-        return $report_ID;
648
-    }
649
-
650
-
651
-
652
-    /**
653
-     * Generates Business Report showing total registrations per event.
654
-     *
655
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
656
-     * @return string
657
-     */
658
-    private function _registrations_per_event_report($period = '-1 month')
659
-    {
660
-        $report_ID = 'reg-admin-registrations-per-event-report-dv';
661
-        $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
662
-        $results = (array)$results;
663
-        $regs = array();
664
-        $subtitle = '';
665
-        if ($results) {
666
-            $column_titles = array();
667
-            $tracker = 0;
668
-            foreach ($results as $result) {
669
-                $report_column_values = array();
670
-                foreach ($result as $property_name => $property_value) {
671
-                    $property_value = $property_name === 'Registration_Event' ? wp_trim_words(
672
-                        $property_value,
673
-                        4,
674
-                        '...'
675
-                    ) : (int)$property_value;
676
-                    $report_column_values[] = $property_value;
677
-                    if ($tracker === 0) {
678
-                        if ($property_name === 'Registration_Event') {
679
-                            $column_titles[] = __('Event', 'event_espresso');
680
-                        } else {
681
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
682
-                        }
683
-                    }
684
-                }
685
-                $tracker++;
686
-                $regs[] = $report_column_values;
687
-            }
688
-            //make sure the column_titles is pushed to the beginning of the array
689
-            array_unshift($regs, $column_titles);
690
-            //setup the date range.
691
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
692
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
693
-            $ending_date = new DateTime("now", $DateTimeZone);
694
-            $subtitle = sprintf(
695
-                _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
696
-                $beginning_date->format('Y-m-d'),
697
-                $ending_date->format('Y-m-d')
698
-            );
699
-        }
700
-        $report_title = __('Total Registrations per Event', 'event_espresso');
701
-        $report_params = array(
702
-            'title'     => $report_title,
703
-            'subtitle'  => $subtitle,
704
-            'id'        => $report_ID,
705
-            'regs'      => $regs,
706
-            'noResults' => empty($regs),
707
-            'noRegsMsg' => sprintf(
708
-                __(
709
-                    '%sThere are currently no registration records in the last month for this report.%s',
710
-                    'event_espresso'
711
-                ),
712
-                '<h2>' . $report_title . '</h2><p>',
713
-                '</p>'
714
-            ),
715
-        );
716
-        wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
717
-        return $report_ID;
718
-    }
719
-
720
-
721
-
722
-    /**
723
-     * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
724
-     *
725
-     * @access protected
726
-     * @return void
727
-     * @throws \EE_Error
728
-     */
729
-    protected function _registration_checkin_list_table()
730
-    {
731
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
732
-        $reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null;
733
-        /** @var EE_Registration $reg */
734
-        $reg = EEM_Registration::instance()->get_one_by_ID($reg_id);
735
-        $this->_admin_page_title .= $this->get_action_link_or_button(
736
-            'new_registration',
737
-            'add-registrant',
738
-            array('event_id' => $reg->event_ID()),
739
-            'add-new-h2'
740
-        );
741
-        $legend_items = array(
742
-            'checkin'  => array(
743
-                'class' => 'ee-icon ee-icon-check-in',
744
-                'desc'  => __('This indicates the attendee has been checked in', 'event_espresso'),
745
-            ),
746
-            'checkout' => array(
747
-                'class' => 'ee-icon ee-icon-check-out',
748
-                'desc'  => __('This indicates the attendee has been checked out', 'event_espresso'),
749
-            ),
750
-        );
751
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
752
-        $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
753
-        $go_back_url = ! empty($reg_id) ? EE_Admin_Page::add_query_args_and_nonce(
754
-            array(
755
-                'action'   => 'event_registrations',
756
-                'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID(),
757
-                'DTT_ID'   => $dtt_id,
758
-            ),
759
-            $this->_admin_base_url
760
-        ) : '';
761
-        $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
762
-            ? '<h2>' . sprintf(
763
-                __("%s's check in records for %s at the event, %s", 'event_espresso'),
764
-                '<span id="checkin-attendee-name">'
765
-                . EEM_Registration::instance()
766
-                                  ->get_one_by_ID($reg_id)
767
-                                  ->get_first_related('Attendee')
768
-                                  ->full_name() . '</span>',
769
-                '<span id="checkin-dtt"><a href="' . $go_back_url . '">'
770
-                . EEM_Datetime::instance()
771
-                              ->get_one_by_ID($dtt_id)
772
-                              ->start_date_and_time() . ' - '
773
-                . EEM_Datetime::instance()
774
-                              ->get_one_by_ID($dtt_id)
775
-                              ->end_date_and_time() . '</a></span>',
776
-                '<span id="checkin-event-name">'
777
-                . EEM_Datetime::instance()
778
-                              ->get_one_by_ID($dtt_id)
779
-                              ->get_first_related('Event')
780
-                              ->get('EVT_name') . '</span>'
781
-            ) . '</h2>'
782
-            : '';
783
-        $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
784
-            ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : '';
785
-        $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
786
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
787
-        $this->display_admin_list_table_page_with_no_sidebar();
788
-    }
789
-
790
-
791
-
792
-    /**
793
-     * toggle the Check-in status for the given registration (coming from ajax)
794
-     *
795
-     * @return void (JSON)
796
-     */
797
-    public function toggle_checkin_status()
798
-    {
799
-        //first make sure we have the necessary data
800
-        if ( ! isset($this->_req_data['_regid'])) {
801
-            EE_Error::add_error(
802
-                __(
803
-                    'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
804
-                    'event_espresso'
805
-                ),
806
-                __FILE__,
807
-                __FUNCTION__,
808
-                __LINE__
809
-            );
810
-            $this->_template_args['success'] = false;
811
-            $this->_template_args['error'] = true;
812
-            $this->_return_json();
813
-        };
814
-        //do a nonce check cause we're not coming in from an normal route here.
815
-        $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
816
-            : '';
817
-        $nonce_ref = 'checkin_nonce';
818
-        $this->_verify_nonce($nonce, $nonce_ref);
819
-        //beautiful! Made it this far so let's get the status.
820
-        $new_status = $this->_toggle_checkin_status();
821
-        //setup new class to return via ajax
822
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-'
823
-                                                      . $new_status;
824
-        $this->_template_args['success'] = true;
825
-        $this->_return_json();
826
-    }
827
-
828
-
829
-
830
-    /**
831
-     * handles toggling the checkin status for the registration,
832
-     *
833
-     * @access protected
834
-     * @return int|void
835
-     */
836
-    protected function _toggle_checkin_status()
837
-    {
838
-        //first let's get the query args out of the way for the redirect
839
-        $query_args = array(
840
-            'action'   => 'event_registrations',
841
-            'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
842
-            'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
843
-        );
844
-        $new_status = false;
845
-        // bulk action check in toggle
846
-        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
847
-            // cycle thru checkboxes
848
-            while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
849
-                $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
850
-                $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
851
-            }
852
-        } elseif (isset($this->_req_data['_regid'])) {
853
-            //coming from ajax request
854
-            $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
855
-            $query_args['DTT_ID'] = $DTT_ID;
856
-            $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
857
-        } else {
858
-            EE_Error::add_error(
859
-                __('Missing some required data to toggle the Check-in', 'event_espresso'),
860
-                __FILE__,
861
-                __FUNCTION__,
862
-                __LINE__
863
-            );
864
-        }
865
-        if (defined('DOING_AJAX')) {
866
-            return $new_status;
867
-        }
868
-        $this->_redirect_after_action(false, '', '', $query_args, true);
869
-    }
870
-
871
-
872
-
873
-    /**
874
-     * This is toggles a single Check-in for the given registration and datetime.
875
-     *
876
-     * @param  int $REG_ID The registration we're toggling
877
-     * @param  int $DTT_ID The datetime we're toggling
878
-     * @return int            The new status toggled to.
879
-     * @throws \EE_Error
880
-     */
881
-    private function _toggle_checkin($REG_ID, $DTT_ID)
882
-    {
883
-        /** @var EE_Registration $REG */
884
-        $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
885
-        $new_status = $REG->toggle_checkin_status($DTT_ID);
886
-        if ($new_status !== false) {
887
-            EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
888
-        } else {
889
-            EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
890
-            $new_status = false;
891
-        }
892
-        return $new_status;
893
-    }
894
-
895
-
896
-
897
-    /**
898
-     * Takes care of deleting multiple EE_Checkin table rows
899
-     *
900
-     * @access protected
901
-     * @return void
902
-     * @throws \EE_Error
903
-     */
904
-    protected function _delete_checkin_rows()
905
-    {
906
-        $query_args = array(
907
-            'action' => 'registration_checkins',
908
-            'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
909
-            '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0,
910
-        );
911
-        $errors = 0;
912
-        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
913
-            while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
914
-                if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
915
-                    $errors++;
916
-                }
917
-            }
918
-        } else {
919
-            EE_Error::add_error(
920
-                __(
921
-                    'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
922
-                    'event_espresso'
923
-                ),
924
-                __FILE__,
925
-                __FUNCTION__,
926
-                __LINE__
927
-            );
928
-            $this->_redirect_after_action(false, '', '', $query_args, true);
929
-        }
930
-        if ($errors > 0) {
931
-            EE_Error::add_error(
932
-                sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
933
-                __FILE__,
934
-                __FUNCTION__,
935
-                __LINE__
936
-            );
937
-        } else {
938
-            EE_Error::add_success(__('Records were successfully deleted', 'event_espresso'));
939
-        }
940
-        $this->_redirect_after_action(false, '', '', $query_args, true);
941
-    }
942
-
943
-
944
-
945
-    /**
946
-     * Deletes a single EE_Checkin row
947
-     *
948
-     * @return void
949
-     * @throws \EE_Error
950
-     */
951
-    protected function _delete_checkin_row()
952
-    {
953
-        $query_args = array(
954
-            'action' => 'registration_checkins',
955
-            'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
956
-            '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0,
957
-        );
958
-        if ( ! empty($this->_req_data['CHK_ID'])) {
959
-            if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
960
-                EE_Error::add_error(
961
-                    __('Something went wrong and this check-in record was not deleted', 'event_espresso'),
962
-                    __FILE__,
963
-                    __FUNCTION__,
964
-                    __LINE__
965
-                );
966
-            } else {
967
-                EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso'));
968
-            }
969
-        } else {
970
-            EE_Error::add_error(
971
-                __(
972
-                    'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
973
-                    'event_espresso'
974
-                ),
975
-                __FILE__,
976
-                __FUNCTION__,
977
-                __LINE__
978
-            );
979
-        }
980
-        $this->_redirect_after_action(false, '', '', $query_args, true);
981
-    }
982
-
983
-
984
-
985
-    /**
986
-     *        generates HTML for the Event Registrations List Table
987
-     *
988
-     * @access protected
989
-     * @return void
990
-     * @throws \EE_Error
991
-     */
992
-    protected function _event_registrations_list_table()
993
-    {
994
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
995
-        $this->_admin_page_title .= isset($this->_req_data['event_id'])
996
-            ? $this->get_action_link_or_button(
997
-                'new_registration',
998
-                'add-registrant',
999
-                array('event_id' => $this->_req_data['event_id']),
1000
-                'add-new-h2',
1001
-                '',
1002
-                false
1003
-            )
1004
-            : '';
1005
-        $legend_items = array(
1006
-            'star-icon'        => array(
1007
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1008
-                'desc'  => __('This Registrant is the Primary Registrant', 'event_espresso'),
1009
-            ),
1010
-            'checkin'          => array(
1011
-                'class' => 'ee-icon ee-icon-check-in',
1012
-                'desc'  => __('This Registrant has been Checked In', 'event_espresso'),
1013
-            ),
1014
-            'checkout'         => array(
1015
-                'class' => 'ee-icon ee-icon-check-out',
1016
-                'desc'  => __('This Registrant has been Checked Out', 'event_espresso'),
1017
-            ),
1018
-            'nocheckinrecord'  => array(
1019
-                'class' => 'dashicons dashicons-no',
1020
-                'desc'  => __('No Check-in Record has been Created for this Registrant', 'event_espresso'),
1021
-            ),
1022
-            'view_details'     => array(
1023
-                'class' => 'dashicons dashicons-search',
1024
-                'desc'  => __('View All Check-in Records for this Registrant', 'event_espresso'),
1025
-            ),
1026
-            'approved_status'  => array(
1027
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1028
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1029
-            ),
1030
-            'cancelled_status' => array(
1031
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1032
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1033
-            ),
1034
-            'declined_status'  => array(
1035
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1036
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1037
-            ),
1038
-            'not_approved'     => array(
1039
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1040
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1041
-            ),
1042
-            'pending_status'   => array(
1043
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1044
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1045
-            ),
1046
-            'wait_list'        => array(
1047
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1048
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1049
-            ),
1050
-        );
1051
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1052
-        $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1053
-        $this->_template_args['before_list_table'] = ! empty($event_id)
1054
-            ? '<h2>' . sprintf(
1055
-                __('Viewing Registrations for Event: %s', 'event_espresso'),
1056
-                EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1057
-            ) . '</h2>'
1058
-            : '';
1059
-        //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event.
1060
-        /** @var EE_Event $event */
1061
-        $event = EEM_Event::instance()->get_one_by_ID($event_id);
1062
-        $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1063
-        $datetime = null;
1064
-        if ($event instanceof EE_Event) {
1065
-            $datetimes_on_event = $event->datetimes();
1066
-            if (count($datetimes_on_event) === 1) {
1067
-                $datetime = reset($datetimes_on_event);
1068
-            }
1069
-        }
1070
-        $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1071
-        if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1072
-            $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1073
-            $this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1074
-            $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1075
-            $this->_template_args['before_list_table'] .= $datetime->name();
1076
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1077
-            $this->_template_args['before_list_table'] .= '</span></h2>';
1078
-        }
1079
-        //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column
1080
-        //represents
1081
-        if ( ! $datetime instanceof EE_Datetime) {
1082
-            $this->_template_args['before_list_table'] .= '<br><p class="description">'
1083
-                                                          . __('In this view, the check-in status represents the latest check-in record for the registration in that row.',
1084
-                    'event_espresso')
1085
-                                                          . '</p>';
1086
-        }
1087
-        $this->display_admin_list_table_page_with_no_sidebar();
1088
-    }
1089
-
1090
-    /**
1091
-     * Download the registrations check-in report (same as the normal registration report, but with different where
1092
-     * conditions)
1093
-     *
1094
-     * @return void ends the request by a redirect or download
1095
-     */
1096
-    public function _registrations_checkin_report()
1097
-    {
1098
-        $this->_registrations_report_base('_get_checkin_query_params_from_request');
1099
-    }
1100
-
1101
-    /**
1102
-     * Gets the query params from the request, plus adds a where condition for the registration status,
1103
-     * because on the checkin page we only ever want to see approved and pending-approval registrations
1104
-     *
1105
-     * @param array     $request
1106
-     * @param int  $per_page
1107
-     * @param bool $count
1108
-     * @return array
1109
-     */
1110
-    protected function _get_checkin_query_params_from_request(
1111
-        $request,
1112
-        $per_page = 10,
1113
-        $count = false
1114
-    ) {
1115
-        $query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1116
-        //unlike the regular registrations list table,
1117
-        $status_ids_array = apply_filters(
1118
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1119
-            array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1120
-        );
1121
-        $query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1122
-        return $query_params;
1123
-    }
1124
-
1125
-
1126
-
1127
-
1128
-    /**
1129
-     * Gets registrations for an event
1130
-     *
1131
-     * @param int    $per_page
1132
-     * @param bool   $count whether to return count or data.
1133
-     * @param bool   $trash
1134
-     * @param string $orderby
1135
-     * @return EE_Registration[]|int
1136
-     * @throws \EE_Error
1137
-     */
1138
-    public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1139
-    {
1140
-        //normalize some request params that get setup by the parent `get_registrations` method.
1141
-        $request = $this->_req_data;
1142
-        $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1143
-        $request['order'] =  ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1144
-        if($trash){
1145
-            $request['status'] = 'trash';
1146
-        }
1147
-        $query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count );
1148
-        /**
1149
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1150
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1151
-         * @see EEM_Base::get_all()
1152
-         */
1153
-        $query_params['group_by'] = '';
1154
-
1155
-        return $count
1156
-            ? EEM_Registration::instance()->count($query_params)
1157
-            /** @type EE_Registration[] */
1158
-            : EEM_Registration::instance()->get_all($query_params);
1159
-    }
20
+	/**
21
+	 * This is used to hold the reports template data which is setup early in the request.
22
+	 *
23
+	 * @type array
24
+	 */
25
+	protected $_reports_template_data = array();
26
+
27
+
28
+
29
+	/**
30
+	 * Extend_Registrations_Admin_Page constructor.
31
+	 *
32
+	 * @param bool $routing
33
+	 */
34
+	public function __construct($routing = true)
35
+	{
36
+		parent::__construct($routing);
37
+		if ( ! defined('REG_CAF_TEMPLATE_PATH')) {
38
+			define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
39
+			define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
40
+			define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
41
+		}
42
+	}
43
+
44
+
45
+
46
+	protected function _extend_page_config()
47
+	{
48
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50
+			? $this->_req_data['_REG_ID']
51
+			: 0;
52
+		// $att_id = ! empty( $this->_req_data['ATT_ID'] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0;
53
+		// $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] )
54
+		// 	? $this->_req_data['post'] : $att_id;
55
+		$new_page_routes = array(
56
+			'reports'                  => array(
57
+				'func'       => '_registration_reports',
58
+				'capability' => 'ee_read_registrations',
59
+			),
60
+			'registration_checkins'    => array(
61
+				'func'       => '_registration_checkin_list_table',
62
+				'capability' => 'ee_read_checkins',
63
+			),
64
+			'newsletter_selected_send' => array(
65
+				'func'       => '_newsletter_selected_send',
66
+				'noheader'   => true,
67
+				'capability' => 'ee_send_message',
68
+			),
69
+			'delete_checkin_rows'      => array(
70
+				'func'       => '_delete_checkin_rows',
71
+				'noheader'   => true,
72
+				'capability' => 'ee_delete_checkins',
73
+			),
74
+			'delete_checkin_row'       => array(
75
+				'func'       => '_delete_checkin_row',
76
+				'noheader'   => true,
77
+				'capability' => 'ee_delete_checkin',
78
+				'obj_id'     => $reg_id,
79
+			),
80
+			'toggle_checkin_status'    => array(
81
+				'func'       => '_toggle_checkin_status',
82
+				'noheader'   => true,
83
+				'capability' => 'ee_edit_checkin',
84
+				'obj_id'     => $reg_id,
85
+			),
86
+			'event_registrations'      => array(
87
+				'func'       => '_event_registrations_list_table',
88
+				'capability' => 'ee_read_checkins',
89
+			),
90
+			'registrations_checkin_report' => array(
91
+				'func'       => '_registrations_checkin_report',
92
+				'noheader'   => true,
93
+				'capability' => 'ee_read_registrations',
94
+			),
95
+		);
96
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
97
+		$new_page_config = array(
98
+			'reports'               => array(
99
+				'nav'           => array(
100
+					'label' => __('Reports', 'event_espresso'),
101
+					'order' => 30,
102
+				),
103
+				'help_tabs'     => array(
104
+					'registrations_reports_help_tab' => array(
105
+						'title'    => __('Registration Reports', 'event_espresso'),
106
+						'filename' => 'registrations_reports',
107
+					),
108
+				),
109
+				/*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/
110
+				'require_nonce' => false,
111
+			),
112
+			'event_registrations'   => array(
113
+				'nav'           => array(
114
+					'label'      => __('Event Check-In', 'event_espresso'),
115
+					'order'      => 10,
116
+					'persistent' => true,
117
+				),
118
+				'help_tabs'     => array(
119
+					'registrations_event_checkin_help_tab'                       => array(
120
+						'title'    => __('Registrations Event Check-In', 'event_espresso'),
121
+						'filename' => 'registrations_event_checkin',
122
+					),
123
+					'registrations_event_checkin_table_column_headings_help_tab' => array(
124
+						'title'    => __('Event Check-In Table Column Headings', 'event_espresso'),
125
+						'filename' => 'registrations_event_checkin_table_column_headings',
126
+					),
127
+					'registrations_event_checkin_filters_help_tab'               => array(
128
+						'title'    => __('Event Check-In Filters', 'event_espresso'),
129
+						'filename' => 'registrations_event_checkin_filters',
130
+					),
131
+					'registrations_event_checkin_views_help_tab'                 => array(
132
+						'title'    => __('Event Check-In Views', 'event_espresso'),
133
+						'filename' => 'registrations_event_checkin_views',
134
+					),
135
+					'registrations_event_checkin_other_help_tab'                 => array(
136
+						'title'    => __('Event Check-In Other', 'event_espresso'),
137
+						'filename' => 'registrations_event_checkin_other',
138
+					),
139
+				),
140
+				'help_tour'     => array('Event_Checkin_Help_Tour'),
141
+				'qtips'         => array('Registration_List_Table_Tips'),
142
+				'list_table'    => 'EE_Event_Registrations_List_Table',
143
+				'metaboxes'     => array(),
144
+				'require_nonce' => false,
145
+			),
146
+			'registration_checkins' => array(
147
+				'nav'           => array(
148
+					'label'      => __('Check-In Records', 'event_espresso'),
149
+					'order'      => 15,
150
+					'persistent' => false,
151
+				),
152
+				'list_table'    => 'EE_Registration_CheckIn_List_Table',
153
+				//'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ),
154
+				'metaboxes'     => array(),
155
+				'require_nonce' => false,
156
+			),
157
+		);
158
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
159
+		$this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
160
+		$this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
161
+	}
162
+
163
+
164
+
165
+	protected function _ajax_hooks()
166
+	{
167
+		parent::_ajax_hooks();
168
+		add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
169
+	}
170
+
171
+
172
+
173
+	public function load_scripts_styles()
174
+	{
175
+		parent::load_scripts_styles();
176
+		//if newsletter message type is active then let's add filter and load js for it.
177
+		if (EEH_MSG_Template::is_mt_active('newsletter')) {
178
+			//enqueue newsletter js
179
+			wp_enqueue_script(
180
+				'ee-newsletter-trigger',
181
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
182
+				array('ee-dialog'),
183
+				EVENT_ESPRESSO_VERSION,
184
+				true
185
+			);
186
+			wp_enqueue_style(
187
+				'ee-newsletter-trigger-css',
188
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
189
+				array(),
190
+				EVENT_ESPRESSO_VERSION
191
+			);
192
+			//hook in buttons for newsletter message type trigger.
193
+			add_action(
194
+				'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
195
+				array($this, 'add_newsletter_action_buttons'),
196
+				10
197
+			);
198
+		}
199
+	}
200
+
201
+
202
+
203
+	public function load_scripts_styles_reports()
204
+	{
205
+		wp_register_script(
206
+			'ee-reg-reports-js',
207
+			REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
208
+			array('google-charts'),
209
+			EVENT_ESPRESSO_VERSION,
210
+			true
211
+		);
212
+		wp_enqueue_script('ee-reg-reports-js');
213
+		$this->_registration_reports_js_setup();
214
+	}
215
+
216
+
217
+
218
+	protected function _add_screen_options_event_registrations()
219
+	{
220
+		$this->_per_page_screen_option();
221
+	}
222
+
223
+
224
+
225
+	protected function _add_screen_options_registration_checkins()
226
+	{
227
+		$page_title = $this->_admin_page_title;
228
+		$this->_admin_page_title = __('Check-In Records', 'event_espresso');
229
+		$this->_per_page_screen_option();
230
+		$this->_admin_page_title = $page_title;
231
+	}
232
+
233
+
234
+
235
+	protected function _set_list_table_views_event_registrations()
236
+	{
237
+		$this->_views = array(
238
+			'all' => array(
239
+				'slug'        => 'all',
240
+				'label'       => __('All', 'event_espresso'),
241
+				'count'       => 0,
242
+				'bulk_action' => ! isset($this->_req_data['event_id'])
243
+					? array()
244
+					: array(
245
+						'toggle_checkin_status' => __('Toggle Check-In', 'event_espresso'),
246
+						//'trash_registrations' => __('Trash Registrations', 'event_espresso')
247
+					),
248
+			),
249
+		);
250
+	}
251
+
252
+
253
+
254
+	protected function _set_list_table_views_registration_checkins()
255
+	{
256
+		$this->_views = array(
257
+			'all' => array(
258
+				'slug'        => 'all',
259
+				'label'       => __('All', 'event_espresso'),
260
+				'count'       => 0,
261
+				'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')),
262
+			),
263
+		);
264
+	}
265
+
266
+
267
+
268
+	/**
269
+	 * callback for ajax action.
270
+	 *
271
+	 * @since 4.3.0
272
+	 * @return void (JSON)
273
+	 * @throws \EE_Error
274
+	 */
275
+	public function get_newsletter_form_content()
276
+	{
277
+		//do a nonce check cause we're not coming in from an normal route here.
278
+		$nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
279
+			$this->_req_data['get_newsletter_form_content_nonce']
280
+		) : '';
281
+		$nonce_ref = 'get_newsletter_form_content_nonce';
282
+		$this->_verify_nonce($nonce, $nonce_ref);
283
+		//let's get the mtp for the incoming MTP_ ID
284
+		if ( ! isset($this->_req_data['GRP_ID'])) {
285
+			EE_Error::add_error(
286
+				__(
287
+					'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
288
+					'event_espresso'
289
+				),
290
+				__FILE__,
291
+				__FUNCTION__,
292
+				__LINE__
293
+			);
294
+			$this->_template_args['success'] = false;
295
+			$this->_template_args['error'] = true;
296
+			$this->_return_json();
297
+		}
298
+		$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
299
+		if ( ! $MTPG instanceof EE_Message_Template_Group) {
300
+			EE_Error::add_error(
301
+				sprintf(
302
+					__(
303
+						'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
304
+						'event_espresso'
305
+					),
306
+					$this->_req_data['GRP_ID']
307
+				),
308
+				__FILE__,
309
+				__FUNCTION__,
310
+				__LINE__
311
+			);
312
+			$this->_template_args['success'] = false;
313
+			$this->_template_args['error'] = true;
314
+			$this->_return_json();
315
+		}
316
+		$MTPs = $MTPG->context_templates();
317
+		$MTPs = $MTPs['attendee'];
318
+		$template_fields = array();
319
+		/** @var EE_Message_Template $MTP */
320
+		foreach ($MTPs as $MTP) {
321
+			$field = $MTP->get('MTP_template_field');
322
+			if ($field === 'content') {
323
+				$content = $MTP->get('MTP_content');
324
+				if ( ! empty($content['newsletter_content'])) {
325
+					$template_fields['newsletter_content'] = $content['newsletter_content'];
326
+				}
327
+				continue;
328
+			}
329
+			$template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content');
330
+		}
331
+		$this->_template_args['success'] = true;
332
+		$this->_template_args['error'] = false;
333
+		$this->_template_args['data'] = array(
334
+			'batch_message_from'    => isset($template_fields['from'])
335
+				? $template_fields['from']
336
+				: '',
337
+			'batch_message_subject' => isset($template_fields['subject'])
338
+				? $template_fields['subject']
339
+				: '',
340
+			'batch_message_content' => isset($template_fields['newsletter_content'])
341
+				? $template_fields['newsletter_content']
342
+				: '',
343
+		);
344
+		$this->_return_json();
345
+	}
346
+
347
+
348
+
349
+	/**
350
+	 * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
351
+	 *
352
+	 * @since 4.3.0
353
+	 * @param EE_Admin_List_Table $list_table
354
+	 * @return void
355
+	 */
356
+	public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
357
+	{
358
+		if ( ! EE_Registry::instance()->CAP->current_user_can(
359
+			'ee_send_message',
360
+			'espresso_registrations_newsletter_selected_send'
361
+		)
362
+		) {
363
+			return;
364
+		}
365
+		$routes_to_add_to = array(
366
+			'contact_list',
367
+			'event_registrations',
368
+			'default',
369
+		);
370
+		if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
371
+			if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
372
+				|| (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
373
+			) {
374
+				echo '';
375
+			} else {
376
+				$button_text = sprintf(
377
+					__('Send Batch Message (%s selected)', 'event_espresso'),
378
+					'<span class="send-selected-newsletter-count">0</span>'
379
+				);
380
+				echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>'
381
+					 . $button_text
382
+					 . '</button>';
383
+				add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
384
+			}
385
+		}
386
+	}
387
+
388
+
389
+
390
+	public function newsletter_send_form_skeleton()
391
+	{
392
+		$list_table = $this->_list_table_object;
393
+		$codes = array();
394
+		//need to templates for the newsletter message type for the template selector.
395
+		$values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0);
396
+		$mtps = EEM_Message_Template_Group::instance()->get_all(
397
+			array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
398
+		);
399
+		foreach ($mtps as $mtp) {
400
+			$name = $mtp->name();
401
+			$values[] = array(
402
+				'text' => empty($name) ? __('Global', 'event_espresso') : $name,
403
+				'id'   => $mtp->ID(),
404
+			);
405
+		}
406
+		//need to get a list of shortcodes that are available for the newsletter message type.
407
+		$shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', false);
408
+		foreach ($shortcodes as $field => $shortcode_array) {
409
+			$codes[$field] = implode(', ', array_keys($shortcode_array));
410
+		}
411
+		$shortcodes = $codes;
412
+		$form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
413
+		$form_template_args = array(
414
+			'form_action'       => admin_url('admin.php?page=espresso_registrations'),
415
+			'form_route'        => 'newsletter_selected_send',
416
+			'form_nonce_name'   => 'newsletter_selected_send_nonce',
417
+			'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
418
+			'redirect_back_to'  => $this->_req_action,
419
+			'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
420
+			'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
421
+			'shortcodes'        => $shortcodes,
422
+			'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
423
+		);
424
+		EEH_Template::display_template($form_template, $form_template_args);
425
+	}
426
+
427
+
428
+
429
+	/**
430
+	 * Handles sending selected registrations/contacts a newsletter.
431
+	 *
432
+	 * @since  4.3.0
433
+	 * @return void
434
+	 * @throws \EE_Error
435
+	 */
436
+	protected function _newsletter_selected_send()
437
+	{
438
+		$success = true;
439
+		//first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
440
+		if (empty($this->_req_data['newsletter_mtp_selected'])) {
441
+			EE_Error::add_error(
442
+				__(
443
+					'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
444
+					'event_espresso'
445
+				),
446
+				__FILE__,
447
+				__FUNCTION__,
448
+				__LINE__
449
+			);
450
+			$success = false;
451
+		}
452
+		if ($success) {
453
+			//update Message template in case there are any changes
454
+			$Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
455
+				$this->_req_data['newsletter_mtp_selected']
456
+			);
457
+			$Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
458
+				? $Message_Template_Group->context_templates()
459
+				: array();
460
+			if (empty($Message_Templates)) {
461
+				EE_Error::add_error(
462
+					__(
463
+						'Unable to retrieve message template fields from the db. Messages not sent.',
464
+						'event_espresso'
465
+					),
466
+					__FILE__,
467
+					__FUNCTION__,
468
+					__LINE__
469
+				);
470
+			}
471
+			//let's just update the specific fields
472
+			foreach ($Message_Templates['attendee'] as $Message_Template) {
473
+				if ($Message_Template instanceof EE_Message_Template) {
474
+					$field = $Message_Template->get('MTP_template_field');
475
+					$content = $Message_Template->get('MTP_content');
476
+					$new_content = $content;
477
+					switch ($field) {
478
+						case 'from' :
479
+							$new_content = ! empty($this->_req_data['batch_message']['from'])
480
+								? $this->_req_data['batch_message']['from']
481
+								: $content;
482
+							break;
483
+						case 'subject' :
484
+							$new_content = ! empty($this->_req_data['batch_message']['subject'])
485
+								? $this->_req_data['batch_message']['subject']
486
+								: $content;
487
+							break;
488
+						case 'content' :
489
+							$new_content = $content;
490
+							$new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
491
+								? $this->_req_data['batch_message']['content']
492
+								: $content['newsletter_content'];
493
+							break;
494
+						default :
495
+							//continue the foreach loop, we don't want to set $new_content nor save.
496
+							continue 2;
497
+					}
498
+					$Message_Template->set('MTP_content', $new_content);
499
+					$Message_Template->save();
500
+				}
501
+			}
502
+			//great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
503
+			$id_type = ! empty($this->_req_data['batch_message']['id_type'])
504
+				? $this->_req_data['batch_message']['id_type']
505
+				: 'registration';
506
+			//id_type will affect how we assemble the ids.
507
+			$ids = ! empty($this->_req_data['batch_message']['ids'])
508
+				? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
509
+				: array();
510
+			$registrations_used_for_contact_data = array();
511
+			//using switch because eventually we'll have other contexts that will be used for generating messages.
512
+			switch ($id_type) {
513
+				case 'registration' :
514
+					$registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
515
+						array(
516
+							array(
517
+								'REG_ID' => array('IN', $ids),
518
+							),
519
+						)
520
+					);
521
+					break;
522
+				case 'contact' :
523
+					$registrations_used_for_contact_data = EEM_Registration::instance()
524
+																		   ->get_latest_registration_for_each_of_given_contacts($ids);
525
+					break;
526
+			}
527
+			do_action(
528
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
529
+				$registrations_used_for_contact_data,
530
+				$Message_Template_Group->ID()
531
+			);
532
+			//kept for backward compat, internally we no longer use this action.
533
+			//@deprecated 4.8.36.rc.002
534
+			$contacts = $id_type === 'registration'
535
+				? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
536
+				: EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
537
+			do_action(
538
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
539
+				$contacts,
540
+				$Message_Template_Group->ID()
541
+			);
542
+		}
543
+		$query_args = array(
544
+			'action' => ! empty($this->_req_data['redirect_back_to'])
545
+				? $this->_req_data['redirect_back_to']
546
+				: 'default',
547
+		);
548
+		$this->_redirect_after_action(false, '', '', $query_args, true);
549
+	}
550
+
551
+
552
+
553
+	/**
554
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
555
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
556
+	 */
557
+	protected function _registration_reports_js_setup()
558
+	{
559
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
560
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
561
+	}
562
+
563
+
564
+
565
+	/**
566
+	 *        generates Business Reports regarding Registrations
567
+	 *
568
+	 * @access protected
569
+	 * @return void
570
+	 */
571
+	protected function _registration_reports()
572
+	{
573
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
574
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
575
+			$template_path,
576
+			$this->_reports_template_data,
577
+			true
578
+		);
579
+		// the final template wrapper
580
+		$this->display_admin_page_with_no_sidebar();
581
+	}
582
+
583
+
584
+
585
+	/**
586
+	 * Generates Business Report showing total registrations per day.
587
+	 *
588
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
589
+	 * @return string
590
+	 */
591
+	private function _registrations_per_day_report($period = '-1 month')
592
+	{
593
+		$report_ID = 'reg-admin-registrations-per-day-report-dv';
594
+		$results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
595
+		$results = (array)$results;
596
+		$regs = array();
597
+		$subtitle = '';
598
+		if ($results) {
599
+			$column_titles = array();
600
+			$tracker = 0;
601
+			foreach ($results as $result) {
602
+				$report_column_values = array();
603
+				foreach ($result as $property_name => $property_value) {
604
+					$property_value = $property_name === 'Registration_REG_date' ? $property_value
605
+						: (int)$property_value;
606
+					$report_column_values[] = $property_value;
607
+					if ($tracker === 0) {
608
+						if ($property_name === 'Registration_REG_date') {
609
+							$column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso');
610
+						} else {
611
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
612
+						}
613
+					}
614
+				}
615
+				$tracker++;
616
+				$regs[] = $report_column_values;
617
+			}
618
+			//make sure the column_titles is pushed to the beginning of the array
619
+			array_unshift($regs, $column_titles);
620
+			//setup the date range.
621
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
622
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
623
+			$ending_date = new DateTime("now", $DateTimeZone);
624
+			$subtitle = sprintf(
625
+				_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
626
+				$beginning_date->format('Y-m-d'),
627
+				$ending_date->format('Y-m-d')
628
+			);
629
+		}
630
+		$report_title = __('Total Registrations per Day', 'event_espresso');
631
+		$report_params = array(
632
+			'title'     => $report_title,
633
+			'subtitle'  => $subtitle,
634
+			'id'        => $report_ID,
635
+			'regs'      => $regs,
636
+			'noResults' => empty($regs),
637
+			'noRegsMsg' => sprintf(
638
+				__(
639
+					'%sThere are currently no registration records in the last month for this report.%s',
640
+					'event_espresso'
641
+				),
642
+				'<h2>' . $report_title . '</h2><p>',
643
+				'</p>'
644
+			),
645
+		);
646
+		wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
647
+		return $report_ID;
648
+	}
649
+
650
+
651
+
652
+	/**
653
+	 * Generates Business Report showing total registrations per event.
654
+	 *
655
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
656
+	 * @return string
657
+	 */
658
+	private function _registrations_per_event_report($period = '-1 month')
659
+	{
660
+		$report_ID = 'reg-admin-registrations-per-event-report-dv';
661
+		$results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
662
+		$results = (array)$results;
663
+		$regs = array();
664
+		$subtitle = '';
665
+		if ($results) {
666
+			$column_titles = array();
667
+			$tracker = 0;
668
+			foreach ($results as $result) {
669
+				$report_column_values = array();
670
+				foreach ($result as $property_name => $property_value) {
671
+					$property_value = $property_name === 'Registration_Event' ? wp_trim_words(
672
+						$property_value,
673
+						4,
674
+						'...'
675
+					) : (int)$property_value;
676
+					$report_column_values[] = $property_value;
677
+					if ($tracker === 0) {
678
+						if ($property_name === 'Registration_Event') {
679
+							$column_titles[] = __('Event', 'event_espresso');
680
+						} else {
681
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
682
+						}
683
+					}
684
+				}
685
+				$tracker++;
686
+				$regs[] = $report_column_values;
687
+			}
688
+			//make sure the column_titles is pushed to the beginning of the array
689
+			array_unshift($regs, $column_titles);
690
+			//setup the date range.
691
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
692
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
693
+			$ending_date = new DateTime("now", $DateTimeZone);
694
+			$subtitle = sprintf(
695
+				_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
696
+				$beginning_date->format('Y-m-d'),
697
+				$ending_date->format('Y-m-d')
698
+			);
699
+		}
700
+		$report_title = __('Total Registrations per Event', 'event_espresso');
701
+		$report_params = array(
702
+			'title'     => $report_title,
703
+			'subtitle'  => $subtitle,
704
+			'id'        => $report_ID,
705
+			'regs'      => $regs,
706
+			'noResults' => empty($regs),
707
+			'noRegsMsg' => sprintf(
708
+				__(
709
+					'%sThere are currently no registration records in the last month for this report.%s',
710
+					'event_espresso'
711
+				),
712
+				'<h2>' . $report_title . '</h2><p>',
713
+				'</p>'
714
+			),
715
+		);
716
+		wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
717
+		return $report_ID;
718
+	}
719
+
720
+
721
+
722
+	/**
723
+	 * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
724
+	 *
725
+	 * @access protected
726
+	 * @return void
727
+	 * @throws \EE_Error
728
+	 */
729
+	protected function _registration_checkin_list_table()
730
+	{
731
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
732
+		$reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null;
733
+		/** @var EE_Registration $reg */
734
+		$reg = EEM_Registration::instance()->get_one_by_ID($reg_id);
735
+		$this->_admin_page_title .= $this->get_action_link_or_button(
736
+			'new_registration',
737
+			'add-registrant',
738
+			array('event_id' => $reg->event_ID()),
739
+			'add-new-h2'
740
+		);
741
+		$legend_items = array(
742
+			'checkin'  => array(
743
+				'class' => 'ee-icon ee-icon-check-in',
744
+				'desc'  => __('This indicates the attendee has been checked in', 'event_espresso'),
745
+			),
746
+			'checkout' => array(
747
+				'class' => 'ee-icon ee-icon-check-out',
748
+				'desc'  => __('This indicates the attendee has been checked out', 'event_espresso'),
749
+			),
750
+		);
751
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
752
+		$dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
753
+		$go_back_url = ! empty($reg_id) ? EE_Admin_Page::add_query_args_and_nonce(
754
+			array(
755
+				'action'   => 'event_registrations',
756
+				'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID(),
757
+				'DTT_ID'   => $dtt_id,
758
+			),
759
+			$this->_admin_base_url
760
+		) : '';
761
+		$this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
762
+			? '<h2>' . sprintf(
763
+				__("%s's check in records for %s at the event, %s", 'event_espresso'),
764
+				'<span id="checkin-attendee-name">'
765
+				. EEM_Registration::instance()
766
+								  ->get_one_by_ID($reg_id)
767
+								  ->get_first_related('Attendee')
768
+								  ->full_name() . '</span>',
769
+				'<span id="checkin-dtt"><a href="' . $go_back_url . '">'
770
+				. EEM_Datetime::instance()
771
+							  ->get_one_by_ID($dtt_id)
772
+							  ->start_date_and_time() . ' - '
773
+				. EEM_Datetime::instance()
774
+							  ->get_one_by_ID($dtt_id)
775
+							  ->end_date_and_time() . '</a></span>',
776
+				'<span id="checkin-event-name">'
777
+				. EEM_Datetime::instance()
778
+							  ->get_one_by_ID($dtt_id)
779
+							  ->get_first_related('Event')
780
+							  ->get('EVT_name') . '</span>'
781
+			) . '</h2>'
782
+			: '';
783
+		$this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
784
+			? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : '';
785
+		$this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
786
+			? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
787
+		$this->display_admin_list_table_page_with_no_sidebar();
788
+	}
789
+
790
+
791
+
792
+	/**
793
+	 * toggle the Check-in status for the given registration (coming from ajax)
794
+	 *
795
+	 * @return void (JSON)
796
+	 */
797
+	public function toggle_checkin_status()
798
+	{
799
+		//first make sure we have the necessary data
800
+		if ( ! isset($this->_req_data['_regid'])) {
801
+			EE_Error::add_error(
802
+				__(
803
+					'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
804
+					'event_espresso'
805
+				),
806
+				__FILE__,
807
+				__FUNCTION__,
808
+				__LINE__
809
+			);
810
+			$this->_template_args['success'] = false;
811
+			$this->_template_args['error'] = true;
812
+			$this->_return_json();
813
+		};
814
+		//do a nonce check cause we're not coming in from an normal route here.
815
+		$nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
816
+			: '';
817
+		$nonce_ref = 'checkin_nonce';
818
+		$this->_verify_nonce($nonce, $nonce_ref);
819
+		//beautiful! Made it this far so let's get the status.
820
+		$new_status = $this->_toggle_checkin_status();
821
+		//setup new class to return via ajax
822
+		$this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-'
823
+													  . $new_status;
824
+		$this->_template_args['success'] = true;
825
+		$this->_return_json();
826
+	}
827
+
828
+
829
+
830
+	/**
831
+	 * handles toggling the checkin status for the registration,
832
+	 *
833
+	 * @access protected
834
+	 * @return int|void
835
+	 */
836
+	protected function _toggle_checkin_status()
837
+	{
838
+		//first let's get the query args out of the way for the redirect
839
+		$query_args = array(
840
+			'action'   => 'event_registrations',
841
+			'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
842
+			'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
843
+		);
844
+		$new_status = false;
845
+		// bulk action check in toggle
846
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
847
+			// cycle thru checkboxes
848
+			while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
849
+				$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
850
+				$new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
851
+			}
852
+		} elseif (isset($this->_req_data['_regid'])) {
853
+			//coming from ajax request
854
+			$DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
855
+			$query_args['DTT_ID'] = $DTT_ID;
856
+			$new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
857
+		} else {
858
+			EE_Error::add_error(
859
+				__('Missing some required data to toggle the Check-in', 'event_espresso'),
860
+				__FILE__,
861
+				__FUNCTION__,
862
+				__LINE__
863
+			);
864
+		}
865
+		if (defined('DOING_AJAX')) {
866
+			return $new_status;
867
+		}
868
+		$this->_redirect_after_action(false, '', '', $query_args, true);
869
+	}
870
+
871
+
872
+
873
+	/**
874
+	 * This is toggles a single Check-in for the given registration and datetime.
875
+	 *
876
+	 * @param  int $REG_ID The registration we're toggling
877
+	 * @param  int $DTT_ID The datetime we're toggling
878
+	 * @return int            The new status toggled to.
879
+	 * @throws \EE_Error
880
+	 */
881
+	private function _toggle_checkin($REG_ID, $DTT_ID)
882
+	{
883
+		/** @var EE_Registration $REG */
884
+		$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
885
+		$new_status = $REG->toggle_checkin_status($DTT_ID);
886
+		if ($new_status !== false) {
887
+			EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
888
+		} else {
889
+			EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
890
+			$new_status = false;
891
+		}
892
+		return $new_status;
893
+	}
894
+
895
+
896
+
897
+	/**
898
+	 * Takes care of deleting multiple EE_Checkin table rows
899
+	 *
900
+	 * @access protected
901
+	 * @return void
902
+	 * @throws \EE_Error
903
+	 */
904
+	protected function _delete_checkin_rows()
905
+	{
906
+		$query_args = array(
907
+			'action' => 'registration_checkins',
908
+			'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
909
+			'_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0,
910
+		);
911
+		$errors = 0;
912
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
913
+			while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
914
+				if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
915
+					$errors++;
916
+				}
917
+			}
918
+		} else {
919
+			EE_Error::add_error(
920
+				__(
921
+					'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
922
+					'event_espresso'
923
+				),
924
+				__FILE__,
925
+				__FUNCTION__,
926
+				__LINE__
927
+			);
928
+			$this->_redirect_after_action(false, '', '', $query_args, true);
929
+		}
930
+		if ($errors > 0) {
931
+			EE_Error::add_error(
932
+				sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
933
+				__FILE__,
934
+				__FUNCTION__,
935
+				__LINE__
936
+			);
937
+		} else {
938
+			EE_Error::add_success(__('Records were successfully deleted', 'event_espresso'));
939
+		}
940
+		$this->_redirect_after_action(false, '', '', $query_args, true);
941
+	}
942
+
943
+
944
+
945
+	/**
946
+	 * Deletes a single EE_Checkin row
947
+	 *
948
+	 * @return void
949
+	 * @throws \EE_Error
950
+	 */
951
+	protected function _delete_checkin_row()
952
+	{
953
+		$query_args = array(
954
+			'action' => 'registration_checkins',
955
+			'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
956
+			'_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0,
957
+		);
958
+		if ( ! empty($this->_req_data['CHK_ID'])) {
959
+			if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
960
+				EE_Error::add_error(
961
+					__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
962
+					__FILE__,
963
+					__FUNCTION__,
964
+					__LINE__
965
+				);
966
+			} else {
967
+				EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso'));
968
+			}
969
+		} else {
970
+			EE_Error::add_error(
971
+				__(
972
+					'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
973
+					'event_espresso'
974
+				),
975
+				__FILE__,
976
+				__FUNCTION__,
977
+				__LINE__
978
+			);
979
+		}
980
+		$this->_redirect_after_action(false, '', '', $query_args, true);
981
+	}
982
+
983
+
984
+
985
+	/**
986
+	 *        generates HTML for the Event Registrations List Table
987
+	 *
988
+	 * @access protected
989
+	 * @return void
990
+	 * @throws \EE_Error
991
+	 */
992
+	protected function _event_registrations_list_table()
993
+	{
994
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
995
+		$this->_admin_page_title .= isset($this->_req_data['event_id'])
996
+			? $this->get_action_link_or_button(
997
+				'new_registration',
998
+				'add-registrant',
999
+				array('event_id' => $this->_req_data['event_id']),
1000
+				'add-new-h2',
1001
+				'',
1002
+				false
1003
+			)
1004
+			: '';
1005
+		$legend_items = array(
1006
+			'star-icon'        => array(
1007
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1008
+				'desc'  => __('This Registrant is the Primary Registrant', 'event_espresso'),
1009
+			),
1010
+			'checkin'          => array(
1011
+				'class' => 'ee-icon ee-icon-check-in',
1012
+				'desc'  => __('This Registrant has been Checked In', 'event_espresso'),
1013
+			),
1014
+			'checkout'         => array(
1015
+				'class' => 'ee-icon ee-icon-check-out',
1016
+				'desc'  => __('This Registrant has been Checked Out', 'event_espresso'),
1017
+			),
1018
+			'nocheckinrecord'  => array(
1019
+				'class' => 'dashicons dashicons-no',
1020
+				'desc'  => __('No Check-in Record has been Created for this Registrant', 'event_espresso'),
1021
+			),
1022
+			'view_details'     => array(
1023
+				'class' => 'dashicons dashicons-search',
1024
+				'desc'  => __('View All Check-in Records for this Registrant', 'event_espresso'),
1025
+			),
1026
+			'approved_status'  => array(
1027
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1028
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1029
+			),
1030
+			'cancelled_status' => array(
1031
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1032
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1033
+			),
1034
+			'declined_status'  => array(
1035
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1036
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1037
+			),
1038
+			'not_approved'     => array(
1039
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1040
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1041
+			),
1042
+			'pending_status'   => array(
1043
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1044
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1045
+			),
1046
+			'wait_list'        => array(
1047
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1048
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1049
+			),
1050
+		);
1051
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1052
+		$event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1053
+		$this->_template_args['before_list_table'] = ! empty($event_id)
1054
+			? '<h2>' . sprintf(
1055
+				__('Viewing Registrations for Event: %s', 'event_espresso'),
1056
+				EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1057
+			) . '</h2>'
1058
+			: '';
1059
+		//need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event.
1060
+		/** @var EE_Event $event */
1061
+		$event = EEM_Event::instance()->get_one_by_ID($event_id);
1062
+		$DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1063
+		$datetime = null;
1064
+		if ($event instanceof EE_Event) {
1065
+			$datetimes_on_event = $event->datetimes();
1066
+			if (count($datetimes_on_event) === 1) {
1067
+				$datetime = reset($datetimes_on_event);
1068
+			}
1069
+		}
1070
+		$datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1071
+		if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1072
+			$this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1073
+			$this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1074
+			$this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1075
+			$this->_template_args['before_list_table'] .= $datetime->name();
1076
+			$this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1077
+			$this->_template_args['before_list_table'] .= '</span></h2>';
1078
+		}
1079
+		//if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column
1080
+		//represents
1081
+		if ( ! $datetime instanceof EE_Datetime) {
1082
+			$this->_template_args['before_list_table'] .= '<br><p class="description">'
1083
+														  . __('In this view, the check-in status represents the latest check-in record for the registration in that row.',
1084
+					'event_espresso')
1085
+														  . '</p>';
1086
+		}
1087
+		$this->display_admin_list_table_page_with_no_sidebar();
1088
+	}
1089
+
1090
+	/**
1091
+	 * Download the registrations check-in report (same as the normal registration report, but with different where
1092
+	 * conditions)
1093
+	 *
1094
+	 * @return void ends the request by a redirect or download
1095
+	 */
1096
+	public function _registrations_checkin_report()
1097
+	{
1098
+		$this->_registrations_report_base('_get_checkin_query_params_from_request');
1099
+	}
1100
+
1101
+	/**
1102
+	 * Gets the query params from the request, plus adds a where condition for the registration status,
1103
+	 * because on the checkin page we only ever want to see approved and pending-approval registrations
1104
+	 *
1105
+	 * @param array     $request
1106
+	 * @param int  $per_page
1107
+	 * @param bool $count
1108
+	 * @return array
1109
+	 */
1110
+	protected function _get_checkin_query_params_from_request(
1111
+		$request,
1112
+		$per_page = 10,
1113
+		$count = false
1114
+	) {
1115
+		$query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1116
+		//unlike the regular registrations list table,
1117
+		$status_ids_array = apply_filters(
1118
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1119
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1120
+		);
1121
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1122
+		return $query_params;
1123
+	}
1124
+
1125
+
1126
+
1127
+
1128
+	/**
1129
+	 * Gets registrations for an event
1130
+	 *
1131
+	 * @param int    $per_page
1132
+	 * @param bool   $count whether to return count or data.
1133
+	 * @param bool   $trash
1134
+	 * @param string $orderby
1135
+	 * @return EE_Registration[]|int
1136
+	 * @throws \EE_Error
1137
+	 */
1138
+	public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1139
+	{
1140
+		//normalize some request params that get setup by the parent `get_registrations` method.
1141
+		$request = $this->_req_data;
1142
+		$request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1143
+		$request['order'] =  ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1144
+		if($trash){
1145
+			$request['status'] = 'trash';
1146
+		}
1147
+		$query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count );
1148
+		/**
1149
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1150
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1151
+		 * @see EEM_Base::get_all()
1152
+		 */
1153
+		$query_params['group_by'] = '';
1154
+
1155
+		return $count
1156
+			? EEM_Registration::instance()->count($query_params)
1157
+			/** @type EE_Registration[] */
1158
+			: EEM_Registration::instance()->get_all($query_params);
1159
+	}
1160 1160
 
1161 1161
 } //end class Registrations Admin Page
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
     {
36 36
         parent::__construct($routing);
37 37
         if ( ! defined('REG_CAF_TEMPLATE_PATH')) {
38
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
39
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
40
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
38
+            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/');
39
+            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/');
40
+            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/');
41 41
         }
42 42
     }
43 43
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
     protected function _extend_page_config()
47 47
     {
48
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
48
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations';
49 49
         $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50 50
             ? $this->_req_data['_REG_ID']
51 51
             : 0;
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
             //enqueue newsletter js
179 179
             wp_enqueue_script(
180 180
                 'ee-newsletter-trigger',
181
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
181
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js',
182 182
                 array('ee-dialog'),
183 183
                 EVENT_ESPRESSO_VERSION,
184 184
                 true
185 185
             );
186 186
             wp_enqueue_style(
187 187
                 'ee-newsletter-trigger-css',
188
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
188
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css',
189 189
                 array(),
190 190
                 EVENT_ESPRESSO_VERSION
191 191
             );
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     {
205 205
         wp_register_script(
206 206
             'ee-reg-reports-js',
207
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
207
+            REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js',
208 208
             array('google-charts'),
209 209
             EVENT_ESPRESSO_VERSION,
210 210
             true
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
             $codes[$field] = implode(', ', array_keys($shortcode_array));
410 410
         }
411 411
         $shortcodes = $codes;
412
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
412
+        $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php';
413 413
         $form_template_args = array(
414 414
             'form_action'       => admin_url('admin.php?page=espresso_registrations'),
415 415
             'form_route'        => 'newsletter_selected_send',
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
      */
571 571
     protected function _registration_reports()
572 572
     {
573
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
573
+        $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php';
574 574
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
575 575
             $template_path,
576 576
             $this->_reports_template_data,
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
     {
593 593
         $report_ID = 'reg-admin-registrations-per-day-report-dv';
594 594
         $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
595
-        $results = (array)$results;
595
+        $results = (array) $results;
596 596
         $regs = array();
597 597
         $subtitle = '';
598 598
         if ($results) {
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
                 $report_column_values = array();
603 603
                 foreach ($result as $property_name => $property_value) {
604 604
                     $property_value = $property_name === 'Registration_REG_date' ? $property_value
605
-                        : (int)$property_value;
605
+                        : (int) $property_value;
606 606
                     $report_column_values[] = $property_value;
607 607
                     if ($tracker === 0) {
608 608
                         if ($property_name === 'Registration_REG_date') {
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
             array_unshift($regs, $column_titles);
620 620
             //setup the date range.
621 621
             $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
622
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
622
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
623 623
             $ending_date = new DateTime("now", $DateTimeZone);
624 624
             $subtitle = sprintf(
625 625
                 _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
                     '%sThere are currently no registration records in the last month for this report.%s',
640 640
                     'event_espresso'
641 641
                 ),
642
-                '<h2>' . $report_title . '</h2><p>',
642
+                '<h2>'.$report_title.'</h2><p>',
643 643
                 '</p>'
644 644
             ),
645 645
         );
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
     {
660 660
         $report_ID = 'reg-admin-registrations-per-event-report-dv';
661 661
         $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
662
-        $results = (array)$results;
662
+        $results = (array) $results;
663 663
         $regs = array();
664 664
         $subtitle = '';
665 665
         if ($results) {
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
                         $property_value,
673 673
                         4,
674 674
                         '...'
675
-                    ) : (int)$property_value;
675
+                    ) : (int) $property_value;
676 676
                     $report_column_values[] = $property_value;
677 677
                     if ($tracker === 0) {
678 678
                         if ($property_name === 'Registration_Event') {
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
             array_unshift($regs, $column_titles);
690 690
             //setup the date range.
691 691
             $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
692
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
692
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
693 693
             $ending_date = new DateTime("now", $DateTimeZone);
694 694
             $subtitle = sprintf(
695 695
                 _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
                     '%sThere are currently no registration records in the last month for this report.%s',
710 710
                     'event_espresso'
711 711
                 ),
712
-                '<h2>' . $report_title . '</h2><p>',
712
+                '<h2>'.$report_title.'</h2><p>',
713 713
                 '</p>'
714 714
             ),
715 715
         );
@@ -759,31 +759,31 @@  discard block
 block discarded – undo
759 759
             $this->_admin_base_url
760 760
         ) : '';
761 761
         $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
762
-            ? '<h2>' . sprintf(
762
+            ? '<h2>'.sprintf(
763 763
                 __("%s's check in records for %s at the event, %s", 'event_espresso'),
764 764
                 '<span id="checkin-attendee-name">'
765 765
                 . EEM_Registration::instance()
766 766
                                   ->get_one_by_ID($reg_id)
767 767
                                   ->get_first_related('Attendee')
768
-                                  ->full_name() . '</span>',
769
-                '<span id="checkin-dtt"><a href="' . $go_back_url . '">'
768
+                                  ->full_name().'</span>',
769
+                '<span id="checkin-dtt"><a href="'.$go_back_url.'">'
770 770
                 . EEM_Datetime::instance()
771 771
                               ->get_one_by_ID($dtt_id)
772
-                              ->start_date_and_time() . ' - '
772
+                              ->start_date_and_time().' - '
773 773
                 . EEM_Datetime::instance()
774 774
                               ->get_one_by_ID($dtt_id)
775
-                              ->end_date_and_time() . '</a></span>',
775
+                              ->end_date_and_time().'</a></span>',
776 776
                 '<span id="checkin-event-name">'
777 777
                 . EEM_Datetime::instance()
778 778
                               ->get_one_by_ID($dtt_id)
779 779
                               ->get_first_related('Event')
780
-                              ->get('EVT_name') . '</span>'
781
-            ) . '</h2>'
780
+                              ->get('EVT_name').'</span>'
781
+            ).'</h2>'
782 782
             : '';
783 783
         $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
784
-            ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : '';
784
+            ? '<input type="hidden" name="_REGID" value="'.$reg_id.'">' : '';
785 785
         $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
786
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
786
+            ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : '';
787 787
         $this->display_admin_list_table_page_with_no_sidebar();
788 788
     }
789 789
 
@@ -1024,37 +1024,37 @@  discard block
 block discarded – undo
1024 1024
                 'desc'  => __('View All Check-in Records for this Registrant', 'event_espresso'),
1025 1025
             ),
1026 1026
             'approved_status'  => array(
1027
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1027
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
1028 1028
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1029 1029
             ),
1030 1030
             'cancelled_status' => array(
1031
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1031
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
1032 1032
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1033 1033
             ),
1034 1034
             'declined_status'  => array(
1035
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1035
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
1036 1036
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1037 1037
             ),
1038 1038
             'not_approved'     => array(
1039
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1039
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
1040 1040
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1041 1041
             ),
1042 1042
             'pending_status'   => array(
1043
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1043
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
1044 1044
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1045 1045
             ),
1046 1046
             'wait_list'        => array(
1047
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1047
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
1048 1048
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1049 1049
             ),
1050 1050
         );
1051 1051
         $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1052 1052
         $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1053 1053
         $this->_template_args['before_list_table'] = ! empty($event_id)
1054
-            ? '<h2>' . sprintf(
1054
+            ? '<h2>'.sprintf(
1055 1055
                 __('Viewing Registrations for Event: %s', 'event_espresso'),
1056 1056
                 EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1057
-            ) . '</h2>'
1057
+            ).'</h2>'
1058 1058
             : '';
1059 1059
         //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event.
1060 1060
         /** @var EE_Event $event */
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
             $this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1074 1074
             $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1075 1075
             $this->_template_args['before_list_table'] .= $datetime->name();
1076
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1076
+            $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )';
1077 1077
             $this->_template_args['before_list_table'] .= '</span></h2>';
1078 1078
         }
1079 1079
         //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column
@@ -1140,11 +1140,11 @@  discard block
 block discarded – undo
1140 1140
         //normalize some request params that get setup by the parent `get_registrations` method.
1141 1141
         $request = $this->_req_data;
1142 1142
         $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1143
-        $request['order'] =  ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1144
-        if($trash){
1143
+        $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1144
+        if ($trash) {
1145 1145
             $request['status'] = 'trash';
1146 1146
         }
1147
-        $query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count );
1147
+        $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count);
1148 1148
         /**
1149 1149
          * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1150 1150
          * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
Please login to merge, or discard this patch.
core/db_classes/EE_Attendee.class.php 1 patch
Indentation   +660 added lines, -660 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -23,665 +23,665 @@  discard block
 block discarded – undo
23 23
 class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee
24 24
 {
25 25
 
26
-    /**
27
-     * Sets some dynamic defaults
28
-     *
29
-     * @param array  $fieldValues
30
-     * @param bool   $bydb
31
-     * @param string $timezone
32
-     * @param array  $date_formats
33
-     */
34
-    protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
35
-    {
36
-        if (! isset($fieldValues['ATT_full_name'])) {
37
-            $fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
38
-            $lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
39
-            $fieldValues['ATT_full_name'] = $fname . $lname;
40
-        }
41
-        if (! isset($fieldValues['ATT_slug'])) {
42
-            //			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
43
-            $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
44
-        }
45
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
46
-            $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
47
-        }
48
-        parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
49
-    }
50
-
51
-
52
-    /**
53
-     * @param array  $props_n_values          incoming values
54
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
55
-     *                                        used.)
56
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
57
-     *                                        date_format and the second value is the time format
58
-     * @return EE_Attendee
59
-     */
60
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
61
-    {
62
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
63
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
64
-    }
65
-
66
-
67
-    /**
68
-     * @param array  $props_n_values  incoming values from the database
69
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
70
-     *                                the website will be used.
71
-     * @return EE_Attendee
72
-     */
73
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
74
-    {
75
-        return new self($props_n_values, true, $timezone);
76
-    }
77
-
78
-
79
-    /**
80
-     *        Set Attendee First Name
81
-     *
82
-     * @access        public
83
-     * @param string $fname
84
-     */
85
-    public function set_fname($fname = '')
86
-    {
87
-        $this->set('ATT_fname', $fname);
88
-    }
89
-
90
-
91
-    /**
92
-     *        Set Attendee Last Name
93
-     *
94
-     * @access        public
95
-     * @param string $lname
96
-     */
97
-    public function set_lname($lname = '')
98
-    {
99
-        $this->set('ATT_lname', $lname);
100
-    }
101
-
102
-
103
-    /**
104
-     *        Set Attendee Address
105
-     *
106
-     * @access        public
107
-     * @param string $address
108
-     */
109
-    public function set_address($address = '')
110
-    {
111
-        $this->set('ATT_address', $address);
112
-    }
113
-
114
-
115
-    /**
116
-     *        Set Attendee Address2
117
-     *
118
-     * @access        public
119
-     * @param        string $address2
120
-     */
121
-    public function set_address2($address2 = '')
122
-    {
123
-        $this->set('ATT_address2', $address2);
124
-    }
125
-
126
-
127
-    /**
128
-     *        Set Attendee City
129
-     *
130
-     * @access        public
131
-     * @param        string $city
132
-     */
133
-    public function set_city($city = '')
134
-    {
135
-        $this->set('ATT_city', $city);
136
-    }
137
-
138
-
139
-    /**
140
-     *        Set Attendee State ID
141
-     *
142
-     * @access        public
143
-     * @param        int $STA_ID
144
-     */
145
-    public function set_state($STA_ID = 0)
146
-    {
147
-        $this->set('STA_ID', $STA_ID);
148
-    }
149
-
150
-
151
-    /**
152
-     *        Set Attendee Country ISO Code
153
-     *
154
-     * @access        public
155
-     * @param        string $CNT_ISO
156
-     */
157
-    public function set_country($CNT_ISO = '')
158
-    {
159
-        $this->set('CNT_ISO', $CNT_ISO);
160
-    }
161
-
162
-
163
-    /**
164
-     *        Set Attendee Zip/Postal Code
165
-     *
166
-     * @access        public
167
-     * @param        string $zip
168
-     */
169
-    public function set_zip($zip = '')
170
-    {
171
-        $this->set('ATT_zip', $zip);
172
-    }
173
-
174
-
175
-    /**
176
-     *        Set Attendee Email Address
177
-     *
178
-     * @access        public
179
-     * @param        string $email
180
-     */
181
-    public function set_email($email = '')
182
-    {
183
-        $this->set('ATT_email', $email);
184
-    }
185
-
186
-
187
-    /**
188
-     *        Set Attendee Phone
189
-     *
190
-     * @access        public
191
-     * @param        string $phone
192
-     */
193
-    public function set_phone($phone = '')
194
-    {
195
-        $this->set('ATT_phone', $phone);
196
-    }
197
-
198
-
199
-    /**
200
-     *        set deleted
201
-     *
202
-     * @access        public
203
-     * @param        bool $ATT_deleted
204
-     */
205
-    public function set_deleted($ATT_deleted = false)
206
-    {
207
-        $this->set('ATT_deleted', $ATT_deleted);
208
-    }
209
-
210
-
211
-    /**
212
-     * Returns the value for the post_author id saved with the cpt
213
-     *
214
-     * @since 4.5.0
215
-     * @return int
216
-     */
217
-    public function wp_user()
218
-    {
219
-        return $this->get('ATT_author');
220
-    }
221
-
222
-
223
-    /**
224
-     *        get Attendee First Name
225
-     *
226
-     * @access        public
227
-     * @return string
228
-     */
229
-    public function fname()
230
-    {
231
-        return $this->get('ATT_fname');
232
-    }
233
-
234
-
235
-    /**
236
-     * echoes out the attendee's first name
237
-     *
238
-     * @return void
239
-     */
240
-    public function e_full_name()
241
-    {
242
-        echo $this->full_name();
243
-    }
244
-
245
-
246
-    /**
247
-     * Returns the first and last name concatenated together with a space.
248
-     *
249
-     * @param bool $apply_html_entities
250
-     * @return string
251
-     */
252
-    public function full_name($apply_html_entities = false)
253
-    {
254
-        $full_name = $this->fname() . ' ' . $this->lname();
255
-        return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
256
-    }
257
-
258
-
259
-    /**
260
-     * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
261
-     * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
262
-     * attendee.
263
-     *
264
-     * @param bool $apply_html_entities
265
-     * @return string
266
-     */
267
-    public function ATT_full_name($apply_html_entities = false)
268
-    {
269
-        return $apply_html_entities
270
-            ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
271
-            : $this->get('ATT_full_name');
272
-    }
273
-
274
-
275
-    /**
276
-     *        get Attendee Last Name
277
-     *
278
-     * @access        public
279
-     * @return string
280
-     */
281
-    public function lname()
282
-    {
283
-        return $this->get('ATT_lname');
284
-    }
285
-
286
-
287
-    /**
288
-     * Gets the attendee's full address as an array so client code can decide hwo to display it
289
-     *
290
-     * @return array numerically indexed, with each part of the address that is known.
291
-     * Eg, if the user only responded to state and country,
292
-     * it would be array(0=>'Alabama',1=>'USA')
293
-     * @return array
294
-     */
295
-    public function full_address_as_array()
296
-    {
297
-        $full_address_array     = array();
298
-        $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
299
-        foreach ($initial_address_fields as $address_field_name) {
300
-            $address_fields_value = $this->get($address_field_name);
301
-            if (! empty($address_fields_value)) {
302
-                $full_address_array[] = $address_fields_value;
303
-            }
304
-        }
305
-        //now handle state and country
306
-        $state_obj = $this->state_obj();
307
-        if (! empty($state_obj)) {
308
-            $full_address_array[] = $state_obj->name();
309
-        }
310
-        $country_obj = $this->country_obj();
311
-        if (! empty($country_obj)) {
312
-            $full_address_array[] = $country_obj->name();
313
-        }
314
-        //lastly get the xip
315
-        $zip_value = $this->zip();
316
-        if (! empty($zip_value)) {
317
-            $full_address_array[] = $zip_value;
318
-        }
319
-        return $full_address_array;
320
-    }
321
-
322
-
323
-    /**
324
-     *        get Attendee Address
325
-     *
326
-     * @return string
327
-     */
328
-    public function address()
329
-    {
330
-        return $this->get('ATT_address');
331
-    }
332
-
333
-
334
-    /**
335
-     *        get Attendee Address2
336
-     *
337
-     * @return string
338
-     */
339
-    public function address2()
340
-    {
341
-        return $this->get('ATT_address2');
342
-    }
343
-
344
-
345
-    /**
346
-     *        get Attendee City
347
-     *
348
-     * @return string
349
-     */
350
-    public function city()
351
-    {
352
-        return $this->get('ATT_city');
353
-    }
354
-
355
-
356
-    /**
357
-     *        get Attendee State ID
358
-     *
359
-     * @return string
360
-     */
361
-    public function state_ID()
362
-    {
363
-        return $this->get('STA_ID');
364
-    }
365
-
366
-
367
-    /**
368
-     * @return string
369
-     */
370
-    public function state_abbrev()
371
-    {
372
-        return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
373
-    }
374
-
375
-
376
-    /**
377
-     * Gets the state set to this attendee
378
-     *
379
-     * @return EE_State
380
-     */
381
-    public function state_obj()
382
-    {
383
-        return $this->get_first_related('State');
384
-    }
385
-
386
-
387
-    /**
388
-     * Returns the state's name, otherwise 'Unknown'
389
-     *
390
-     * @return string
391
-     */
392
-    public function state_name()
393
-    {
394
-        if ($this->state_obj()) {
395
-            return $this->state_obj()->name();
396
-        } else {
397
-            return '';
398
-        }
399
-    }
400
-
401
-
402
-    /**
403
-     * either displays the state abbreviation or the state name, as determined
404
-     * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
405
-     * defaults to abbreviation
406
-     *
407
-     * @return string
408
-     */
409
-    public function state()
410
-    {
411
-        if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
412
-            return $this->state_abbrev();
413
-        } else {
414
-            return $this->state_name();
415
-        }
416
-    }
417
-
418
-
419
-    /**
420
-     *    get Attendee Country ISO Code
421
-     *
422
-     * @return string
423
-     */
424
-    public function country_ID()
425
-    {
426
-        return $this->get('CNT_ISO');
427
-    }
428
-
429
-
430
-    /**
431
-     * Gets country set for this attendee
432
-     *
433
-     * @return EE_Country
434
-     */
435
-    public function country_obj()
436
-    {
437
-        return $this->get_first_related('Country');
438
-    }
439
-
440
-
441
-    /**
442
-     * Returns the country's name if known, otherwise 'Unknown'
443
-     *
444
-     * @return string
445
-     */
446
-    public function country_name()
447
-    {
448
-        if ($this->country_obj()) {
449
-            return $this->country_obj()->name();
450
-        } else {
451
-            return '';
452
-        }
453
-    }
454
-
455
-
456
-    /**
457
-     * either displays the country ISO2 code or the country name, as determined
458
-     * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
459
-     * defaults to abbreviation
460
-     *
461
-     * @return string
462
-     */
463
-    public function country()
464
-    {
465
-        if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
466
-            return $this->country_ID();
467
-        } else {
468
-            return $this->country_name();
469
-        }
470
-    }
471
-
472
-
473
-    /**
474
-     *        get Attendee Zip/Postal Code
475
-     *
476
-     * @return string
477
-     */
478
-    public function zip()
479
-    {
480
-        return $this->get('ATT_zip');
481
-    }
482
-
483
-
484
-    /**
485
-     *        get Attendee Email Address
486
-     *
487
-     * @return string
488
-     */
489
-    public function email()
490
-    {
491
-        return $this->get('ATT_email');
492
-    }
493
-
494
-
495
-    /**
496
-     *        get Attendee Phone #
497
-     *
498
-     * @return string
499
-     */
500
-    public function phone()
501
-    {
502
-        return $this->get('ATT_phone');
503
-    }
504
-
505
-
506
-    /**
507
-     *    get deleted
508
-     *
509
-     * @return        bool
510
-     */
511
-    public function deleted()
512
-    {
513
-        return $this->get('ATT_deleted');
514
-    }
515
-
516
-
517
-    /**
518
-     * Gets registrations of this attendee
519
-     *
520
-     * @param array $query_params
521
-     * @return EE_Registration[]
522
-     */
523
-    public function get_registrations($query_params = array())
524
-    {
525
-        return $this->get_many_related('Registration', $query_params);
526
-    }
527
-
528
-
529
-    /**
530
-     * Gets the most recent registration of this attendee
531
-     *
532
-     * @return EE_Registration
533
-     */
534
-    public function get_most_recent_registration()
535
-    {
536
-        return $this->get_first_related('Registration',
537
-            array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K');
538
-    }
539
-
540
-
541
-    /**
542
-     * Gets the most recent registration for this attend at this event
543
-     *
544
-     * @param int $event_id
545
-     * @return EE_Registration
546
-     */
547
-    public function get_most_recent_registration_for_event($event_id)
548
-    {
549
-        return $this->get_first_related('Registration',
550
-            array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' );
551
-    }
552
-
553
-
554
-    /**
555
-     * returns any events attached to this attendee ($_Event property);
556
-     *
557
-     * @return array
558
-     */
559
-    public function events()
560
-    {
561
-        return $this->get_many_related('Event');
562
-    }
563
-
564
-
565
-    /**
566
-     * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
567
-     * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
568
-     * used to save the billing info
569
-     *
570
-     * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
571
-     * @return EE_Form_Section_Proper|null
572
-     */
573
-    public function billing_info_for_payment_method($payment_method)
574
-    {
575
-        $pm_type = $payment_method->type_obj();
576
-        if (! $pm_type instanceof EE_PMT_Base) {
577
-            return null;
578
-        }
579
-        $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
580
-        if (! $billing_info) {
581
-            return null;
582
-        }
583
-        $billing_form = $pm_type->billing_form();
584
-        if ($billing_form instanceof EE_Form_Section_Proper) {
585
-            $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
586
-        }
587
-        return $billing_form;
588
-    }
589
-
590
-
591
-    /**
592
-     * Gets the postmeta key that holds this attendee's billing info for the
593
-     * specified payment method
594
-     *
595
-     * @param EE_Payment_Method $payment_method
596
-     * @return string
597
-     */
598
-    public function get_billing_info_postmeta_name($payment_method)
599
-    {
600
-        if ($payment_method->type_obj() instanceof EE_PMT_Base) {
601
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
602
-        } else {
603
-            return null;
604
-        }
605
-    }
606
-
607
-
608
-    /**
609
-     * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
610
-     * retrieve it
611
-     *
612
-     * @param EE_Billing_Attendee_Info_Form $billing_form
613
-     * @param EE_Payment_Method             $payment_method
614
-     * @return boolean
615
-     */
616
-    public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
617
-    {
618
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
619
-            EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
620
-            return false;
621
-        }
622
-        $billing_form->clean_sensitive_data();
623
-        return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method),
624
-            $billing_form->input_values(true));
625
-    }
626
-
627
-
628
-    /**
629
-     * Return the link to the admin details for the object.
630
-     *
631
-     * @return string
632
-     */
633
-    public function get_admin_details_link()
634
-    {
635
-        return $this->get_admin_edit_link();
636
-    }
637
-
638
-
639
-    /**
640
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
641
-     *
642
-     * @return string
643
-     */
644
-    public function get_admin_edit_link()
645
-    {
646
-        EE_Registry::instance()->load_helper('URL');
647
-        return EEH_URL::add_query_args_and_nonce(
648
-            array(
649
-                'page'   => 'espresso_registrations',
650
-                'action' => 'edit_attendee',
651
-                'post'   => $this->ID(),
652
-            ),
653
-            admin_url('admin.php')
654
-        );
655
-    }
656
-
657
-
658
-    /**
659
-     * Returns the link to a settings page for the object.
660
-     *
661
-     * @return string
662
-     */
663
-    public function get_admin_settings_link()
664
-    {
665
-        return $this->get_admin_edit_link();
666
-    }
667
-
668
-
669
-    /**
670
-     * Returns the link to the "overview" for the object (typically the "list table" view).
671
-     *
672
-     * @return string
673
-     */
674
-    public function get_admin_overview_link()
675
-    {
676
-        EE_Registry::instance()->load_helper('URL');
677
-        return EEH_URL::add_query_args_and_nonce(
678
-            array(
679
-                'page'   => 'espresso_registrations',
680
-                'action' => 'contact_list',
681
-            ),
682
-            admin_url('admin.php')
683
-        );
684
-    }
26
+	/**
27
+	 * Sets some dynamic defaults
28
+	 *
29
+	 * @param array  $fieldValues
30
+	 * @param bool   $bydb
31
+	 * @param string $timezone
32
+	 * @param array  $date_formats
33
+	 */
34
+	protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
35
+	{
36
+		if (! isset($fieldValues['ATT_full_name'])) {
37
+			$fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
38
+			$lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
39
+			$fieldValues['ATT_full_name'] = $fname . $lname;
40
+		}
41
+		if (! isset($fieldValues['ATT_slug'])) {
42
+			//			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
43
+			$fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
44
+		}
45
+		if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
46
+			$fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
47
+		}
48
+		parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
49
+	}
50
+
51
+
52
+	/**
53
+	 * @param array  $props_n_values          incoming values
54
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
55
+	 *                                        used.)
56
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
57
+	 *                                        date_format and the second value is the time format
58
+	 * @return EE_Attendee
59
+	 */
60
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
61
+	{
62
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
63
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
64
+	}
65
+
66
+
67
+	/**
68
+	 * @param array  $props_n_values  incoming values from the database
69
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
70
+	 *                                the website will be used.
71
+	 * @return EE_Attendee
72
+	 */
73
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
74
+	{
75
+		return new self($props_n_values, true, $timezone);
76
+	}
77
+
78
+
79
+	/**
80
+	 *        Set Attendee First Name
81
+	 *
82
+	 * @access        public
83
+	 * @param string $fname
84
+	 */
85
+	public function set_fname($fname = '')
86
+	{
87
+		$this->set('ATT_fname', $fname);
88
+	}
89
+
90
+
91
+	/**
92
+	 *        Set Attendee Last Name
93
+	 *
94
+	 * @access        public
95
+	 * @param string $lname
96
+	 */
97
+	public function set_lname($lname = '')
98
+	{
99
+		$this->set('ATT_lname', $lname);
100
+	}
101
+
102
+
103
+	/**
104
+	 *        Set Attendee Address
105
+	 *
106
+	 * @access        public
107
+	 * @param string $address
108
+	 */
109
+	public function set_address($address = '')
110
+	{
111
+		$this->set('ATT_address', $address);
112
+	}
113
+
114
+
115
+	/**
116
+	 *        Set Attendee Address2
117
+	 *
118
+	 * @access        public
119
+	 * @param        string $address2
120
+	 */
121
+	public function set_address2($address2 = '')
122
+	{
123
+		$this->set('ATT_address2', $address2);
124
+	}
125
+
126
+
127
+	/**
128
+	 *        Set Attendee City
129
+	 *
130
+	 * @access        public
131
+	 * @param        string $city
132
+	 */
133
+	public function set_city($city = '')
134
+	{
135
+		$this->set('ATT_city', $city);
136
+	}
137
+
138
+
139
+	/**
140
+	 *        Set Attendee State ID
141
+	 *
142
+	 * @access        public
143
+	 * @param        int $STA_ID
144
+	 */
145
+	public function set_state($STA_ID = 0)
146
+	{
147
+		$this->set('STA_ID', $STA_ID);
148
+	}
149
+
150
+
151
+	/**
152
+	 *        Set Attendee Country ISO Code
153
+	 *
154
+	 * @access        public
155
+	 * @param        string $CNT_ISO
156
+	 */
157
+	public function set_country($CNT_ISO = '')
158
+	{
159
+		$this->set('CNT_ISO', $CNT_ISO);
160
+	}
161
+
162
+
163
+	/**
164
+	 *        Set Attendee Zip/Postal Code
165
+	 *
166
+	 * @access        public
167
+	 * @param        string $zip
168
+	 */
169
+	public function set_zip($zip = '')
170
+	{
171
+		$this->set('ATT_zip', $zip);
172
+	}
173
+
174
+
175
+	/**
176
+	 *        Set Attendee Email Address
177
+	 *
178
+	 * @access        public
179
+	 * @param        string $email
180
+	 */
181
+	public function set_email($email = '')
182
+	{
183
+		$this->set('ATT_email', $email);
184
+	}
185
+
186
+
187
+	/**
188
+	 *        Set Attendee Phone
189
+	 *
190
+	 * @access        public
191
+	 * @param        string $phone
192
+	 */
193
+	public function set_phone($phone = '')
194
+	{
195
+		$this->set('ATT_phone', $phone);
196
+	}
197
+
198
+
199
+	/**
200
+	 *        set deleted
201
+	 *
202
+	 * @access        public
203
+	 * @param        bool $ATT_deleted
204
+	 */
205
+	public function set_deleted($ATT_deleted = false)
206
+	{
207
+		$this->set('ATT_deleted', $ATT_deleted);
208
+	}
209
+
210
+
211
+	/**
212
+	 * Returns the value for the post_author id saved with the cpt
213
+	 *
214
+	 * @since 4.5.0
215
+	 * @return int
216
+	 */
217
+	public function wp_user()
218
+	{
219
+		return $this->get('ATT_author');
220
+	}
221
+
222
+
223
+	/**
224
+	 *        get Attendee First Name
225
+	 *
226
+	 * @access        public
227
+	 * @return string
228
+	 */
229
+	public function fname()
230
+	{
231
+		return $this->get('ATT_fname');
232
+	}
233
+
234
+
235
+	/**
236
+	 * echoes out the attendee's first name
237
+	 *
238
+	 * @return void
239
+	 */
240
+	public function e_full_name()
241
+	{
242
+		echo $this->full_name();
243
+	}
244
+
245
+
246
+	/**
247
+	 * Returns the first and last name concatenated together with a space.
248
+	 *
249
+	 * @param bool $apply_html_entities
250
+	 * @return string
251
+	 */
252
+	public function full_name($apply_html_entities = false)
253
+	{
254
+		$full_name = $this->fname() . ' ' . $this->lname();
255
+		return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
256
+	}
257
+
258
+
259
+	/**
260
+	 * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
261
+	 * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
262
+	 * attendee.
263
+	 *
264
+	 * @param bool $apply_html_entities
265
+	 * @return string
266
+	 */
267
+	public function ATT_full_name($apply_html_entities = false)
268
+	{
269
+		return $apply_html_entities
270
+			? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
271
+			: $this->get('ATT_full_name');
272
+	}
273
+
274
+
275
+	/**
276
+	 *        get Attendee Last Name
277
+	 *
278
+	 * @access        public
279
+	 * @return string
280
+	 */
281
+	public function lname()
282
+	{
283
+		return $this->get('ATT_lname');
284
+	}
285
+
286
+
287
+	/**
288
+	 * Gets the attendee's full address as an array so client code can decide hwo to display it
289
+	 *
290
+	 * @return array numerically indexed, with each part of the address that is known.
291
+	 * Eg, if the user only responded to state and country,
292
+	 * it would be array(0=>'Alabama',1=>'USA')
293
+	 * @return array
294
+	 */
295
+	public function full_address_as_array()
296
+	{
297
+		$full_address_array     = array();
298
+		$initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
299
+		foreach ($initial_address_fields as $address_field_name) {
300
+			$address_fields_value = $this->get($address_field_name);
301
+			if (! empty($address_fields_value)) {
302
+				$full_address_array[] = $address_fields_value;
303
+			}
304
+		}
305
+		//now handle state and country
306
+		$state_obj = $this->state_obj();
307
+		if (! empty($state_obj)) {
308
+			$full_address_array[] = $state_obj->name();
309
+		}
310
+		$country_obj = $this->country_obj();
311
+		if (! empty($country_obj)) {
312
+			$full_address_array[] = $country_obj->name();
313
+		}
314
+		//lastly get the xip
315
+		$zip_value = $this->zip();
316
+		if (! empty($zip_value)) {
317
+			$full_address_array[] = $zip_value;
318
+		}
319
+		return $full_address_array;
320
+	}
321
+
322
+
323
+	/**
324
+	 *        get Attendee Address
325
+	 *
326
+	 * @return string
327
+	 */
328
+	public function address()
329
+	{
330
+		return $this->get('ATT_address');
331
+	}
332
+
333
+
334
+	/**
335
+	 *        get Attendee Address2
336
+	 *
337
+	 * @return string
338
+	 */
339
+	public function address2()
340
+	{
341
+		return $this->get('ATT_address2');
342
+	}
343
+
344
+
345
+	/**
346
+	 *        get Attendee City
347
+	 *
348
+	 * @return string
349
+	 */
350
+	public function city()
351
+	{
352
+		return $this->get('ATT_city');
353
+	}
354
+
355
+
356
+	/**
357
+	 *        get Attendee State ID
358
+	 *
359
+	 * @return string
360
+	 */
361
+	public function state_ID()
362
+	{
363
+		return $this->get('STA_ID');
364
+	}
365
+
366
+
367
+	/**
368
+	 * @return string
369
+	 */
370
+	public function state_abbrev()
371
+	{
372
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
373
+	}
374
+
375
+
376
+	/**
377
+	 * Gets the state set to this attendee
378
+	 *
379
+	 * @return EE_State
380
+	 */
381
+	public function state_obj()
382
+	{
383
+		return $this->get_first_related('State');
384
+	}
385
+
386
+
387
+	/**
388
+	 * Returns the state's name, otherwise 'Unknown'
389
+	 *
390
+	 * @return string
391
+	 */
392
+	public function state_name()
393
+	{
394
+		if ($this->state_obj()) {
395
+			return $this->state_obj()->name();
396
+		} else {
397
+			return '';
398
+		}
399
+	}
400
+
401
+
402
+	/**
403
+	 * either displays the state abbreviation or the state name, as determined
404
+	 * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
405
+	 * defaults to abbreviation
406
+	 *
407
+	 * @return string
408
+	 */
409
+	public function state()
410
+	{
411
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
412
+			return $this->state_abbrev();
413
+		} else {
414
+			return $this->state_name();
415
+		}
416
+	}
417
+
418
+
419
+	/**
420
+	 *    get Attendee Country ISO Code
421
+	 *
422
+	 * @return string
423
+	 */
424
+	public function country_ID()
425
+	{
426
+		return $this->get('CNT_ISO');
427
+	}
428
+
429
+
430
+	/**
431
+	 * Gets country set for this attendee
432
+	 *
433
+	 * @return EE_Country
434
+	 */
435
+	public function country_obj()
436
+	{
437
+		return $this->get_first_related('Country');
438
+	}
439
+
440
+
441
+	/**
442
+	 * Returns the country's name if known, otherwise 'Unknown'
443
+	 *
444
+	 * @return string
445
+	 */
446
+	public function country_name()
447
+	{
448
+		if ($this->country_obj()) {
449
+			return $this->country_obj()->name();
450
+		} else {
451
+			return '';
452
+		}
453
+	}
454
+
455
+
456
+	/**
457
+	 * either displays the country ISO2 code or the country name, as determined
458
+	 * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
459
+	 * defaults to abbreviation
460
+	 *
461
+	 * @return string
462
+	 */
463
+	public function country()
464
+	{
465
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
466
+			return $this->country_ID();
467
+		} else {
468
+			return $this->country_name();
469
+		}
470
+	}
471
+
472
+
473
+	/**
474
+	 *        get Attendee Zip/Postal Code
475
+	 *
476
+	 * @return string
477
+	 */
478
+	public function zip()
479
+	{
480
+		return $this->get('ATT_zip');
481
+	}
482
+
483
+
484
+	/**
485
+	 *        get Attendee Email Address
486
+	 *
487
+	 * @return string
488
+	 */
489
+	public function email()
490
+	{
491
+		return $this->get('ATT_email');
492
+	}
493
+
494
+
495
+	/**
496
+	 *        get Attendee Phone #
497
+	 *
498
+	 * @return string
499
+	 */
500
+	public function phone()
501
+	{
502
+		return $this->get('ATT_phone');
503
+	}
504
+
505
+
506
+	/**
507
+	 *    get deleted
508
+	 *
509
+	 * @return        bool
510
+	 */
511
+	public function deleted()
512
+	{
513
+		return $this->get('ATT_deleted');
514
+	}
515
+
516
+
517
+	/**
518
+	 * Gets registrations of this attendee
519
+	 *
520
+	 * @param array $query_params
521
+	 * @return EE_Registration[]
522
+	 */
523
+	public function get_registrations($query_params = array())
524
+	{
525
+		return $this->get_many_related('Registration', $query_params);
526
+	}
527
+
528
+
529
+	/**
530
+	 * Gets the most recent registration of this attendee
531
+	 *
532
+	 * @return EE_Registration
533
+	 */
534
+	public function get_most_recent_registration()
535
+	{
536
+		return $this->get_first_related('Registration',
537
+			array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K');
538
+	}
539
+
540
+
541
+	/**
542
+	 * Gets the most recent registration for this attend at this event
543
+	 *
544
+	 * @param int $event_id
545
+	 * @return EE_Registration
546
+	 */
547
+	public function get_most_recent_registration_for_event($event_id)
548
+	{
549
+		return $this->get_first_related('Registration',
550
+			array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' );
551
+	}
552
+
553
+
554
+	/**
555
+	 * returns any events attached to this attendee ($_Event property);
556
+	 *
557
+	 * @return array
558
+	 */
559
+	public function events()
560
+	{
561
+		return $this->get_many_related('Event');
562
+	}
563
+
564
+
565
+	/**
566
+	 * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
567
+	 * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
568
+	 * used to save the billing info
569
+	 *
570
+	 * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
571
+	 * @return EE_Form_Section_Proper|null
572
+	 */
573
+	public function billing_info_for_payment_method($payment_method)
574
+	{
575
+		$pm_type = $payment_method->type_obj();
576
+		if (! $pm_type instanceof EE_PMT_Base) {
577
+			return null;
578
+		}
579
+		$billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
580
+		if (! $billing_info) {
581
+			return null;
582
+		}
583
+		$billing_form = $pm_type->billing_form();
584
+		if ($billing_form instanceof EE_Form_Section_Proper) {
585
+			$billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
586
+		}
587
+		return $billing_form;
588
+	}
589
+
590
+
591
+	/**
592
+	 * Gets the postmeta key that holds this attendee's billing info for the
593
+	 * specified payment method
594
+	 *
595
+	 * @param EE_Payment_Method $payment_method
596
+	 * @return string
597
+	 */
598
+	public function get_billing_info_postmeta_name($payment_method)
599
+	{
600
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
601
+			return 'billing_info_' . $payment_method->type_obj()->system_name();
602
+		} else {
603
+			return null;
604
+		}
605
+	}
606
+
607
+
608
+	/**
609
+	 * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
610
+	 * retrieve it
611
+	 *
612
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
613
+	 * @param EE_Payment_Method             $payment_method
614
+	 * @return boolean
615
+	 */
616
+	public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
617
+	{
618
+		if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
619
+			EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
620
+			return false;
621
+		}
622
+		$billing_form->clean_sensitive_data();
623
+		return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method),
624
+			$billing_form->input_values(true));
625
+	}
626
+
627
+
628
+	/**
629
+	 * Return the link to the admin details for the object.
630
+	 *
631
+	 * @return string
632
+	 */
633
+	public function get_admin_details_link()
634
+	{
635
+		return $this->get_admin_edit_link();
636
+	}
637
+
638
+
639
+	/**
640
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
641
+	 *
642
+	 * @return string
643
+	 */
644
+	public function get_admin_edit_link()
645
+	{
646
+		EE_Registry::instance()->load_helper('URL');
647
+		return EEH_URL::add_query_args_and_nonce(
648
+			array(
649
+				'page'   => 'espresso_registrations',
650
+				'action' => 'edit_attendee',
651
+				'post'   => $this->ID(),
652
+			),
653
+			admin_url('admin.php')
654
+		);
655
+	}
656
+
657
+
658
+	/**
659
+	 * Returns the link to a settings page for the object.
660
+	 *
661
+	 * @return string
662
+	 */
663
+	public function get_admin_settings_link()
664
+	{
665
+		return $this->get_admin_edit_link();
666
+	}
667
+
668
+
669
+	/**
670
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
671
+	 *
672
+	 * @return string
673
+	 */
674
+	public function get_admin_overview_link()
675
+	{
676
+		EE_Registry::instance()->load_helper('URL');
677
+		return EEH_URL::add_query_args_and_nonce(
678
+			array(
679
+				'page'   => 'espresso_registrations',
680
+				'action' => 'contact_list',
681
+			),
682
+			admin_url('admin.php')
683
+		);
684
+	}
685 685
 
686 686
 
687 687
 }
Please login to merge, or discard this patch.