Completed
Branch BUG-8698-ticket-sellouts (6f3040)
by
unknown
12:05 queued 10s
created
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -588,6 +588,7 @@  discard block
 block discarded – undo
588 588
 	 * @param EE_Registration $registration
589 589
 	 * @param EE_Question     $question
590 590
 	 * @param                 mixed EE_Answer|NULL      $answer
591
+	 * @param EE_Answer $answer
591 592
 	 * @return EE_Form_Input_Base
592 593
 	 * @throws \EE_Error
593 594
 	 */
@@ -1190,7 +1191,7 @@  discard block
 block discarded – undo
1190 1191
 	 *
1191 1192
 	 * @param EE_Registration $registration
1192 1193
 	 * @param array           $attendee_data
1193
-	 * @return boolean|EE_Attendee
1194
+	 * @return EE_Attendee
1194 1195
 	 * @throws \EE_Error
1195 1196
 	 */
1196 1197
 	private function _find_existing_attendee( EE_Registration $registration, $attendee_data = array() ) {
Please login to merge, or discard this patch.
Spacing   +230 added lines, -231 removed lines patch added patch discarded remove patch
@@ -41,21 +41,21 @@  discard block
 block discarded – undo
41 41
 	 * @access    public
42 42
 	 * @param    EE_Checkout $checkout
43 43
 	 */
44
-	public function __construct( EE_Checkout $checkout ) {
44
+	public function __construct(EE_Checkout $checkout) {
45 45
 		$this->_slug = 'attendee_information';
46 46
 		$this->_name = __('Attendee Information', 'event_espresso');
47
-		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
47
+		$this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php';
48 48
 		$this->checkout = $checkout;
49 49
 		$this->_reset_success_message();
50 50
 		$this->set_instructions(
51
-			__( 'Please answer the following registration questions before proceeding.', 'event_espresso' )
51
+			__('Please answer the following registration questions before proceeding.', 'event_espresso')
52 52
 		);
53 53
 	}
54 54
 
55 55
 
56 56
 
57 57
 	public function translate_js_strings() {
58
-		EE_Registry::$i18n_js_strings['required_field'] = __( ' is a required question.', 'event_espresso' );
58
+		EE_Registry::$i18n_js_strings['required_field'] = __(' is a required question.', 'event_espresso');
59 59
 		EE_Registry::$i18n_js_strings['required_multi_field'] = __(
60 60
 			' is a required question. Please enter a value for at least one of the options.',
61 61
 			'event_espresso'
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		// calculate taxes
116 116
 		$Line_Item_Display->display_line_item(
117 117
 			$this->checkout->cart->get_grand_total(),
118
-			array( 'set_tax_rate' => true )
118
+			array('set_tax_rate' => true)
119 119
 		);
120 120
 		/** @var $subsections EE_Form_Section_Proper[] */
121 121
 		$subsections = array(
@@ -127,51 +127,51 @@  discard block
 block discarded – undo
127 127
 			'ticket_count' 	=> array()
128 128
 		);
129 129
 		// grab the saved registrations from the transaction
130
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
131
-		if ( $registrations ) {
132
-			foreach ( $registrations as $registration ) {
130
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
131
+		if ($registrations) {
132
+			foreach ($registrations as $registration) {
133 133
 				// can this registration be processed during this visit ?
134 134
 				if (
135 135
 					$registration instanceof EE_Registration
136
-					&& $this->checkout->visit_allows_processing_of_this_registration( $registration )
136
+					&& $this->checkout->visit_allows_processing_of_this_registration($registration)
137 137
 				) {
138
-					$subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form( $registration );
139
-					if ( ! $this->checkout->admin_request ) {
140
-						$template_args['registrations'][ $registration->reg_url_link() ] = $registration;
141
-						$template_args['ticket_count'][ $registration->ticket()->ID() ] = isset(
142
-							$template_args['ticket_count'][ $registration->ticket()->ID() ]
138
+					$subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
139
+					if ( ! $this->checkout->admin_request) {
140
+						$template_args['registrations'][$registration->reg_url_link()] = $registration;
141
+						$template_args['ticket_count'][$registration->ticket()->ID()] = isset(
142
+							$template_args['ticket_count'][$registration->ticket()->ID()]
143 143
 						)
144
-							? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1
144
+							? $template_args['ticket_count'][$registration->ticket()->ID()] + 1
145 145
 							: 1;
146 146
 						$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
147 147
 							$this->checkout->cart->get_grand_total(),
148 148
 							'Ticket',
149
-							array( $registration->ticket()->ID() )
149
+							array($registration->ticket()->ID())
150 150
 						);
151
-						$ticket_line_item = is_array( $ticket_line_item )
152
-							? reset( $ticket_line_item )
151
+						$ticket_line_item = is_array($ticket_line_item)
152
+							? reset($ticket_line_item)
153 153
 							: $ticket_line_item;
154
-						$template_args['ticket_line_item'][ $registration->ticket()->ID() ] = $Line_Item_Display->display_line_item(
154
+						$template_args['ticket_line_item'][$registration->ticket()->ID()] = $Line_Item_Display->display_line_item(
155 155
 							$ticket_line_item
156 156
 						);
157 157
 					}
158
-					if ( $registration->is_primary_registrant() ) {
158
+					if ($registration->is_primary_registrant()) {
159 159
 						$primary_registrant = $registration->reg_url_link();
160 160
 					}
161 161
 				}
162 162
 			}
163 163
 			// print_copy_info ?
164
-			if ( $primary_registrant && ! $this->checkout->admin_request && count( $registrations ) > 1 ) {
164
+			if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) {
165 165
 				// TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info
166 166
 				$copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
167 167
 					? $this->_copy_attendee_info_form()
168 168
 					: $this->_auto_copy_attendee_info();
169 169
 				// generate hidden input
170 170
 				if (
171
-					isset( $subsections[ $primary_registrant ] )
172
-				     && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
171
+					isset($subsections[$primary_registrant])
172
+				     && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper
173 173
 				) {
174
-					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
174
+					$subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false);
175 175
 				}
176 176
 			}
177 177
 
@@ -183,8 +183,7 @@  discard block
 block discarded – undo
183 183
 				'html_id' 					=> $this->reg_form_name(),
184 184
 				'subsections' 			=> $subsections,
185 185
 				'layout_strategy'		=> $this->checkout->admin_request ?
186
-					new EE_Div_Per_Section_Layout() :
187
-					new EE_Template_Layout(
186
+					new EE_Div_Per_Section_Layout() : new EE_Template_Layout(
188 187
 						array(
189 188
 							'layout_template_file' 	=> $this->_template, // layout_template
190 189
 							'template_args' 				=> $template_args
@@ -202,11 +201,11 @@  discard block
 block discarded – undo
202 201
 	 * @return EE_Form_Section_Proper
203 202
 	 * @throws \EE_Error
204 203
 	 */
205
-	private function _registrations_reg_form( EE_Registration $registration ) {
204
+	private function _registrations_reg_form(EE_Registration $registration) {
206 205
 		static $attendee_nmbr = 1;
207 206
 		// array of params to pass to parent constructor
208 207
 		$form_args = array(
209
-			'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
208
+			'html_id'         => 'ee-registration-'.$registration->reg_url_link(),
210 209
 			'html_class'      => 'ee-reg-form-attendee-dv',
211 210
 			'html_style'      => $this->checkout->admin_request
212 211
 				? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
@@ -215,24 +214,24 @@  discard block
 block discarded – undo
215 214
 			'layout_strategy' => new EE_Fieldset_Section_Layout(
216 215
 				array(
217 216
 					'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
218
-					'legend_text'  => sprintf( __( 'Attendee %d', 'event_espresso' ), $attendee_nmbr )
217
+					'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr)
219 218
 				)
220 219
 			)
221 220
 		);
222 221
 		// verify that registration has valid event
223
-		if ( $registration->event() instanceof EE_Event ) {
222
+		if ($registration->event() instanceof EE_Event) {
224 223
 			$query_params = array(
225 224
 				array(
226 225
 					'Event.EVT_ID' => $registration->event()->ID(),
227 226
 					'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false
228 227
 				),
229
-				'order_by'=>array( 'QSG_order'=>'ASC' )
228
+				'order_by'=>array('QSG_order'=>'ASC')
230 229
 			);
231
-			$question_groups = $registration->event()->question_groups( $query_params );
232
-			if ( $question_groups ) {
233
-				foreach ( $question_groups as $question_group ) {
234
-					if ( $question_group instanceof EE_Question_Group ) {
235
-						$form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
230
+			$question_groups = $registration->event()->question_groups($query_params);
231
+			if ($question_groups) {
232
+				foreach ($question_groups as $question_group) {
233
+					if ($question_group instanceof EE_Question_Group) {
234
+						$form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form(
236 235
 							$registration,
237 236
 							$question_group
238 237
 						);
@@ -245,10 +244,10 @@  discard block
 block discarded – undo
245 244
 				// if we have question groups for additional attendees, then display the copy options
246 245
 				$this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info;
247 246
 			} else {
248
-				$form_args['subsections'][ 'attendee_info_not_required_' . $registration->reg_url_link(
249
-				) ] = new EE_Form_Section_HTML(
247
+				$form_args['subsections']['attendee_info_not_required_'.$registration->reg_url_link(
248
+				)] = new EE_Form_Section_HTML(
250 249
 					EEH_Template::locate_template(
251
-						SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_not_required.template.php',
250
+						SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_not_required.template.php',
252 251
 						apply_filters(
253 252
 							'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__attendee_info_not_required_template_args',
254 253
 							array()
@@ -267,12 +266,12 @@  discard block
 block discarded – undo
267 266
 
268 267
 			}
269 268
 		}
270
-		if ( $registration->is_primary_registrant() ) {
269
+		if ($registration->is_primary_registrant()) {
271 270
 			// generate hidden input
272
-			$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( $registration );
271
+			$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration);
273 272
 		}
274 273
 		$attendee_nmbr++;
275
-		return new EE_Form_Section_Proper( $form_args );
274
+		return new EE_Form_Section_Proper($form_args);
276 275
 	}
277 276
 
278 277
 
@@ -293,7 +292,7 @@  discard block
 block discarded – undo
293 292
 		// generate hidden input
294 293
 		return new EE_Hidden_Input(
295 294
 			array(
296
-				'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
295
+				'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(),
297 296
 				'default' => $additional_attendee_reg_info
298 297
 			)
299 298
 		);
@@ -307,26 +306,26 @@  discard block
 block discarded – undo
307 306
 	 * @return EE_Form_Section_Proper
308 307
 	 * @throws \EE_Error
309 308
 	 */
310
-	private function _question_group_reg_form( EE_Registration $registration, EE_Question_Group $question_group ){
309
+	private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) {
311 310
 		// array of params to pass to parent constructor
312 311
 		$form_args = array(
313
-			'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
312
+			'html_id'         => 'ee-reg-form-qstn-grp-'.$question_group->identifier(),
314 313
 			'html_class'      => $this->checkout->admin_request
315 314
 				? 'form-table ee-reg-form-qstn-grp-dv'
316 315
 				: 'ee-reg-form-qstn-grp-dv',
317
-			'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
316
+			'html_label_id'   => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl',
318 317
 			'subsections'     => array(
319
-				'reg_form_qstn_grp_hdr' => $this->_question_group_header( $question_group )
318
+				'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group)
320 319
 			),
321 320
 			'layout_strategy' => $this->checkout->admin_request
322 321
 				? new EE_Admin_Two_Column_Layout()
323 322
 				: new EE_Div_Per_Section_Layout()
324 323
 		);
325 324
 		// where params
326
-		$query_params = array( 'QST_deleted' => 0 );
325
+		$query_params = array('QST_deleted' => 0);
327 326
 		// don't load admin only questions on the frontend
328
-		if ( ! $this->checkout->admin_request ) {
329
-			$query_params['QST_admin_only'] = array( '!=', true );
327
+		if ( ! $this->checkout->admin_request) {
328
+			$query_params['QST_admin_only'] = array('!=', true);
330 329
 		}
331 330
 		$questions = $question_group->get_many_related(
332 331
 			'Question',
@@ -348,10 +347,10 @@  discard block
 block discarded – undo
348 347
 			)
349 348
 		);
350 349
 		// loop thru questions
351
-		foreach ( $questions as $question ) {
352
-			if( $question instanceof EE_Question ){
350
+		foreach ($questions as $question) {
351
+			if ($question instanceof EE_Question) {
353 352
 				$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
354
-				$form_args['subsections'][ $identifier ] = $this->reg_form_question( $registration, $question );
353
+				$form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question);
355 354
 			}
356 355
 		}
357 356
 		$form_args['subsections'] = apply_filters(
@@ -372,7 +371,7 @@  discard block
 block discarded – undo
372 371
 			)
373 372
 		);
374 373
 //		d( $form_args );
375
-		$question_group_reg_form = new EE_Form_Section_Proper( $form_args );
374
+		$question_group_reg_form = new EE_Form_Section_Proper($form_args);
376 375
 		return apply_filters(
377 376
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
378 377
 			$question_group_reg_form,
@@ -389,11 +388,11 @@  discard block
 block discarded – undo
389 388
 	 * @param EE_Question_Group $question_group
390 389
 	 * @return 	EE_Form_Section_HTML
391 390
 	 */
392
-	private function _question_group_header( EE_Question_Group $question_group ){
391
+	private function _question_group_header(EE_Question_Group $question_group) {
393 392
 		$html = '';
394 393
 		// group_name
395
-		if ( $question_group->show_group_name() && $question_group->name() !== '' ) {
396
-			if ( $this->checkout->admin_request ) {
394
+		if ($question_group->show_group_name() && $question_group->name() !== '') {
395
+			if ($this->checkout->admin_request) {
397 396
 				$html .= EEH_HTML::br();
398 397
 				$html .= EEH_HTML::h3(
399 398
 					$question_group->name(),
@@ -407,7 +406,7 @@  discard block
 block discarded – undo
407 406
 			}
408 407
 		}
409 408
 		// group_desc
410
-		if ( $question_group->show_group_desc() && $question_group->desc() !== '' ) {
409
+		if ($question_group->show_group_desc() && $question_group->desc() !== '') {
411 410
 			$html .= EEH_HTML::p(
412 411
 				$question_group->desc(),
413 412
 				'',
@@ -417,7 +416,7 @@  discard block
 block discarded – undo
417 416
 			);
418 417
 
419 418
 		}
420
-		return new EE_Form_Section_HTML( $html );
419
+		return new EE_Form_Section_HTML($html);
421 420
 	}
422 421
 
423 422
 
@@ -427,7 +426,7 @@  discard block
 block discarded – undo
427 426
 	 * @return    EE_Form_Section_Proper
428 427
 	 * @throws \EE_Error
429 428
 	 */
430
-	private function _copy_attendee_info_form(){
429
+	private function _copy_attendee_info_form() {
431 430
 		// array of params to pass to parent constructor
432 431
 		return new EE_Form_Section_Proper(
433 432
 			array(
@@ -456,7 +455,7 @@  discard block
 block discarded – undo
456 455
 	private function _auto_copy_attendee_info() {
457 456
 		return new EE_Form_Section_HTML(
458 457
 			EEH_Template::locate_template(
459
-				SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
458
+				SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php',
460 459
 				apply_filters(
461 460
 					'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
462 461
 					array()
@@ -480,32 +479,32 @@  discard block
 block discarded – undo
480 479
 		$copy_attendee_info_inputs = array();
481 480
 		$prev_ticket = NULL;
482 481
 		// grab the saved registrations from the transaction
483
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
484
-		foreach ( $registrations as $registration ) {
482
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
483
+		foreach ($registrations as $registration) {
485 484
 			// for all  attendees other than the primary attendee
486
-			if ( $registration instanceof EE_Registration && ! $registration->is_primary_registrant() ) {
485
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
487 486
 				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
488
-				if ( $registration->ticket()->ID() !== $prev_ticket ) {
487
+				if ($registration->ticket()->ID() !== $prev_ticket) {
489 488
 					$item_name = $registration->ticket()->name();
490 489
 					$item_name .= $registration->ticket()->description() !== ''
491
-						? ' - ' . $registration->ticket()->description()
490
+						? ' - '.$registration->ticket()->description()
492 491
 						: '';
493
-					$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = new EE_Form_Section_HTML(
494
-						'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
492
+					$copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = new EE_Form_Section_HTML(
493
+						'<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>'
495 494
 					);
496 495
 					$prev_ticket = $registration->ticket()->ID();
497 496
 				}
498 497
 
499
-				$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = new
498
+				$copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = new
500 499
 				EE_Checkbox_Multi_Input(
501 500
 					array(
502 501
 						$registration->ID() => sprintf(
503
-							__( 'Attendee #%s', 'event_espresso' ),
502
+							__('Attendee #%s', 'event_espresso'),
504 503
 							$registration->count()
505 504
 						)
506 505
 					),
507 506
 					array(
508
-						'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
507
+						'html_id'                 => 'spco-copy-attendee-chk-'.$registration->reg_url_link(),
509 508
 						'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
510 509
 						'display_html_label_text' => false
511 510
 					)
@@ -525,7 +524,7 @@  discard block
 block discarded – undo
525 524
 	 * @return    EE_Form_Input_Base
526 525
 	 * @throws \EE_Error
527 526
 	 */
528
-	private function _additional_primary_registrant_inputs( EE_Registration $registration ){
527
+	private function _additional_primary_registrant_inputs(EE_Registration $registration) {
529 528
 		// generate hidden input
530 529
 		return new EE_Hidden_Input(
531 530
 			array(
@@ -544,7 +543,7 @@  discard block
 block discarded – undo
544 543
 	 * @return    EE_Form_Input_Base
545 544
 	 * @throws \EE_Error
546 545
 	 */
547
-	public function reg_form_question( EE_Registration $registration, EE_Question $question ){
546
+	public function reg_form_question(EE_Registration $registration, EE_Question $question) {
548 547
 
549 548
 		// if this question was for an attendee detail, then check for that answer
550 549
 		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
@@ -553,32 +552,32 @@  discard block
 block discarded – undo
553 552
 		);
554 553
 		$answer = $answer_value === null
555 554
 			? EEM_Answer::instance()->get_one(
556
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
555
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
557 556
 			)
558 557
 			: null;
559 558
 		// if NOT returning to edit an existing registration
560 559
 		// OR if this question is for an attendee property
561 560
 		// OR we still don't have an EE_Answer object
562
-		if( $answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link() ) {
561
+		if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
563 562
 			// create an EE_Answer object for storing everything in
564
-			$answer = EE_Answer::new_instance ( array(
563
+			$answer = EE_Answer::new_instance(array(
565 564
 				'QST_ID'=> $question->ID(),
566 565
 				'REG_ID'=> $registration->ID()
567 566
 			));
568 567
 		}
569 568
 		// verify instance
570
-		if( $answer instanceof EE_Answer ){
571
-			if ( ! empty( $answer_value )) {
572
-				$answer->set( 'ANS_value', $answer_value );
569
+		if ($answer instanceof EE_Answer) {
570
+			if ( ! empty($answer_value)) {
571
+				$answer->set('ANS_value', $answer_value);
573 572
 			}
574
-			$answer->cache( 'Question', $question );
573
+			$answer->cache('Question', $question);
575 574
 			//remember system ID had a bug where sometimes it could be null
576
-			$answer_cache_id =$question->is_system_question()
577
-				? $question->system_ID() . '-' . $registration->reg_url_link()
578
-				: $question->ID() . '-' . $registration->reg_url_link();
579
-			$registration->cache( 'Answer', $answer, $answer_cache_id );
575
+			$answer_cache_id = $question->is_system_question()
576
+				? $question->system_ID().'-'.$registration->reg_url_link()
577
+				: $question->ID().'-'.$registration->reg_url_link();
578
+			$registration->cache('Answer', $answer, $answer_cache_id);
580 579
 		}
581
-		return $this->_generate_question_input( $registration, $question, $answer );
580
+		return $this->_generate_question_input($registration, $question, $answer);
582 581
 
583 582
 	}
584 583
 
@@ -591,46 +590,46 @@  discard block
 block discarded – undo
591 590
 	 * @return EE_Form_Input_Base
592 591
 	 * @throws \EE_Error
593 592
 	 */
594
-	private function _generate_question_input( EE_Registration $registration, EE_Question $question, $answer ){
593
+	private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) {
595 594
 		$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
596
-		$this->_required_questions[ $identifier ] = $question->required() ? true : false;
595
+		$this->_required_questions[$identifier] = $question->required() ? true : false;
597 596
 		add_filter(
598 597
 			'FHEE__EE_Question__generate_form_input__country_options',
599
-			array( $this, 'use_cached_countries_for_form_input' ),
598
+			array($this, 'use_cached_countries_for_form_input'),
600 599
 			10,
601 600
 			4
602 601
 		);
603 602
 		add_filter(
604 603
 			'FHEE__EE_Question__generate_form_input__state_options',
605
-			array( $this, 'use_cached_states_for_form_input' ),
604
+			array($this, 'use_cached_states_for_form_input'),
606 605
 			10,
607 606
 			4
608 607
 		);
609 608
 		$input_constructor_args = array(
610
-			'html_name'     => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
611
-			'html_id'       => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
612
-			'html_class'    => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
613
-			'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
609
+			'html_name'     => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']',
610
+			'html_id'       => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
611
+			'html_class'    => 'ee-reg-qstn ee-reg-qstn-'.$identifier,
612
+			'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
614 613
 			'html_label_class'	=> 'ee-reg-qstn',
615 614
 		);
616
-		$input_constructor_args['html_label_id'] 	.= '-lbl';
617
-		if ( $answer instanceof EE_Answer && $answer->ID() ) {
618
-			$input_constructor_args[ 'html_name' ] .= '[' . $answer->ID() . ']';
619
-			$input_constructor_args[ 'html_id' ] .= '-' . $answer->ID();
620
-			$input_constructor_args[ 'html_label_id' ] .= '-' . $answer->ID();
615
+		$input_constructor_args['html_label_id'] .= '-lbl';
616
+		if ($answer instanceof EE_Answer && $answer->ID()) {
617
+			$input_constructor_args['html_name'] .= '['.$answer->ID().']';
618
+			$input_constructor_args['html_id'] .= '-'.$answer->ID();
619
+			$input_constructor_args['html_label_id'] .= '-'.$answer->ID();
621 620
 		}
622
-		$form_input =  $question->generate_form_input(
621
+		$form_input = $question->generate_form_input(
623 622
 			$registration,
624 623
 			$answer,
625 624
 			$input_constructor_args
626 625
 		);
627 626
 		remove_filter(
628 627
 			'FHEE__EE_Question__generate_form_input__country_options',
629
-			array( $this, 'use_cached_countries_for_form_input' )
628
+			array($this, 'use_cached_countries_for_form_input')
630 629
 		);
631 630
 		remove_filter(
632 631
 			'FHEE__EE_Question__generate_form_input__state_options',
633
-			array( $this, 'use_cached_states_for_form_input' )
632
+			array($this, 'use_cached_states_for_form_input')
634 633
 		);
635 634
 		return $form_input;
636 635
 	}
@@ -652,22 +651,22 @@  discard block
 block discarded – undo
652 651
 		\EE_Registration $registration = null,
653 652
 		\EE_Answer $answer = null
654 653
 	) {
655
-		$country_options = array( '' => '' );
654
+		$country_options = array('' => '');
656 655
 		// get possibly cached list of countries
657 656
 		$countries = $this->checkout->action === 'process_reg_step'
658 657
 			? EEM_Country::instance()->get_all_countries()
659 658
 			: EEM_Country::instance()->get_all_active_countries();
660
-		if ( ! empty( $countries )) {
661
-			foreach( $countries as $country ){
662
-				if ( $country instanceof EE_Country ) {
663
-					$country_options[ $country->ID() ] = $country->name();
659
+		if ( ! empty($countries)) {
660
+			foreach ($countries as $country) {
661
+				if ($country instanceof EE_Country) {
662
+					$country_options[$country->ID()] = $country->name();
664 663
 				}
665 664
 			}
666 665
 		}
667
-		if( $question instanceof EE_Question
668
-			&& $registration instanceof EE_Registration ) {
666
+		if ($question instanceof EE_Question
667
+			&& $registration instanceof EE_Registration) {
669 668
 			$answer = EEM_Answer::instance()->get_one(
670
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
669
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
671 670
 			);
672 671
 		} else {
673 672
 			$answer = EE_Answer::new_instance();
@@ -700,14 +699,14 @@  discard block
 block discarded – undo
700 699
 		\EE_Registration $registration = null,
701 700
 		\EE_Answer $answer = null
702 701
 	) {
703
-		$state_options = array( '' => array( '' => ''));
702
+		$state_options = array('' => array('' => ''));
704 703
 		$states = $this->checkout->action === 'process_reg_step'
705 704
 			? EEM_State::instance()->get_all_states()
706 705
 			: EEM_State::instance()->get_all_active_states();
707
-		if ( ! empty( $states )) {
708
-			foreach( $states as $state ){
709
-				if ( $state instanceof EE_State ) {
710
-					$state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
706
+		if ( ! empty($states)) {
707
+			foreach ($states as $state) {
708
+				if ($state instanceof EE_State) {
709
+					$state_options[$state->country()->name()][$state->ID()] = $state->name();
711 710
 				}
712 711
 			}
713 712
 		}
@@ -735,24 +734,24 @@  discard block
 block discarded – undo
735 734
 	 * @throws \EE_Error
736 735
 	 */
737 736
 	public function process_reg_step() {
738
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
737
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
739 738
 		// grab validated data from form
740 739
 		$valid_data = $this->checkout->current_step->valid_data();
741 740
 		// EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
742 741
 		// EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
743 742
 		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
744
-		if ( empty( $valid_data ))  {
743
+		if (empty($valid_data)) {
745 744
 			EE_Error::add_error(
746
-				__( 'No valid question responses were received.', 'event_espresso' ),
745
+				__('No valid question responses were received.', 'event_espresso'),
747 746
 				__FILE__,
748 747
 				__FUNCTION__,
749 748
 				__LINE__
750 749
 			);
751 750
 			return false;
752 751
 		}
753
-		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg ) {
752
+		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
754 753
 			EE_Error::add_error(
755
-				__( 'A valid transaction could not be initiated for processing your registrations.', 'event_espresso' ),
754
+				__('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'),
756 755
 				__FILE__,
757 756
 				__FUNCTION__,
758 757
 				__LINE__
@@ -760,11 +759,11 @@  discard block
 block discarded – undo
760 759
 			return false;
761 760
 		}
762 761
 		// get cached registrations
763
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
762
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
764 763
 		// verify we got the goods
765
-		if ( empty( $registrations )) {
764
+		if (empty($registrations)) {
766 765
 			EE_Error::add_error(
767
-				__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ),
766
+				__('Your form data could not be applied to any valid registrations.', 'event_espresso'),
768 767
 				__FILE__,
769 768
 				__FUNCTION__,
770 769
 				__LINE__
@@ -772,15 +771,15 @@  discard block
 block discarded – undo
772 771
 			return false;
773 772
 		}
774 773
 		// extract attendee info from form data and save to model objects
775
-		$registrations_processed = $this->_process_registrations( $registrations, $valid_data );
774
+		$registrations_processed = $this->_process_registrations($registrations, $valid_data);
776 775
 		// if first pass thru SPCO,
777 776
 		// then let's check processed registrations against the total number of tickets in the cart
778
-		if ( $registrations_processed === false ) {
777
+		if ($registrations_processed === false) {
779 778
 			// but return immediately if the previous step exited early due to errors
780 779
 			return false;
781
-		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count ) {
780
+		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
782 781
 			// generate a correctly translated string for all possible singular/plural combinations
783
-			if ( $this->checkout->total_ticket_count === 1 && $registrations_processed !== 1 ) {
782
+			if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
784 783
 				$error_msg = sprintf(
785 784
 					__(
786 785
 						'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
@@ -789,7 +788,7 @@  discard block
 block discarded – undo
789 788
 					$this->checkout->total_ticket_count,
790 789
 					$registrations_processed
791 790
 				);
792
-			} else if ( $this->checkout->total_ticket_count !== 1 && $registrations_processed === 1 ) {
791
+			} else if ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
793 792
 				$error_msg = sprintf(
794 793
 					__(
795 794
 						'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
@@ -808,17 +807,17 @@  discard block
 block discarded – undo
808 807
 					$registrations_processed
809 808
 				);
810 809
 			}
811
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
810
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
812 811
 			return false;
813 812
 		}
814 813
 		// mark this reg step as completed
815 814
 		$this->set_completed();
816 815
 		$this->_set_success_message(
817
-			__( 'The Attendee Information Step has been successfully completed.', 'event_espresso' )
816
+			__('The Attendee Information Step has been successfully completed.', 'event_espresso')
818 817
 		);
819 818
 		//do action in case a plugin wants to do something with the data submitted in step 1.
820 819
 		//passes EE_Single_Page_Checkout, and it's posted data
821
-		do_action( 'AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data );
820
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
822 821
 		return true;
823 822
 	}
824 823
 
@@ -832,9 +831,9 @@  discard block
 block discarded – undo
832 831
 	 * @return boolean | int
833 832
 	 * @throws \EE_Error
834 833
 	 */
835
-	private function _process_registrations( $registrations = array(), $valid_data = array() ) {
834
+	private function _process_registrations($registrations = array(), $valid_data = array()) {
836 835
 		// load resources and set some defaults
837
-		EE_Registry::instance()->load_model( 'Attendee' );
836
+		EE_Registry::instance()->load_model('Attendee');
838 837
 		// holder for primary registrant attendee object
839 838
 		$this->checkout->primary_attendee_obj = NULL;
840 839
 		// array for tracking reg form data for the primary registrant
@@ -851,9 +850,9 @@  discard block
 block discarded – undo
851 850
 		// attendee counter
852 851
 		$att_nmbr = 0;
853 852
 		// grab the saved registrations from the transaction
854
-		foreach ( $registrations  as $registration ) {
853
+		foreach ($registrations  as $registration) {
855 854
 			// verify EE_Registration object
856
-			if ( ! $registration instanceof EE_Registration ) {
855
+			if ( ! $registration instanceof EE_Registration) {
857 856
 				EE_Error::add_error(
858 857
 					__(
859 858
 						'An invalid Registration object was discovered when attempting to process your registration information.',
@@ -868,12 +867,12 @@  discard block
 block discarded – undo
868 867
 			/** @var string $reg_url_link */
869 868
 			$reg_url_link = $registration->reg_url_link();
870 869
 			// reg_url_link exists ?
871
-			if ( ! empty( $reg_url_link ) ) {
870
+			if ( ! empty($reg_url_link)) {
872 871
 				// should this registration be processed during this visit ?
873
-				if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) {
872
+				if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
874 873
 					// if NOT revisiting, then let's save the registration now,
875 874
 					// so that we have a REG_ID to use when generating other objects
876
-					if ( ! $this->checkout->revisit ) {
875
+					if ( ! $this->checkout->revisit) {
877 876
 						$registration->save();
878 877
 					}
879 878
 					/**
@@ -883,7 +882,7 @@  discard block
 block discarded – undo
883 882
 					 * @var bool   if true is returned by the plugin then the
884 883
 					 *      		registration processing is halted.
885 884
 					 */
886
-					if ( apply_filters(
885
+					if (apply_filters(
887 886
 						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
888 887
 						false,
889 888
 						$att_nmbr,
@@ -891,38 +890,38 @@  discard block
 block discarded – undo
891 890
 						$registrations,
892 891
 						$valid_data,
893 892
 						$this
894
-					) ) {
893
+					)) {
895 894
 						return false;
896 895
 					}
897 896
 
898 897
 					// Houston, we have a registration!
899 898
 					$att_nmbr++;
900
-					$this->_attendee_data[ $reg_url_link ] = array();
899
+					$this->_attendee_data[$reg_url_link] = array();
901 900
 					// grab any existing related answer objects
902 901
 					$this->_registration_answers = $registration->answers();
903 902
 					// unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
904
-					if ( isset( $valid_data[ $reg_url_link ] ) ) {
903
+					if (isset($valid_data[$reg_url_link])) {
905 904
 						// do we need to copy basic info from primary attendee ?
906
-						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] )
907
-						                && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
905
+						$copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info'])
906
+						                && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0
908 907
 							? true
909 908
 							: false;
910 909
 						// filter form input data for this registration
911
-						$valid_data[ $reg_url_link ] = (array)apply_filters(
910
+						$valid_data[$reg_url_link] = (array) apply_filters(
912 911
 							'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
913
-							$valid_data[ $reg_url_link ]
912
+							$valid_data[$reg_url_link]
914 913
 						);
915 914
 						// EEH_Debug_Tools::printr( $valid_data[ $reg_url_link ], '$valid_data[ $reg_url_link ]', __FILE__, __LINE__ );
916
-						if ( isset( $valid_data['primary_attendee'] )) {
917
-							$primary_registrant['line_item_id'] =  ! empty( $valid_data['primary_attendee'] )
915
+						if (isset($valid_data['primary_attendee'])) {
916
+							$primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
918 917
 								? $valid_data['primary_attendee']
919 918
 								: false;
920
-							unset( $valid_data['primary_attendee'] );
919
+							unset($valid_data['primary_attendee']);
921 920
 						}
922 921
 						// now loop through our array of valid post data && process attendee reg forms
923
-						foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) {
924
-							if ( ! in_array( $form_section, $non_input_form_sections )) {
925
-								foreach ( $form_inputs as $form_input => $input_value ) {
922
+						foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
923
+							if ( ! in_array($form_section, $non_input_form_sections)) {
924
+								foreach ($form_inputs as $form_input => $input_value) {
926 925
 									// \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
927 926
 									// check for critical inputs
928 927
 									if (
@@ -936,16 +935,16 @@  discard block
 block discarded – undo
936 935
 									// store a bit of data about the primary attendee
937 936
 									if (
938 937
 										$att_nmbr === 1
939
-										&& ! empty( $input_value )
938
+										&& ! empty($input_value)
940 939
 										&& $reg_url_link === $primary_registrant['line_item_id']
941 940
 									) {
942
-										$primary_registrant[ $form_input ] = $input_value;
941
+										$primary_registrant[$form_input] = $input_value;
943 942
 									} else if (
944 943
 										$copy_primary
945 944
 										&& $input_value === null
946
-										&& isset( $primary_registrant[ $form_input ] )
945
+										&& isset($primary_registrant[$form_input])
947 946
 									) {
948
-										$input_value = $primary_registrant[ $form_input ];
947
+										$input_value = $primary_registrant[$form_input];
949 948
 									}
950 949
 									// now attempt to save the input data
951 950
 									if (
@@ -987,55 +986,55 @@  discard block
 block discarded – undo
987 986
 						// have we met before?
988 987
 						$attendee = $this->_find_existing_attendee(
989 988
 							$registration,
990
-							$this->_attendee_data[ $reg_url_link ]
989
+							$this->_attendee_data[$reg_url_link]
991 990
 						);
992 991
 						// did we find an already existing record for this attendee ?
993
-						if ( $attendee instanceof EE_Attendee ) {
992
+						if ($attendee instanceof EE_Attendee) {
994 993
 							$attendee = $this->_update_existing_attendee_data(
995 994
 								$attendee,
996
-								$this->_attendee_data[ $reg_url_link ]
995
+								$this->_attendee_data[$reg_url_link]
997 996
 							);
998 997
 						} else {
999 998
 							// ensure critical details are set for additional attendees
1000
-							$this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1
999
+							$this->_attendee_data[$reg_url_link] = $att_nmbr > 1
1001 1000
 								? $this->_copy_critical_attendee_details_from_primary_registrant(
1002
-									$this->_attendee_data[ $reg_url_link ]
1001
+									$this->_attendee_data[$reg_url_link]
1003 1002
 								)
1004
-								: $this->_attendee_data[ $reg_url_link ];
1003
+								: $this->_attendee_data[$reg_url_link];
1005 1004
 							$attendee = $this->_create_new_attendee(
1006 1005
 								$registration,
1007
-								$this->_attendee_data[ $reg_url_link ]
1006
+								$this->_attendee_data[$reg_url_link]
1008 1007
 							);
1009 1008
 						}
1010 1009
 						// who's #1 ?
1011
-						if ( $att_nmbr === 1 ) {
1010
+						if ($att_nmbr === 1) {
1012 1011
 							$this->checkout->primary_attendee_obj = $attendee;
1013 1012
 						}
1014 1013
 					}
1015 1014
 					// EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1016 1015
 					// add relation to registration, set attendee ID, and cache attendee
1017
-					$this->_associate_attendee_with_registration( $registration, $attendee );
1016
+					$this->_associate_attendee_with_registration($registration, $attendee);
1018 1017
 					// \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1019
-					if ( ! $registration->attendee() instanceof EE_Attendee ) {
1020
-						EE_Error::add_error( sprintf( __( 'Registration %s has an invalid or missing Attendee object.', 'event_espresso' ), $reg_url_link ), __FILE__, __FUNCTION__, __LINE__ );
1018
+					if ( ! $registration->attendee() instanceof EE_Attendee) {
1019
+						EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $reg_url_link), __FILE__, __FUNCTION__, __LINE__);
1021 1020
 						return false;
1022 1021
 					}
1023 1022
 					/** @type EE_Registration_Processor $registration_processor */
1024
-					$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
1023
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1025 1024
 					// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
1026
-					$registration_processor->toggle_incomplete_registration_status_to_default( $registration, false );
1025
+					$registration_processor->toggle_incomplete_registration_status_to_default($registration, false);
1027 1026
 					// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
1028 1027
 					$this->checkout->transaction->toggle_failed_transaction_status();
1029 1028
 					// if we've gotten this far, then let's save what we have
1030 1029
 					$registration->save();
1031 1030
 					// add relation between TXN and registration
1032
-					$this->_associate_registration_with_transaction( $registration );
1031
+					$this->_associate_registration_with_transaction($registration);
1033 1032
 				} // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) {
1034 1033
 
1035
-			}  else {
1036
-				EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1034
+			} else {
1035
+				EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1037 1036
 				// remove malformed data
1038
-				unset( $valid_data[ $reg_url_link ] );
1037
+				unset($valid_data[$reg_url_link]);
1039 1038
 				return false;
1040 1039
 			}
1041 1040
 
@@ -1064,26 +1063,26 @@  discard block
 block discarded – undo
1064 1063
 		// \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1065 1064
 		// allow for plugins to hook in and do their own processing of the form input.
1066 1065
 		// For plugins to bypass normal processing here, they just need to return a boolean value.
1067
-		if ( apply_filters(
1066
+		if (apply_filters(
1068 1067
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1069 1068
 			false,
1070 1069
 			$registration,
1071 1070
 			$form_input,
1072 1071
 			$input_value,
1073 1072
 			$this
1074
-		) ) {
1073
+		)) {
1075 1074
 			return true;
1076 1075
 		}
1077 1076
 		// $answer_cache_id is the key used to find the EE_Answer we want
1078 1077
 		$answer_cache_id = $this->checkout->reg_url_link
1079 1078
 			? $form_input
1080
-			: $form_input . '-' . $registration->reg_url_link();
1081
-		$answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] )
1082
-		                 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1079
+			: $form_input.'-'.$registration->reg_url_link();
1080
+		$answer_is_obj = isset($this->_registration_answers[$answer_cache_id])
1081
+		                 && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer
1083 1082
 			? true
1084 1083
 			: false;
1085 1084
 		//rename form_inputs if they are EE_Attendee properties
1086
-		switch( (string)$form_input ) {
1085
+		switch ((string) $form_input) {
1087 1086
 
1088 1087
 			case 'state' :
1089 1088
 			case 'STA_ID' :
@@ -1098,32 +1097,32 @@  discard block
 block discarded – undo
1098 1097
 				break;
1099 1098
 
1100 1099
 			default :
1101
-				$ATT_input = 'ATT_' . $form_input;
1100
+				$ATT_input = 'ATT_'.$form_input;
1102 1101
 				//EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1103
-				$attendee_property = EEM_Attendee::instance()->has_field( $ATT_input ) ? true : false;
1104
-				$form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
1102
+				$attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1103
+				$form_input = $attendee_property ? 'ATT_'.$form_input : $form_input;
1105 1104
 		}
1106 1105
 		// EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1107 1106
 		// EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1108 1107
 		// EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1109 1108
 		// if this form input has a corresponding attendee property
1110
-		if ( $attendee_property ) {
1111
-			$this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
1112
-			if ( $answer_is_obj ) {
1109
+		if ($attendee_property) {
1110
+			$this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value;
1111
+			if ($answer_is_obj) {
1113 1112
 				// and delete the corresponding answer since we won't be storing this data in that object
1114
-				$registration->_remove_relation_to( $this->_registration_answers[ $answer_cache_id ], 'Answer' );
1115
-				$this->_registration_answers[ $answer_cache_id ]->delete_permanently();
1113
+				$registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer');
1114
+				$this->_registration_answers[$answer_cache_id]->delete_permanently();
1116 1115
 			}
1117 1116
 			return true;
1118
-		} elseif ( $answer_is_obj ) {
1117
+		} elseif ($answer_is_obj) {
1119 1118
 			// save this data to the answer object
1120
-			$this->_registration_answers[ $answer_cache_id ]->set_value( $input_value );
1121
-			$result = $this->_registration_answers[ $answer_cache_id ]->save();
1119
+			$this->_registration_answers[$answer_cache_id]->set_value($input_value);
1120
+			$result = $this->_registration_answers[$answer_cache_id]->save();
1122 1121
 			return $result !== false ? true : false;
1123 1122
 		} else {
1124
-			foreach ( $this->_registration_answers as $answer ) {
1125
-				if ( $answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id ) {
1126
-					$answer->set_value( $input_value );
1123
+			foreach ($this->_registration_answers as $answer) {
1124
+				if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1125
+					$answer->set_value($input_value);
1127 1126
 					$result = $answer->save();
1128 1127
 					return $result !== false ? true : false;
1129 1128
 				}
@@ -1145,15 +1144,15 @@  discard block
 block discarded – undo
1145 1144
 		$form_input = '',
1146 1145
 		$input_value = ''
1147 1146
 	) {
1148
-		if ( empty( $input_value ) ) {
1147
+		if (empty($input_value)) {
1149 1148
 			// if the form input isn't marked as being required, then just return
1150
-			if ( ! isset( $this->_required_questions[ $form_input ] ) || ! $this->_required_questions[ $form_input ] ) {
1149
+			if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1151 1150
 				return true;
1152 1151
 			}
1153
-			switch ( $form_input ) {
1152
+			switch ($form_input) {
1154 1153
 				case 'fname' :
1155 1154
 					EE_Error::add_error(
1156
-						__( 'First Name is a required value.', 'event_espresso' ),
1155
+						__('First Name is a required value.', 'event_espresso'),
1157 1156
 						__FILE__,
1158 1157
 						__FUNCTION__,
1159 1158
 						__LINE__
@@ -1162,7 +1161,7 @@  discard block
 block discarded – undo
1162 1161
 					break;
1163 1162
 				case 'lname' :
1164 1163
 					EE_Error::add_error(
1165
-						__( 'Last Name is a required value.', 'event_espresso' ),
1164
+						__('Last Name is a required value.', 'event_espresso'),
1166 1165
 						__FILE__,
1167 1166
 						__FUNCTION__,
1168 1167
 						__LINE__
@@ -1171,7 +1170,7 @@  discard block
 block discarded – undo
1171 1170
 					break;
1172 1171
 				case 'email' :
1173 1172
 					EE_Error::add_error(
1174
-						__( 'Please enter a valid email address.', 'event_espresso' ),
1173
+						__('Please enter a valid email address.', 'event_espresso'),
1175 1174
 						__FILE__,
1176 1175
 						__FUNCTION__,
1177 1176
 						__LINE__
@@ -1193,30 +1192,30 @@  discard block
 block discarded – undo
1193 1192
 	 * @return boolean|EE_Attendee
1194 1193
 	 * @throws \EE_Error
1195 1194
 	 */
1196
-	private function _find_existing_attendee( EE_Registration $registration, $attendee_data = array() ) {
1195
+	private function _find_existing_attendee(EE_Registration $registration, $attendee_data = array()) {
1197 1196
 		$existing_attendee = null;
1198 1197
 		// if none of the critical properties are set in the incoming attendee data...
1199 1198
 		// then attempt to copy them from the primary attendee
1200 1199
 		if (
1201
-			! isset( $attendee_data['ATT_fname'], $attendee_data['ATT_lname'], $attendee_data['ATT_email'] )
1200
+			! isset($attendee_data['ATT_fname'], $attendee_data['ATT_lname'], $attendee_data['ATT_email'])
1202 1201
 			&& $this->checkout->primary_attendee_obj instanceof EE_Attendee
1203 1202
 		) {
1204 1203
 			return $this->checkout->primary_attendee_obj;
1205 1204
 		}
1206 1205
 		// does this attendee already exist in the db ?
1207 1206
 		// we're searching using a combination of first name, last name, AND email address
1208
-		$ATT_fname = isset( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_fname'] )
1207
+		$ATT_fname = isset($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_fname'])
1209 1208
 			? $attendee_data['ATT_fname']
1210 1209
 			: '';
1211
-		$ATT_lname = isset( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_lname'] )
1210
+		$ATT_lname = isset($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_lname'])
1212 1211
 			? $attendee_data['ATT_lname']
1213 1212
 			: '';
1214
-		$ATT_email = isset( $attendee_data['ATT_email'] ) && ! empty( $attendee_data['ATT_email'] )
1213
+		$ATT_email = isset($attendee_data['ATT_email']) && ! empty($attendee_data['ATT_email'])
1215 1214
 			? $attendee_data['ATT_email']
1216 1215
 			: '';
1217 1216
 		// but only if those have values
1218
-		if ( $ATT_fname && $ATT_lname && $ATT_email ) {
1219
-			$existing_attendee = EEM_Attendee::instance()->find_existing_attendee( array(
1217
+		if ($ATT_fname && $ATT_lname && $ATT_email) {
1218
+			$existing_attendee = EEM_Attendee::instance()->find_existing_attendee(array(
1220 1219
 				'ATT_fname' => $ATT_fname,
1221 1220
 				'ATT_lname' => $ATT_lname,
1222 1221
 				'ATT_email' => $ATT_email
@@ -1240,13 +1239,13 @@  discard block
 block discarded – undo
1240 1239
 	 * @return \EE_Attendee
1241 1240
 	 * @throws \EE_Error
1242 1241
 	 */
1243
-	private function _update_existing_attendee_data( EE_Attendee $existing_attendee, $attendee_data = array() ) {
1242
+	private function _update_existing_attendee_data(EE_Attendee $existing_attendee, $attendee_data = array()) {
1244 1243
 		// first remove fname, lname, and email from attendee data
1245
-		$dont_set = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1244
+		$dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email');
1246 1245
 		// now loop thru what's left and add to attendee CPT
1247
-		foreach ( $attendee_data as $property_name => $property_value ) {
1248
-			if ( ! in_array( $property_name, $dont_set ) && EEM_Attendee::instance()->has_field( $property_name )) {
1249
-				$existing_attendee->set( $property_name, $property_value );
1246
+		foreach ($attendee_data as $property_name => $property_value) {
1247
+			if ( ! in_array($property_name, $dont_set) && EEM_Attendee::instance()->has_field($property_name)) {
1248
+				$existing_attendee->set($property_name, $property_value);
1250 1249
 			}
1251 1250
 		}
1252 1251
 		// better save that now
@@ -1264,11 +1263,11 @@  discard block
 block discarded – undo
1264 1263
 	 * @return void
1265 1264
 	 * @throws \EE_Error
1266 1265
 	 */
1267
-	private function _associate_attendee_with_registration( EE_Registration $registration, EE_Attendee $attendee ) {
1266
+	private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) {
1268 1267
 		// add relation to attendee
1269
-		$registration->_add_relation_to( $attendee, 'Attendee' );
1270
-		$registration->set_attendee_id( $attendee->ID() );
1271
-		$registration->update_cache_after_object_save( 'Attendee', $attendee );
1268
+		$registration->_add_relation_to($attendee, 'Attendee');
1269
+		$registration->set_attendee_id($attendee->ID());
1270
+		$registration->update_cache_after_object_save('Attendee', $attendee);
1272 1271
 	}
1273 1272
 
1274 1273
 
@@ -1280,10 +1279,10 @@  discard block
 block discarded – undo
1280 1279
 	 * @return void
1281 1280
 	 * @throws \EE_Error
1282 1281
 	 */
1283
-	private function _associate_registration_with_transaction( EE_Registration $registration ) {
1282
+	private function _associate_registration_with_transaction(EE_Registration $registration) {
1284 1283
 		// add relation to attendee
1285
-		$this->checkout->transaction->_add_relation_to( $registration, 'Registration' );
1286
-		$this->checkout->transaction->update_cache_after_object_save( 'Registration', $registration );
1284
+		$this->checkout->transaction->_add_relation_to($registration, 'Registration');
1285
+		$this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1287 1286
 	}
1288 1287
 
1289 1288
 
@@ -1296,14 +1295,14 @@  discard block
 block discarded – undo
1296 1295
 	 * @return array
1297 1296
 	 * @throws \EE_Error
1298 1297
 	 */
1299
-	private function _copy_critical_attendee_details_from_primary_registrant( $attendee_data = array() ) {
1298
+	private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) {
1300 1299
 		// bare minimum critical details include first name, last name, email address
1301
-		$critical_attendee_details = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1300
+		$critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1302 1301
 		// add address info to critical details?
1303
-		if ( apply_filters(
1302
+		if (apply_filters(
1304 1303
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1305 1304
 			false
1306
-		) ) {
1305
+		)) {
1307 1306
 			$address_details = array(
1308 1307
 				'ATT_address',
1309 1308
 				'ATT_address2',
@@ -1313,13 +1312,13 @@  discard block
 block discarded – undo
1313 1312
 				'ATT_zip',
1314 1313
 				'ATT_phone'
1315 1314
 			);
1316
-			$critical_attendee_details = array_merge( $critical_attendee_details, $address_details );
1315
+			$critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1317 1316
 		}
1318
-		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1319
-			if ( ! isset( $attendee_data[ $critical_attendee_detail ] )
1320
-			     || empty( $attendee_data[ $critical_attendee_detail ] )
1317
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
1318
+			if ( ! isset($attendee_data[$critical_attendee_detail])
1319
+			     || empty($attendee_data[$critical_attendee_detail])
1321 1320
 			) {
1322
-				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1321
+				$attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get(
1323 1322
 					$critical_attendee_detail
1324 1323
 				);
1325 1324
 			}
@@ -1337,11 +1336,11 @@  discard block
 block discarded – undo
1337 1336
 	 * @return \EE_Attendee
1338 1337
 	 * @throws \EE_Error
1339 1338
 	 */
1340
-	private function _create_new_attendee( EE_Registration $registration, $attendee_data = array() ) {
1339
+	private function _create_new_attendee(EE_Registration $registration, $attendee_data = array()) {
1341 1340
 		// create new attendee object
1342
-		$new_attendee = EE_Attendee::new_instance( $attendee_data );
1341
+		$new_attendee = EE_Attendee::new_instance($attendee_data);
1343 1342
 		// set author to event creator
1344
-		$new_attendee->set( 'ATT_author', $registration->event()->wp_user() );
1343
+		$new_attendee->set('ATT_author', $registration->event()->wp_user());
1345 1344
 		$new_attendee->save();
1346 1345
 		return $new_attendee;
1347 1346
 	}
@@ -1358,7 +1357,7 @@  discard block
 block discarded – undo
1358 1357
 	 */
1359 1358
 	public function update_reg_step() {
1360 1359
 		// save everything
1361
-		if ( $this->process_reg_step() ) {
1360
+		if ($this->process_reg_step()) {
1362 1361
 			$this->checkout->redirect = true;
1363 1362
 			$this->checkout->redirect_url = add_query_arg(
1364 1363
 				array(
@@ -1367,7 +1366,7 @@  discard block
 block discarded – undo
1367 1366
 				),
1368 1367
 				$this->checkout->thank_you_page_url
1369 1368
 			);
1370
-			$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1369
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1371 1370
 			return true;
1372 1371
 		}
1373 1372
 		return false;
Please login to merge, or discard this patch.
templates/reg_admin_details_side_meta_box_registrant.template.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 
27 27
 <p class="contact-details-buttons">
28 28
     <?php if (
29
-        $att_check instanceof EE_Attendee
30
-        && EE_Registry::instance()->CAP->current_user_can(
31
-            'ee_edit_contact',
32
-            'view_or_edit_contact_button',
33
-            $att_check->ID()
34
-        )
35
-    ) : ?>
29
+		$att_check instanceof EE_Attendee
30
+		&& EE_Registry::instance()->CAP->current_user_can(
31
+			'ee_edit_contact',
32
+			'view_or_edit_contact_button',
33
+			$att_check->ID()
34
+		)
35
+	) : ?>
36 36
     <a class="button button-small" href="<?php echo $att_edit_link; ?>"
37 37
        title="<?php echo esc_attr($att_edit_label); ?>">
38 38
         <span class="ee-icon ee-icon-user-edit"></span><?php echo $att_edit_label; ?>
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     <?php if (! empty($create_link)) : ?>
41 41
         <a class="button button-small" href="<?php echo $create_link; ?>"
42 42
            title="<?php esc_attr_e('This registration shares the contact details for the primary registration in this group.  If you\'d like this registration to have its own details, you can do so by clicking this button',
43
-               'event_espresso'); ?>">
43
+			   'event_espresso'); ?>">
44 44
             <span class="ee-icon ee-icon-user-add-new"></span><?php echo $create_label; ?>
45 45
         </a>
46 46
     <?php endif; ?>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
     <p class="clearfix">
3 3
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left">
4 4
             <?php _e('Name', 'event_espresso'); ?>
5
-        </span><?php echo $fname . ' ' . $lname; ?>
5
+        </span><?php echo $fname.' '.$lname; ?>
6 6
     </p>
7 7
     <p class="clearfix">
8 8
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php _e('Email', 'event_espresso'); ?></span><a
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
        title="<?php echo esc_attr($att_edit_label); ?>">
38 38
         <span class="ee-icon ee-icon-user-edit"></span><?php echo $att_edit_label; ?>
39 39
     </a>
40
-    <?php if (! empty($create_link)) : ?>
40
+    <?php if ( ! empty($create_link)) : ?>
41 41
         <a class="button button-small" href="<?php echo $create_link; ?>"
42 42
            title="<?php esc_attr_e('This registration shares the contact details for the primary registration in this group.  If you\'d like this registration to have its own details, you can do so by clicking this button',
43 43
                'event_espresso'); ?>">
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Transaction_Shortcodes.lib.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class EE_Transaction_Shortcodes extends EE_Shortcodes {
33 33
 
34
-    /**
35
-     * @var EE_Payment_Method $_invoice_pm the invoiec payment method for use in invoices etc
36
-     */
37
-    protected $_invoice_pm;
34
+	/**
35
+	 * @var EE_Payment_Method $_invoice_pm the invoiec payment method for use in invoices etc
36
+	 */
37
+	protected $_invoice_pm;
38 38
 
39 39
 	/**
40 40
 	 * EE_Transaction_Shortcodes constructor.
@@ -378,17 +378,17 @@  discard block
 block discarded – undo
378 378
 	 * @return \EE_Payment_Method|null
379 379
 	 */
380 380
 	private function _get_invoice_payment_method(){
381
-	    if( ! $this->_invoice_pm instanceof EE_Payment_Method ) {
382
-            $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
383
-            $transaction = ! $transaction instanceof EE_Transaction
384
-                           && is_array($this->_extra_data)
385
-                           && isset($this->_extra_data['data'])
386
-                           && $this->_extra_data['data'] instanceof EE_Messages_Addressee
387
-                ? $this->_extra_data['data']->txn : $transaction;
388
-            //get the invoice payment method, and remember it for the next call too
389
-            $this->_invoice_pm = apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type( 'Invoice' ), $transaction );
390
-        }
391
-        return $this->_invoice_pm;
381
+		if( ! $this->_invoice_pm instanceof EE_Payment_Method ) {
382
+			$transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
383
+			$transaction = ! $transaction instanceof EE_Transaction
384
+						   && is_array($this->_extra_data)
385
+						   && isset($this->_extra_data['data'])
386
+						   && $this->_extra_data['data'] instanceof EE_Messages_Addressee
387
+				? $this->_extra_data['data']->txn : $transaction;
388
+			//get the invoice payment method, and remember it for the next call too
389
+			$this->_invoice_pm = apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type( 'Invoice' ), $transaction );
390
+		}
391
+		return $this->_invoice_pm;
392 392
 	}
393 393
 
394 394
 
Please login to merge, or discard this patch.
Spacing   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -45,50 +45,50 @@  discard block
 block discarded – undo
45 45
 
46 46
 
47 47
 	protected function _init_props() {
48
-		$this->label = esc_html__( 'Transaction Shortcodes', 'event_espresso' );
49
-		$this->description = esc_html__( 'All shortcodes specific to transaction related data', 'event_espresso' );
48
+		$this->label = esc_html__('Transaction Shortcodes', 'event_espresso');
49
+		$this->description = esc_html__('All shortcodes specific to transaction related data', 'event_espresso');
50 50
 		$this->_shortcodes = array(
51
-			'[TXN_ID]' => esc_html__( 'The transaction id for the purchase.', 'event_espresso' ),
52
-			'[PAYMENT_URL]' => esc_html__( 'This is a link to make a payment for the event', 'event_espresso' ),
53
-			'[PAYMENT_LINK_IF_NEEDED_*]' => esc_html__( 'This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso' ) . '<ul>'
54
-				. '<li>' . sprintf( esc_html__( '%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
55
-				. '<li>' . sprintf( esc_html__( '%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
56
-				. '<li>' . sprintf( esc_html__( '%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
51
+			'[TXN_ID]' => esc_html__('The transaction id for the purchase.', 'event_espresso'),
52
+			'[PAYMENT_URL]' => esc_html__('This is a link to make a payment for the event', 'event_espresso'),
53
+			'[PAYMENT_LINK_IF_NEEDED_*]' => esc_html__('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso').'<ul>'
54
+				. '<li>'.sprintf(esc_html__('%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso'), '<strong>', '</strong>').'</li>'
55
+				. '<li>'.sprintf(esc_html__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso'), '<strong>', '</strong>').'</li>'
56
+				. '<li>'.sprintf(esc_html__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso'), '<strong>', '</strong>').'</li>'
57 57
 				. '</ul>',
58
-			'[PAYMENT_DUE_DATE_*]' => esc_html__( 'This is a special dynamic shortcode that allows one to output a payment due date.  It will only result in a date shown if there is money owing.  Three parameters are available on this shortcode:', 'event_espresso' )
58
+			'[PAYMENT_DUE_DATE_*]' => esc_html__('This is a special dynamic shortcode that allows one to output a payment due date.  It will only result in a date shown if there is money owing.  Three parameters are available on this shortcode:', 'event_espresso')
59 59
 				. '<ul>'
60
-				. '<li>' . sprintf( esc_html__( '%sformat:%s This is used to indicate what format the date is in.  Default is whatever is set as date formats for your website.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
61
-				. '<li>' . sprintf( esc_html__( '%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due.  Defaults to 30.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
62
-				. '<li>' . sprintf( esc_html__( '%sprefix_text:%s You can use this to indicate what text will prefix the date string.  Defaults to "Payment in full due by:"', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>',
63
-			'[INVOICE_LINK]' => esc_html__( 'This is a full html link to the invoice', 'event_espresso' ),
64
-			'[INVOICE_URL]' => esc_html__( 'This is just the url for the invoice', 'event_espresso' ),
65
-			'[INVOICE_LOGO_URL]' => esc_html__( 'This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso' ),
66
-			'[INVOICE_LOGO]' => esc_html__( 'This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso' ),
67
-			'[INVOICE_PAYEE_NAME]' => esc_html__( 'This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ),
68
-			'[INVOICE_PAYEE_ADDRESS]' => esc_html__( 'This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ),
69
-			'[INVOICE_PAYMENT_INSTRUCTIONS]' => esc_html__( 'This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso' ),
70
-			'[INVOICE_PAYEE_EMAIL]' => esc_html__( 'This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ),
71
-			'[INVOICE_PAYEE_TAX_NUMBER_*]' => sprintf( esc_html__( 'This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number.  It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56.  If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso' ), '<code>', '</code>' ),
72
-			'[TOTAL_COST]' => esc_html__( 'The total cost for the transaction', 'event_espresso' ),
73
-			'[TXN_STATUS]' => esc_html__( 'The transaction status for the transaction.', 'event_espresso' ),
74
-			'[TXN_STATUS_ID]' => esc_html__( 'The ID representing the transaction status as saved in the db.  This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso' ),
75
-			'[PAYMENT_STATUS]' => esc_html__( 'The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.', 'event_espresso' ),
76
-			'[PAYMENT_GATEWAY]' => esc_html__( 'The payment gateway used for the transaction', 'event_espresso' ),
77
-			'[AMOUNT_PAID]' => esc_html__( 'The amount paid or refunded.  This will only have a value if there was a payment or refund at the time of generating the message.', 'event_espresso' ),
78
-			'[LAST_AMOUNT_PAID]' => esc_html__( 'This is the last payment or refund made on the transaction related to the message being generated.', 'event_espresso' ),
79
-			'[TOTAL_AMOUNT_PAID]' => esc_html__( 'This parses to the total amount paid over all payments', 'event_espresso' ),
80
-			'[TOTAL_OWING]' => esc_html__( 'The total owing on a transaction with no attributes.', 'event_espresso' ),
81
-			'[TXN_SUBTOTAL]' => esc_html__( 'The subtotal for all txn line items.', 'event_espresso' ),
82
-			'[TXN_TAX_SUBTOTAL]' => esc_html__( 'The subtotal for all tax line items.', 'event_espresso' ),
83
-			'[OWING_STATUS_MESSAGE_*]' => esc_html__( 'A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso' ) . '<p></ul>' .
84
-				'<li><strong>still_owing</strong>:' . esc_html__( 'If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:', 'event_espresso' ) . sprintf( esc_html__( '%sPlease make a payment.%s', 'event_espresso' ),  '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ) . '</li>' .
85
-				'<li><strong>none_owing</strong>:' . esc_html__( 'If the transaction is paid in full, then you can indicate how this gets displayed.  Note, that it defaults to just be the total owing.', 'event_espresso' ) . '</li></ul></p>',
86
-			'[TXN_TOTAL_TICKETS]' => esc_html__( 'The total number of all tickets purchased in a transaction', 'event_espresso' ),
87
-			'[TKT_QTY_PURCHASED]' => sprintf( esc_html__( 'The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s', 'event_espresso' ), '<strong>', '</strong>' ),
88
-			'[TRANSACTION_ADMIN_URL]' => esc_html__( 'The url to the admin page for this transaction', 'event_espresso' ),
89
-			'[RECEIPT_URL]' => esc_html__( 'This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso' ),
90
-			'[INVOICE_RECEIPT_SWITCHER_URL]' => esc_html__( 'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active  then will parse to an empty string.', 'event_espresso' ),
91
-			'[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf( esc_html__( 'The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso' ), '<code>', '</code>' )
60
+				. '<li>'.sprintf(esc_html__('%sformat:%s This is used to indicate what format the date is in.  Default is whatever is set as date formats for your website.', 'event_espresso'), '<strong>', '</strong>').'</li>'
61
+				. '<li>'.sprintf(esc_html__('%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due.  Defaults to 30.', 'event_espresso'), '<strong>', '</strong>').'</li>'
62
+				. '<li>'.sprintf(esc_html__('%sprefix_text:%s You can use this to indicate what text will prefix the date string.  Defaults to "Payment in full due by:"', 'event_espresso'), '<strong>', '</strong>').'</li>',
63
+			'[INVOICE_LINK]' => esc_html__('This is a full html link to the invoice', 'event_espresso'),
64
+			'[INVOICE_URL]' => esc_html__('This is just the url for the invoice', 'event_espresso'),
65
+			'[INVOICE_LOGO_URL]' => esc_html__('This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso'),
66
+			'[INVOICE_LOGO]' => esc_html__('This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso'),
67
+			'[INVOICE_PAYEE_NAME]' => esc_html__('This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'),
68
+			'[INVOICE_PAYEE_ADDRESS]' => esc_html__('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'),
69
+			'[INVOICE_PAYMENT_INSTRUCTIONS]' => esc_html__('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso'),
70
+			'[INVOICE_PAYEE_EMAIL]' => esc_html__('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'),
71
+			'[INVOICE_PAYEE_TAX_NUMBER_*]' => sprintf(esc_html__('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number.  It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56.  If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso'), '<code>', '</code>'),
72
+			'[TOTAL_COST]' => esc_html__('The total cost for the transaction', 'event_espresso'),
73
+			'[TXN_STATUS]' => esc_html__('The transaction status for the transaction.', 'event_espresso'),
74
+			'[TXN_STATUS_ID]' => esc_html__('The ID representing the transaction status as saved in the db.  This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso'),
75
+			'[PAYMENT_STATUS]' => esc_html__('The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.', 'event_espresso'),
76
+			'[PAYMENT_GATEWAY]' => esc_html__('The payment gateway used for the transaction', 'event_espresso'),
77
+			'[AMOUNT_PAID]' => esc_html__('The amount paid or refunded.  This will only have a value if there was a payment or refund at the time of generating the message.', 'event_espresso'),
78
+			'[LAST_AMOUNT_PAID]' => esc_html__('This is the last payment or refund made on the transaction related to the message being generated.', 'event_espresso'),
79
+			'[TOTAL_AMOUNT_PAID]' => esc_html__('This parses to the total amount paid over all payments', 'event_espresso'),
80
+			'[TOTAL_OWING]' => esc_html__('The total owing on a transaction with no attributes.', 'event_espresso'),
81
+			'[TXN_SUBTOTAL]' => esc_html__('The subtotal for all txn line items.', 'event_espresso'),
82
+			'[TXN_TAX_SUBTOTAL]' => esc_html__('The subtotal for all tax line items.', 'event_espresso'),
83
+			'[OWING_STATUS_MESSAGE_*]' => esc_html__('A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso').'<p></ul>'.
84
+				'<li><strong>still_owing</strong>:'.esc_html__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:', 'event_espresso').sprintf(esc_html__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>').'</li>'.
85
+				'<li><strong>none_owing</strong>:'.esc_html__('If the transaction is paid in full, then you can indicate how this gets displayed.  Note, that it defaults to just be the total owing.', 'event_espresso').'</li></ul></p>',
86
+			'[TXN_TOTAL_TICKETS]' => esc_html__('The total number of all tickets purchased in a transaction', 'event_espresso'),
87
+			'[TKT_QTY_PURCHASED]' => sprintf(esc_html__('The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s', 'event_espresso'), '<strong>', '</strong>'),
88
+			'[TRANSACTION_ADMIN_URL]' => esc_html__('The url to the admin page for this transaction', 'event_espresso'),
89
+			'[RECEIPT_URL]' => esc_html__('This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso'),
90
+			'[INVOICE_RECEIPT_SWITCHER_URL]' => esc_html__('This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active  then will parse to an empty string.', 'event_espresso'),
91
+			'[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(esc_html__('The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso'), '<code>', '</code>')
92 92
 			);
93 93
 	}
94 94
 
@@ -99,40 +99,40 @@  discard block
 block discarded – undo
99 99
 	 * @param  string $shortcode the shortcode to be parsed.
100 100
 	 * @return string parsed shortcode
101 101
 	 */
102
-	protected function _parser( $shortcode ) {
102
+	protected function _parser($shortcode) {
103 103
 
104 104
 		//attempt to get the transaction.  Since this is potentially used in more fields, we may have to look in the _extra_data for the transaction.
105 105
 		$transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
106
-		$transaction = ! $transaction instanceof EE_Transaction && is_array( $this->_extra_data ) &&  isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn: $transaction;
106
+		$transaction = ! $transaction instanceof EE_Transaction && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn : $transaction;
107 107
 
108 108
 		//payment
109 109
 		$payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null;
110
-		$payment = ! $payment instanceof EE_Payment && is_array( $this->_extra_data ) &&  isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment: $payment;
110
+		$payment = ! $payment instanceof EE_Payment && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment : $payment;
111 111
 
112 112
 
113
-		if ( ! $transaction instanceof EE_Transaction ) {
113
+		if ( ! $transaction instanceof EE_Transaction) {
114 114
 			return '';
115 115
 		}
116 116
 
117
-		switch ( $shortcode ) {
117
+		switch ($shortcode) {
118 118
 			case '[TXN_ID]' :
119 119
 				return $transaction->ID();
120 120
 				break;
121 121
 
122 122
 			case '[PAYMENT_URL]' :
123 123
 				$payment_url = $transaction->payment_overview_url();
124
-				return empty( $payment_url ) ? esc_html__( 'http://dummypaymenturlforpreview.com', 'event_espresso' ) : $payment_url;
124
+				return empty($payment_url) ? esc_html__('http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url;
125 125
 				break;
126 126
 
127 127
 			case '[INVOICE_LINK]' :
128 128
 				$invoice_url = $transaction->invoice_url();
129
-				$invoice_url = empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
130
-				return sprintf( esc_html__( '%sClick here for Invoice%s', 'event_espresso' ), '<a href="' . $invoice_url . '">', '</a>' );
129
+				$invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
130
+				return sprintf(esc_html__('%sClick here for Invoice%s', 'event_espresso'), '<a href="'.$invoice_url.'">', '</a>');
131 131
 				break; /**/
132 132
 
133 133
 			case '[INVOICE_URL]' :
134 134
 				$invoice_url = $transaction->invoice_url();
135
-				return empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
135
+				return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
136 136
 				break;
137 137
 
138 138
 			case '[INVOICE_LOGO_URL]' :
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 				break;
141 141
 
142 142
 			case '[INVOICE_LOGO]' :
143
-				return $this->_get_invoice_logo( true );
143
+				return $this->_get_invoice_logo(true);
144 144
 				break;
145 145
 
146 146
 			case '[INVOICE_PAYEE_NAME]' :
@@ -162,18 +162,18 @@  discard block
 block discarded – undo
162 162
 
163 163
 			case '[TOTAL_COST]' :
164 164
 				$total = $transaction->total();
165
-				return ! empty($total) ? EEH_Template::format_currency( $total ) : '';
165
+				return ! empty($total) ? EEH_Template::format_currency($total) : '';
166 166
 				break;
167 167
 
168 168
 			case '[PAYMENT_STATUS]' :
169 169
 				$status = $transaction->pretty_status();
170
-				return ! empty($status) ? $status : esc_html__( 'Unknown', 'event_espresso' );
170
+				return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso');
171 171
 				break; /**/
172 172
 
173 173
 			// note the [payment_status] shortcode is kind of misleading because payment status might be different from txn status so I'm adding this here for clarity.
174 174
 			case '[TXN_STATUS]':
175 175
 				$status = $transaction->pretty_status();
176
-				return ! empty( $status ) ? $status : esc_html__( 'Unknown', 'event_espresso' );
176
+				return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso');
177 177
 				break;
178 178
 
179 179
 			case '[TXN_STATUS_ID]' :
@@ -181,36 +181,36 @@  discard block
 block discarded – undo
181 181
 				break;
182 182
 
183 183
 			case '[PAYMENT_GATEWAY]' :
184
-				return $this->_get_payment_gateway( $transaction );
184
+				return $this->_get_payment_gateway($transaction);
185 185
 				break;
186 186
 
187 187
 			case '[AMOUNT_PAID]' :
188 188
 				return $payment instanceof EE_Payment
189
-					? EEH_Template::format_currency( $payment->amount() )
190
-					: EEH_Template::format_currency( 0 );
189
+					? EEH_Template::format_currency($payment->amount())
190
+					: EEH_Template::format_currency(0);
191 191
 				break;
192 192
 
193 193
 			case '[LAST_AMOUNT_PAID]' :
194 194
 				$last_payment = $transaction->last_payment();
195 195
 				return $last_payment instanceof EE_Payment
196
-					? EEH_Template::format_currency( $last_payment->amount() )
197
-					: EEH_Template::format_currency( 0 );
196
+					? EEH_Template::format_currency($last_payment->amount())
197
+					: EEH_Template::format_currency(0);
198 198
 
199 199
 			case '[TOTAL_AMOUNT_PAID]' :
200
-				return EEH_Template::format_currency( $transaction->paid() );
200
+				return EEH_Template::format_currency($transaction->paid());
201 201
 				break;
202 202
 
203 203
 			case '[TOTAL_OWING]' :
204 204
 				$total_owing = $transaction->remaining();
205
-				return EEH_Template::format_currency( $total_owing );
205
+				return EEH_Template::format_currency($total_owing);
206 206
 				break;
207 207
 
208 208
 			case '[TXN_SUBTOTAL]' :
209
-				return EEH_Template::format_currency( $this->_get_subtotal() );
209
+				return EEH_Template::format_currency($this->_get_subtotal());
210 210
 				break;
211 211
 
212 212
 			case '[TXN_TAX_SUBTOTAL]' :
213
-				return EEH_Template::format_currency( $this->_get_subtotal( true ) );
213
+				return EEH_Template::format_currency($this->_get_subtotal(true));
214 214
 				break;
215 215
 
216 216
 			case '[TKT_QTY_PURCHASED]' :
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
 				break;
220 220
 
221 221
 			case '[TRANSACTION_ADMIN_URL]' :
222
-				require_once EE_CORE . 'admin/EE_Admin_Page.core.php';
223
-				$query_args = array( 'page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID() );
224
-				$url = EE_Admin_Page::add_query_args_and_nonce( $query_args, admin_url( 'admin.php' ) );
222
+				require_once EE_CORE.'admin/EE_Admin_Page.core.php';
223
+				$query_args = array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID());
224
+				$url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php'));
225 225
 				return $url;
226 226
 				break;
227 227
 
@@ -229,14 +229,14 @@  discard block
 block discarded – undo
229 229
 				//get primary_registration
230 230
 				$reg = $this->_data->primary_reg_obj;
231 231
 
232
-				if ( ! $reg instanceof EE_Registration ) {
232
+				if ( ! $reg instanceof EE_Registration) {
233 233
 					return '';
234 234
 				}
235 235
 				return $reg->receipt_url();
236 236
 				break;
237 237
 
238 238
 			case '[INVOICE_RECEIPT_SWITCHER_URL]' :
239
-				return $this->_get_invoice_receipt_switcher( false );
239
+				return $this->_get_invoice_receipt_switcher(false);
240 240
 				break;
241 241
 
242 242
 			case '[INVOICE_RECEIPT_SWITCHER_BUTTON]' :
@@ -246,20 +246,20 @@  discard block
 block discarded – undo
246 246
 
247 247
 		}
248 248
 
249
-		if ( strpos( $shortcode, '[OWING_STATUS_MESSAGE_*' ) !== false ) {
250
-			return $this->_get_custom_total_owing( $shortcode );
249
+		if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== false) {
250
+			return $this->_get_custom_total_owing($shortcode);
251 251
 		}
252 252
 
253
-		if ( strpos( $shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*' ) !== false ) {
254
-			return $this->_get_invoice_payee_tax_number( $shortcode );
253
+		if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== false) {
254
+			return $this->_get_invoice_payee_tax_number($shortcode);
255 255
 		}
256 256
 
257
-		if ( strpos( $shortcode, '[PAYMENT_LINK_IF_NEEDED_*' ) !== false ) {
258
-			return $this->_get_payment_link_if_needed( $shortcode );
257
+		if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== false) {
258
+			return $this->_get_payment_link_if_needed($shortcode);
259 259
 		}
260 260
 
261
-		if ( strpos( $shortcode, '[PAYMENT_DUE_DATE_*' ) !== false ) {
262
-			return $this->_get_payment_due_date( $shortcode, $transaction );
261
+		if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) {
262
+			return $this->_get_payment_due_date($shortcode, $transaction);
263 263
 		}
264 264
 
265 265
 		return '';
@@ -276,19 +276,19 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return string parsed.
278 278
 	 */
279
-	private function _get_custom_total_owing( $shortcode ) {
280
-		$valid_shortcodes = array( 'transaction' );
281
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
279
+	private function _get_custom_total_owing($shortcode) {
280
+		$valid_shortcodes = array('transaction');
281
+		$attrs = $this->_get_shortcode_attrs($shortcode);
282 282
 
283 283
 		//ensure default is set.
284 284
 		$addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
285 285
 		$total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0;
286 286
 
287
-		if ( $total_owing > 0 ) {
288
-			$owing_content = ! empty( $attrs['still_owing'] ) ? $attrs['still_owing'] : sprintf( esc_html__( '%sPlease make a payment.%s', 'event_espresso' ),  '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' );
289
-			$owing_content = $this->_shortcode_helper->parse_message_template( $owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message );
287
+		if ($total_owing > 0) {
288
+			$owing_content = ! empty($attrs['still_owing']) ? $attrs['still_owing'] : sprintf(esc_html__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>');
289
+			$owing_content = $this->_shortcode_helper->parse_message_template($owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message);
290 290
 		} else {
291
-			$owing_content = ! empty( $attrs['none_owing']) ? $attrs['none_owing'] : '';
291
+			$owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : '';
292 292
 		}
293 293
 
294 294
 		return $owing_content;
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 	 * @param EE_Transaction $transaction
301 301
 	 * @return string
302 302
 	 */
303
-	private function _get_payment_gateway( $transaction ) {
304
-		$pm = $this->_get_invoice_payment_method( $transaction );
303
+	private function _get_payment_gateway($transaction) {
304
+		$pm = $this->_get_invoice_payment_method($transaction);
305 305
 		return $pm instanceof EE_Payment_Method ? $pm->name() : '';
306 306
 	}
307 307
 
@@ -316,37 +316,37 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @return string url or html
318 318
 	 */
319
-	private function _get_invoice_logo( $img_tags = false ) {
319
+	private function _get_invoice_logo($img_tags = false) {
320 320
 		//try to get the invoice payment method's logo for this transaction image first
321 321
 		$pm = $this->_get_invoice_payment_method();
322
-		if ( $pm instanceof EE_Payment_Method ){
323
-			$invoice_logo_url = $pm->get_extra_meta( 'pdf_logo_image', true );
322
+		if ($pm instanceof EE_Payment_Method) {
323
+			$invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', true);
324 324
 		} else {
325 325
 			$invoice_logo_url = null;
326 326
 		}
327
-		if ( empty( $invoice_logo_url ) ){
327
+		if (empty($invoice_logo_url)) {
328 328
 			$invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url;
329 329
 		}
330 330
 
331
-		if ( empty( $invoice_logo_url ) ) {
331
+		if (empty($invoice_logo_url)) {
332 332
 			return '';
333 333
 		}
334 334
 
335
-		if ( ! $img_tags ) {
335
+		if ( ! $img_tags) {
336 336
 			return $invoice_logo_url;
337 337
 		}
338 338
 
339 339
 		//image tags have been requested.
340
-		$image_size = getimagesize( $invoice_logo_url );
340
+		$image_size = getimagesize($invoice_logo_url);
341 341
 
342 342
 		//if image is wider than 300px, set the width to 300
343
-		if ( $image_size[0] > 300 ) {
343
+		if ($image_size[0] > 300) {
344 344
 			$image_width = 300;
345 345
 		} else {
346 346
 			$image_width = $image_size[0];
347 347
 		}
348 348
 
349
-		return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />';
349
+		return '<img class="logo screen" src="'.$invoice_logo_url.'" width="'.$image_width.'" alt="logo" />';
350 350
 	}
351 351
 
352 352
 
@@ -363,10 +363,10 @@  discard block
 block discarded – undo
363 363
 	private function _get_invoice_payee_name() {
364 364
 		$payee_name = null;
365 365
 		$pm = $this->_get_invoice_payment_method();
366
-		if ( $pm instanceof EE_Payment_Method ){
367
-			$payee_name = $pm->get_extra_meta( 'pdf_payee_name', true );
366
+		if ($pm instanceof EE_Payment_Method) {
367
+			$payee_name = $pm->get_extra_meta('pdf_payee_name', true);
368 368
 		}
369
-		$payee_name = empty( $payee_name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : $payee_name;
369
+		$payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name;
370 370
 		return $payee_name;
371 371
 	}
372 372
 
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 	 *
378 378
 	 * @return \EE_Payment_Method|null
379 379
 	 */
380
-	private function _get_invoice_payment_method(){
381
-	    if( ! $this->_invoice_pm instanceof EE_Payment_Method ) {
380
+	private function _get_invoice_payment_method() {
381
+	    if ( ! $this->_invoice_pm instanceof EE_Payment_Method) {
382 382
             $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
383 383
             $transaction = ! $transaction instanceof EE_Transaction
384 384
                            && is_array($this->_extra_data)
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
                            && $this->_extra_data['data'] instanceof EE_Messages_Addressee
387 387
                 ? $this->_extra_data['data']->txn : $transaction;
388 388
             //get the invoice payment method, and remember it for the next call too
389
-            $this->_invoice_pm = apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type( 'Invoice' ), $transaction );
389
+            $this->_invoice_pm = apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice'), $transaction);
390 390
         }
391 391
         return $this->_invoice_pm;
392 392
 	}
@@ -404,10 +404,10 @@  discard block
 block discarded – undo
404 404
 	private function _get_invoice_payee_email() {
405 405
 		$payee_email = null;
406 406
 		$pm = $this->_get_invoice_payment_method();
407
-		if ( $pm instanceof EE_Payment_Method ){
408
-			$payee_email = $pm->get_extra_meta( 'pdf_payee_email', true );
407
+		if ($pm instanceof EE_Payment_Method) {
408
+			$payee_email = $pm->get_extra_meta('pdf_payee_email', true);
409 409
 		}
410
-		$payee_email = empty( $payee_email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : $payee_email;
410
+		$payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : $payee_email;
411 411
 		return $payee_email;
412 412
 	}
413 413
 
@@ -423,24 +423,24 @@  discard block
 block discarded – undo
423 423
 	 *
424 424
 	 * @return string
425 425
 	 */
426
-	private function _get_invoice_payee_tax_number( $shortcode ) {
426
+	private function _get_invoice_payee_tax_number($shortcode) {
427 427
 		$payee_tax_number = null;
428 428
 		$pm = $this->_get_invoice_payment_method();
429
-		if ( $pm instanceof EE_Payment_Method ){
430
-			$payee_tax_number = $pm->get_extra_meta( 'pdf_payee_tax_number', true );
429
+		if ($pm instanceof EE_Payment_Method) {
430
+			$payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', true);
431 431
 		}
432
-		$payee_tax_number = empty( $payee_tax_number ) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number;
432
+		$payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number;
433 433
 
434
-		if ( empty( $payee_tax_number ) ) {
434
+		if (empty($payee_tax_number)) {
435 435
 			return '';
436 436
 		}
437 437
 
438 438
 		//any attributes?
439
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
439
+		$attrs = $this->_get_shortcode_attrs($shortcode);
440 440
 
441 441
 		//prefix?
442
-		$prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : esc_html__( 'VAT/Tax Number: ', 'event_espresso' );
443
-		return $prefix . $payee_tax_number;
442
+		$prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso');
443
+		return $prefix.$payee_tax_number;
444 444
 	}
445 445
 
446 446
 
@@ -457,22 +457,22 @@  discard block
 block discarded – undo
457 457
 	private function _get_invoice_payee_address() {
458 458
 		$payee_address = null;
459 459
 		$pm = $this->_get_invoice_payment_method();
460
-		if ( $pm instanceof EE_Payment_Method ){
461
-			$payee_address = $pm->get_extra_meta( 'pdf_payee_address', true );
460
+		if ($pm instanceof EE_Payment_Method) {
461
+			$payee_address = $pm->get_extra_meta('pdf_payee_address', true);
462 462
 		}
463
-		if ( empty( $payee_address ) ) {
463
+		if (empty($payee_address)) {
464 464
 			$organization = EE_Registry::instance()->CFG->organization;
465
-			$payee_address = $organization->get_pretty( 'address_1' ) . '<br>';
466
-			$payee_address .= ! empty( $organization->address_2 ) ? $organization->get_pretty( 'address_2' ) . '<br>' : '';
467
-			$payee_address .= $organization->get_pretty( 'city' ) . '<br>';
465
+			$payee_address = $organization->get_pretty('address_1').'<br>';
466
+			$payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2').'<br>' : '';
467
+			$payee_address .= $organization->get_pretty('city').'<br>';
468 468
 
469 469
 			//state
470
-			$state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $organization->STA_ID );
471
-			$payee_address .= $state instanceof EE_State ? $state->name()  : '';
470
+			$state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
471
+			$payee_address .= $state instanceof EE_State ? $state->name() : '';
472 472
 
473 473
 			//Country
474
-			$payee_address .= ! empty( $organization->CNT_ISO ) ? ', ' . $organization->CNT_ISO . '<br>' : '';
475
-			$payee_address .= ! empty( $organization->zip ) ? $organization->zip : '';
474
+			$payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : '';
475
+			$payee_address .= ! empty($organization->zip) ? $organization->zip : '';
476 476
 		}
477 477
 		return $payee_address;
478 478
 	}
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 	private function _get_invoice_payment_instructions() {
491 491
 		$instructions = null;
492 492
 		$pm = $this->_get_invoice_payment_method();
493
-		return ( $pm instanceof EE_Payment_Method ) ? $pm->get_extra_meta( 'pdf_instructions', true ) : '';
493
+		return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', true) : '';
494 494
 	}
495 495
 
496 496
 
@@ -504,27 +504,27 @@  discard block
 block discarded – undo
504 504
 	 *
505 505
 	 * @return string
506 506
 	 */
507
-	protected function _get_invoice_receipt_switcher( $button = true ) {
507
+	protected function _get_invoice_receipt_switcher($button = true) {
508 508
 		$reg = $this->_data->primary_reg_obj;
509
-		$message_type = isset( $this->_extra_data['message_type'] ) ? $this->_extra_data['message_type'] : '';
510
-		if ( ! $reg instanceof EE_Registration || empty( $message_type ) ) {
509
+		$message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : '';
510
+		if ( ! $reg instanceof EE_Registration || empty($message_type)) {
511 511
 			return '';
512 512
 		}
513 513
 
514
-		$switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type  ? true : false;
515
-		$switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? esc_html__( 'View Invoice', 'event_espresso' ) : esc_html__( 'Switch to Invoice', 'event_espresso' );
516
-		$switch_to_label = ! $switch_to_invoice ? esc_html__( 'Switch to Receipt', 'event_espresso' ) : $switch_to_label;
514
+		$switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false;
515
+		$switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso');
516
+		$switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label;
517 517
 		$switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url();
518 518
 
519
-		if ( ! $button ) {
519
+		if ( ! $button) {
520 520
 			return $switch_to_url;
521 521
 		}
522 522
 
523
-		if ( ! empty( $switch_to_url ) ) {
523
+		if ( ! empty($switch_to_url)) {
524 524
 
525 525
 			return  '
526
-	<form method="post" action="' . $switch_to_url . '" >
527
-		<input class="print_button" type="submit" value="' . $switch_to_label . '" />
526
+	<form method="post" action="' . $switch_to_url.'" >
527
+		<input class="print_button" type="submit" value="' . $switch_to_label.'" />
528 528
 	</form>
529 529
 			';
530 530
 		}
@@ -542,10 +542,10 @@  discard block
 block discarded – undo
542 542
 	 *
543 543
 	 * @return int
544 544
 	 */
545
-	private function _get_subtotal( $tax = false ) {
546
-		$grand_total = isset( $this->_data->grand_total_line_item ) ? $this->_data->grand_total_line_item : null;
545
+	private function _get_subtotal($tax = false) {
546
+		$grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null;
547 547
 
548
-		if ( ! $grand_total instanceof EE_Line_Item ) {
548
+		if ( ! $grand_total instanceof EE_Line_Item) {
549 549
 			return 0;
550 550
 		}
551 551
 
@@ -564,26 +564,26 @@  discard block
 block discarded – undo
564 564
 	 *
565 565
 	 * @return string parsed.
566 566
 	 */
567
-	private function _get_payment_link_if_needed( $shortcode ) {
568
-		$valid_shortcodes = array( 'transaction' );
569
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
567
+	private function _get_payment_link_if_needed($shortcode) {
568
+		$valid_shortcodes = array('transaction');
569
+		$attrs = $this->_get_shortcode_attrs($shortcode);
570 570
 
571 571
 		//ensure default is set.
572 572
 		$addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
573 573
 		$total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0;
574 574
 
575
-		if ( $total_owing > 0 ) {
576
-			$class = isset( $attrs['class'] ) ? $attrs['class'] : 'callout';
577
-			$custom_text = isset( $attrs['custom_text'] ) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
578
-			$container_tag = isset( $attrs['container_tag'] ) ? $attrs['container_tag'] : 'p';
579
-			$opening_tag = ! empty( $container_tag ) ? '<' . $container_tag : '';
580
-			$opening_tag .= ! empty( $opening_tag ) && ! empty( $class ) ? ' class="' . $class . '"' : $opening_tag;
581
-			$opening_tag .= ! empty( $opening_tag ) ? '>' : $opening_tag;
582
-			$closing_tag = ! empty( $container_tag ) ? '</' . $container_tag .'>' : '';
583
-			$content = $opening_tag . sprintf( $custom_text, '<a href="[PAYMENT_URL]">', '</a>' ) . $closing_tag;
575
+		if ($total_owing > 0) {
576
+			$class = isset($attrs['class']) ? $attrs['class'] : 'callout';
577
+			$custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
578
+			$container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p';
579
+			$opening_tag = ! empty($container_tag) ? '<'.$container_tag : '';
580
+			$opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag;
581
+			$opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag;
582
+			$closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : '';
583
+			$content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag;
584 584
 
585 585
 			//we need to re run this string through the parser to catch any shortcodes that are in it.
586
-			$owing_content = $this->_shortcode_helper->parse_message_template( $content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message );
586
+			$owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message);
587 587
 		} else {
588 588
 			return '';
589 589
 		}
@@ -603,31 +603,31 @@  discard block
 block discarded – undo
603 603
 	 * @param EE_Transaction $transaction
604 604
 	 * @return string
605 605
 	 */
606
-	protected function _get_payment_due_date( $shortcode, EE_Transaction $transaction ) {
606
+	protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) {
607 607
 		//if transaction is paid in full then we can just return an empty string
608
-		if ( $transaction->remaining() === 0 ) {
608
+		if ($transaction->remaining() === 0) {
609 609
 			return '';
610 610
 		}
611 611
 
612
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
613
-		$format = isset( $attrs['format'] ) ? $attrs['format'] : get_option( 'date_format' );
614
-		$days_until_due = isset( $attrs['days_until_due'] ) ? (int) $attrs['days_until_due'] : 30;
615
-		$prefix_text = isset( $attrs['prefix_text'] ) ? $attrs['prefix_text'] : esc_html__( 'Payment in full due by: ', 'event_espresso' );
616
-		$transaction_created = $transaction->get_DateTime_object( 'TXN_timestamp' );
612
+		$attrs = $this->_get_shortcode_attrs($shortcode);
613
+		$format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format');
614
+		$days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30;
615
+		$prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] : esc_html__('Payment in full due by: ', 'event_espresso');
616
+		$transaction_created = $transaction->get_DateTime_object('TXN_timestamp');
617 617
 
618 618
 		//setup date due:
619 619
 		try {
620
-			if ( $transaction_created instanceof DateTime ) {
621
-				$date_due = $transaction_created->add( new DateInterval( 'P' . $days_until_due . 'D' ) )->format( $format );
620
+			if ($transaction_created instanceof DateTime) {
621
+				$date_due = $transaction_created->add(new DateInterval('P'.$days_until_due.'D'))->format($format);
622 622
 			} else {
623 623
 				throw new Exception();
624 624
 			}
625
-		} catch( Exception $e ) {
625
+		} catch (Exception $e) {
626 626
 			//format was likely invalid.
627 627
 			$date_due = 'Unable to calculate date due, likely the format string is invalid.';
628 628
 		}
629 629
 
630
-		return $prefix_text . $date_due;
630
+		return $prefix_text.$date_due;
631 631
 	}
632 632
 
633 633
 } //end EE_Transaction Shortcodes library
Please login to merge, or discard this patch.
registration_form/espresso_events_Registration_Form_Hooks_Extend.class.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -44,30 +44,30 @@  discard block
 block discarded – undo
44 44
 	 * @return void
45 45
 	 */
46 46
 	protected function _extend_properties() {
47
-        $this->_metaboxes = array_merge(
48
-            $this->_metaboxes,
49
-            array(
50
-                1 => array(
51
-                    'page_route' => array('create_new', 'edit'),
52
-                    'func'       => 'additional_questions',
53
-                    'label'      => __('Questions for Additional Registrants', 'event_espresso'),
54
-                    'priority'   => 'default',
55
-                    'context'    => 'side',
56
-                ),
57
-            )
58
-        );
59
-        $this->_scripts_styles = array(
60
-            'registers' => array(
61
-                'extended-event-editor' => array(
62
-                    'url'     => EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/event-editor-question-groups.js',
63
-                    'depends' => array('jquery')
64
-                )
65
-            ),
66
-            'enqueues'  => array(
67
-                'extended-event-editor' => array('edit', 'create_new')
68
-            ),
69
-        );
70
-    }
47
+		$this->_metaboxes = array_merge(
48
+			$this->_metaboxes,
49
+			array(
50
+				1 => array(
51
+					'page_route' => array('create_new', 'edit'),
52
+					'func'       => 'additional_questions',
53
+					'label'      => __('Questions for Additional Registrants', 'event_espresso'),
54
+					'priority'   => 'default',
55
+					'context'    => 'side',
56
+				),
57
+			)
58
+		);
59
+		$this->_scripts_styles = array(
60
+			'registers' => array(
61
+				'extended-event-editor' => array(
62
+					'url'     => EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/event-editor-question-groups.js',
63
+					'depends' => array('jquery')
64
+				)
65
+			),
66
+			'enqueues'  => array(
67
+				'extended-event-editor' => array('edit', 'create_new')
68
+			),
69
+		);
70
+	}
71 71
 
72 72
 
73 73
 
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 						<input value="' . $QSG->ID() . '" type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' />
125 125
 						<a href="' . $edit_link . '" title="' . sprintf( esc_attr__( 'Edit %s Group', 'event_espresso' ),  $QSG->get('QSG_name') ) . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
126 126
 					</p>';
127
-                    if ($QSG->ID() === 2) {
128
-                        $html .= '
127
+					if ($QSG->ID() === 2) {
128
+						$html .= '
129 129
 					<p id="question-group-requirements-notice-pg" class="important-notice small-text" style="display: none;">
130 130
 					    '. esc_html__('The Personal Information question group is required whenever the Address Information question group is activated.', 'event_espresso').'
131 131
 					</p>';
132
-                    }
132
+					}
133 133
 				}
134 134
 				$html .= count( $QSGs ) > 10 ? '</div>' : '';
135 135
 
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 class espresso_events_Registration_Form_Hooks_Extend extends espresso_events_Registration_Form_Hooks {
31 31
 
32 32
 
33
-	public function __construct( EE_Admin_Page $admin_page ) {
33
+	public function __construct(EE_Admin_Page $admin_page) {
34 34
 		parent::__construct($admin_page);
35 35
 	}
36 36
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         $this->_scripts_styles = array(
60 60
             'registers' => array(
61 61
                 'extended-event-editor' => array(
62
-                    'url'     => EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/event-editor-question-groups.js',
62
+                    'url'     => EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/event-editor-question-groups.js',
63 63
                     'depends' => array('jquery')
64 64
                 )
65 65
             ),
@@ -72,25 +72,25 @@  discard block
 block discarded – undo
72 72
 
73 73
 
74 74
 
75
-	public function modify_callbacks( $callbacks ) {
76
-		$callbacks = parent::modify_callbacks( $callbacks );
77
-		$callbacks[] = array( $this, 'additional_question_group_update' );
75
+	public function modify_callbacks($callbacks) {
76
+		$callbacks = parent::modify_callbacks($callbacks);
77
+		$callbacks[] = array($this, 'additional_question_group_update');
78 78
 		return $callbacks;
79 79
 	}
80 80
 
81 81
 
82 82
 
83
-	public function restore_revision( $post_id, $revision_id ) {
84
-		$post_evt = parent::restore_revision( $post_id, $revision_id );
83
+	public function restore_revision($post_id, $revision_id) {
84
+		$post_evt = parent::restore_revision($post_id, $revision_id);
85 85
 
86 86
 		//restore revision for additional questions
87
-		$post_evt->restore_revision( $revision_id, array('Question_Group'), array('Question_Group' => array('Event_Question_Group.EQG_primary' => 0 ) ) );
87
+		$post_evt->restore_revision($revision_id, array('Question_Group'), array('Question_Group' => array('Event_Question_Group.EQG_primary' => 0)));
88 88
 	}
89 89
 
90 90
 
91 91
 
92 92
 
93
-	public function additional_questions( $post_id, $post ) {
93
+	public function additional_questions($post_id, $post) {
94 94
 		$this->_event = $this->_adminpage_obj->get_event_object();
95 95
 		$event_id = $this->_event->ID();
96 96
 		?>
@@ -107,22 +107,22 @@  discard block
 block discarded – undo
107 107
 			<?php
108 108
 
109 109
 			$qsg_where['QSG_deleted'] = FALSE;
110
-			$query_params = array( $qsg_where, 'order_by' => array( 'QSG_order' => 'ASC' ) );
111
-			$QSGs = EEM_Question_Group::instance()->get_all( $query_params );
112
-			$EQGs = !empty( $event_id ) ? $this->_event->get_many_related('Question_Group', array(array('Event_Question_Group.EQG_primary' => 0 )) ) : array();
110
+			$query_params = array($qsg_where, 'order_by' => array('QSG_order' => 'ASC'));
111
+			$QSGs = EEM_Question_Group::instance()->get_all($query_params);
112
+			$EQGs = ! empty($event_id) ? $this->_event->get_many_related('Question_Group', array(array('Event_Question_Group.EQG_primary' => 0))) : array();
113 113
 			$EQGids = array_keys($EQGs);
114 114
 
115
-			if ( ! empty( $QSGs )) {
116
- 				$html = count( $QSGs ) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
117
-				foreach ( $QSGs as $QSG ) {
115
+			if ( ! empty($QSGs)) {
116
+ 				$html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
117
+				foreach ($QSGs as $QSG) {
118 118
 
119
-					$checked = in_array( $QSG->ID(), $EQGids ) ? ' checked="checked" ' : '';
120
-					$edit_link = $this->_adminpage_obj->add_query_args_and_nonce( array( 'action' => 'edit_question_group', 'QSG_ID' => $QSG->ID() ), EE_FORMS_ADMIN_URL );
119
+					$checked = in_array($QSG->ID(), $EQGids) ? ' checked="checked" ' : '';
120
+					$edit_link = $this->_adminpage_obj->add_query_args_and_nonce(array('action' => 'edit_question_group', 'QSG_ID' => $QSG->ID()), EE_FORMS_ADMIN_URL);
121 121
 
122 122
 					$html .= '
123
-					<p id="event-question-group-' . $QSG->ID() . '">
124
-						<input value="' . $QSG->ID() . '" type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' />
125
-						<a href="' . $edit_link . '" title="' . sprintf( esc_attr__( 'Edit %s Group', 'event_espresso' ),  $QSG->get('QSG_name') ) . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
123
+					<p id="event-question-group-' . $QSG->ID().'">
124
+						<input value="' . $QSG->ID().'" type="checkbox" name="add_attendee_question_groups['.$QSG->ID().']"'.$checked.' />
125
+						<a href="' . $edit_link.'" title="'.sprintf(esc_attr__('Edit %s Group', 'event_espresso'), $QSG->get('QSG_name')).'" target="_blank">'.$QSG->get('QSG_name').'</a>
126 126
 					</p>';
127 127
                     if ($QSG->ID() === 2) {
128 128
                         $html .= '
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
 					</p>';
132 132
                     }
133 133
 				}
134
-				$html .= count( $QSGs ) > 10 ? '</div>' : '';
134
+				$html .= count($QSGs) > 10 ? '</div>' : '';
135 135
 
136 136
 				echo $html;
137 137
 
138 138
 			} else {
139 139
 				echo __('There seems to be a problem with your questions. Please contact [email protected]', 'event_espresso');
140 140
 			}
141
-			do_action( 'AHEE__espresso_events_Registration_Form_Hooks__additional_questions__after_content' );
141
+			do_action('AHEE__espresso_events_Registration_Form_Hooks__additional_questions__after_content');
142 142
 			?>
143 143
 		</div>
144 144
 		<?php
@@ -148,31 +148,31 @@  discard block
 block discarded – undo
148 148
 
149 149
 
150 150
 
151
-	public function additional_question_group_update( $evtobj, $data ) {
152
-		$question_groups = !empty( $data['add_attendee_question_groups'] ) ? (array) $data['add_attendee_question_groups'] : array();
151
+	public function additional_question_group_update($evtobj, $data) {
152
+		$question_groups = ! empty($data['add_attendee_question_groups']) ? (array) $data['add_attendee_question_groups'] : array();
153 153
 		$added_qgs = array_keys($question_groups);
154 154
 		$success = array();
155 155
 
156 156
 		//let's get all current question groups associated with this event.
157
-		$current_qgs = $evtobj->get_many_related('Question_Group', array(array('Event_Question_Group.EQG_primary' => 0) ) );
157
+		$current_qgs = $evtobj->get_many_related('Question_Group', array(array('Event_Question_Group.EQG_primary' => 0)));
158 158
 		$current_qgs = array_keys($current_qgs); //we just want the ids
159 159
 
160 160
 		//now let's get the groups selected in the editor and update (IF we have data)
161
-		if ( !empty( $question_groups ) ) {
162
-			foreach ( $question_groups as $id => $val ) {
161
+		if ( ! empty($question_groups)) {
162
+			foreach ($question_groups as $id => $val) {
163 163
 				//add to event
164
-				if ( $val )
165
-					$qg = $evtobj->_add_relation_to( $id, 'Question_Group', array('EQG_primary' => 0) );
166
-				$success[] = !empty($qg) ? 1 : 0;
164
+				if ($val)
165
+					$qg = $evtobj->_add_relation_to($id, 'Question_Group', array('EQG_primary' => 0));
166
+				$success[] = ! empty($qg) ? 1 : 0;
167 167
 			}
168 168
 		}
169 169
 
170 170
 		//wait a minute... are there question groups missing in the saved groups that ARE with the current event?
171
-		$removed_qgs = array_diff( $current_qgs, $added_qgs );
171
+		$removed_qgs = array_diff($current_qgs, $added_qgs);
172 172
 
173
-		foreach ( $removed_qgs as $qgid ) {
174
-			$qg = $evtobj->_remove_relation_to( $qgid, 'Question_Group', array('EQG_primary' => 0 ) );
175
-			$success[] = !empty($qg) ? 1 : 0;
173
+		foreach ($removed_qgs as $qgid) {
174
+			$qg = $evtobj->_remove_relation_to($qgid, 'Question_Group', array('EQG_primary' => 0));
175
+			$success[] = ! empty($qg) ? 1 : 0;
176 176
 		}
177 177
 
178 178
 
Please login to merge, or discard this patch.
templates/txn_admin_details_side_meta_box_registrant.template.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 <?php else : ?>
18 18
     <p class="clearfix">
19 19
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php _e('Name',
20
-                    'event_espresso'); ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>
20
+					'event_espresso'); ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>
21 21
     </p>
22 22
     <p class="clearfix">
23 23
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php _e('Email', 'event_espresso'); ?></span><a
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     </p>
26 26
     <p class="clearfix">
27 27
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php _e('Phone #',
28
-                    'event_espresso'); ?></span><?php echo $prime_reg_phone; ?>
28
+					'event_espresso'); ?></span><?php echo $prime_reg_phone; ?>
29 29
     </p>
30 30
     <p class="clearfix">
31 31
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php _e('Address', 'event_espresso'); ?></span>
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
     </div> <!-- end #admin-side-mbox-primary-registrant-dv -->
37 37
 
38 38
     <?php
39
-    /** only show if logged in user has access */
40
-    if ( EE_Registry::instance()->CAP->current_user_can(
41
-            'ee_edit_contact',
42
-            'view_or_edit_contact_button',
43
-            $ATT_ID
44
-    )
45
-    ) : ?>
39
+	/** only show if logged in user has access */
40
+	if ( EE_Registry::instance()->CAP->current_user_can(
41
+			'ee_edit_contact',
42
+			'view_or_edit_contact_button',
43
+			$ATT_ID
44
+	)
45
+	) : ?>
46 46
     <p style="text-align:right;">
47 47
         <a class="button button-small" href="<?php echo $edit_attendee_url; ?>"
48 48
            title="<?php esc_attr_e('View details for this contact.', 'event_espresso'); ?>">
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 <?php else : ?>
18 18
     <p class="clearfix">
19 19
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php _e('Name',
20
-                    'event_espresso'); ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>
20
+                    'event_espresso'); ?></span><?php echo $prime_reg_fname.' '.$prime_reg_lname; ?>
21 21
     </p>
22 22
     <p class="clearfix">
23 23
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php _e('Email', 'event_espresso'); ?></span><a
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
     <?php
39 39
     /** only show if logged in user has access */
40
-    if ( EE_Registry::instance()->CAP->current_user_can(
40
+    if (EE_Registry::instance()->CAP->current_user_can(
41 41
             'ee_edit_contact',
42 42
             'view_or_edit_contact_button',
43 43
             $ATT_ID
@@ -50,4 +50,4 @@  discard block
 block discarded – undo
50 50
         </a>
51 51
     </p>
52 52
     <?php endif; ?>
53
-<?php endif;  //end no attendee check?>
53
+<?php endif; //end no attendee check?>
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,10 +14,13 @@
 block discarded – undo
14 14
         <?php echo $no_attendee_message; ?>
15 15
     </p>
16 16
 </div> <!-- end #admin-side-mbox-primary-registrant-dv -->
17
-<?php else : ?>
17
+<?php else {
18
+	: ?>
18 19
     <p class="clearfix">
19 20
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php _e('Name',
20
-                    'event_espresso'); ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>
21
+                    'event_espresso');
22
+}
23
+?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>
21 24
     </p>
22 25
     <p class="clearfix">
23 26
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php _e('Email', 'event_espresso'); ?></span><a
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_CPT.core.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 
79 79
 
80 80
 	/**
81
-	* @var EE_CPT_Base
82
-	*/
81
+	 * @var EE_CPT_Base
82
+	 */
83 83
 	protected $_cpt_model_obj = FALSE;
84 84
 
85 85
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		//possibly reset pagenow.
208 208
 		if ( ! empty( $this->_req_data['page'] ) && $this->_req_data['page'] == $this->page_slug && !empty( $this->_req_data['action'] ) && isset( $this->_pagenow_map[$this->_req_data['action'] ] ) ) {
209 209
 			$pagenow = $this->_pagenow_map[$this->_req_data['action']];
210
-            $hook_suffix = $pagenow;
210
+			$hook_suffix = $pagenow;
211 211
 		}
212 212
 	}
213 213
 
@@ -646,12 +646,12 @@  discard block
 block discarded – undo
646 646
 		$model = null;
647 647
 		if (
648 648
 			empty( $this->_cpt_model_names )
649
-		    || (
650
-			     ! $ignore_route_check
651
-			     && ! isset( $this->_cpt_routes[ $this->_req_action ] )
652
-		    ) || (
653
-			     $this->_cpt_model_obj instanceof EE_CPT_Base
654
-			     && $this->_cpt_model_obj->ID() === $id
649
+			|| (
650
+				 ! $ignore_route_check
651
+				 && ! isset( $this->_cpt_routes[ $this->_req_action ] )
652
+			) || (
653
+				 $this->_cpt_model_obj instanceof EE_CPT_Base
654
+				 && $this->_cpt_model_obj->ID() === $id
655 655
 			)
656 656
 		) {
657 657
 			//get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent.
@@ -891,9 +891,9 @@  discard block
 block discarded – undo
891 891
 		//if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
892 892
 		if ( $update
893 893
 			&& (
894
-			     ! $this->_cpt_model_obj instanceof EE_CPT_Base
895
-			     || $this->_cpt_model_obj->ID() !== $post_id
896
-		     )
894
+				 ! $this->_cpt_model_obj instanceof EE_CPT_Base
895
+				 || $this->_cpt_model_obj->ID() !== $post_id
896
+			 )
897 897
 		) {
898 898
 			return;
899 899
 		}
Please login to merge, or discard this patch.
admin_pages/events/Events_Admin_Page.core.php 1 patch
Indentation   +2550 added lines, -2550 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,2556 +17,2556 @@  discard block
 block discarded – undo
17 17
 class Events_Admin_Page extends EE_Admin_Page_CPT
18 18
 {
19 19
 
20
-    /**
21
-     * This will hold the event object for event_details screen.
22
-     *
23
-     * @access protected
24
-     * @var EE_Event $_event
25
-     */
26
-    protected $_event;
27
-
28
-
29
-    /**
30
-     * This will hold the category object for category_details screen.
31
-     *
32
-     * @var stdClass $_category
33
-     */
34
-    protected $_category;
35
-
36
-
37
-    /**
38
-     * This will hold the event model instance
39
-     *
40
-     * @var EEM_Event $_event_model
41
-     */
42
-    protected $_event_model;
43
-
44
-
45
-    /**
46
-     * @var EE_Event
47
-     */
48
-    protected $_cpt_model_obj = false;
49
-
50
-
51
-
52
-    protected function _init_page_props()
53
-    {
54
-        $this->page_slug = EVENTS_PG_SLUG;
55
-        $this->page_label = EVENTS_LABEL;
56
-        $this->_admin_base_url = EVENTS_ADMIN_URL;
57
-        $this->_admin_base_path = EVENTS_ADMIN;
58
-        $this->_cpt_model_names = array(
59
-            'create_new' => 'EEM_Event',
60
-            'edit'       => 'EEM_Event',
61
-        );
62
-        $this->_cpt_edit_routes = array(
63
-            'espresso_events' => 'edit',
64
-        );
65
-        add_action(
66
-            'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
67
-            array($this, 'verify_event_edit')
68
-        );
69
-    }
70
-
71
-
72
-
73
-    protected function _ajax_hooks()
74
-    {
75
-        //todo: all hooks for events ajax goes in here.
76
-    }
77
-
78
-
79
-
80
-    protected function _define_page_props()
81
-    {
82
-        $this->_admin_page_title = EVENTS_LABEL;
83
-        $this->_labels = array(
84
-            'buttons'      => array(
85
-                'add'             => esc_html__('Add New Event', 'event_espresso'),
86
-                'edit'            => esc_html__('Edit Event', 'event_espresso'),
87
-                'delete'          => esc_html__('Delete Event', 'event_espresso'),
88
-                'add_category'    => esc_html__('Add New Category', 'event_espresso'),
89
-                'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
90
-                'delete_category' => esc_html__('Delete Category', 'event_espresso'),
91
-            ),
92
-            'editor_title' => array(
93
-                'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
94
-            ),
95
-            'publishbox'   => array(
96
-                'create_new'        => esc_html__('Save New Event', 'event_espresso'),
97
-                'edit'              => esc_html__('Update Event', 'event_espresso'),
98
-                'add_category'      => esc_html__('Save New Category', 'event_espresso'),
99
-                'edit_category'     => esc_html__('Update Category', 'event_espresso'),
100
-                'template_settings' => esc_html__('Update Settings', 'event_espresso'),
101
-            ),
102
-        );
103
-    }
104
-
105
-
106
-
107
-    protected function _set_page_routes()
108
-    {
109
-        //load formatter helper
110
-        //load field generator helper
111
-        //is there a evt_id in the request?
112
-        $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
113
-            ? $this->_req_data['EVT_ID'] : 0;
114
-        $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
115
-        $this->_page_routes = array(
116
-            'default'                       => array(
117
-                'func'       => '_events_overview_list_table',
118
-                'capability' => 'ee_read_events',
119
-            ),
120
-            'create_new'                    => array(
121
-                'func'       => '_create_new_cpt_item',
122
-                'capability' => 'ee_edit_events',
123
-            ),
124
-            'edit'                          => array(
125
-                'func'       => '_edit_cpt_item',
126
-                'capability' => 'ee_edit_event',
127
-                'obj_id'     => $evt_id,
128
-            ),
129
-            'copy_event'                    => array(
130
-                'func'       => '_copy_events',
131
-                'capability' => 'ee_edit_event',
132
-                'obj_id'     => $evt_id,
133
-                'noheader'   => true,
134
-            ),
135
-            'trash_event'                   => array(
136
-                'func'       => '_trash_or_restore_event',
137
-                'args'       => array('event_status' => 'trash'),
138
-                'capability' => 'ee_delete_event',
139
-                'obj_id'     => $evt_id,
140
-                'noheader'   => true,
141
-            ),
142
-            'trash_events'                  => array(
143
-                'func'       => '_trash_or_restore_events',
144
-                'args'       => array('event_status' => 'trash'),
145
-                'capability' => 'ee_delete_events',
146
-                'noheader'   => true,
147
-            ),
148
-            'restore_event'                 => array(
149
-                'func'       => '_trash_or_restore_event',
150
-                'args'       => array('event_status' => 'draft'),
151
-                'capability' => 'ee_delete_event',
152
-                'obj_id'     => $evt_id,
153
-                'noheader'   => true,
154
-            ),
155
-            'restore_events'                => array(
156
-                'func'       => '_trash_or_restore_events',
157
-                'args'       => array('event_status' => 'draft'),
158
-                'capability' => 'ee_delete_events',
159
-                'noheader'   => true,
160
-            ),
161
-            'delete_event'                  => array(
162
-                'func'       => '_delete_event',
163
-                'capability' => 'ee_delete_event',
164
-                'obj_id'     => $evt_id,
165
-                'noheader'   => true,
166
-            ),
167
-            'delete_events'                 => array(
168
-                'func'       => '_delete_events',
169
-                'capability' => 'ee_delete_events',
170
-                'noheader'   => true,
171
-            ),
172
-            'view_report'                   => array(
173
-                'func'      => '_view_report',
174
-                'capablity' => 'ee_edit_events',
175
-            ),
176
-            'default_event_settings'        => array(
177
-                'func'       => '_default_event_settings',
178
-                'capability' => 'manage_options',
179
-            ),
180
-            'update_default_event_settings' => array(
181
-                'func'       => '_update_default_event_settings',
182
-                'capability' => 'manage_options',
183
-                'noheader'   => true,
184
-            ),
185
-            'template_settings'             => array(
186
-                'func'       => '_template_settings',
187
-                'capability' => 'manage_options',
188
-            ),
189
-            //event category tab related
190
-            'add_category'                  => array(
191
-                'func'       => '_category_details',
192
-                'capability' => 'ee_edit_event_category',
193
-                'args'       => array('add'),
194
-            ),
195
-            'edit_category'                 => array(
196
-                'func'       => '_category_details',
197
-                'capability' => 'ee_edit_event_category',
198
-                'args'       => array('edit'),
199
-            ),
200
-            'delete_categories'             => array(
201
-                'func'       => '_delete_categories',
202
-                'capability' => 'ee_delete_event_category',
203
-                'noheader'   => true,
204
-            ),
205
-            'delete_category'               => array(
206
-                'func'       => '_delete_categories',
207
-                'capability' => 'ee_delete_event_category',
208
-                'noheader'   => true,
209
-            ),
210
-            'insert_category'               => array(
211
-                'func'       => '_insert_or_update_category',
212
-                'args'       => array('new_category' => true),
213
-                'capability' => 'ee_edit_event_category',
214
-                'noheader'   => true,
215
-            ),
216
-            'update_category'               => array(
217
-                'func'       => '_insert_or_update_category',
218
-                'args'       => array('new_category' => false),
219
-                'capability' => 'ee_edit_event_category',
220
-                'noheader'   => true,
221
-            ),
222
-            'category_list'                 => array(
223
-                'func'       => '_category_list_table',
224
-                'capability' => 'ee_manage_event_categories',
225
-            ),
226
-        );
227
-    }
228
-
229
-
230
-
231
-    protected function _set_page_config()
232
-    {
233
-        $this->_page_config = array(
234
-            'default'                => array(
235
-                'nav'           => array(
236
-                    'label' => esc_html__('Overview', 'event_espresso'),
237
-                    'order' => 10,
238
-                ),
239
-                'list_table'    => 'Events_Admin_List_Table',
240
-                'help_tabs'     => array(
241
-                    'events_overview_help_tab'                       => array(
242
-                        'title'    => esc_html__('Events Overview', 'event_espresso'),
243
-                        'filename' => 'events_overview',
244
-                    ),
245
-                    'events_overview_table_column_headings_help_tab' => array(
246
-                        'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
247
-                        'filename' => 'events_overview_table_column_headings',
248
-                    ),
249
-                    'events_overview_filters_help_tab'               => array(
250
-                        'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
251
-                        'filename' => 'events_overview_filters',
252
-                    ),
253
-                    'events_overview_view_help_tab'                  => array(
254
-                        'title'    => esc_html__('Events Overview Views', 'event_espresso'),
255
-                        'filename' => 'events_overview_views',
256
-                    ),
257
-                    'events_overview_other_help_tab'                 => array(
258
-                        'title'    => esc_html__('Events Overview Other', 'event_espresso'),
259
-                        'filename' => 'events_overview_other',
260
-                    ),
261
-                ),
262
-                'help_tour'     => array(
263
-                    'Event_Overview_Help_Tour',
264
-                    //'New_Features_Test_Help_Tour' for testing multiple help tour
265
-                ),
266
-                'qtips'         => array(
267
-                    'EE_Event_List_Table_Tips',
268
-                ),
269
-                'require_nonce' => false,
270
-            ),
271
-            'create_new'             => array(
272
-                'nav'           => array(
273
-                    'label'      => esc_html__('Add Event', 'event_espresso'),
274
-                    'order'      => 5,
275
-                    'persistent' => false,
276
-                ),
277
-                'metaboxes'     => array('_register_event_editor_meta_boxes'),
278
-                'help_tabs'     => array(
279
-                    'event_editor_help_tab'                            => array(
280
-                        'title'    => esc_html__('Event Editor', 'event_espresso'),
281
-                        'filename' => 'event_editor',
282
-                    ),
283
-                    'event_editor_title_richtexteditor_help_tab'       => array(
284
-                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
285
-                        'filename' => 'event_editor_title_richtexteditor',
286
-                    ),
287
-                    'event_editor_venue_details_help_tab'              => array(
288
-                        'title'    => esc_html__('Event Venue Details', 'event_espresso'),
289
-                        'filename' => 'event_editor_venue_details',
290
-                    ),
291
-                    'event_editor_event_datetimes_help_tab'            => array(
292
-                        'title'    => esc_html__('Event Datetimes', 'event_espresso'),
293
-                        'filename' => 'event_editor_event_datetimes',
294
-                    ),
295
-                    'event_editor_event_tickets_help_tab'              => array(
296
-                        'title'    => esc_html__('Event Tickets', 'event_espresso'),
297
-                        'filename' => 'event_editor_event_tickets',
298
-                    ),
299
-                    'event_editor_event_registration_options_help_tab' => array(
300
-                        'title'    => esc_html__('Event Registration Options', 'event_espresso'),
301
-                        'filename' => 'event_editor_event_registration_options',
302
-                    ),
303
-                    'event_editor_tags_categories_help_tab'            => array(
304
-                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
305
-                        'filename' => 'event_editor_tags_categories',
306
-                    ),
307
-                    'event_editor_questions_registrants_help_tab'      => array(
308
-                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
309
-                        'filename' => 'event_editor_questions_registrants',
310
-                    ),
311
-                    'event_editor_save_new_event_help_tab'             => array(
312
-                        'title'    => esc_html__('Save New Event', 'event_espresso'),
313
-                        'filename' => 'event_editor_save_new_event',
314
-                    ),
315
-                    'event_editor_other_help_tab'                      => array(
316
-                        'title'    => esc_html__('Event Other', 'event_espresso'),
317
-                        'filename' => 'event_editor_other',
318
-                    ),
319
-                ),
320
-                'help_tour'     => array(
321
-                    'Event_Editor_Help_Tour',
322
-                ),
323
-                'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
324
-                'require_nonce' => false,
325
-            ),
326
-            'edit'                   => array(
327
-                'nav'           => array(
328
-                    'label'      => esc_html__('Edit Event', 'event_espresso'),
329
-                    'order'      => 5,
330
-                    'persistent' => false,
331
-                    'url'        => isset($this->_req_data['post'])
332
-                        ? EE_Admin_Page::add_query_args_and_nonce(
333
-                            array('post' => $this->_req_data['post'], 'action' => 'edit'),
334
-                            $this->_current_page_view_url
335
-                        )
336
-                        : $this->_admin_base_url,
337
-                ),
338
-                'metaboxes'     => array('_register_event_editor_meta_boxes'),
339
-                'help_tabs'     => array(
340
-                    'event_editor_help_tab'                            => array(
341
-                        'title'    => esc_html__('Event Editor', 'event_espresso'),
342
-                        'filename' => 'event_editor',
343
-                    ),
344
-                    'event_editor_title_richtexteditor_help_tab'       => array(
345
-                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
346
-                        'filename' => 'event_editor_title_richtexteditor',
347
-                    ),
348
-                    'event_editor_venue_details_help_tab'              => array(
349
-                        'title'    => esc_html__('Event Venue Details', 'event_espresso'),
350
-                        'filename' => 'event_editor_venue_details',
351
-                    ),
352
-                    'event_editor_event_datetimes_help_tab'            => array(
353
-                        'title'    => esc_html__('Event Datetimes', 'event_espresso'),
354
-                        'filename' => 'event_editor_event_datetimes',
355
-                    ),
356
-                    'event_editor_event_tickets_help_tab'              => array(
357
-                        'title'    => esc_html__('Event Tickets', 'event_espresso'),
358
-                        'filename' => 'event_editor_event_tickets',
359
-                    ),
360
-                    'event_editor_event_registration_options_help_tab' => array(
361
-                        'title'    => esc_html__('Event Registration Options', 'event_espresso'),
362
-                        'filename' => 'event_editor_event_registration_options',
363
-                    ),
364
-                    'event_editor_tags_categories_help_tab'            => array(
365
-                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
366
-                        'filename' => 'event_editor_tags_categories',
367
-                    ),
368
-                    'event_editor_questions_registrants_help_tab'      => array(
369
-                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
370
-                        'filename' => 'event_editor_questions_registrants',
371
-                    ),
372
-                    'event_editor_save_new_event_help_tab'             => array(
373
-                        'title'    => esc_html__('Save New Event', 'event_espresso'),
374
-                        'filename' => 'event_editor_save_new_event',
375
-                    ),
376
-                    'event_editor_other_help_tab'                      => array(
377
-                        'title'    => esc_html__('Event Other', 'event_espresso'),
378
-                        'filename' => 'event_editor_other',
379
-                    ),
380
-                ),
381
-                /*'help_tour' => array(
20
+	/**
21
+	 * This will hold the event object for event_details screen.
22
+	 *
23
+	 * @access protected
24
+	 * @var EE_Event $_event
25
+	 */
26
+	protected $_event;
27
+
28
+
29
+	/**
30
+	 * This will hold the category object for category_details screen.
31
+	 *
32
+	 * @var stdClass $_category
33
+	 */
34
+	protected $_category;
35
+
36
+
37
+	/**
38
+	 * This will hold the event model instance
39
+	 *
40
+	 * @var EEM_Event $_event_model
41
+	 */
42
+	protected $_event_model;
43
+
44
+
45
+	/**
46
+	 * @var EE_Event
47
+	 */
48
+	protected $_cpt_model_obj = false;
49
+
50
+
51
+
52
+	protected function _init_page_props()
53
+	{
54
+		$this->page_slug = EVENTS_PG_SLUG;
55
+		$this->page_label = EVENTS_LABEL;
56
+		$this->_admin_base_url = EVENTS_ADMIN_URL;
57
+		$this->_admin_base_path = EVENTS_ADMIN;
58
+		$this->_cpt_model_names = array(
59
+			'create_new' => 'EEM_Event',
60
+			'edit'       => 'EEM_Event',
61
+		);
62
+		$this->_cpt_edit_routes = array(
63
+			'espresso_events' => 'edit',
64
+		);
65
+		add_action(
66
+			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
67
+			array($this, 'verify_event_edit')
68
+		);
69
+	}
70
+
71
+
72
+
73
+	protected function _ajax_hooks()
74
+	{
75
+		//todo: all hooks for events ajax goes in here.
76
+	}
77
+
78
+
79
+
80
+	protected function _define_page_props()
81
+	{
82
+		$this->_admin_page_title = EVENTS_LABEL;
83
+		$this->_labels = array(
84
+			'buttons'      => array(
85
+				'add'             => esc_html__('Add New Event', 'event_espresso'),
86
+				'edit'            => esc_html__('Edit Event', 'event_espresso'),
87
+				'delete'          => esc_html__('Delete Event', 'event_espresso'),
88
+				'add_category'    => esc_html__('Add New Category', 'event_espresso'),
89
+				'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
90
+				'delete_category' => esc_html__('Delete Category', 'event_espresso'),
91
+			),
92
+			'editor_title' => array(
93
+				'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
94
+			),
95
+			'publishbox'   => array(
96
+				'create_new'        => esc_html__('Save New Event', 'event_espresso'),
97
+				'edit'              => esc_html__('Update Event', 'event_espresso'),
98
+				'add_category'      => esc_html__('Save New Category', 'event_espresso'),
99
+				'edit_category'     => esc_html__('Update Category', 'event_espresso'),
100
+				'template_settings' => esc_html__('Update Settings', 'event_espresso'),
101
+			),
102
+		);
103
+	}
104
+
105
+
106
+
107
+	protected function _set_page_routes()
108
+	{
109
+		//load formatter helper
110
+		//load field generator helper
111
+		//is there a evt_id in the request?
112
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
113
+			? $this->_req_data['EVT_ID'] : 0;
114
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
115
+		$this->_page_routes = array(
116
+			'default'                       => array(
117
+				'func'       => '_events_overview_list_table',
118
+				'capability' => 'ee_read_events',
119
+			),
120
+			'create_new'                    => array(
121
+				'func'       => '_create_new_cpt_item',
122
+				'capability' => 'ee_edit_events',
123
+			),
124
+			'edit'                          => array(
125
+				'func'       => '_edit_cpt_item',
126
+				'capability' => 'ee_edit_event',
127
+				'obj_id'     => $evt_id,
128
+			),
129
+			'copy_event'                    => array(
130
+				'func'       => '_copy_events',
131
+				'capability' => 'ee_edit_event',
132
+				'obj_id'     => $evt_id,
133
+				'noheader'   => true,
134
+			),
135
+			'trash_event'                   => array(
136
+				'func'       => '_trash_or_restore_event',
137
+				'args'       => array('event_status' => 'trash'),
138
+				'capability' => 'ee_delete_event',
139
+				'obj_id'     => $evt_id,
140
+				'noheader'   => true,
141
+			),
142
+			'trash_events'                  => array(
143
+				'func'       => '_trash_or_restore_events',
144
+				'args'       => array('event_status' => 'trash'),
145
+				'capability' => 'ee_delete_events',
146
+				'noheader'   => true,
147
+			),
148
+			'restore_event'                 => array(
149
+				'func'       => '_trash_or_restore_event',
150
+				'args'       => array('event_status' => 'draft'),
151
+				'capability' => 'ee_delete_event',
152
+				'obj_id'     => $evt_id,
153
+				'noheader'   => true,
154
+			),
155
+			'restore_events'                => array(
156
+				'func'       => '_trash_or_restore_events',
157
+				'args'       => array('event_status' => 'draft'),
158
+				'capability' => 'ee_delete_events',
159
+				'noheader'   => true,
160
+			),
161
+			'delete_event'                  => array(
162
+				'func'       => '_delete_event',
163
+				'capability' => 'ee_delete_event',
164
+				'obj_id'     => $evt_id,
165
+				'noheader'   => true,
166
+			),
167
+			'delete_events'                 => array(
168
+				'func'       => '_delete_events',
169
+				'capability' => 'ee_delete_events',
170
+				'noheader'   => true,
171
+			),
172
+			'view_report'                   => array(
173
+				'func'      => '_view_report',
174
+				'capablity' => 'ee_edit_events',
175
+			),
176
+			'default_event_settings'        => array(
177
+				'func'       => '_default_event_settings',
178
+				'capability' => 'manage_options',
179
+			),
180
+			'update_default_event_settings' => array(
181
+				'func'       => '_update_default_event_settings',
182
+				'capability' => 'manage_options',
183
+				'noheader'   => true,
184
+			),
185
+			'template_settings'             => array(
186
+				'func'       => '_template_settings',
187
+				'capability' => 'manage_options',
188
+			),
189
+			//event category tab related
190
+			'add_category'                  => array(
191
+				'func'       => '_category_details',
192
+				'capability' => 'ee_edit_event_category',
193
+				'args'       => array('add'),
194
+			),
195
+			'edit_category'                 => array(
196
+				'func'       => '_category_details',
197
+				'capability' => 'ee_edit_event_category',
198
+				'args'       => array('edit'),
199
+			),
200
+			'delete_categories'             => array(
201
+				'func'       => '_delete_categories',
202
+				'capability' => 'ee_delete_event_category',
203
+				'noheader'   => true,
204
+			),
205
+			'delete_category'               => array(
206
+				'func'       => '_delete_categories',
207
+				'capability' => 'ee_delete_event_category',
208
+				'noheader'   => true,
209
+			),
210
+			'insert_category'               => array(
211
+				'func'       => '_insert_or_update_category',
212
+				'args'       => array('new_category' => true),
213
+				'capability' => 'ee_edit_event_category',
214
+				'noheader'   => true,
215
+			),
216
+			'update_category'               => array(
217
+				'func'       => '_insert_or_update_category',
218
+				'args'       => array('new_category' => false),
219
+				'capability' => 'ee_edit_event_category',
220
+				'noheader'   => true,
221
+			),
222
+			'category_list'                 => array(
223
+				'func'       => '_category_list_table',
224
+				'capability' => 'ee_manage_event_categories',
225
+			),
226
+		);
227
+	}
228
+
229
+
230
+
231
+	protected function _set_page_config()
232
+	{
233
+		$this->_page_config = array(
234
+			'default'                => array(
235
+				'nav'           => array(
236
+					'label' => esc_html__('Overview', 'event_espresso'),
237
+					'order' => 10,
238
+				),
239
+				'list_table'    => 'Events_Admin_List_Table',
240
+				'help_tabs'     => array(
241
+					'events_overview_help_tab'                       => array(
242
+						'title'    => esc_html__('Events Overview', 'event_espresso'),
243
+						'filename' => 'events_overview',
244
+					),
245
+					'events_overview_table_column_headings_help_tab' => array(
246
+						'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
247
+						'filename' => 'events_overview_table_column_headings',
248
+					),
249
+					'events_overview_filters_help_tab'               => array(
250
+						'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
251
+						'filename' => 'events_overview_filters',
252
+					),
253
+					'events_overview_view_help_tab'                  => array(
254
+						'title'    => esc_html__('Events Overview Views', 'event_espresso'),
255
+						'filename' => 'events_overview_views',
256
+					),
257
+					'events_overview_other_help_tab'                 => array(
258
+						'title'    => esc_html__('Events Overview Other', 'event_espresso'),
259
+						'filename' => 'events_overview_other',
260
+					),
261
+				),
262
+				'help_tour'     => array(
263
+					'Event_Overview_Help_Tour',
264
+					//'New_Features_Test_Help_Tour' for testing multiple help tour
265
+				),
266
+				'qtips'         => array(
267
+					'EE_Event_List_Table_Tips',
268
+				),
269
+				'require_nonce' => false,
270
+			),
271
+			'create_new'             => array(
272
+				'nav'           => array(
273
+					'label'      => esc_html__('Add Event', 'event_espresso'),
274
+					'order'      => 5,
275
+					'persistent' => false,
276
+				),
277
+				'metaboxes'     => array('_register_event_editor_meta_boxes'),
278
+				'help_tabs'     => array(
279
+					'event_editor_help_tab'                            => array(
280
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
281
+						'filename' => 'event_editor',
282
+					),
283
+					'event_editor_title_richtexteditor_help_tab'       => array(
284
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
285
+						'filename' => 'event_editor_title_richtexteditor',
286
+					),
287
+					'event_editor_venue_details_help_tab'              => array(
288
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
289
+						'filename' => 'event_editor_venue_details',
290
+					),
291
+					'event_editor_event_datetimes_help_tab'            => array(
292
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
293
+						'filename' => 'event_editor_event_datetimes',
294
+					),
295
+					'event_editor_event_tickets_help_tab'              => array(
296
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
297
+						'filename' => 'event_editor_event_tickets',
298
+					),
299
+					'event_editor_event_registration_options_help_tab' => array(
300
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
301
+						'filename' => 'event_editor_event_registration_options',
302
+					),
303
+					'event_editor_tags_categories_help_tab'            => array(
304
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
305
+						'filename' => 'event_editor_tags_categories',
306
+					),
307
+					'event_editor_questions_registrants_help_tab'      => array(
308
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
309
+						'filename' => 'event_editor_questions_registrants',
310
+					),
311
+					'event_editor_save_new_event_help_tab'             => array(
312
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
313
+						'filename' => 'event_editor_save_new_event',
314
+					),
315
+					'event_editor_other_help_tab'                      => array(
316
+						'title'    => esc_html__('Event Other', 'event_espresso'),
317
+						'filename' => 'event_editor_other',
318
+					),
319
+				),
320
+				'help_tour'     => array(
321
+					'Event_Editor_Help_Tour',
322
+				),
323
+				'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
324
+				'require_nonce' => false,
325
+			),
326
+			'edit'                   => array(
327
+				'nav'           => array(
328
+					'label'      => esc_html__('Edit Event', 'event_espresso'),
329
+					'order'      => 5,
330
+					'persistent' => false,
331
+					'url'        => isset($this->_req_data['post'])
332
+						? EE_Admin_Page::add_query_args_and_nonce(
333
+							array('post' => $this->_req_data['post'], 'action' => 'edit'),
334
+							$this->_current_page_view_url
335
+						)
336
+						: $this->_admin_base_url,
337
+				),
338
+				'metaboxes'     => array('_register_event_editor_meta_boxes'),
339
+				'help_tabs'     => array(
340
+					'event_editor_help_tab'                            => array(
341
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
342
+						'filename' => 'event_editor',
343
+					),
344
+					'event_editor_title_richtexteditor_help_tab'       => array(
345
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
346
+						'filename' => 'event_editor_title_richtexteditor',
347
+					),
348
+					'event_editor_venue_details_help_tab'              => array(
349
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
350
+						'filename' => 'event_editor_venue_details',
351
+					),
352
+					'event_editor_event_datetimes_help_tab'            => array(
353
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
354
+						'filename' => 'event_editor_event_datetimes',
355
+					),
356
+					'event_editor_event_tickets_help_tab'              => array(
357
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
358
+						'filename' => 'event_editor_event_tickets',
359
+					),
360
+					'event_editor_event_registration_options_help_tab' => array(
361
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
362
+						'filename' => 'event_editor_event_registration_options',
363
+					),
364
+					'event_editor_tags_categories_help_tab'            => array(
365
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
366
+						'filename' => 'event_editor_tags_categories',
367
+					),
368
+					'event_editor_questions_registrants_help_tab'      => array(
369
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
370
+						'filename' => 'event_editor_questions_registrants',
371
+					),
372
+					'event_editor_save_new_event_help_tab'             => array(
373
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
374
+						'filename' => 'event_editor_save_new_event',
375
+					),
376
+					'event_editor_other_help_tab'                      => array(
377
+						'title'    => esc_html__('Event Other', 'event_espresso'),
378
+						'filename' => 'event_editor_other',
379
+					),
380
+				),
381
+				/*'help_tour' => array(
382 382
 					'Event_Edit_Help_Tour'
383 383
 				),*/
384
-                'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
385
-                'require_nonce' => false,
386
-            ),
387
-            'default_event_settings' => array(
388
-                'nav'           => array(
389
-                    'label' => esc_html__('Default Settings', 'event_espresso'),
390
-                    'order' => 40,
391
-                ),
392
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
393
-                'labels'        => array(
394
-                    'publishbox' => esc_html__('Update Settings', 'event_espresso'),
395
-                ),
396
-                'help_tabs'     => array(
397
-                    'default_settings_help_tab'        => array(
398
-                        'title'    => esc_html__('Default Event Settings', 'event_espresso'),
399
-                        'filename' => 'events_default_settings',
400
-                    ),
401
-                    'default_settings_status_help_tab' => array(
402
-                        'title'    => esc_html__('Default Registration Status', 'event_espresso'),
403
-                        'filename' => 'events_default_settings_status',
404
-                    ),
405
-                ),
406
-                'help_tour'     => array('Event_Default_Settings_Help_Tour'),
407
-                'require_nonce' => false,
408
-            ),
409
-            //template settings
410
-            'template_settings'      => array(
411
-                'nav'           => array(
412
-                    'label' => esc_html__('Templates', 'event_espresso'),
413
-                    'order' => 30,
414
-                ),
415
-                'metaboxes'     => $this->_default_espresso_metaboxes,
416
-                'help_tabs'     => array(
417
-                    'general_settings_templates_help_tab' => array(
418
-                        'title'    => esc_html__('Templates', 'event_espresso'),
419
-                        'filename' => 'general_settings_templates',
420
-                    ),
421
-                ),
422
-                'help_tour'     => array('Templates_Help_Tour'),
423
-                'require_nonce' => false,
424
-            ),
425
-            //event category stuff
426
-            'add_category'           => array(
427
-                'nav'           => array(
428
-                    'label'      => esc_html__('Add Category', 'event_espresso'),
429
-                    'order'      => 15,
430
-                    'persistent' => false,
431
-                ),
432
-                'help_tabs'     => array(
433
-                    'add_category_help_tab' => array(
434
-                        'title'    => esc_html__('Add New Event Category', 'event_espresso'),
435
-                        'filename' => 'events_add_category',
436
-                    ),
437
-                ),
438
-                'help_tour'     => array('Event_Add_Category_Help_Tour'),
439
-                'metaboxes'     => array('_publish_post_box'),
440
-                'require_nonce' => false,
441
-            ),
442
-            'edit_category'          => array(
443
-                'nav'           => array(
444
-                    'label'      => esc_html__('Edit Category', 'event_espresso'),
445
-                    'order'      => 15,
446
-                    'persistent' => false,
447
-                    'url'        => isset($this->_req_data['EVT_CAT_ID'])
448
-                        ? add_query_arg(
449
-                            array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']),
450
-                            $this->_current_page_view_url
451
-                        )
452
-                        : $this->_admin_base_url,
453
-                ),
454
-                'help_tabs'     => array(
455
-                    'edit_category_help_tab' => array(
456
-                        'title'    => esc_html__('Edit Event Category', 'event_espresso'),
457
-                        'filename' => 'events_edit_category',
458
-                    ),
459
-                ),
460
-                /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/
461
-                'metaboxes'     => array('_publish_post_box'),
462
-                'require_nonce' => false,
463
-            ),
464
-            'category_list'          => array(
465
-                'nav'           => array(
466
-                    'label' => esc_html__('Categories', 'event_espresso'),
467
-                    'order' => 20,
468
-                ),
469
-                'list_table'    => 'Event_Categories_Admin_List_Table',
470
-                'help_tabs'     => array(
471
-                    'events_categories_help_tab'                       => array(
472
-                        'title'    => esc_html__('Event Categories', 'event_espresso'),
473
-                        'filename' => 'events_categories',
474
-                    ),
475
-                    'events_categories_table_column_headings_help_tab' => array(
476
-                        'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
477
-                        'filename' => 'events_categories_table_column_headings',
478
-                    ),
479
-                    'events_categories_view_help_tab'                  => array(
480
-                        'title'    => esc_html__('Event Categories Views', 'event_espresso'),
481
-                        'filename' => 'events_categories_views',
482
-                    ),
483
-                    'events_categories_other_help_tab'                 => array(
484
-                        'title'    => esc_html__('Event Categories Other', 'event_espresso'),
485
-                        'filename' => 'events_categories_other',
486
-                    ),
487
-                ),
488
-                'help_tour'     => array(
489
-                    'Event_Categories_Help_Tour',
490
-                ),
491
-                'metaboxes'     => $this->_default_espresso_metaboxes,
492
-                'require_nonce' => false,
493
-            ),
494
-        );
495
-    }
496
-
497
-
498
-
499
-    protected function _add_screen_options()
500
-    {
501
-        //todo
502
-    }
503
-
504
-
505
-
506
-    protected function _add_screen_options_default()
507
-    {
508
-        $this->_per_page_screen_option();
509
-    }
510
-
511
-
512
-
513
-    protected function _add_screen_options_category_list()
514
-    {
515
-        $page_title = $this->_admin_page_title;
516
-        $this->_admin_page_title = esc_html__('Categories', 'event_espresso');
517
-        $this->_per_page_screen_option();
518
-        $this->_admin_page_title = $page_title;
519
-    }
520
-
521
-
522
-
523
-    protected function _add_feature_pointers()
524
-    {
525
-        //todo
526
-    }
527
-
528
-
529
-
530
-    public function load_scripts_styles()
531
-    {
532
-        wp_register_style(
533
-            'events-admin-css',
534
-            EVENTS_ASSETS_URL . 'events-admin-page.css',
535
-            array(),
536
-            EVENT_ESPRESSO_VERSION
537
-        );
538
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
539
-        wp_enqueue_style('events-admin-css');
540
-        wp_enqueue_style('ee-cat-admin');
541
-        //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
542
-        //registers for all views
543
-        //scripts
544
-        wp_register_script(
545
-            'event_editor_js',
546
-            EVENTS_ASSETS_URL . 'event_editor.js',
547
-            array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
548
-            EVENT_ESPRESSO_VERSION,
549
-            true
550
-        );
551
-    }
552
-
553
-
554
-
555
-    /**
556
-     * enqueuing scripts and styles specific to this view
557
-     *
558
-     * @return void
559
-     */
560
-    public function load_scripts_styles_create_new()
561
-    {
562
-        $this->load_scripts_styles_edit();
563
-    }
564
-
565
-
566
-
567
-    /**
568
-     * enqueuing scripts and styles specific to this view
569
-     *
570
-     * @return void
571
-     */
572
-    public function load_scripts_styles_edit()
573
-    {
574
-        //styles
575
-        wp_enqueue_style('espresso-ui-theme');
576
-        wp_register_style(
577
-            'event-editor-css',
578
-            EVENTS_ASSETS_URL . 'event-editor.css',
579
-            array('ee-admin-css'),
580
-            EVENT_ESPRESSO_VERSION
581
-        );
582
-        wp_enqueue_style('event-editor-css');
583
-        //scripts
584
-        wp_register_script(
585
-            'event-datetime-metabox',
586
-            EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
587
-            array('event_editor_js', 'ee-datepicker'),
588
-            EVENT_ESPRESSO_VERSION
589
-        );
590
-        wp_enqueue_script('event-datetime-metabox');
591
-    }
592
-
593
-
594
-
595
-    public function load_scripts_styles_add_category()
596
-    {
597
-        $this->load_scripts_styles_edit_category();
598
-    }
599
-
600
-
601
-
602
-    public function load_scripts_styles_edit_category()
603
-    {
604
-    }
605
-
606
-
607
-
608
-    protected function _set_list_table_views_category_list()
609
-    {
610
-        $this->_views = array(
611
-            'all' => array(
612
-                'slug'        => 'all',
613
-                'label'       => esc_html__('All', 'event_espresso'),
614
-                'count'       => 0,
615
-                'bulk_action' => array(
616
-                    'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
617
-                ),
618
-            ),
619
-        );
620
-    }
621
-
622
-
623
-
624
-    public function admin_init()
625
-    {
626
-        EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(
627
-            'Do you really want to delete this image? Please remember to update your event to complete the removal.',
628
-            'event_espresso'
629
-        );
630
-    }
631
-
632
-
633
-
634
-    //nothing needed for events with these methods.
635
-    public function admin_notices()
636
-    {
637
-    }
638
-
639
-
640
-
641
-    public function admin_footer_scripts()
642
-    {
643
-    }
644
-
645
-
646
-
647
-    /**
648
-     * Call this function to verify if an event is public and has tickets for sale.  If it does, then we need to show a
649
-     * warning (via EE_Error::add_error());
650
-     *
651
-     * @param  EE_Event $event Event object
652
-     * @access public
653
-     * @return void
654
-     */
655
-    public function verify_event_edit($event = null)
656
-    {
657
-        // no event?
658
-        if (empty($event)) {
659
-            // set event
660
-            $event = $this->_cpt_model_obj;
661
-        }
662
-        // STILL no event?
663
-        if (empty ($event)) {
664
-            return;
665
-        }
666
-        $orig_status = $event->status();
667
-        // first check if event is active.
668
-        if (
669
-            $orig_status === EEM_Event::cancelled
670
-            || $orig_status === EEM_Event::postponed
671
-            || $event->is_expired()
672
-            || $event->is_inactive()
673
-        ) {
674
-            return;
675
-        }
676
-        //made it here so it IS active... next check that any of the tickets are sold.
677
-        if ($event->is_sold_out(true)) {
678
-            if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
679
-                EE_Error::add_attention(
680
-                    sprintf(
681
-                        esc_html__(
682
-                            'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.',
683
-                            'event_espresso'
684
-                        ),
685
-                        EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
686
-                    )
687
-                );
688
-            }
689
-            return;
690
-        } else if ($orig_status === EEM_Event::sold_out) {
691
-            EE_Error::add_attention(
692
-                sprintf(
693
-                    esc_html__(
694
-                        'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
695
-                        'event_espresso'
696
-                    ),
697
-                    EEH_Template::pretty_status($event->status(), false, 'sentence')
698
-                )
699
-            );
700
-        }
701
-        //now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
702
-        if ( ! $event->tickets_on_sale()) {
703
-            return;
704
-        }
705
-        //made it here so show warning
706
-        $this->_edit_event_warning();
707
-    }
708
-
709
-
710
-
711
-    /**
712
-     * This is the text used for when an event is being edited that is public and has tickets for sale.
713
-     * When needed, hook this into a EE_Error::add_error() notice.
714
-     *
715
-     * @access protected
716
-     * @return void
717
-     */
718
-    protected function _edit_event_warning()
719
-    {
720
-        // we don't want to add warnings during these requests
721
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') {
722
-            return;
723
-        }
724
-        EE_Error::add_attention(
725
-            esc_html__(
726
-                'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.',
727
-                'event_espresso'
728
-            )
729
-        );
730
-    }
731
-
732
-
733
-
734
-    /**
735
-     * When a user is creating a new event, notify them if they haven't set their timezone.
736
-     * Otherwise, do the normal logic
737
-     *
738
-     * @return string
739
-     * @throws \EE_Error
740
-     */
741
-    protected function _create_new_cpt_item()
742
-    {
743
-        $gmt_offset = get_option('gmt_offset');
744
-        //only nag them about setting their timezone if it's their first event, and they haven't already done it
745
-        if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) {
746
-            EE_Error::add_attention(
747
-                sprintf(
748
-                    __(
749
-                        'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.',
750
-                        'event_espresso'
751
-                    ),
752
-                    '<a href="' . admin_url('options-general.php') . '">',
753
-                    '</a>'
754
-                ),
755
-                __FILE__,
756
-                __FUNCTION__,
757
-                __LINE__
758
-            );
759
-        }
760
-        return parent::_create_new_cpt_item();
761
-    }
762
-
763
-
764
-
765
-    protected function _set_list_table_views_default()
766
-    {
767
-        $this->_views = array(
768
-            'all'   => array(
769
-                'slug'        => 'all',
770
-                'label'       => esc_html__('View All Events', 'event_espresso'),
771
-                'count'       => 0,
772
-                'bulk_action' => array(
773
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
774
-                ),
775
-            ),
776
-            'draft' => array(
777
-                'slug'        => 'draft',
778
-                'label'       => esc_html__('Draft', 'event_espresso'),
779
-                'count'       => 0,
780
-                'bulk_action' => array(
781
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
782
-                ),
783
-            ),
784
-        );
785
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
786
-            $this->_views['trash'] = array(
787
-                'slug'        => 'trash',
788
-                'label'       => esc_html__('Trash', 'event_espresso'),
789
-                'count'       => 0,
790
-                'bulk_action' => array(
791
-                    'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
792
-                    'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
793
-                ),
794
-            );
795
-        }
796
-    }
797
-
798
-
799
-
800
-    /**
801
-     * @return array
802
-     */
803
-    protected function _event_legend_items()
804
-    {
805
-        $items = array(
806
-            'view_details'   => array(
807
-                'class' => 'dashicons dashicons-search',
808
-                'desc'  => esc_html__('View Event', 'event_espresso'),
809
-            ),
810
-            'edit_event'     => array(
811
-                'class' => 'ee-icon ee-icon-calendar-edit',
812
-                'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
813
-            ),
814
-            'view_attendees' => array(
815
-                'class' => 'dashicons dashicons-groups',
816
-                'desc'  => esc_html__('View Registrations for Event', 'event_espresso'),
817
-            ),
818
-        );
819
-        $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
820
-        $statuses = array(
821
-            'sold_out_status'  => array(
822
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
823
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
824
-            ),
825
-            'active_status'    => array(
826
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
827
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
828
-            ),
829
-            'upcoming_status'  => array(
830
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
831
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
832
-            ),
833
-            'postponed_status' => array(
834
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
835
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
836
-            ),
837
-            'cancelled_status' => array(
838
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
839
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
840
-            ),
841
-            'expired_status'   => array(
842
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
843
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
844
-            ),
845
-            'inactive_status'  => array(
846
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
847
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
848
-            ),
849
-        );
850
-        $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
851
-        return array_merge($items, $statuses);
852
-    }
853
-
854
-
855
-
856
-    /**
857
-     * _event_model
858
-     *
859
-     * @return EEM_Event
860
-     */
861
-    private function _event_model()
862
-    {
863
-        if ( ! $this->_event_model instanceof EEM_Event) {
864
-            $this->_event_model = EE_Registry::instance()->load_model('Event');
865
-        }
866
-        return $this->_event_model;
867
-    }
868
-
869
-
870
-
871
-    /**
872
-     * Adds extra buttons to the WP CPT permalink field row.
873
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
874
-     *
875
-     * @param  string $return    the current html
876
-     * @param  int    $id        the post id for the page
877
-     * @param  string $new_title What the title is
878
-     * @param  string $new_slug  what the slug is
879
-     * @return string            The new html string for the permalink area
880
-     */
881
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
882
-    {
883
-        //make sure this is only when editing
884
-        if ( ! empty($id)) {
885
-            $post = get_post($id);
886
-            $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
887
-                       . esc_html__('Shortcode', 'event_espresso')
888
-                       . '</a> ';
889
-            $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
890
-                       . $post->ID
891
-                       . ']">';
892
-        }
893
-        return $return;
894
-    }
895
-
896
-
897
-
898
-    /**
899
-     * _events_overview_list_table
900
-     * This contains the logic for showing the events_overview list
901
-     *
902
-     * @access protected
903
-     * @return void
904
-     */
905
-    protected function _events_overview_list_table()
906
-    {
907
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
908
-        $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(
909
-            get_post_type_archive_link('espresso_events'),
910
-            esc_html__("View Event Archive Page", "event_espresso"),
911
-            'button'
912
-        );
913
-        $this->_template_args['after_list_table'] .= $this->_display_legend($this->_event_legend_items());
914
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
915
-                'create_new',
916
-                'add',
917
-                array(),
918
-                'add-new-h2'
919
-            );
920
-        $this->display_admin_list_table_page_with_no_sidebar();
921
-    }
922
-
923
-
924
-
925
-    /**
926
-     * this allows for extra misc actions in the default WP publish box
927
-     *
928
-     * @return void
929
-     */
930
-    public function extra_misc_actions_publish_box()
931
-    {
932
-        $this->_generate_publish_box_extra_content();
933
-    }
934
-
935
-
936
-
937
-    /**
938
-     * @param string $post_id
939
-     * @param object $post
940
-     */
941
-    protected function _insert_update_cpt_item($post_id, $post)
942
-    {
943
-        if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
944
-            //get out we're not processing an event save.
945
-            return;
946
-        }
947
-        $event_values = array(
948
-            'EVT_display_desc'                => ! empty($this->_req_data['display_desc']) ? 1 : 0,
949
-            'EVT_display_ticket_selector'     => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
950
-            'EVT_additional_limit'            => min(
951
-                apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
952
-                ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null
953
-            ),
954
-            'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])
955
-                ? $this->_req_data['EVT_default_registration_status']
956
-                : EE_Registry::instance()->CFG->registration->default_STS_ID,
957
-            'EVT_member_only'                 => ! empty($this->_req_data['member_only']) ? 1 : 0,
958
-            'EVT_allow_overflow'              => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
959
-            'EVT_timezone_string'             => ! empty($this->_req_data['timezone_string'])
960
-                ? $this->_req_data['timezone_string'] : null,
961
-            'EVT_external_URL'                => ! empty($this->_req_data['externalURL'])
962
-                ? $this->_req_data['externalURL'] : null,
963
-            'EVT_phone'                       => ! empty($this->_req_data['event_phone'])
964
-                ? $this->_req_data['event_phone'] : null,
965
-        );
966
-        //update event
967
-        $success = $this->_event_model()->update_by_ID($event_values, $post_id);
968
-        //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
969
-        $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status);
970
-        $event = $this->_event_model()->get_one(array($get_one_where));
971
-        //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
972
-        $event_update_callbacks = apply_filters(
973
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
974
-            array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))
975
-        );
976
-        $att_success = true;
977
-        foreach ($event_update_callbacks as $e_callback) {
978
-            $_succ = call_user_func_array($e_callback, array($event, $this->_req_data));
979
-            $att_success = ! $att_success ? $att_success
980
-                : $_succ; //if ANY of these updates fail then we want the appropriate global error message
981
-        }
982
-        //any errors?
983
-        if ($success && false === $att_success) {
984
-            EE_Error::add_error(
985
-                esc_html__(
986
-                    'Event Details saved successfully but something went wrong with saving attachments.',
987
-                    'event_espresso'
988
-                ),
989
-                __FILE__,
990
-                __FUNCTION__,
991
-                __LINE__
992
-            );
993
-        } else if ($success === false) {
994
-            EE_Error::add_error(
995
-                esc_html__('Event Details did not save successfully.', 'event_espresso'),
996
-                __FILE__,
997
-                __FUNCTION__,
998
-                __LINE__
999
-            );
1000
-        }
1001
-    }
1002
-
1003
-
1004
-
1005
-    /**
1006
-     * @see parent::restore_item()
1007
-     * @param int $post_id
1008
-     * @param int $revision_id
1009
-     */
1010
-    protected function _restore_cpt_item($post_id, $revision_id)
1011
-    {
1012
-        //copy existing event meta to new post
1013
-        $post_evt = $this->_event_model()->get_one_by_ID($post_id);
1014
-        if ($post_evt instanceof EE_Event) {
1015
-            //meta revision restore
1016
-            $post_evt->restore_revision($revision_id);
1017
-            //related objs restore
1018
-            $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
1019
-        }
1020
-    }
1021
-
1022
-
1023
-
1024
-    /**
1025
-     * Attach the venue to the Event
1026
-     *
1027
-     * @param  \EE_Event $evtobj Event Object to add the venue to
1028
-     * @param  array     $data   The request data from the form
1029
-     * @return bool           Success or fail.
1030
-     */
1031
-    protected function _default_venue_update(\EE_Event $evtobj, $data)
1032
-    {
1033
-        require_once(EE_MODELS . 'EEM_Venue.model.php');
1034
-        $venue_model = EE_Registry::instance()->load_model('Venue');
1035
-        $rows_affected = null;
1036
-        $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1037
-        // very important.  If we don't have a venue name...
1038
-        // then we'll get out because not necessary to create empty venue
1039
-        if (empty($data['venue_title'])) {
1040
-            return false;
1041
-        }
1042
-        $venue_array = array(
1043
-            'VNU_wp_user'         => $evtobj->get('EVT_wp_user'),
1044
-            'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1045
-            'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1046
-            'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1047
-            'VNU_short_desc'      => ! empty($data['venue_short_description']) ? $data['venue_short_description']
1048
-                : null,
1049
-            'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1050
-            'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1051
-            'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1052
-            'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1053
-            'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1054
-            'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1055
-            'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1056
-            'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1057
-            'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1058
-            'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1059
-            'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1060
-            'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1061
-            'status'              => 'publish',
1062
-        );
1063
-        //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1064
-        if ( ! empty($venue_id)) {
1065
-            $update_where = array($venue_model->primary_key_name() => $venue_id);
1066
-            $rows_affected = $venue_model->update($venue_array, array($update_where));
1067
-            //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present.
1068
-            $evtobj->_add_relation_to($venue_id, 'Venue');
1069
-            return $rows_affected > 0 ? true : false;
1070
-        } else {
1071
-            //we insert the venue
1072
-            $venue_id = $venue_model->insert($venue_array);
1073
-            $evtobj->_add_relation_to($venue_id, 'Venue');
1074
-            return ! empty($venue_id) ? true : false;
1075
-        }
1076
-        //when we have the ancestor come in it's already been handled by the revision save.
1077
-    }
1078
-
1079
-
1080
-
1081
-    /**
1082
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
1083
-     *
1084
-     * @param  EE_Event $evtobj The Event object we're attaching data to
1085
-     * @param  array    $data   The request data from the form
1086
-     * @return array
1087
-     */
1088
-    protected function _default_tickets_update(EE_Event $evtobj, $data)
1089
-    {
1090
-        $success = true;
1091
-        $saved_dtt = null;
1092
-        $saved_tickets = array();
1093
-        $incoming_date_formats = array('Y-m-d', 'h:i a');
1094
-        foreach ($data['edit_event_datetimes'] as $row => $dtt) {
1095
-            //trim all values to ensure any excess whitespace is removed.
1096
-            $dtt = array_map('trim', $dtt);
1097
-            $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']
1098
-                : $dtt['DTT_EVT_start'];
1099
-            $datetime_values = array(
1100
-                'DTT_ID'        => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
1101
-                'DTT_EVT_start' => $dtt['DTT_EVT_start'],
1102
-                'DTT_EVT_end'   => $dtt['DTT_EVT_end'],
1103
-                'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
1104
-                'DTT_order'     => $row,
1105
-            );
1106
-            //if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
1107
-            if ( ! empty($dtt['DTT_ID'])) {
1108
-                $DTM = EE_Registry::instance()
1109
-                                  ->load_model('Datetime', array($evtobj->get_timezone()))
1110
-                                  ->get_one_by_ID($dtt['DTT_ID']);
1111
-                $DTM->set_date_format($incoming_date_formats[0]);
1112
-                $DTM->set_time_format($incoming_date_formats[1]);
1113
-                foreach ($datetime_values as $field => $value) {
1114
-                    $DTM->set($field, $value);
1115
-                }
1116
-                //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.  We need to do this so we dont' TRASH the parent DTT.
1117
-                $saved_dtts[$DTM->ID()] = $DTM;
1118
-            } else {
1119
-                $DTM = EE_Registry::instance()->load_class(
1120
-                    'Datetime',
1121
-                    array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats),
1122
-                    false,
1123
-                    false
1124
-                );
1125
-                foreach ($datetime_values as $field => $value) {
1126
-                    $DTM->set($field, $value);
1127
-                }
1128
-            }
1129
-            $DTM->save();
1130
-            $DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1131
-            //load DTT helper
1132
-            //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1133
-            if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1134
-                $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1135
-                $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1136
-                $DTT->save();
1137
-            }
1138
-            //now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
1139
-            $saved_dtt = $DTT;
1140
-            $success = ! $success ? $success : $DTT;
1141
-            //if ANY of these updates fail then we want the appropriate global error message.
1142
-            // //todo this is actually sucky we need a better error message but this is what it is for now.
1143
-        }
1144
-        //no dtts get deleted so we don't do any of that logic here.
1145
-        //update tickets next
1146
-        $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1147
-        foreach ($data['edit_tickets'] as $row => $tkt) {
1148
-            $incoming_date_formats = array('Y-m-d', 'h:i a');
1149
-            $update_prices = false;
1150
-            $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount'])
1151
-                ? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1152
-            // trim inputs to ensure any excess whitespace is removed.
1153
-            $tkt = array_map('trim', $tkt);
1154
-            if (empty($tkt['TKT_start_date'])) {
1155
-                //let's use now in the set timezone.
1156
-                $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1157
-                $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1158
-            }
1159
-            if (empty($tkt['TKT_end_date'])) {
1160
-                //use the start date of the first datetime
1161
-                $dtt = $evtobj->first_datetime();
1162
-                $tkt['TKT_end_date'] = $dtt->start_date_and_time(
1163
-                    $incoming_date_formats[0],
1164
-                    $incoming_date_formats[1]
1165
-                );
1166
-            }
1167
-            $TKT_values = array(
1168
-                'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
1169
-                'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1170
-                'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1171
-                'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1172
-                'TKT_start_date'  => $tkt['TKT_start_date'],
1173
-                'TKT_end_date'    => $tkt['TKT_end_date'],
1174
-                'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1175
-                'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1176
-                'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1177
-                'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1178
-                'TKT_row'         => $row,
1179
-                'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1180
-                'TKT_price'       => $ticket_price,
1181
-            );
1182
-            //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
1183
-            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1184
-                $TKT_values['TKT_ID'] = 0;
1185
-                $TKT_values['TKT_is_default'] = 0;
1186
-                $TKT_values['TKT_price'] = $ticket_price;
1187
-                $update_prices = true;
1188
-            }
1189
-            //if we have a TKT_ID then we need to get that existing TKT_obj and update it
1190
-            //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified.
1191
-            //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1192
-            if ( ! empty($tkt['TKT_ID'])) {
1193
-                $TKT = EE_Registry::instance()
1194
-                                  ->load_model('Ticket', array($evtobj->get_timezone()))
1195
-                                  ->get_one_by_ID($tkt['TKT_ID']);
1196
-                if ($TKT instanceof EE_Ticket) {
1197
-                    $ticket_sold = $TKT->count_related(
1198
-                        'Registration',
1199
-                        array(
1200
-                            array(
1201
-                                'STS_ID' => array(
1202
-                                    'NOT IN',
1203
-                                    array(EEM_Registration::status_id_incomplete),
1204
-                                ),
1205
-                            ),
1206
-                        )
1207
-                    ) > 0 ? true : false;
1208
-                    //let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1209
-                    $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price')
1210
-                                      && ! $TKT->get(
1211
-                        'TKT_deleted'
1212
-                    ) ? true : false;
1213
-                    $TKT->set_date_format($incoming_date_formats[0]);
1214
-                    $TKT->set_time_format($incoming_date_formats[1]);
1215
-                    //set new values
1216
-                    foreach ($TKT_values as $field => $value) {
1217
-                        if ($field == 'TKT_qty') {
1218
-                            $TKT->set_qty($value);
1219
-                        } else {
1220
-                            $TKT->set($field, $value);
1221
-                        }
1222
-                    }
1223
-                    //if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1224
-                    if ($create_new_TKT) {
1225
-                        //archive the old ticket first
1226
-                        $TKT->set('TKT_deleted', 1);
1227
-                        $TKT->save();
1228
-                        //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1229
-                        $saved_tickets[$TKT->ID()] = $TKT;
1230
-                        //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it.
1231
-                        $TKT = clone $TKT;
1232
-                        $TKT->set('TKT_ID', 0);
1233
-                        $TKT->set('TKT_deleted', 0);
1234
-                        $TKT->set('TKT_price', $ticket_price);
1235
-                        $TKT->set('TKT_sold', 0);
1236
-                        //now we need to make sure that $new prices are created as well and attached to new ticket.
1237
-                        $update_prices = true;
1238
-                    }
1239
-                    //make sure price is set if it hasn't been already
1240
-                    $TKT->set('TKT_price', $ticket_price);
1241
-                }
1242
-            } else {
1243
-                //no TKT_id so a new TKT
1244
-                $TKT_values['TKT_price'] = $ticket_price;
1245
-                $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false);
1246
-                if ($TKT instanceof EE_Ticket) {
1247
-                    //need to reset values to properly account for the date formats
1248
-                    $TKT->set_date_format($incoming_date_formats[0]);
1249
-                    $TKT->set_time_format($incoming_date_formats[1]);
1250
-                    $TKT->set_timezone($evtobj->get_timezone());
1251
-                    //set new values
1252
-                    foreach ($TKT_values as $field => $value) {
1253
-                        if ($field == 'TKT_qty') {
1254
-                            $TKT->set_qty($value);
1255
-                        } else {
1256
-                            $TKT->set($field, $value);
1257
-                        }
1258
-                    }
1259
-                    $update_prices = true;
1260
-                }
1261
-            }
1262
-            // cap ticket qty by datetime reg limits
1263
-            $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1264
-            //update ticket.
1265
-            $TKT->save();
1266
-            //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1267
-            if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1268
-                $TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1269
-                $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1270
-                $TKT->save();
1271
-            }
1272
-            //initially let's add the ticket to the dtt
1273
-            $saved_dtt->_add_relation_to($TKT, 'Ticket');
1274
-            $saved_tickets[$TKT->ID()] = $TKT;
1275
-            //add prices to ticket
1276
-            $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices);
1277
-        }
1278
-        //however now we need to handle permanently deleting tickets via the ui.  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.  However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db.
1279
-        $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1280
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1281
-        foreach ($tickets_removed as $id) {
1282
-            $id = absint($id);
1283
-            //get the ticket for this id
1284
-            $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
1285
-            //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold)
1286
-            $dtts = $tkt_to_remove->get_many_related('Datetime');
1287
-            foreach ($dtts as $dtt) {
1288
-                $tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1289
-            }
1290
-            //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
1291
-            $tkt_to_remove->delete_related_permanently('Price');
1292
-            //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1293
-            $tkt_to_remove->delete_permanently();
1294
-        }
1295
-        return array($saved_dtt, $saved_tickets);
1296
-    }
1297
-
1298
-
1299
-
1300
-    /**
1301
-     * This attaches a list of given prices to a ticket.
1302
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
1303
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
1304
-     * price info and prices are automatically "archived" via the ticket.
1305
-     *
1306
-     * @access  private
1307
-     * @param array     $prices     Array of prices from the form.
1308
-     * @param EE_Ticket $ticket     EE_Ticket object that prices are being attached to.
1309
-     * @param bool      $new_prices Whether attach existing incoming prices or create new ones.
1310
-     * @return  void
1311
-     */
1312
-    private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false)
1313
-    {
1314
-        foreach ($prices as $row => $prc) {
1315
-            $PRC_values = array(
1316
-                'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
1317
-                'PRT_ID'         => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,
1318
-                'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1319
-                'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1320
-                'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1321
-                'PRC_is_default' => 0, //make sure prices are NOT set as default from this context
1322
-                'PRC_order'      => $row,
1323
-            );
1324
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
1325
-                $PRC_values['PRC_ID'] = 0;
1326
-                $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
1327
-            } else {
1328
-                $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1329
-                //update this price with new values
1330
-                foreach ($PRC_values as $field => $newprc) {
1331
-                    $PRC->set($field, $newprc);
1332
-                }
1333
-                $PRC->save();
1334
-            }
1335
-            $ticket->_add_relation_to($PRC, 'Price');
1336
-        }
1337
-    }
1338
-
1339
-
1340
-
1341
-    /**
1342
-     * Add in our autosave ajax handlers
1343
-     *
1344
-     * @return void
1345
-     */
1346
-    protected function _ee_autosave_create_new()
1347
-    {
1348
-        // $this->_ee_autosave_edit();
1349
-    }
1350
-
1351
-
1352
-
1353
-    protected function _ee_autosave_edit()
1354
-    {
1355
-        return; //TEMPORARILY EXITING CAUSE THIS IS A TODO
1356
-    }
1357
-
1358
-
1359
-
1360
-    /**
1361
-     *    _generate_publish_box_extra_content
1362
-     *
1363
-     * @access private
1364
-     * @return void
1365
-     */
1366
-    private function _generate_publish_box_extra_content()
1367
-    {
1368
-        //load formatter helper
1369
-        //args for getting related registrations
1370
-        $approved_query_args = array(
1371
-            array(
1372
-                'REG_deleted' => 0,
1373
-                'STS_ID'      => EEM_Registration::status_id_approved,
1374
-            ),
1375
-        );
1376
-        $not_approved_query_args = array(
1377
-            array(
1378
-                'REG_deleted' => 0,
1379
-                'STS_ID'      => EEM_Registration::status_id_not_approved,
1380
-            ),
1381
-        );
1382
-        $pending_payment_query_args = array(
1383
-            array(
1384
-                'REG_deleted' => 0,
1385
-                'STS_ID'      => EEM_Registration::status_id_pending_payment,
1386
-            ),
1387
-        );
1388
-        // publish box
1389
-        $publish_box_extra_args = array(
1390
-            'view_approved_reg_url'        => add_query_arg(
1391
-                array(
1392
-                    'action'      => 'default',
1393
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1394
-                    '_reg_status' => EEM_Registration::status_id_approved,
1395
-                ),
1396
-                REG_ADMIN_URL
1397
-            ),
1398
-            'view_not_approved_reg_url'    => add_query_arg(
1399
-                array(
1400
-                    'action'      => 'default',
1401
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1402
-                    '_reg_status' => EEM_Registration::status_id_not_approved,
1403
-                ),
1404
-                REG_ADMIN_URL
1405
-            ),
1406
-            'view_pending_payment_reg_url' => add_query_arg(
1407
-                array(
1408
-                    'action'      => 'default',
1409
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1410
-                    '_reg_status' => EEM_Registration::status_id_pending_payment,
1411
-                ),
1412
-                REG_ADMIN_URL
1413
-            ),
1414
-            'approved_regs'                => $this->_cpt_model_obj->count_related(
1415
-                'Registration',
1416
-                $approved_query_args
1417
-            ),
1418
-            'not_approved_regs'            => $this->_cpt_model_obj->count_related(
1419
-                'Registration',
1420
-                $not_approved_query_args
1421
-            ),
1422
-            'pending_payment_regs'         => $this->_cpt_model_obj->count_related(
1423
-                'Registration',
1424
-                $pending_payment_query_args
1425
-            ),
1426
-            'misc_pub_section_class'       => apply_filters(
1427
-                'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1428
-                'misc-pub-section'
1429
-            ),
1430
-            //'email_attendees_url' => add_query_arg(
1431
-            //	array(
1432
-            //		'event_admin_reports' => 'event_newsletter',
1433
-            //		'event_id' => $this->_cpt_model_obj->id
1434
-            //	),
1435
-            //	'admin.php?page=espresso_registrations'
1436
-            //),
1437
-        );
1438
-        ob_start();
1439
-        do_action(
1440
-            'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1441
-            $this->_cpt_model_obj
1442
-        );
1443
-        $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1444
-        // load template
1445
-        EEH_Template::display_template(
1446
-            EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1447
-            $publish_box_extra_args
1448
-        );
1449
-    }
1450
-
1451
-
1452
-
1453
-    /**
1454
-     * This just returns whatever is set as the _event object property
1455
-     * //todo this will become obsolete once the models are in place
1456
-     *
1457
-     * @return object
1458
-     */
1459
-    public function get_event_object()
1460
-    {
1461
-        return $this->_cpt_model_obj;
1462
-    }
1463
-
1464
-
1465
-
1466
-
1467
-    /** METABOXES * */
1468
-    /**
1469
-     * _register_event_editor_meta_boxes
1470
-     * add all metaboxes related to the event_editor
1471
-     *
1472
-     * @return void
1473
-     */
1474
-    protected function _register_event_editor_meta_boxes()
1475
-    {
1476
-        $this->verify_cpt_object();
1477
-        add_meta_box(
1478
-            'espresso_event_editor_tickets',
1479
-            esc_html__('Event Datetime & Ticket', 'event_espresso'),
1480
-            array($this, 'ticket_metabox'),
1481
-            $this->page_slug,
1482
-            'normal',
1483
-            'high'
1484
-        );
1485
-        add_meta_box(
1486
-            'espresso_event_editor_event_options',
1487
-            esc_html__('Event Registration Options', 'event_espresso'),
1488
-            array($this, 'registration_options_meta_box'),
1489
-            $this->page_slug,
1490
-            'side',
1491
-            'default'
1492
-        );
1493
-        // NOTE: if you're looking for other metaboxes in here,
1494
-        // where a metabox has a related management page in the admin
1495
-        // you will find it setup in the related management page's "_Hooks" file.
1496
-        // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".
1497
-    }
1498
-
1499
-
1500
-
1501
-    public function ticket_metabox()
1502
-    {
1503
-        $existing_datetime_ids = $existing_ticket_ids = array();
1504
-        //defaults for template args
1505
-        $template_args = array(
1506
-            'existing_datetime_ids'    => '',
1507
-            'event_datetime_help_link' => '',
1508
-            'ticket_options_help_link' => '',
1509
-            'time'                     => null,
1510
-            'ticket_rows'              => '',
1511
-            'existing_ticket_ids'      => '',
1512
-            'total_ticket_rows'        => 1,
1513
-            'ticket_js_structure'      => '',
1514
-            'trash_icon'               => 'ee-lock-icon',
1515
-            'disabled'                 => '',
1516
-        );
1517
-        $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1518
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1519
-        /**
1520
-         * 1. Start with retrieving Datetimes
1521
-         * 2. Fore each datetime get related tickets
1522
-         * 3. For each ticket get related prices
1523
-         */
1524
-        $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1525
-        /** @type EE_Datetime $first_datetime */
1526
-        $first_datetime = reset($times);
1527
-        //do we get related tickets?
1528
-        if ($first_datetime instanceof EE_Datetime
1529
-            && $first_datetime->ID() !== 0
1530
-        ) {
1531
-            $existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1532
-            $template_args['time'] = $first_datetime;
1533
-            $related_tickets = $first_datetime->tickets(
1534
-                array(
1535
-                    array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1536
-                    'default_where_conditions' => 'none',
1537
-                )
1538
-            );
1539
-            if ( ! empty($related_tickets)) {
1540
-                $template_args['total_ticket_rows'] = count($related_tickets);
1541
-                $row = 0;
1542
-                foreach ($related_tickets as $ticket) {
1543
-                    $existing_ticket_ids[] = $ticket->get('TKT_ID');
1544
-                    $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1545
-                    $row++;
1546
-                }
1547
-            } else {
1548
-                $template_args['total_ticket_rows'] = 1;
1549
-                /** @type EE_Ticket $ticket */
1550
-                $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1551
-                $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1552
-            }
1553
-        } else {
1554
-            $template_args['time'] = $times[0];
1555
-            /** @type EE_Ticket $ticket */
1556
-            $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1557
-            $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1558
-            // NOTE: we're just sending the first default row
1559
-            // (decaf can't manage default tickets so this should be sufficient);
1560
-        }
1561
-        $template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1562
-            'event_editor_event_datetimes_help_tab'
1563
-        );
1564
-        $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1565
-        $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1566
-        $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1567
-        $template_args['ticket_js_structure'] = $this->_get_ticket_row(
1568
-            EE_Registry::instance()->load_model('Ticket')->create_default_object(),
1569
-            true
1570
-        );
1571
-        $template = apply_filters(
1572
-            'FHEE__Events_Admin_Page__ticket_metabox__template',
1573
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1574
-        );
1575
-        EEH_Template::display_template($template, $template_args);
1576
-    }
1577
-
1578
-
1579
-
1580
-    /**
1581
-     * Setup an individual ticket form for the decaf event editor page
1582
-     *
1583
-     * @access private
1584
-     * @param  EE_Ticket $ticket   the ticket object
1585
-     * @param  boolean   $skeleton whether we're generating a skeleton for js manipulation
1586
-     * @param int        $row
1587
-     * @return string generated html for the ticket row.
1588
-     */
1589
-    private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1590
-    {
1591
-        $template_args = array(
1592
-            'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1593
-            'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1594
-                : '',
1595
-            'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1596
-            'TKT_ID'              => $ticket->get('TKT_ID'),
1597
-            'TKT_name'            => $ticket->get('TKT_name'),
1598
-            'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1599
-            'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1600
-            'TKT_is_default'      => $ticket->get('TKT_is_default'),
1601
-            'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1602
-            'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1603
-            'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1604
-            'trash_icon'          => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')))
1605
-                                     && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0)
1606
-                ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1607
-            'disabled'            => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1608
-                : ' disabled=disabled',
1609
-        );
1610
-        $price = $ticket->ID() !== 0
1611
-            ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none'))
1612
-            : EE_Registry::instance()->load_model('Price')->create_default_object();
1613
-        $price_args = array(
1614
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1615
-            'PRC_amount'            => $price->get('PRC_amount'),
1616
-            'PRT_ID'                => $price->get('PRT_ID'),
1617
-            'PRC_ID'                => $price->get('PRC_ID'),
1618
-            'PRC_is_default'        => $price->get('PRC_is_default'),
1619
-        );
1620
-        //make sure we have default start and end dates if skeleton
1621
-        //handle rows that should NOT be empty
1622
-        if (empty($template_args['TKT_start_date'])) {
1623
-            //if empty then the start date will be now.
1624
-            $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1625
-        }
1626
-        if (empty($template_args['TKT_end_date'])) {
1627
-            //get the earliest datetime (if present);
1628
-            $earliest_dtt = $this->_cpt_model_obj->ID() > 0
1629
-                ? $this->_cpt_model_obj->get_first_related(
1630
-                    'Datetime',
1631
-                    array('order_by' => array('DTT_EVT_start' => 'ASC'))
1632
-                )
1633
-                : null;
1634
-            if ( ! empty($earliest_dtt)) {
1635
-                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1636
-            } else {
1637
-                $template_args['TKT_end_date'] = date(
1638
-                    'Y-m-d h:i a',
1639
-                    mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))
1640
-                );
1641
-            }
1642
-        }
1643
-        $template_args = array_merge($template_args, $price_args);
1644
-        $template = apply_filters(
1645
-            'FHEE__Events_Admin_Page__get_ticket_row__template',
1646
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1647
-            $ticket
1648
-        );
1649
-        return EEH_Template::display_template($template, $template_args, true);
1650
-    }
1651
-
1652
-
1653
-
1654
-    public function registration_options_meta_box()
1655
-    {
1656
-        $yes_no_values = array(
1657
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
1658
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
1659
-        );
1660
-        $default_reg_status_values = EEM_Registration::reg_status_array(
1661
-            array(
1662
-                EEM_Registration::status_id_cancelled,
1663
-                EEM_Registration::status_id_declined,
1664
-                EEM_Registration::status_id_incomplete,
1665
-            ),
1666
-            true
1667
-        );
1668
-        //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active());
1669
-        $template_args['_event'] = $this->_cpt_model_obj;
1670
-        $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
1671
-        $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
1672
-        $template_args['default_registration_status'] = EEH_Form_Fields::select_input(
1673
-            'default_reg_status',
1674
-            $default_reg_status_values,
1675
-            $this->_cpt_model_obj->default_registration_status()
1676
-        );
1677
-        $template_args['display_description'] = EEH_Form_Fields::select_input(
1678
-            'display_desc',
1679
-            $yes_no_values,
1680
-            $this->_cpt_model_obj->display_description()
1681
-        );
1682
-        $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
1683
-            'display_ticket_selector',
1684
-            $yes_no_values,
1685
-            $this->_cpt_model_obj->display_ticket_selector(),
1686
-            '',
1687
-            '',
1688
-            false
1689
-        );
1690
-        $template_args['additional_registration_options'] = apply_filters(
1691
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1692
-            '',
1693
-            $template_args,
1694
-            $yes_no_values,
1695
-            $default_reg_status_values
1696
-        );
1697
-        EEH_Template::display_template(
1698
-            EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1699
-            $template_args
1700
-        );
1701
-    }
1702
-
1703
-
1704
-
1705
-    /**
1706
-     * _get_events()
1707
-     * This method simply returns all the events (for the given _view and paging)
1708
-     *
1709
-     * @access public
1710
-     * @param int  $per_page     count of items per page (20 default);
1711
-     * @param int  $current_page what is the current page being viewed.
1712
-     * @param bool $count        if TRUE then we just return a count of ALL events matching the given _view.
1713
-     *                           If FALSE then we return an array of event objects
1714
-     *                           that match the given _view and paging parameters.
1715
-     * @return array an array of event objects.
1716
-     */
1717
-    public function get_events($per_page = 10, $current_page = 1, $count = false)
1718
-    {
1719
-        $EEME = $this->_event_model();
1720
-        $offset = ($current_page - 1) * $per_page;
1721
-        $limit = $count ? null : $offset . ',' . $per_page;
1722
-        $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1723
-        $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1724
-        if (isset($this->_req_data['month_range'])) {
1725
-            $pieces = explode(' ', $this->_req_data['month_range'], 3);
1726
-            $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1727
-            $year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1728
-        }
1729
-        $where = array();
1730
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1731
-        //determine what post_status our condition will have for the query.
1732
-        switch ($status) {
1733
-            case 'month' :
1734
-            case 'today' :
1735
-            case null :
1736
-            case 'all' :
1737
-                break;
1738
-            case 'draft' :
1739
-                $where['status'] = array('IN', array('draft', 'auto-draft'));
1740
-                break;
1741
-            default :
1742
-                $where['status'] = $status;
1743
-        }
1744
-        //categories?
1745
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1746
-            ? $this->_req_data['EVT_CAT'] : null;
1747
-        if ( ! empty ($category)) {
1748
-            $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1749
-            $where['Term_Taxonomy.term_id'] = $category;
1750
-        }
1751
-        //date where conditions
1752
-        $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1753
-        if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1754
-            $DateTime = new DateTime(
1755
-                $year_r . '-' . $month_r . '-01 00:00:00',
1756
-                new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1757
-            );
1758
-            $start = $DateTime->format(implode(' ', $start_formats));
1759
-            $end = $DateTime->setDate($year_r, $month_r, $DateTime
1760
-                ->format('t'))->setTime(23, 59, 59)
1761
-                            ->format(implode(' ', $start_formats));
1762
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1763
-        } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1764
-            $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1765
-            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1766
-            $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1767
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1768
-        } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1769
-            $now = date('Y-m-01');
1770
-            $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1771
-            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1772
-            $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1773
-                            ->setTime(23, 59, 59)
1774
-                            ->format(implode(' ', $start_formats));
1775
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1776
-        }
1777
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1778
-            $where['EVT_wp_user'] = get_current_user_id();
1779
-        } else {
1780
-            if ( ! isset($where['status'])) {
1781
-                if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1782
-                    $where['OR'] = array(
1783
-                        'status*restrict_private' => array('!=', 'private'),
1784
-                        'AND'                     => array(
1785
-                            'status*inclusive' => array('=', 'private'),
1786
-                            'EVT_wp_user'      => get_current_user_id(),
1787
-                        ),
1788
-                    );
1789
-                }
1790
-            }
1791
-        }
1792
-        if (isset($this->_req_data['EVT_wp_user'])) {
1793
-            if ($this->_req_data['EVT_wp_user'] != get_current_user_id()
1794
-                && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1795
-            ) {
1796
-                $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1797
-            }
1798
-        }
1799
-        //search query handling
1800
-        if (isset($this->_req_data['s'])) {
1801
-            $search_string = '%' . $this->_req_data['s'] . '%';
1802
-            $where['OR'] = array(
1803
-                'EVT_name'       => array('LIKE', $search_string),
1804
-                'EVT_desc'       => array('LIKE', $search_string),
1805
-                'EVT_short_desc' => array('LIKE', $search_string),
1806
-            );
1807
-        }
1808
-        $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1809
-        $query_params = apply_filters(
1810
-            'FHEE__Events_Admin_Page__get_events__query_params',
1811
-            array(
1812
-                $where,
1813
-                'limit'    => $limit,
1814
-                'order_by' => $orderby,
1815
-                'order'    => $order,
1816
-                'group_by' => 'EVT_ID',
1817
-            ),
1818
-            $this->_req_data
1819
-        );
1820
-        //let's first check if we have special requests coming in.
1821
-        if (isset($this->_req_data['active_status'])) {
1822
-            switch ($this->_req_data['active_status']) {
1823
-                case 'upcoming' :
1824
-                    return $EEME->get_upcoming_events($query_params, $count);
1825
-                    break;
1826
-                case 'expired' :
1827
-                    return $EEME->get_expired_events($query_params, $count);
1828
-                    break;
1829
-                case 'active' :
1830
-                    return $EEME->get_active_events($query_params, $count);
1831
-                    break;
1832
-                case 'inactive' :
1833
-                    return $EEME->get_inactive_events($query_params, $count);
1834
-                    break;
1835
-            }
1836
-        }
1837
-        $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1838
-        return $events;
1839
-    }
1840
-
1841
-
1842
-
1843
-    /**
1844
-     * handling for WordPress CPT actions (trash, restore, delete)
1845
-     *
1846
-     * @param string $post_id
1847
-     */
1848
-    public function trash_cpt_item($post_id)
1849
-    {
1850
-        $this->_req_data['EVT_ID'] = $post_id;
1851
-        $this->_trash_or_restore_event('trash', false);
1852
-    }
1853
-
1854
-
1855
-
1856
-    /**
1857
-     * @param string $post_id
1858
-     */
1859
-    public function restore_cpt_item($post_id)
1860
-    {
1861
-        $this->_req_data['EVT_ID'] = $post_id;
1862
-        $this->_trash_or_restore_event('draft', false);
1863
-    }
1864
-
1865
-
1866
-
1867
-    /**
1868
-     * @param string $post_id
1869
-     */
1870
-    public function delete_cpt_item($post_id)
1871
-    {
1872
-        $this->_req_data['EVT_ID'] = $post_id;
1873
-        $this->_delete_event(false);
1874
-    }
1875
-
1876
-
1877
-
1878
-    /**
1879
-     * _trash_or_restore_event
1880
-     *
1881
-     * @access protected
1882
-     * @param  string $event_status
1883
-     * @param bool    $redirect_after
1884
-     */
1885
-    protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
1886
-    {
1887
-        //determine the event id and set to array.
1888
-        $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
1889
-        // loop thru events
1890
-        if ($EVT_ID) {
1891
-            // clean status
1892
-            $event_status = sanitize_key($event_status);
1893
-            // grab status
1894
-            if ( ! empty($event_status)) {
1895
-                $success = $this->_change_event_status($EVT_ID, $event_status);
1896
-            } else {
1897
-                $success = false;
1898
-                $msg = esc_html__(
1899
-                    'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1900
-                    'event_espresso'
1901
-                );
1902
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1903
-            }
1904
-        } else {
1905
-            $success = false;
1906
-            $msg = esc_html__(
1907
-                'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
1908
-                'event_espresso'
1909
-            );
1910
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1911
-        }
1912
-        $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1913
-        if ($redirect_after) {
1914
-            $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1915
-        }
1916
-    }
1917
-
1918
-
1919
-
1920
-    /**
1921
-     * _trash_or_restore_events
1922
-     *
1923
-     * @access protected
1924
-     * @param  string $event_status
1925
-     * @return void
1926
-     */
1927
-    protected function _trash_or_restore_events($event_status = 'trash')
1928
-    {
1929
-        // clean status
1930
-        $event_status = sanitize_key($event_status);
1931
-        // grab status
1932
-        if ( ! empty($event_status)) {
1933
-            $success = true;
1934
-            //determine the event id and set to array.
1935
-            $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
1936
-            // loop thru events
1937
-            foreach ($EVT_IDs as $EVT_ID) {
1938
-                if ($EVT_ID = absint($EVT_ID)) {
1939
-                    $results = $this->_change_event_status($EVT_ID, $event_status);
1940
-                    $success = $results !== false ? $success : false;
1941
-                } else {
1942
-                    $msg = sprintf(
1943
-                        esc_html__(
1944
-                            'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',
1945
-                            'event_espresso'
1946
-                        ),
1947
-                        $EVT_ID
1948
-                    );
1949
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1950
-                    $success = false;
1951
-                }
1952
-            }
1953
-        } else {
1954
-            $success = false;
1955
-            $msg = esc_html__(
1956
-                'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1957
-                'event_espresso'
1958
-            );
1959
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1960
-        }
1961
-        // in order to force a pluralized result message we need to send back a success status greater than 1
1962
-        $success = $success ? 2 : false;
1963
-        $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1964
-        $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
1965
-    }
1966
-
1967
-
1968
-
1969
-    /**
1970
-     * _trash_or_restore_events
1971
-     *
1972
-     * @access  private
1973
-     * @param  int    $EVT_ID
1974
-     * @param  string $event_status
1975
-     * @return bool
1976
-     */
1977
-    private function _change_event_status($EVT_ID = 0, $event_status = '')
1978
-    {
1979
-        // grab event id
1980
-        if ( ! $EVT_ID) {
1981
-            $msg = esc_html__(
1982
-                'An error occurred. No Event ID or an invalid Event ID was received.',
1983
-                'event_espresso'
1984
-            );
1985
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1986
-            return false;
1987
-        }
1988
-        $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1989
-        // clean status
1990
-        $event_status = sanitize_key($event_status);
1991
-        // grab status
1992
-        if (empty($event_status)) {
1993
-            $msg = esc_html__(
1994
-                'An error occurred. No Event Status or an invalid Event Status was received.',
1995
-                'event_espresso'
1996
-            );
1997
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1998
-            return false;
1999
-        }
2000
-        // was event trashed or restored ?
2001
-        switch ($event_status) {
2002
-            case 'draft' :
2003
-                $action = 'restored from the trash';
2004
-                $hook = 'AHEE_event_restored_from_trash';
2005
-                break;
2006
-            case 'trash' :
2007
-                $action = 'moved to the trash';
2008
-                $hook = 'AHEE_event_moved_to_trash';
2009
-                break;
2010
-            default :
2011
-                $action = 'updated';
2012
-                $hook = false;
2013
-        }
2014
-        //use class to change status
2015
-        $this->_cpt_model_obj->set_status($event_status);
2016
-        $success = $this->_cpt_model_obj->save();
2017
-        if ($success === false) {
2018
-            $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
2019
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2020
-            return false;
2021
-        }
2022
-        if ($hook) {
2023
-            do_action($hook);
2024
-        }
2025
-        return true;
2026
-    }
2027
-
2028
-
2029
-
2030
-    /**
2031
-     * _delete_event
2032
-     *
2033
-     * @access protected
2034
-     * @param bool $redirect_after
2035
-     */
2036
-    protected function _delete_event($redirect_after = true)
2037
-    {
2038
-        //determine the event id and set to array.
2039
-        $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;
2040
-        $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
2041
-        // loop thru events
2042
-        if ($EVT_ID) {
2043
-            $success = $this->_permanently_delete_event($EVT_ID);
2044
-            // get list of events with no prices
2045
-            $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2046
-            // remove this event from the list of events with no prices
2047
-            if (isset($espresso_no_ticket_prices[$EVT_ID])) {
2048
-                unset($espresso_no_ticket_prices[$EVT_ID]);
2049
-            }
2050
-            update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2051
-        } else {
2052
-            $success = false;
2053
-            $msg = esc_html__(
2054
-                'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2055
-                'event_espresso'
2056
-            );
2057
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2058
-        }
2059
-        if ($redirect_after) {
2060
-            $this->_redirect_after_action(
2061
-                $success,
2062
-                'Event',
2063
-                'deleted',
2064
-                array('action' => 'default', 'status' => 'trash')
2065
-            );
2066
-        }
2067
-    }
2068
-
2069
-
2070
-
2071
-    /**
2072
-     * _delete_events
2073
-     *
2074
-     * @access protected
2075
-     * @return void
2076
-     */
2077
-    protected function _delete_events()
2078
-    {
2079
-        $success = true;
2080
-        // get list of events with no prices
2081
-        $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2082
-        //determine the event id and set to array.
2083
-        $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
2084
-        // loop thru events
2085
-        foreach ($EVT_IDs as $EVT_ID) {
2086
-            $EVT_ID = absint($EVT_ID);
2087
-            if ($EVT_ID) {
2088
-                $results = $this->_permanently_delete_event($EVT_ID);
2089
-                $success = $results !== false ? $success : false;
2090
-                // remove this event from the list of events with no prices
2091
-                unset($espresso_no_ticket_prices[$EVT_ID]);
2092
-            } else {
2093
-                $success = false;
2094
-                $msg = esc_html__(
2095
-                    'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2096
-                    'event_espresso'
2097
-                );
2098
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2099
-            }
2100
-        }
2101
-        update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2102
-        // in order to force a pluralized result message we need to send back a success status greater than 1
2103
-        $success = $success ? 2 : false;
2104
-        $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default'));
2105
-    }
2106
-
2107
-
2108
-
2109
-    /**
2110
-     * _permanently_delete_event
2111
-     *
2112
-     * @access  private
2113
-     * @param  int $EVT_ID
2114
-     * @return bool
2115
-     */
2116
-    private function _permanently_delete_event($EVT_ID = 0)
2117
-    {
2118
-        // grab event id
2119
-        if ( ! $EVT_ID) {
2120
-            $msg = esc_html__(
2121
-                'An error occurred. No Event ID or an invalid Event ID was received.',
2122
-                'event_espresso'
2123
-            );
2124
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2125
-            return false;
2126
-        }
2127
-        if (
2128
-            ! $this->_cpt_model_obj instanceof EE_Event
2129
-            || $this->_cpt_model_obj->ID() !== $EVT_ID
2130
-        ) {
2131
-            $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2132
-        }
2133
-        if ( ! $this->_cpt_model_obj instanceof EE_Event) {
2134
-            return false;
2135
-        }
2136
-        //need to delete related tickets and prices first.
2137
-        $datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
2138
-        foreach ($datetimes as $datetime) {
2139
-            $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
2140
-            $tickets = $datetime->get_many_related('Ticket');
2141
-            foreach ($tickets as $ticket) {
2142
-                $ticket->_remove_relation_to($datetime, 'Datetime');
2143
-                $ticket->delete_related_permanently('Price');
2144
-                $ticket->delete_permanently();
2145
-            }
2146
-            $datetime->delete();
2147
-        }
2148
-        //what about related venues or terms?
2149
-        $venues = $this->_cpt_model_obj->get_many_related('Venue');
2150
-        foreach ($venues as $venue) {
2151
-            $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
2152
-        }
2153
-        //any attached question groups?
2154
-        $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
2155
-        if ( ! empty($question_groups)) {
2156
-            foreach ($question_groups as $question_group) {
2157
-                $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
2158
-            }
2159
-        }
2160
-        //Message Template Groups
2161
-        $this->_cpt_model_obj->_remove_relations('Message_Template_Group');
2162
-        /** @type EE_Term_Taxonomy[] $term_taxonomies */
2163
-        $term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
2164
-        foreach ($term_taxonomies as $term_taxonomy) {
2165
-            $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
2166
-        }
2167
-        $success = $this->_cpt_model_obj->delete_permanently();
2168
-        // did it all go as planned ?
2169
-        if ($success) {
2170
-            $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID);
2171
-            EE_Error::add_success($msg);
2172
-        } else {
2173
-            $msg = sprintf(
2174
-                esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'),
2175
-                $EVT_ID
2176
-            );
2177
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2178
-            return false;
2179
-        }
2180
-        do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
2181
-        return true;
2182
-    }
2183
-
2184
-
2185
-
2186
-    /**
2187
-     * get total number of events
2188
-     *
2189
-     * @access public
2190
-     * @return int
2191
-     */
2192
-    public function total_events()
2193
-    {
2194
-        $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2195
-        return $count;
2196
-    }
2197
-
2198
-
2199
-
2200
-    /**
2201
-     * get total number of draft events
2202
-     *
2203
-     * @access public
2204
-     * @return int
2205
-     */
2206
-    public function total_events_draft()
2207
-    {
2208
-        $where = array(
2209
-            'status' => array('IN', array('draft', 'auto-draft')),
2210
-        );
2211
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2212
-        return $count;
2213
-    }
2214
-
2215
-
2216
-
2217
-    /**
2218
-     * get total number of trashed events
2219
-     *
2220
-     * @access public
2221
-     * @return int
2222
-     */
2223
-    public function total_trashed_events()
2224
-    {
2225
-        $where = array(
2226
-            'status' => 'trash',
2227
-        );
2228
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2229
-        return $count;
2230
-    }
2231
-
2232
-
2233
-
2234
-    /**
2235
-     *    _default_event_settings
2236
-     *    This generates the Default Settings Tab
2237
-     *
2238
-     * @return void
2239
-     */
2240
-    protected function _default_event_settings()
2241
-    {
2242
-        $this->_template_args['values'] = $this->_yes_no_values;
2243
-        $this->_template_args['reg_status_array'] = EEM_Registration::reg_status_array(
2244
-        // exclude array
2245
-            array(
2246
-                EEM_Registration::status_id_cancelled,
2247
-                EEM_Registration::status_id_declined,
2248
-                EEM_Registration::status_id_incomplete,
2249
-                EEM_Registration::status_id_wait_list,
2250
-            ),
2251
-            // translated
2252
-            true
2253
-        );
2254
-        $this->_template_args['default_reg_status'] = isset(
2255
-                                                          EE_Registry::instance()->CFG->registration->default_STS_ID
2256
-                                                      )
2257
-                                                      && array_key_exists(
2258
-                                                          EE_Registry::instance()->CFG->registration->default_STS_ID,
2259
-                                                          $this->_template_args['reg_status_array']
2260
-                                                      )
2261
-            ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID)
2262
-            : EEM_Registration::status_id_pending_payment;
2263
-        $this->_set_add_edit_form_tags('update_default_event_settings');
2264
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
2265
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2266
-            EVENTS_TEMPLATE_PATH . 'event_settings.template.php',
2267
-            $this->_template_args,
2268
-            true
2269
-        );
2270
-        $this->display_admin_page_with_sidebar();
2271
-    }
2272
-
2273
-
2274
-
2275
-    /**
2276
-     * _update_default_event_settings
2277
-     *
2278
-     * @access protected
2279
-     * @return void
2280
-     */
2281
-    protected function _update_default_event_settings()
2282
-    {
2283
-        EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status'])
2284
-            ? sanitize_text_field($this->_req_data['default_reg_status'])
2285
-            : EEM_Registration::status_id_pending_payment;
2286
-        $what = 'Default Event Settings';
2287
-        $success = $this->_update_espresso_configuration(
2288
-            $what,
2289
-            EE_Config::instance(),
2290
-            __FILE__,
2291
-            __FUNCTION__,
2292
-            __LINE__
2293
-        );
2294
-        $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings'));
2295
-    }
2296
-
2297
-
2298
-
2299
-    /*************        Templates        *************/
2300
-    protected function _template_settings()
2301
-    {
2302
-        $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso');
2303
-        $this->_template_args['preview_img'] = '<img src="'
2304
-                                               . EVENTS_ASSETS_URL
2305
-                                               . DS
2306
-                                               . 'images'
2307
-                                               . DS
2308
-                                               . 'caffeinated_template_features.jpg" alt="'
2309
-                                               . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2310
-                                               . '" />';
2311
-        $this->_template_args['preview_text'] = '<strong>' . esc_html__(
2312
-                'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.',
2313
-                'event_espresso'
2314
-            ) . '</strong>';
2315
-        $this->display_admin_caf_preview_page('template_settings_tab');
2316
-    }
2317
-
2318
-
2319
-    /** Event Category Stuff **/
2320
-    /**
2321
-     * set the _category property with the category object for the loaded page.
2322
-     *
2323
-     * @access private
2324
-     * @return void
2325
-     */
2326
-    private function _set_category_object()
2327
-    {
2328
-        if (isset($this->_category->id) && ! empty($this->_category->id)) {
2329
-            return;
2330
-        } //already have the category object so get out.
2331
-        //set default category object
2332
-        $this->_set_empty_category_object();
2333
-        //only set if we've got an id
2334
-        if ( ! isset($this->_req_data['EVT_CAT_ID'])) {
2335
-            return;
2336
-        }
2337
-        $category_id = absint($this->_req_data['EVT_CAT_ID']);
2338
-        $term = get_term($category_id, 'espresso_event_categories');
2339
-        if ( ! empty($term)) {
2340
-            $this->_category->category_name = $term->name;
2341
-            $this->_category->category_identifier = $term->slug;
2342
-            $this->_category->category_desc = $term->description;
2343
-            $this->_category->id = $term->term_id;
2344
-            $this->_category->parent = $term->parent;
2345
-        }
2346
-    }
2347
-
2348
-
2349
-
2350
-    private function _set_empty_category_object()
2351
-    {
2352
-        $this->_category = new stdClass();
2353
-        $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2354
-        $this->_category->id = $this->_category->parent = 0;
2355
-    }
2356
-
2357
-
2358
-
2359
-    protected function _category_list_table()
2360
-    {
2361
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2362
-        $this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2363
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2364
-                'add_category',
2365
-                'add_category',
2366
-                array(),
2367
-                'add-new-h2'
2368
-            );
2369
-        $this->display_admin_list_table_page_with_sidebar();
2370
-    }
2371
-
2372
-
2373
-
2374
-    /**
2375
-     * @param $view
2376
-     */
2377
-    protected function _category_details($view)
2378
-    {
2379
-        //load formatter helper
2380
-        //load field generator helper
2381
-        $route = $view == 'edit' ? 'update_category' : 'insert_category';
2382
-        $this->_set_add_edit_form_tags($route);
2383
-        $this->_set_category_object();
2384
-        $id = ! empty($this->_category->id) ? $this->_category->id : '';
2385
-        $delete_action = 'delete_category';
2386
-        //custom redirect
2387
-        $redirect = EE_Admin_Page::add_query_args_and_nonce(
2388
-            array('action' => 'category_list'),
2389
-            $this->_admin_base_url
2390
-        );
2391
-        $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2392
-        //take care of contents
2393
-        $this->_template_args['admin_page_content'] = $this->_category_details_content();
2394
-        $this->display_admin_page_with_sidebar();
2395
-    }
2396
-
2397
-
2398
-
2399
-    /**
2400
-     * @return mixed
2401
-     */
2402
-    protected function _category_details_content()
2403
-    {
2404
-        $editor_args['category_desc'] = array(
2405
-            'type'          => 'wp_editor',
2406
-            'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2407
-            'class'         => 'my_editor_custom',
2408
-            'wpeditor_args' => array('media_buttons' => false),
2409
-        );
2410
-        $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2411
-        $all_terms = get_terms(
2412
-            array('espresso_event_categories'),
2413
-            array('hide_empty' => 0, 'exclude' => array($this->_category->id))
2414
-        );
2415
-        //setup category select for term parents.
2416
-        $category_select_values[] = array(
2417
-            'text' => esc_html__('No Parent', 'event_espresso'),
2418
-            'id'   => 0,
2419
-        );
2420
-        foreach ($all_terms as $term) {
2421
-            $category_select_values[] = array(
2422
-                'text' => $term->name,
2423
-                'id'   => $term->term_id,
2424
-            );
2425
-        }
2426
-        $category_select = EEH_Form_Fields::select_input(
2427
-            'category_parent',
2428
-            $category_select_values,
2429
-            $this->_category->parent
2430
-        );
2431
-        $template_args = array(
2432
-            'category'                 => $this->_category,
2433
-            'category_select'          => $category_select,
2434
-            'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2435
-            'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2436
-            'disable'                  => '',
2437
-            'disabled_message'         => false,
2438
-        );
2439
-        $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2440
-        return EEH_Template::display_template($template, $template_args, true);
2441
-    }
2442
-
2443
-
2444
-
2445
-    protected function _delete_categories()
2446
-    {
2447
-        $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID']
2448
-            : (array)$this->_req_data['category_id'];
2449
-        foreach ($cat_ids as $cat_id) {
2450
-            $this->_delete_category($cat_id);
2451
-        }
2452
-        //doesn't matter what page we're coming from... we're going to the same place after delete.
2453
-        $query_args = array(
2454
-            'action' => 'category_list',
2455
-        );
2456
-        $this->_redirect_after_action(0, '', '', $query_args);
2457
-    }
2458
-
2459
-
2460
-
2461
-    /**
2462
-     * @param $cat_id
2463
-     */
2464
-    protected function _delete_category($cat_id)
2465
-    {
2466
-        $cat_id = absint($cat_id);
2467
-        wp_delete_term($cat_id, 'espresso_event_categories');
2468
-    }
2469
-
2470
-
2471
-
2472
-    /**
2473
-     * @param $new_category
2474
-     */
2475
-    protected function _insert_or_update_category($new_category)
2476
-    {
2477
-        $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2478
-        $success = 0; //we already have a success message so lets not send another.
2479
-        if ($cat_id) {
2480
-            $query_args = array(
2481
-                'action'     => 'edit_category',
2482
-                'EVT_CAT_ID' => $cat_id,
2483
-            );
2484
-        } else {
2485
-            $query_args = array('action' => 'add_category');
2486
-        }
2487
-        $this->_redirect_after_action($success, '', '', $query_args, true);
2488
-    }
2489
-
2490
-
2491
-
2492
-    /**
2493
-     * @param bool $update
2494
-     * @return bool|mixed|string
2495
-     */
2496
-    private function _insert_category($update = false)
2497
-    {
2498
-        $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2499
-        $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2500
-        $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2501
-        $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2502
-        if (empty($category_name)) {
2503
-            $msg = esc_html__('You must add a name for the category.', 'event_espresso');
2504
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2505
-            return false;
2506
-        }
2507
-        $term_args = array(
2508
-            'name'        => $category_name,
2509
-            'description' => $category_desc,
2510
-            'parent'      => $category_parent,
2511
-        );
2512
-        //was the category_identifier input disabled?
2513
-        if (isset($this->_req_data['category_identifier'])) {
2514
-            $term_args['slug'] = $this->_req_data['category_identifier'];
2515
-        }
2516
-        $insert_ids = $update
2517
-            ? wp_update_term($cat_id, 'espresso_event_categories', $term_args)
2518
-            : wp_insert_term($category_name, 'espresso_event_categories', $term_args);
2519
-        if ( ! is_array($insert_ids)) {
2520
-            $msg = esc_html__(
2521
-                'An error occurred and the category has not been saved to the database.',
2522
-                'event_espresso'
2523
-            );
2524
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2525
-        } else {
2526
-            $cat_id = $insert_ids['term_id'];
2527
-            $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name);
2528
-            EE_Error::add_success($msg);
2529
-        }
2530
-        return $cat_id;
2531
-    }
2532
-
2533
-
2534
-
2535
-    /**
2536
-     * @param int  $per_page
2537
-     * @param int  $current_page
2538
-     * @param bool $count
2539
-     * @return \EE_Base_Class[]|int
2540
-     */
2541
-    public function get_categories($per_page = 10, $current_page = 1, $count = false)
2542
-    {
2543
-        //testing term stuff
2544
-        $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2545
-        $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2546
-        $limit = ($current_page - 1) * $per_page;
2547
-        $where = array('taxonomy' => 'espresso_event_categories');
2548
-        if (isset($this->_req_data['s'])) {
2549
-            $sstr = '%' . $this->_req_data['s'] . '%';
2550
-            $where['OR'] = array(
2551
-                'Term.name'   => array('LIKE', $sstr),
2552
-                'description' => array('LIKE', $sstr),
2553
-            );
2554
-        }
2555
-        $query_params = array(
2556
-            $where,
2557
-            'order_by'   => array($orderby => $order),
2558
-            'limit'      => $limit . ',' . $per_page,
2559
-            'force_join' => array('Term'),
2560
-        );
2561
-        $categories = $count
2562
-            ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2563
-            : EEM_Term_Taxonomy::instance()->get_all($query_params);
2564
-        return $categories;
2565
-    }
2566
-
2567
-
2568
-
2569
-    /* end category stuff */
2570
-    /**************/
384
+				'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
385
+				'require_nonce' => false,
386
+			),
387
+			'default_event_settings' => array(
388
+				'nav'           => array(
389
+					'label' => esc_html__('Default Settings', 'event_espresso'),
390
+					'order' => 40,
391
+				),
392
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
393
+				'labels'        => array(
394
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
395
+				),
396
+				'help_tabs'     => array(
397
+					'default_settings_help_tab'        => array(
398
+						'title'    => esc_html__('Default Event Settings', 'event_espresso'),
399
+						'filename' => 'events_default_settings',
400
+					),
401
+					'default_settings_status_help_tab' => array(
402
+						'title'    => esc_html__('Default Registration Status', 'event_espresso'),
403
+						'filename' => 'events_default_settings_status',
404
+					),
405
+				),
406
+				'help_tour'     => array('Event_Default_Settings_Help_Tour'),
407
+				'require_nonce' => false,
408
+			),
409
+			//template settings
410
+			'template_settings'      => array(
411
+				'nav'           => array(
412
+					'label' => esc_html__('Templates', 'event_espresso'),
413
+					'order' => 30,
414
+				),
415
+				'metaboxes'     => $this->_default_espresso_metaboxes,
416
+				'help_tabs'     => array(
417
+					'general_settings_templates_help_tab' => array(
418
+						'title'    => esc_html__('Templates', 'event_espresso'),
419
+						'filename' => 'general_settings_templates',
420
+					),
421
+				),
422
+				'help_tour'     => array('Templates_Help_Tour'),
423
+				'require_nonce' => false,
424
+			),
425
+			//event category stuff
426
+			'add_category'           => array(
427
+				'nav'           => array(
428
+					'label'      => esc_html__('Add Category', 'event_espresso'),
429
+					'order'      => 15,
430
+					'persistent' => false,
431
+				),
432
+				'help_tabs'     => array(
433
+					'add_category_help_tab' => array(
434
+						'title'    => esc_html__('Add New Event Category', 'event_espresso'),
435
+						'filename' => 'events_add_category',
436
+					),
437
+				),
438
+				'help_tour'     => array('Event_Add_Category_Help_Tour'),
439
+				'metaboxes'     => array('_publish_post_box'),
440
+				'require_nonce' => false,
441
+			),
442
+			'edit_category'          => array(
443
+				'nav'           => array(
444
+					'label'      => esc_html__('Edit Category', 'event_espresso'),
445
+					'order'      => 15,
446
+					'persistent' => false,
447
+					'url'        => isset($this->_req_data['EVT_CAT_ID'])
448
+						? add_query_arg(
449
+							array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']),
450
+							$this->_current_page_view_url
451
+						)
452
+						: $this->_admin_base_url,
453
+				),
454
+				'help_tabs'     => array(
455
+					'edit_category_help_tab' => array(
456
+						'title'    => esc_html__('Edit Event Category', 'event_espresso'),
457
+						'filename' => 'events_edit_category',
458
+					),
459
+				),
460
+				/*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/
461
+				'metaboxes'     => array('_publish_post_box'),
462
+				'require_nonce' => false,
463
+			),
464
+			'category_list'          => array(
465
+				'nav'           => array(
466
+					'label' => esc_html__('Categories', 'event_espresso'),
467
+					'order' => 20,
468
+				),
469
+				'list_table'    => 'Event_Categories_Admin_List_Table',
470
+				'help_tabs'     => array(
471
+					'events_categories_help_tab'                       => array(
472
+						'title'    => esc_html__('Event Categories', 'event_espresso'),
473
+						'filename' => 'events_categories',
474
+					),
475
+					'events_categories_table_column_headings_help_tab' => array(
476
+						'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
477
+						'filename' => 'events_categories_table_column_headings',
478
+					),
479
+					'events_categories_view_help_tab'                  => array(
480
+						'title'    => esc_html__('Event Categories Views', 'event_espresso'),
481
+						'filename' => 'events_categories_views',
482
+					),
483
+					'events_categories_other_help_tab'                 => array(
484
+						'title'    => esc_html__('Event Categories Other', 'event_espresso'),
485
+						'filename' => 'events_categories_other',
486
+					),
487
+				),
488
+				'help_tour'     => array(
489
+					'Event_Categories_Help_Tour',
490
+				),
491
+				'metaboxes'     => $this->_default_espresso_metaboxes,
492
+				'require_nonce' => false,
493
+			),
494
+		);
495
+	}
496
+
497
+
498
+
499
+	protected function _add_screen_options()
500
+	{
501
+		//todo
502
+	}
503
+
504
+
505
+
506
+	protected function _add_screen_options_default()
507
+	{
508
+		$this->_per_page_screen_option();
509
+	}
510
+
511
+
512
+
513
+	protected function _add_screen_options_category_list()
514
+	{
515
+		$page_title = $this->_admin_page_title;
516
+		$this->_admin_page_title = esc_html__('Categories', 'event_espresso');
517
+		$this->_per_page_screen_option();
518
+		$this->_admin_page_title = $page_title;
519
+	}
520
+
521
+
522
+
523
+	protected function _add_feature_pointers()
524
+	{
525
+		//todo
526
+	}
527
+
528
+
529
+
530
+	public function load_scripts_styles()
531
+	{
532
+		wp_register_style(
533
+			'events-admin-css',
534
+			EVENTS_ASSETS_URL . 'events-admin-page.css',
535
+			array(),
536
+			EVENT_ESPRESSO_VERSION
537
+		);
538
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
539
+		wp_enqueue_style('events-admin-css');
540
+		wp_enqueue_style('ee-cat-admin');
541
+		//todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
542
+		//registers for all views
543
+		//scripts
544
+		wp_register_script(
545
+			'event_editor_js',
546
+			EVENTS_ASSETS_URL . 'event_editor.js',
547
+			array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
548
+			EVENT_ESPRESSO_VERSION,
549
+			true
550
+		);
551
+	}
552
+
553
+
554
+
555
+	/**
556
+	 * enqueuing scripts and styles specific to this view
557
+	 *
558
+	 * @return void
559
+	 */
560
+	public function load_scripts_styles_create_new()
561
+	{
562
+		$this->load_scripts_styles_edit();
563
+	}
564
+
565
+
566
+
567
+	/**
568
+	 * enqueuing scripts and styles specific to this view
569
+	 *
570
+	 * @return void
571
+	 */
572
+	public function load_scripts_styles_edit()
573
+	{
574
+		//styles
575
+		wp_enqueue_style('espresso-ui-theme');
576
+		wp_register_style(
577
+			'event-editor-css',
578
+			EVENTS_ASSETS_URL . 'event-editor.css',
579
+			array('ee-admin-css'),
580
+			EVENT_ESPRESSO_VERSION
581
+		);
582
+		wp_enqueue_style('event-editor-css');
583
+		//scripts
584
+		wp_register_script(
585
+			'event-datetime-metabox',
586
+			EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
587
+			array('event_editor_js', 'ee-datepicker'),
588
+			EVENT_ESPRESSO_VERSION
589
+		);
590
+		wp_enqueue_script('event-datetime-metabox');
591
+	}
592
+
593
+
594
+
595
+	public function load_scripts_styles_add_category()
596
+	{
597
+		$this->load_scripts_styles_edit_category();
598
+	}
599
+
600
+
601
+
602
+	public function load_scripts_styles_edit_category()
603
+	{
604
+	}
605
+
606
+
607
+
608
+	protected function _set_list_table_views_category_list()
609
+	{
610
+		$this->_views = array(
611
+			'all' => array(
612
+				'slug'        => 'all',
613
+				'label'       => esc_html__('All', 'event_espresso'),
614
+				'count'       => 0,
615
+				'bulk_action' => array(
616
+					'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
617
+				),
618
+			),
619
+		);
620
+	}
621
+
622
+
623
+
624
+	public function admin_init()
625
+	{
626
+		EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(
627
+			'Do you really want to delete this image? Please remember to update your event to complete the removal.',
628
+			'event_espresso'
629
+		);
630
+	}
631
+
632
+
633
+
634
+	//nothing needed for events with these methods.
635
+	public function admin_notices()
636
+	{
637
+	}
638
+
639
+
640
+
641
+	public function admin_footer_scripts()
642
+	{
643
+	}
644
+
645
+
646
+
647
+	/**
648
+	 * Call this function to verify if an event is public and has tickets for sale.  If it does, then we need to show a
649
+	 * warning (via EE_Error::add_error());
650
+	 *
651
+	 * @param  EE_Event $event Event object
652
+	 * @access public
653
+	 * @return void
654
+	 */
655
+	public function verify_event_edit($event = null)
656
+	{
657
+		// no event?
658
+		if (empty($event)) {
659
+			// set event
660
+			$event = $this->_cpt_model_obj;
661
+		}
662
+		// STILL no event?
663
+		if (empty ($event)) {
664
+			return;
665
+		}
666
+		$orig_status = $event->status();
667
+		// first check if event is active.
668
+		if (
669
+			$orig_status === EEM_Event::cancelled
670
+			|| $orig_status === EEM_Event::postponed
671
+			|| $event->is_expired()
672
+			|| $event->is_inactive()
673
+		) {
674
+			return;
675
+		}
676
+		//made it here so it IS active... next check that any of the tickets are sold.
677
+		if ($event->is_sold_out(true)) {
678
+			if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
679
+				EE_Error::add_attention(
680
+					sprintf(
681
+						esc_html__(
682
+							'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.',
683
+							'event_espresso'
684
+						),
685
+						EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
686
+					)
687
+				);
688
+			}
689
+			return;
690
+		} else if ($orig_status === EEM_Event::sold_out) {
691
+			EE_Error::add_attention(
692
+				sprintf(
693
+					esc_html__(
694
+						'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
695
+						'event_espresso'
696
+					),
697
+					EEH_Template::pretty_status($event->status(), false, 'sentence')
698
+				)
699
+			);
700
+		}
701
+		//now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
702
+		if ( ! $event->tickets_on_sale()) {
703
+			return;
704
+		}
705
+		//made it here so show warning
706
+		$this->_edit_event_warning();
707
+	}
708
+
709
+
710
+
711
+	/**
712
+	 * This is the text used for when an event is being edited that is public and has tickets for sale.
713
+	 * When needed, hook this into a EE_Error::add_error() notice.
714
+	 *
715
+	 * @access protected
716
+	 * @return void
717
+	 */
718
+	protected function _edit_event_warning()
719
+	{
720
+		// we don't want to add warnings during these requests
721
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') {
722
+			return;
723
+		}
724
+		EE_Error::add_attention(
725
+			esc_html__(
726
+				'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.',
727
+				'event_espresso'
728
+			)
729
+		);
730
+	}
731
+
732
+
733
+
734
+	/**
735
+	 * When a user is creating a new event, notify them if they haven't set their timezone.
736
+	 * Otherwise, do the normal logic
737
+	 *
738
+	 * @return string
739
+	 * @throws \EE_Error
740
+	 */
741
+	protected function _create_new_cpt_item()
742
+	{
743
+		$gmt_offset = get_option('gmt_offset');
744
+		//only nag them about setting their timezone if it's their first event, and they haven't already done it
745
+		if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) {
746
+			EE_Error::add_attention(
747
+				sprintf(
748
+					__(
749
+						'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.',
750
+						'event_espresso'
751
+					),
752
+					'<a href="' . admin_url('options-general.php') . '">',
753
+					'</a>'
754
+				),
755
+				__FILE__,
756
+				__FUNCTION__,
757
+				__LINE__
758
+			);
759
+		}
760
+		return parent::_create_new_cpt_item();
761
+	}
762
+
763
+
764
+
765
+	protected function _set_list_table_views_default()
766
+	{
767
+		$this->_views = array(
768
+			'all'   => array(
769
+				'slug'        => 'all',
770
+				'label'       => esc_html__('View All Events', 'event_espresso'),
771
+				'count'       => 0,
772
+				'bulk_action' => array(
773
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
774
+				),
775
+			),
776
+			'draft' => array(
777
+				'slug'        => 'draft',
778
+				'label'       => esc_html__('Draft', 'event_espresso'),
779
+				'count'       => 0,
780
+				'bulk_action' => array(
781
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
782
+				),
783
+			),
784
+		);
785
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
786
+			$this->_views['trash'] = array(
787
+				'slug'        => 'trash',
788
+				'label'       => esc_html__('Trash', 'event_espresso'),
789
+				'count'       => 0,
790
+				'bulk_action' => array(
791
+					'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
792
+					'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
793
+				),
794
+			);
795
+		}
796
+	}
797
+
798
+
799
+
800
+	/**
801
+	 * @return array
802
+	 */
803
+	protected function _event_legend_items()
804
+	{
805
+		$items = array(
806
+			'view_details'   => array(
807
+				'class' => 'dashicons dashicons-search',
808
+				'desc'  => esc_html__('View Event', 'event_espresso'),
809
+			),
810
+			'edit_event'     => array(
811
+				'class' => 'ee-icon ee-icon-calendar-edit',
812
+				'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
813
+			),
814
+			'view_attendees' => array(
815
+				'class' => 'dashicons dashicons-groups',
816
+				'desc'  => esc_html__('View Registrations for Event', 'event_espresso'),
817
+			),
818
+		);
819
+		$items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
820
+		$statuses = array(
821
+			'sold_out_status'  => array(
822
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
823
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
824
+			),
825
+			'active_status'    => array(
826
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
827
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
828
+			),
829
+			'upcoming_status'  => array(
830
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
831
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
832
+			),
833
+			'postponed_status' => array(
834
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
835
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
836
+			),
837
+			'cancelled_status' => array(
838
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
839
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
840
+			),
841
+			'expired_status'   => array(
842
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
843
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
844
+			),
845
+			'inactive_status'  => array(
846
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
847
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
848
+			),
849
+		);
850
+		$statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
851
+		return array_merge($items, $statuses);
852
+	}
853
+
854
+
855
+
856
+	/**
857
+	 * _event_model
858
+	 *
859
+	 * @return EEM_Event
860
+	 */
861
+	private function _event_model()
862
+	{
863
+		if ( ! $this->_event_model instanceof EEM_Event) {
864
+			$this->_event_model = EE_Registry::instance()->load_model('Event');
865
+		}
866
+		return $this->_event_model;
867
+	}
868
+
869
+
870
+
871
+	/**
872
+	 * Adds extra buttons to the WP CPT permalink field row.
873
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
874
+	 *
875
+	 * @param  string $return    the current html
876
+	 * @param  int    $id        the post id for the page
877
+	 * @param  string $new_title What the title is
878
+	 * @param  string $new_slug  what the slug is
879
+	 * @return string            The new html string for the permalink area
880
+	 */
881
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
882
+	{
883
+		//make sure this is only when editing
884
+		if ( ! empty($id)) {
885
+			$post = get_post($id);
886
+			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
887
+					   . esc_html__('Shortcode', 'event_espresso')
888
+					   . '</a> ';
889
+			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
890
+					   . $post->ID
891
+					   . ']">';
892
+		}
893
+		return $return;
894
+	}
895
+
896
+
897
+
898
+	/**
899
+	 * _events_overview_list_table
900
+	 * This contains the logic for showing the events_overview list
901
+	 *
902
+	 * @access protected
903
+	 * @return void
904
+	 */
905
+	protected function _events_overview_list_table()
906
+	{
907
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
908
+		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(
909
+			get_post_type_archive_link('espresso_events'),
910
+			esc_html__("View Event Archive Page", "event_espresso"),
911
+			'button'
912
+		);
913
+		$this->_template_args['after_list_table'] .= $this->_display_legend($this->_event_legend_items());
914
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
915
+				'create_new',
916
+				'add',
917
+				array(),
918
+				'add-new-h2'
919
+			);
920
+		$this->display_admin_list_table_page_with_no_sidebar();
921
+	}
922
+
923
+
924
+
925
+	/**
926
+	 * this allows for extra misc actions in the default WP publish box
927
+	 *
928
+	 * @return void
929
+	 */
930
+	public function extra_misc_actions_publish_box()
931
+	{
932
+		$this->_generate_publish_box_extra_content();
933
+	}
934
+
935
+
936
+
937
+	/**
938
+	 * @param string $post_id
939
+	 * @param object $post
940
+	 */
941
+	protected function _insert_update_cpt_item($post_id, $post)
942
+	{
943
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
944
+			//get out we're not processing an event save.
945
+			return;
946
+		}
947
+		$event_values = array(
948
+			'EVT_display_desc'                => ! empty($this->_req_data['display_desc']) ? 1 : 0,
949
+			'EVT_display_ticket_selector'     => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
950
+			'EVT_additional_limit'            => min(
951
+				apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
952
+				! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null
953
+			),
954
+			'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])
955
+				? $this->_req_data['EVT_default_registration_status']
956
+				: EE_Registry::instance()->CFG->registration->default_STS_ID,
957
+			'EVT_member_only'                 => ! empty($this->_req_data['member_only']) ? 1 : 0,
958
+			'EVT_allow_overflow'              => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
959
+			'EVT_timezone_string'             => ! empty($this->_req_data['timezone_string'])
960
+				? $this->_req_data['timezone_string'] : null,
961
+			'EVT_external_URL'                => ! empty($this->_req_data['externalURL'])
962
+				? $this->_req_data['externalURL'] : null,
963
+			'EVT_phone'                       => ! empty($this->_req_data['event_phone'])
964
+				? $this->_req_data['event_phone'] : null,
965
+		);
966
+		//update event
967
+		$success = $this->_event_model()->update_by_ID($event_values, $post_id);
968
+		//get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
969
+		$get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status);
970
+		$event = $this->_event_model()->get_one(array($get_one_where));
971
+		//the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
972
+		$event_update_callbacks = apply_filters(
973
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
974
+			array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))
975
+		);
976
+		$att_success = true;
977
+		foreach ($event_update_callbacks as $e_callback) {
978
+			$_succ = call_user_func_array($e_callback, array($event, $this->_req_data));
979
+			$att_success = ! $att_success ? $att_success
980
+				: $_succ; //if ANY of these updates fail then we want the appropriate global error message
981
+		}
982
+		//any errors?
983
+		if ($success && false === $att_success) {
984
+			EE_Error::add_error(
985
+				esc_html__(
986
+					'Event Details saved successfully but something went wrong with saving attachments.',
987
+					'event_espresso'
988
+				),
989
+				__FILE__,
990
+				__FUNCTION__,
991
+				__LINE__
992
+			);
993
+		} else if ($success === false) {
994
+			EE_Error::add_error(
995
+				esc_html__('Event Details did not save successfully.', 'event_espresso'),
996
+				__FILE__,
997
+				__FUNCTION__,
998
+				__LINE__
999
+			);
1000
+		}
1001
+	}
1002
+
1003
+
1004
+
1005
+	/**
1006
+	 * @see parent::restore_item()
1007
+	 * @param int $post_id
1008
+	 * @param int $revision_id
1009
+	 */
1010
+	protected function _restore_cpt_item($post_id, $revision_id)
1011
+	{
1012
+		//copy existing event meta to new post
1013
+		$post_evt = $this->_event_model()->get_one_by_ID($post_id);
1014
+		if ($post_evt instanceof EE_Event) {
1015
+			//meta revision restore
1016
+			$post_evt->restore_revision($revision_id);
1017
+			//related objs restore
1018
+			$post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
1019
+		}
1020
+	}
1021
+
1022
+
1023
+
1024
+	/**
1025
+	 * Attach the venue to the Event
1026
+	 *
1027
+	 * @param  \EE_Event $evtobj Event Object to add the venue to
1028
+	 * @param  array     $data   The request data from the form
1029
+	 * @return bool           Success or fail.
1030
+	 */
1031
+	protected function _default_venue_update(\EE_Event $evtobj, $data)
1032
+	{
1033
+		require_once(EE_MODELS . 'EEM_Venue.model.php');
1034
+		$venue_model = EE_Registry::instance()->load_model('Venue');
1035
+		$rows_affected = null;
1036
+		$venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1037
+		// very important.  If we don't have a venue name...
1038
+		// then we'll get out because not necessary to create empty venue
1039
+		if (empty($data['venue_title'])) {
1040
+			return false;
1041
+		}
1042
+		$venue_array = array(
1043
+			'VNU_wp_user'         => $evtobj->get('EVT_wp_user'),
1044
+			'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1045
+			'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1046
+			'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1047
+			'VNU_short_desc'      => ! empty($data['venue_short_description']) ? $data['venue_short_description']
1048
+				: null,
1049
+			'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1050
+			'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1051
+			'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1052
+			'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1053
+			'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1054
+			'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1055
+			'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1056
+			'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1057
+			'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1058
+			'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1059
+			'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1060
+			'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1061
+			'status'              => 'publish',
1062
+		);
1063
+		//if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1064
+		if ( ! empty($venue_id)) {
1065
+			$update_where = array($venue_model->primary_key_name() => $venue_id);
1066
+			$rows_affected = $venue_model->update($venue_array, array($update_where));
1067
+			//we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present.
1068
+			$evtobj->_add_relation_to($venue_id, 'Venue');
1069
+			return $rows_affected > 0 ? true : false;
1070
+		} else {
1071
+			//we insert the venue
1072
+			$venue_id = $venue_model->insert($venue_array);
1073
+			$evtobj->_add_relation_to($venue_id, 'Venue');
1074
+			return ! empty($venue_id) ? true : false;
1075
+		}
1076
+		//when we have the ancestor come in it's already been handled by the revision save.
1077
+	}
1078
+
1079
+
1080
+
1081
+	/**
1082
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
1083
+	 *
1084
+	 * @param  EE_Event $evtobj The Event object we're attaching data to
1085
+	 * @param  array    $data   The request data from the form
1086
+	 * @return array
1087
+	 */
1088
+	protected function _default_tickets_update(EE_Event $evtobj, $data)
1089
+	{
1090
+		$success = true;
1091
+		$saved_dtt = null;
1092
+		$saved_tickets = array();
1093
+		$incoming_date_formats = array('Y-m-d', 'h:i a');
1094
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
1095
+			//trim all values to ensure any excess whitespace is removed.
1096
+			$dtt = array_map('trim', $dtt);
1097
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']
1098
+				: $dtt['DTT_EVT_start'];
1099
+			$datetime_values = array(
1100
+				'DTT_ID'        => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
1101
+				'DTT_EVT_start' => $dtt['DTT_EVT_start'],
1102
+				'DTT_EVT_end'   => $dtt['DTT_EVT_end'],
1103
+				'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
1104
+				'DTT_order'     => $row,
1105
+			);
1106
+			//if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
1107
+			if ( ! empty($dtt['DTT_ID'])) {
1108
+				$DTM = EE_Registry::instance()
1109
+								  ->load_model('Datetime', array($evtobj->get_timezone()))
1110
+								  ->get_one_by_ID($dtt['DTT_ID']);
1111
+				$DTM->set_date_format($incoming_date_formats[0]);
1112
+				$DTM->set_time_format($incoming_date_formats[1]);
1113
+				foreach ($datetime_values as $field => $value) {
1114
+					$DTM->set($field, $value);
1115
+				}
1116
+				//make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.  We need to do this so we dont' TRASH the parent DTT.
1117
+				$saved_dtts[$DTM->ID()] = $DTM;
1118
+			} else {
1119
+				$DTM = EE_Registry::instance()->load_class(
1120
+					'Datetime',
1121
+					array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats),
1122
+					false,
1123
+					false
1124
+				);
1125
+				foreach ($datetime_values as $field => $value) {
1126
+					$DTM->set($field, $value);
1127
+				}
1128
+			}
1129
+			$DTM->save();
1130
+			$DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1131
+			//load DTT helper
1132
+			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1133
+			if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1134
+				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1135
+				$DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1136
+				$DTT->save();
1137
+			}
1138
+			//now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
1139
+			$saved_dtt = $DTT;
1140
+			$success = ! $success ? $success : $DTT;
1141
+			//if ANY of these updates fail then we want the appropriate global error message.
1142
+			// //todo this is actually sucky we need a better error message but this is what it is for now.
1143
+		}
1144
+		//no dtts get deleted so we don't do any of that logic here.
1145
+		//update tickets next
1146
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1147
+		foreach ($data['edit_tickets'] as $row => $tkt) {
1148
+			$incoming_date_formats = array('Y-m-d', 'h:i a');
1149
+			$update_prices = false;
1150
+			$ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount'])
1151
+				? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1152
+			// trim inputs to ensure any excess whitespace is removed.
1153
+			$tkt = array_map('trim', $tkt);
1154
+			if (empty($tkt['TKT_start_date'])) {
1155
+				//let's use now in the set timezone.
1156
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1157
+				$tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1158
+			}
1159
+			if (empty($tkt['TKT_end_date'])) {
1160
+				//use the start date of the first datetime
1161
+				$dtt = $evtobj->first_datetime();
1162
+				$tkt['TKT_end_date'] = $dtt->start_date_and_time(
1163
+					$incoming_date_formats[0],
1164
+					$incoming_date_formats[1]
1165
+				);
1166
+			}
1167
+			$TKT_values = array(
1168
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
1169
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1170
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1171
+				'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1172
+				'TKT_start_date'  => $tkt['TKT_start_date'],
1173
+				'TKT_end_date'    => $tkt['TKT_end_date'],
1174
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1175
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1176
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1177
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1178
+				'TKT_row'         => $row,
1179
+				'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1180
+				'TKT_price'       => $ticket_price,
1181
+			);
1182
+			//if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
1183
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1184
+				$TKT_values['TKT_ID'] = 0;
1185
+				$TKT_values['TKT_is_default'] = 0;
1186
+				$TKT_values['TKT_price'] = $ticket_price;
1187
+				$update_prices = true;
1188
+			}
1189
+			//if we have a TKT_ID then we need to get that existing TKT_obj and update it
1190
+			//we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified.
1191
+			//keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1192
+			if ( ! empty($tkt['TKT_ID'])) {
1193
+				$TKT = EE_Registry::instance()
1194
+								  ->load_model('Ticket', array($evtobj->get_timezone()))
1195
+								  ->get_one_by_ID($tkt['TKT_ID']);
1196
+				if ($TKT instanceof EE_Ticket) {
1197
+					$ticket_sold = $TKT->count_related(
1198
+						'Registration',
1199
+						array(
1200
+							array(
1201
+								'STS_ID' => array(
1202
+									'NOT IN',
1203
+									array(EEM_Registration::status_id_incomplete),
1204
+								),
1205
+							),
1206
+						)
1207
+					) > 0 ? true : false;
1208
+					//let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1209
+					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price')
1210
+									  && ! $TKT->get(
1211
+						'TKT_deleted'
1212
+					) ? true : false;
1213
+					$TKT->set_date_format($incoming_date_formats[0]);
1214
+					$TKT->set_time_format($incoming_date_formats[1]);
1215
+					//set new values
1216
+					foreach ($TKT_values as $field => $value) {
1217
+						if ($field == 'TKT_qty') {
1218
+							$TKT->set_qty($value);
1219
+						} else {
1220
+							$TKT->set($field, $value);
1221
+						}
1222
+					}
1223
+					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1224
+					if ($create_new_TKT) {
1225
+						//archive the old ticket first
1226
+						$TKT->set('TKT_deleted', 1);
1227
+						$TKT->save();
1228
+						//make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1229
+						$saved_tickets[$TKT->ID()] = $TKT;
1230
+						//create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it.
1231
+						$TKT = clone $TKT;
1232
+						$TKT->set('TKT_ID', 0);
1233
+						$TKT->set('TKT_deleted', 0);
1234
+						$TKT->set('TKT_price', $ticket_price);
1235
+						$TKT->set('TKT_sold', 0);
1236
+						//now we need to make sure that $new prices are created as well and attached to new ticket.
1237
+						$update_prices = true;
1238
+					}
1239
+					//make sure price is set if it hasn't been already
1240
+					$TKT->set('TKT_price', $ticket_price);
1241
+				}
1242
+			} else {
1243
+				//no TKT_id so a new TKT
1244
+				$TKT_values['TKT_price'] = $ticket_price;
1245
+				$TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false);
1246
+				if ($TKT instanceof EE_Ticket) {
1247
+					//need to reset values to properly account for the date formats
1248
+					$TKT->set_date_format($incoming_date_formats[0]);
1249
+					$TKT->set_time_format($incoming_date_formats[1]);
1250
+					$TKT->set_timezone($evtobj->get_timezone());
1251
+					//set new values
1252
+					foreach ($TKT_values as $field => $value) {
1253
+						if ($field == 'TKT_qty') {
1254
+							$TKT->set_qty($value);
1255
+						} else {
1256
+							$TKT->set($field, $value);
1257
+						}
1258
+					}
1259
+					$update_prices = true;
1260
+				}
1261
+			}
1262
+			// cap ticket qty by datetime reg limits
1263
+			$TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1264
+			//update ticket.
1265
+			$TKT->save();
1266
+			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1267
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1268
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1269
+				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1270
+				$TKT->save();
1271
+			}
1272
+			//initially let's add the ticket to the dtt
1273
+			$saved_dtt->_add_relation_to($TKT, 'Ticket');
1274
+			$saved_tickets[$TKT->ID()] = $TKT;
1275
+			//add prices to ticket
1276
+			$this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices);
1277
+		}
1278
+		//however now we need to handle permanently deleting tickets via the ui.  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.  However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db.
1279
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1280
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1281
+		foreach ($tickets_removed as $id) {
1282
+			$id = absint($id);
1283
+			//get the ticket for this id
1284
+			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
1285
+			//need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold)
1286
+			$dtts = $tkt_to_remove->get_many_related('Datetime');
1287
+			foreach ($dtts as $dtt) {
1288
+				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1289
+			}
1290
+			//need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
1291
+			$tkt_to_remove->delete_related_permanently('Price');
1292
+			//finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1293
+			$tkt_to_remove->delete_permanently();
1294
+		}
1295
+		return array($saved_dtt, $saved_tickets);
1296
+	}
1297
+
1298
+
1299
+
1300
+	/**
1301
+	 * This attaches a list of given prices to a ticket.
1302
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
1303
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
1304
+	 * price info and prices are automatically "archived" via the ticket.
1305
+	 *
1306
+	 * @access  private
1307
+	 * @param array     $prices     Array of prices from the form.
1308
+	 * @param EE_Ticket $ticket     EE_Ticket object that prices are being attached to.
1309
+	 * @param bool      $new_prices Whether attach existing incoming prices or create new ones.
1310
+	 * @return  void
1311
+	 */
1312
+	private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false)
1313
+	{
1314
+		foreach ($prices as $row => $prc) {
1315
+			$PRC_values = array(
1316
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
1317
+				'PRT_ID'         => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,
1318
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1319
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1320
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1321
+				'PRC_is_default' => 0, //make sure prices are NOT set as default from this context
1322
+				'PRC_order'      => $row,
1323
+			);
1324
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
1325
+				$PRC_values['PRC_ID'] = 0;
1326
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
1327
+			} else {
1328
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1329
+				//update this price with new values
1330
+				foreach ($PRC_values as $field => $newprc) {
1331
+					$PRC->set($field, $newprc);
1332
+				}
1333
+				$PRC->save();
1334
+			}
1335
+			$ticket->_add_relation_to($PRC, 'Price');
1336
+		}
1337
+	}
1338
+
1339
+
1340
+
1341
+	/**
1342
+	 * Add in our autosave ajax handlers
1343
+	 *
1344
+	 * @return void
1345
+	 */
1346
+	protected function _ee_autosave_create_new()
1347
+	{
1348
+		// $this->_ee_autosave_edit();
1349
+	}
1350
+
1351
+
1352
+
1353
+	protected function _ee_autosave_edit()
1354
+	{
1355
+		return; //TEMPORARILY EXITING CAUSE THIS IS A TODO
1356
+	}
1357
+
1358
+
1359
+
1360
+	/**
1361
+	 *    _generate_publish_box_extra_content
1362
+	 *
1363
+	 * @access private
1364
+	 * @return void
1365
+	 */
1366
+	private function _generate_publish_box_extra_content()
1367
+	{
1368
+		//load formatter helper
1369
+		//args for getting related registrations
1370
+		$approved_query_args = array(
1371
+			array(
1372
+				'REG_deleted' => 0,
1373
+				'STS_ID'      => EEM_Registration::status_id_approved,
1374
+			),
1375
+		);
1376
+		$not_approved_query_args = array(
1377
+			array(
1378
+				'REG_deleted' => 0,
1379
+				'STS_ID'      => EEM_Registration::status_id_not_approved,
1380
+			),
1381
+		);
1382
+		$pending_payment_query_args = array(
1383
+			array(
1384
+				'REG_deleted' => 0,
1385
+				'STS_ID'      => EEM_Registration::status_id_pending_payment,
1386
+			),
1387
+		);
1388
+		// publish box
1389
+		$publish_box_extra_args = array(
1390
+			'view_approved_reg_url'        => add_query_arg(
1391
+				array(
1392
+					'action'      => 'default',
1393
+					'event_id'    => $this->_cpt_model_obj->ID(),
1394
+					'_reg_status' => EEM_Registration::status_id_approved,
1395
+				),
1396
+				REG_ADMIN_URL
1397
+			),
1398
+			'view_not_approved_reg_url'    => add_query_arg(
1399
+				array(
1400
+					'action'      => 'default',
1401
+					'event_id'    => $this->_cpt_model_obj->ID(),
1402
+					'_reg_status' => EEM_Registration::status_id_not_approved,
1403
+				),
1404
+				REG_ADMIN_URL
1405
+			),
1406
+			'view_pending_payment_reg_url' => add_query_arg(
1407
+				array(
1408
+					'action'      => 'default',
1409
+					'event_id'    => $this->_cpt_model_obj->ID(),
1410
+					'_reg_status' => EEM_Registration::status_id_pending_payment,
1411
+				),
1412
+				REG_ADMIN_URL
1413
+			),
1414
+			'approved_regs'                => $this->_cpt_model_obj->count_related(
1415
+				'Registration',
1416
+				$approved_query_args
1417
+			),
1418
+			'not_approved_regs'            => $this->_cpt_model_obj->count_related(
1419
+				'Registration',
1420
+				$not_approved_query_args
1421
+			),
1422
+			'pending_payment_regs'         => $this->_cpt_model_obj->count_related(
1423
+				'Registration',
1424
+				$pending_payment_query_args
1425
+			),
1426
+			'misc_pub_section_class'       => apply_filters(
1427
+				'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1428
+				'misc-pub-section'
1429
+			),
1430
+			//'email_attendees_url' => add_query_arg(
1431
+			//	array(
1432
+			//		'event_admin_reports' => 'event_newsletter',
1433
+			//		'event_id' => $this->_cpt_model_obj->id
1434
+			//	),
1435
+			//	'admin.php?page=espresso_registrations'
1436
+			//),
1437
+		);
1438
+		ob_start();
1439
+		do_action(
1440
+			'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1441
+			$this->_cpt_model_obj
1442
+		);
1443
+		$publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1444
+		// load template
1445
+		EEH_Template::display_template(
1446
+			EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1447
+			$publish_box_extra_args
1448
+		);
1449
+	}
1450
+
1451
+
1452
+
1453
+	/**
1454
+	 * This just returns whatever is set as the _event object property
1455
+	 * //todo this will become obsolete once the models are in place
1456
+	 *
1457
+	 * @return object
1458
+	 */
1459
+	public function get_event_object()
1460
+	{
1461
+		return $this->_cpt_model_obj;
1462
+	}
1463
+
1464
+
1465
+
1466
+
1467
+	/** METABOXES * */
1468
+	/**
1469
+	 * _register_event_editor_meta_boxes
1470
+	 * add all metaboxes related to the event_editor
1471
+	 *
1472
+	 * @return void
1473
+	 */
1474
+	protected function _register_event_editor_meta_boxes()
1475
+	{
1476
+		$this->verify_cpt_object();
1477
+		add_meta_box(
1478
+			'espresso_event_editor_tickets',
1479
+			esc_html__('Event Datetime & Ticket', 'event_espresso'),
1480
+			array($this, 'ticket_metabox'),
1481
+			$this->page_slug,
1482
+			'normal',
1483
+			'high'
1484
+		);
1485
+		add_meta_box(
1486
+			'espresso_event_editor_event_options',
1487
+			esc_html__('Event Registration Options', 'event_espresso'),
1488
+			array($this, 'registration_options_meta_box'),
1489
+			$this->page_slug,
1490
+			'side',
1491
+			'default'
1492
+		);
1493
+		// NOTE: if you're looking for other metaboxes in here,
1494
+		// where a metabox has a related management page in the admin
1495
+		// you will find it setup in the related management page's "_Hooks" file.
1496
+		// i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".
1497
+	}
1498
+
1499
+
1500
+
1501
+	public function ticket_metabox()
1502
+	{
1503
+		$existing_datetime_ids = $existing_ticket_ids = array();
1504
+		//defaults for template args
1505
+		$template_args = array(
1506
+			'existing_datetime_ids'    => '',
1507
+			'event_datetime_help_link' => '',
1508
+			'ticket_options_help_link' => '',
1509
+			'time'                     => null,
1510
+			'ticket_rows'              => '',
1511
+			'existing_ticket_ids'      => '',
1512
+			'total_ticket_rows'        => 1,
1513
+			'ticket_js_structure'      => '',
1514
+			'trash_icon'               => 'ee-lock-icon',
1515
+			'disabled'                 => '',
1516
+		);
1517
+		$event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1518
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1519
+		/**
1520
+		 * 1. Start with retrieving Datetimes
1521
+		 * 2. Fore each datetime get related tickets
1522
+		 * 3. For each ticket get related prices
1523
+		 */
1524
+		$times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1525
+		/** @type EE_Datetime $first_datetime */
1526
+		$first_datetime = reset($times);
1527
+		//do we get related tickets?
1528
+		if ($first_datetime instanceof EE_Datetime
1529
+			&& $first_datetime->ID() !== 0
1530
+		) {
1531
+			$existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1532
+			$template_args['time'] = $first_datetime;
1533
+			$related_tickets = $first_datetime->tickets(
1534
+				array(
1535
+					array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1536
+					'default_where_conditions' => 'none',
1537
+				)
1538
+			);
1539
+			if ( ! empty($related_tickets)) {
1540
+				$template_args['total_ticket_rows'] = count($related_tickets);
1541
+				$row = 0;
1542
+				foreach ($related_tickets as $ticket) {
1543
+					$existing_ticket_ids[] = $ticket->get('TKT_ID');
1544
+					$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1545
+					$row++;
1546
+				}
1547
+			} else {
1548
+				$template_args['total_ticket_rows'] = 1;
1549
+				/** @type EE_Ticket $ticket */
1550
+				$ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1551
+				$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1552
+			}
1553
+		} else {
1554
+			$template_args['time'] = $times[0];
1555
+			/** @type EE_Ticket $ticket */
1556
+			$ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1557
+			$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1558
+			// NOTE: we're just sending the first default row
1559
+			// (decaf can't manage default tickets so this should be sufficient);
1560
+		}
1561
+		$template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1562
+			'event_editor_event_datetimes_help_tab'
1563
+		);
1564
+		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1565
+		$template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1566
+		$template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1567
+		$template_args['ticket_js_structure'] = $this->_get_ticket_row(
1568
+			EE_Registry::instance()->load_model('Ticket')->create_default_object(),
1569
+			true
1570
+		);
1571
+		$template = apply_filters(
1572
+			'FHEE__Events_Admin_Page__ticket_metabox__template',
1573
+			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1574
+		);
1575
+		EEH_Template::display_template($template, $template_args);
1576
+	}
1577
+
1578
+
1579
+
1580
+	/**
1581
+	 * Setup an individual ticket form for the decaf event editor page
1582
+	 *
1583
+	 * @access private
1584
+	 * @param  EE_Ticket $ticket   the ticket object
1585
+	 * @param  boolean   $skeleton whether we're generating a skeleton for js manipulation
1586
+	 * @param int        $row
1587
+	 * @return string generated html for the ticket row.
1588
+	 */
1589
+	private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1590
+	{
1591
+		$template_args = array(
1592
+			'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1593
+			'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1594
+				: '',
1595
+			'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1596
+			'TKT_ID'              => $ticket->get('TKT_ID'),
1597
+			'TKT_name'            => $ticket->get('TKT_name'),
1598
+			'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1599
+			'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1600
+			'TKT_is_default'      => $ticket->get('TKT_is_default'),
1601
+			'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1602
+			'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1603
+			'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1604
+			'trash_icon'          => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')))
1605
+									 && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0)
1606
+				? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1607
+			'disabled'            => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1608
+				: ' disabled=disabled',
1609
+		);
1610
+		$price = $ticket->ID() !== 0
1611
+			? $ticket->get_first_related('Price', array('default_where_conditions' => 'none'))
1612
+			: EE_Registry::instance()->load_model('Price')->create_default_object();
1613
+		$price_args = array(
1614
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1615
+			'PRC_amount'            => $price->get('PRC_amount'),
1616
+			'PRT_ID'                => $price->get('PRT_ID'),
1617
+			'PRC_ID'                => $price->get('PRC_ID'),
1618
+			'PRC_is_default'        => $price->get('PRC_is_default'),
1619
+		);
1620
+		//make sure we have default start and end dates if skeleton
1621
+		//handle rows that should NOT be empty
1622
+		if (empty($template_args['TKT_start_date'])) {
1623
+			//if empty then the start date will be now.
1624
+			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1625
+		}
1626
+		if (empty($template_args['TKT_end_date'])) {
1627
+			//get the earliest datetime (if present);
1628
+			$earliest_dtt = $this->_cpt_model_obj->ID() > 0
1629
+				? $this->_cpt_model_obj->get_first_related(
1630
+					'Datetime',
1631
+					array('order_by' => array('DTT_EVT_start' => 'ASC'))
1632
+				)
1633
+				: null;
1634
+			if ( ! empty($earliest_dtt)) {
1635
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1636
+			} else {
1637
+				$template_args['TKT_end_date'] = date(
1638
+					'Y-m-d h:i a',
1639
+					mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))
1640
+				);
1641
+			}
1642
+		}
1643
+		$template_args = array_merge($template_args, $price_args);
1644
+		$template = apply_filters(
1645
+			'FHEE__Events_Admin_Page__get_ticket_row__template',
1646
+			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1647
+			$ticket
1648
+		);
1649
+		return EEH_Template::display_template($template, $template_args, true);
1650
+	}
1651
+
1652
+
1653
+
1654
+	public function registration_options_meta_box()
1655
+	{
1656
+		$yes_no_values = array(
1657
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
1658
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
1659
+		);
1660
+		$default_reg_status_values = EEM_Registration::reg_status_array(
1661
+			array(
1662
+				EEM_Registration::status_id_cancelled,
1663
+				EEM_Registration::status_id_declined,
1664
+				EEM_Registration::status_id_incomplete,
1665
+			),
1666
+			true
1667
+		);
1668
+		//$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active());
1669
+		$template_args['_event'] = $this->_cpt_model_obj;
1670
+		$template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
1671
+		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
1672
+		$template_args['default_registration_status'] = EEH_Form_Fields::select_input(
1673
+			'default_reg_status',
1674
+			$default_reg_status_values,
1675
+			$this->_cpt_model_obj->default_registration_status()
1676
+		);
1677
+		$template_args['display_description'] = EEH_Form_Fields::select_input(
1678
+			'display_desc',
1679
+			$yes_no_values,
1680
+			$this->_cpt_model_obj->display_description()
1681
+		);
1682
+		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
1683
+			'display_ticket_selector',
1684
+			$yes_no_values,
1685
+			$this->_cpt_model_obj->display_ticket_selector(),
1686
+			'',
1687
+			'',
1688
+			false
1689
+		);
1690
+		$template_args['additional_registration_options'] = apply_filters(
1691
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1692
+			'',
1693
+			$template_args,
1694
+			$yes_no_values,
1695
+			$default_reg_status_values
1696
+		);
1697
+		EEH_Template::display_template(
1698
+			EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1699
+			$template_args
1700
+		);
1701
+	}
1702
+
1703
+
1704
+
1705
+	/**
1706
+	 * _get_events()
1707
+	 * This method simply returns all the events (for the given _view and paging)
1708
+	 *
1709
+	 * @access public
1710
+	 * @param int  $per_page     count of items per page (20 default);
1711
+	 * @param int  $current_page what is the current page being viewed.
1712
+	 * @param bool $count        if TRUE then we just return a count of ALL events matching the given _view.
1713
+	 *                           If FALSE then we return an array of event objects
1714
+	 *                           that match the given _view and paging parameters.
1715
+	 * @return array an array of event objects.
1716
+	 */
1717
+	public function get_events($per_page = 10, $current_page = 1, $count = false)
1718
+	{
1719
+		$EEME = $this->_event_model();
1720
+		$offset = ($current_page - 1) * $per_page;
1721
+		$limit = $count ? null : $offset . ',' . $per_page;
1722
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1723
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1724
+		if (isset($this->_req_data['month_range'])) {
1725
+			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1726
+			$month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1727
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1728
+		}
1729
+		$where = array();
1730
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1731
+		//determine what post_status our condition will have for the query.
1732
+		switch ($status) {
1733
+			case 'month' :
1734
+			case 'today' :
1735
+			case null :
1736
+			case 'all' :
1737
+				break;
1738
+			case 'draft' :
1739
+				$where['status'] = array('IN', array('draft', 'auto-draft'));
1740
+				break;
1741
+			default :
1742
+				$where['status'] = $status;
1743
+		}
1744
+		//categories?
1745
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1746
+			? $this->_req_data['EVT_CAT'] : null;
1747
+		if ( ! empty ($category)) {
1748
+			$where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1749
+			$where['Term_Taxonomy.term_id'] = $category;
1750
+		}
1751
+		//date where conditions
1752
+		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1753
+		if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1754
+			$DateTime = new DateTime(
1755
+				$year_r . '-' . $month_r . '-01 00:00:00',
1756
+				new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1757
+			);
1758
+			$start = $DateTime->format(implode(' ', $start_formats));
1759
+			$end = $DateTime->setDate($year_r, $month_r, $DateTime
1760
+				->format('t'))->setTime(23, 59, 59)
1761
+							->format(implode(' ', $start_formats));
1762
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1763
+		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1764
+			$DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1765
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1766
+			$end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1767
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1768
+		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1769
+			$now = date('Y-m-01');
1770
+			$DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1771
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1772
+			$end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1773
+							->setTime(23, 59, 59)
1774
+							->format(implode(' ', $start_formats));
1775
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1776
+		}
1777
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1778
+			$where['EVT_wp_user'] = get_current_user_id();
1779
+		} else {
1780
+			if ( ! isset($where['status'])) {
1781
+				if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1782
+					$where['OR'] = array(
1783
+						'status*restrict_private' => array('!=', 'private'),
1784
+						'AND'                     => array(
1785
+							'status*inclusive' => array('=', 'private'),
1786
+							'EVT_wp_user'      => get_current_user_id(),
1787
+						),
1788
+					);
1789
+				}
1790
+			}
1791
+		}
1792
+		if (isset($this->_req_data['EVT_wp_user'])) {
1793
+			if ($this->_req_data['EVT_wp_user'] != get_current_user_id()
1794
+				&& EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1795
+			) {
1796
+				$where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1797
+			}
1798
+		}
1799
+		//search query handling
1800
+		if (isset($this->_req_data['s'])) {
1801
+			$search_string = '%' . $this->_req_data['s'] . '%';
1802
+			$where['OR'] = array(
1803
+				'EVT_name'       => array('LIKE', $search_string),
1804
+				'EVT_desc'       => array('LIKE', $search_string),
1805
+				'EVT_short_desc' => array('LIKE', $search_string),
1806
+			);
1807
+		}
1808
+		$where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1809
+		$query_params = apply_filters(
1810
+			'FHEE__Events_Admin_Page__get_events__query_params',
1811
+			array(
1812
+				$where,
1813
+				'limit'    => $limit,
1814
+				'order_by' => $orderby,
1815
+				'order'    => $order,
1816
+				'group_by' => 'EVT_ID',
1817
+			),
1818
+			$this->_req_data
1819
+		);
1820
+		//let's first check if we have special requests coming in.
1821
+		if (isset($this->_req_data['active_status'])) {
1822
+			switch ($this->_req_data['active_status']) {
1823
+				case 'upcoming' :
1824
+					return $EEME->get_upcoming_events($query_params, $count);
1825
+					break;
1826
+				case 'expired' :
1827
+					return $EEME->get_expired_events($query_params, $count);
1828
+					break;
1829
+				case 'active' :
1830
+					return $EEME->get_active_events($query_params, $count);
1831
+					break;
1832
+				case 'inactive' :
1833
+					return $EEME->get_inactive_events($query_params, $count);
1834
+					break;
1835
+			}
1836
+		}
1837
+		$events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1838
+		return $events;
1839
+	}
1840
+
1841
+
1842
+
1843
+	/**
1844
+	 * handling for WordPress CPT actions (trash, restore, delete)
1845
+	 *
1846
+	 * @param string $post_id
1847
+	 */
1848
+	public function trash_cpt_item($post_id)
1849
+	{
1850
+		$this->_req_data['EVT_ID'] = $post_id;
1851
+		$this->_trash_or_restore_event('trash', false);
1852
+	}
1853
+
1854
+
1855
+
1856
+	/**
1857
+	 * @param string $post_id
1858
+	 */
1859
+	public function restore_cpt_item($post_id)
1860
+	{
1861
+		$this->_req_data['EVT_ID'] = $post_id;
1862
+		$this->_trash_or_restore_event('draft', false);
1863
+	}
1864
+
1865
+
1866
+
1867
+	/**
1868
+	 * @param string $post_id
1869
+	 */
1870
+	public function delete_cpt_item($post_id)
1871
+	{
1872
+		$this->_req_data['EVT_ID'] = $post_id;
1873
+		$this->_delete_event(false);
1874
+	}
1875
+
1876
+
1877
+
1878
+	/**
1879
+	 * _trash_or_restore_event
1880
+	 *
1881
+	 * @access protected
1882
+	 * @param  string $event_status
1883
+	 * @param bool    $redirect_after
1884
+	 */
1885
+	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
1886
+	{
1887
+		//determine the event id and set to array.
1888
+		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
1889
+		// loop thru events
1890
+		if ($EVT_ID) {
1891
+			// clean status
1892
+			$event_status = sanitize_key($event_status);
1893
+			// grab status
1894
+			if ( ! empty($event_status)) {
1895
+				$success = $this->_change_event_status($EVT_ID, $event_status);
1896
+			} else {
1897
+				$success = false;
1898
+				$msg = esc_html__(
1899
+					'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1900
+					'event_espresso'
1901
+				);
1902
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1903
+			}
1904
+		} else {
1905
+			$success = false;
1906
+			$msg = esc_html__(
1907
+				'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
1908
+				'event_espresso'
1909
+			);
1910
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1911
+		}
1912
+		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1913
+		if ($redirect_after) {
1914
+			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1915
+		}
1916
+	}
1917
+
1918
+
1919
+
1920
+	/**
1921
+	 * _trash_or_restore_events
1922
+	 *
1923
+	 * @access protected
1924
+	 * @param  string $event_status
1925
+	 * @return void
1926
+	 */
1927
+	protected function _trash_or_restore_events($event_status = 'trash')
1928
+	{
1929
+		// clean status
1930
+		$event_status = sanitize_key($event_status);
1931
+		// grab status
1932
+		if ( ! empty($event_status)) {
1933
+			$success = true;
1934
+			//determine the event id and set to array.
1935
+			$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
1936
+			// loop thru events
1937
+			foreach ($EVT_IDs as $EVT_ID) {
1938
+				if ($EVT_ID = absint($EVT_ID)) {
1939
+					$results = $this->_change_event_status($EVT_ID, $event_status);
1940
+					$success = $results !== false ? $success : false;
1941
+				} else {
1942
+					$msg = sprintf(
1943
+						esc_html__(
1944
+							'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',
1945
+							'event_espresso'
1946
+						),
1947
+						$EVT_ID
1948
+					);
1949
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1950
+					$success = false;
1951
+				}
1952
+			}
1953
+		} else {
1954
+			$success = false;
1955
+			$msg = esc_html__(
1956
+				'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1957
+				'event_espresso'
1958
+			);
1959
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1960
+		}
1961
+		// in order to force a pluralized result message we need to send back a success status greater than 1
1962
+		$success = $success ? 2 : false;
1963
+		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1964
+		$this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
1965
+	}
1966
+
1967
+
1968
+
1969
+	/**
1970
+	 * _trash_or_restore_events
1971
+	 *
1972
+	 * @access  private
1973
+	 * @param  int    $EVT_ID
1974
+	 * @param  string $event_status
1975
+	 * @return bool
1976
+	 */
1977
+	private function _change_event_status($EVT_ID = 0, $event_status = '')
1978
+	{
1979
+		// grab event id
1980
+		if ( ! $EVT_ID) {
1981
+			$msg = esc_html__(
1982
+				'An error occurred. No Event ID or an invalid Event ID was received.',
1983
+				'event_espresso'
1984
+			);
1985
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1986
+			return false;
1987
+		}
1988
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1989
+		// clean status
1990
+		$event_status = sanitize_key($event_status);
1991
+		// grab status
1992
+		if (empty($event_status)) {
1993
+			$msg = esc_html__(
1994
+				'An error occurred. No Event Status or an invalid Event Status was received.',
1995
+				'event_espresso'
1996
+			);
1997
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1998
+			return false;
1999
+		}
2000
+		// was event trashed or restored ?
2001
+		switch ($event_status) {
2002
+			case 'draft' :
2003
+				$action = 'restored from the trash';
2004
+				$hook = 'AHEE_event_restored_from_trash';
2005
+				break;
2006
+			case 'trash' :
2007
+				$action = 'moved to the trash';
2008
+				$hook = 'AHEE_event_moved_to_trash';
2009
+				break;
2010
+			default :
2011
+				$action = 'updated';
2012
+				$hook = false;
2013
+		}
2014
+		//use class to change status
2015
+		$this->_cpt_model_obj->set_status($event_status);
2016
+		$success = $this->_cpt_model_obj->save();
2017
+		if ($success === false) {
2018
+			$msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
2019
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2020
+			return false;
2021
+		}
2022
+		if ($hook) {
2023
+			do_action($hook);
2024
+		}
2025
+		return true;
2026
+	}
2027
+
2028
+
2029
+
2030
+	/**
2031
+	 * _delete_event
2032
+	 *
2033
+	 * @access protected
2034
+	 * @param bool $redirect_after
2035
+	 */
2036
+	protected function _delete_event($redirect_after = true)
2037
+	{
2038
+		//determine the event id and set to array.
2039
+		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;
2040
+		$EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
2041
+		// loop thru events
2042
+		if ($EVT_ID) {
2043
+			$success = $this->_permanently_delete_event($EVT_ID);
2044
+			// get list of events with no prices
2045
+			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2046
+			// remove this event from the list of events with no prices
2047
+			if (isset($espresso_no_ticket_prices[$EVT_ID])) {
2048
+				unset($espresso_no_ticket_prices[$EVT_ID]);
2049
+			}
2050
+			update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2051
+		} else {
2052
+			$success = false;
2053
+			$msg = esc_html__(
2054
+				'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2055
+				'event_espresso'
2056
+			);
2057
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2058
+		}
2059
+		if ($redirect_after) {
2060
+			$this->_redirect_after_action(
2061
+				$success,
2062
+				'Event',
2063
+				'deleted',
2064
+				array('action' => 'default', 'status' => 'trash')
2065
+			);
2066
+		}
2067
+	}
2068
+
2069
+
2070
+
2071
+	/**
2072
+	 * _delete_events
2073
+	 *
2074
+	 * @access protected
2075
+	 * @return void
2076
+	 */
2077
+	protected function _delete_events()
2078
+	{
2079
+		$success = true;
2080
+		// get list of events with no prices
2081
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2082
+		//determine the event id and set to array.
2083
+		$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
2084
+		// loop thru events
2085
+		foreach ($EVT_IDs as $EVT_ID) {
2086
+			$EVT_ID = absint($EVT_ID);
2087
+			if ($EVT_ID) {
2088
+				$results = $this->_permanently_delete_event($EVT_ID);
2089
+				$success = $results !== false ? $success : false;
2090
+				// remove this event from the list of events with no prices
2091
+				unset($espresso_no_ticket_prices[$EVT_ID]);
2092
+			} else {
2093
+				$success = false;
2094
+				$msg = esc_html__(
2095
+					'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2096
+					'event_espresso'
2097
+				);
2098
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2099
+			}
2100
+		}
2101
+		update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2102
+		// in order to force a pluralized result message we need to send back a success status greater than 1
2103
+		$success = $success ? 2 : false;
2104
+		$this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default'));
2105
+	}
2106
+
2107
+
2108
+
2109
+	/**
2110
+	 * _permanently_delete_event
2111
+	 *
2112
+	 * @access  private
2113
+	 * @param  int $EVT_ID
2114
+	 * @return bool
2115
+	 */
2116
+	private function _permanently_delete_event($EVT_ID = 0)
2117
+	{
2118
+		// grab event id
2119
+		if ( ! $EVT_ID) {
2120
+			$msg = esc_html__(
2121
+				'An error occurred. No Event ID or an invalid Event ID was received.',
2122
+				'event_espresso'
2123
+			);
2124
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2125
+			return false;
2126
+		}
2127
+		if (
2128
+			! $this->_cpt_model_obj instanceof EE_Event
2129
+			|| $this->_cpt_model_obj->ID() !== $EVT_ID
2130
+		) {
2131
+			$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2132
+		}
2133
+		if ( ! $this->_cpt_model_obj instanceof EE_Event) {
2134
+			return false;
2135
+		}
2136
+		//need to delete related tickets and prices first.
2137
+		$datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
2138
+		foreach ($datetimes as $datetime) {
2139
+			$this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
2140
+			$tickets = $datetime->get_many_related('Ticket');
2141
+			foreach ($tickets as $ticket) {
2142
+				$ticket->_remove_relation_to($datetime, 'Datetime');
2143
+				$ticket->delete_related_permanently('Price');
2144
+				$ticket->delete_permanently();
2145
+			}
2146
+			$datetime->delete();
2147
+		}
2148
+		//what about related venues or terms?
2149
+		$venues = $this->_cpt_model_obj->get_many_related('Venue');
2150
+		foreach ($venues as $venue) {
2151
+			$this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
2152
+		}
2153
+		//any attached question groups?
2154
+		$question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
2155
+		if ( ! empty($question_groups)) {
2156
+			foreach ($question_groups as $question_group) {
2157
+				$this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
2158
+			}
2159
+		}
2160
+		//Message Template Groups
2161
+		$this->_cpt_model_obj->_remove_relations('Message_Template_Group');
2162
+		/** @type EE_Term_Taxonomy[] $term_taxonomies */
2163
+		$term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
2164
+		foreach ($term_taxonomies as $term_taxonomy) {
2165
+			$this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
2166
+		}
2167
+		$success = $this->_cpt_model_obj->delete_permanently();
2168
+		// did it all go as planned ?
2169
+		if ($success) {
2170
+			$msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID);
2171
+			EE_Error::add_success($msg);
2172
+		} else {
2173
+			$msg = sprintf(
2174
+				esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'),
2175
+				$EVT_ID
2176
+			);
2177
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2178
+			return false;
2179
+		}
2180
+		do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
2181
+		return true;
2182
+	}
2183
+
2184
+
2185
+
2186
+	/**
2187
+	 * get total number of events
2188
+	 *
2189
+	 * @access public
2190
+	 * @return int
2191
+	 */
2192
+	public function total_events()
2193
+	{
2194
+		$count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2195
+		return $count;
2196
+	}
2197
+
2198
+
2199
+
2200
+	/**
2201
+	 * get total number of draft events
2202
+	 *
2203
+	 * @access public
2204
+	 * @return int
2205
+	 */
2206
+	public function total_events_draft()
2207
+	{
2208
+		$where = array(
2209
+			'status' => array('IN', array('draft', 'auto-draft')),
2210
+		);
2211
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2212
+		return $count;
2213
+	}
2214
+
2215
+
2216
+
2217
+	/**
2218
+	 * get total number of trashed events
2219
+	 *
2220
+	 * @access public
2221
+	 * @return int
2222
+	 */
2223
+	public function total_trashed_events()
2224
+	{
2225
+		$where = array(
2226
+			'status' => 'trash',
2227
+		);
2228
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2229
+		return $count;
2230
+	}
2231
+
2232
+
2233
+
2234
+	/**
2235
+	 *    _default_event_settings
2236
+	 *    This generates the Default Settings Tab
2237
+	 *
2238
+	 * @return void
2239
+	 */
2240
+	protected function _default_event_settings()
2241
+	{
2242
+		$this->_template_args['values'] = $this->_yes_no_values;
2243
+		$this->_template_args['reg_status_array'] = EEM_Registration::reg_status_array(
2244
+		// exclude array
2245
+			array(
2246
+				EEM_Registration::status_id_cancelled,
2247
+				EEM_Registration::status_id_declined,
2248
+				EEM_Registration::status_id_incomplete,
2249
+				EEM_Registration::status_id_wait_list,
2250
+			),
2251
+			// translated
2252
+			true
2253
+		);
2254
+		$this->_template_args['default_reg_status'] = isset(
2255
+														  EE_Registry::instance()->CFG->registration->default_STS_ID
2256
+													  )
2257
+													  && array_key_exists(
2258
+														  EE_Registry::instance()->CFG->registration->default_STS_ID,
2259
+														  $this->_template_args['reg_status_array']
2260
+													  )
2261
+			? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID)
2262
+			: EEM_Registration::status_id_pending_payment;
2263
+		$this->_set_add_edit_form_tags('update_default_event_settings');
2264
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
2265
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2266
+			EVENTS_TEMPLATE_PATH . 'event_settings.template.php',
2267
+			$this->_template_args,
2268
+			true
2269
+		);
2270
+		$this->display_admin_page_with_sidebar();
2271
+	}
2272
+
2273
+
2274
+
2275
+	/**
2276
+	 * _update_default_event_settings
2277
+	 *
2278
+	 * @access protected
2279
+	 * @return void
2280
+	 */
2281
+	protected function _update_default_event_settings()
2282
+	{
2283
+		EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status'])
2284
+			? sanitize_text_field($this->_req_data['default_reg_status'])
2285
+			: EEM_Registration::status_id_pending_payment;
2286
+		$what = 'Default Event Settings';
2287
+		$success = $this->_update_espresso_configuration(
2288
+			$what,
2289
+			EE_Config::instance(),
2290
+			__FILE__,
2291
+			__FUNCTION__,
2292
+			__LINE__
2293
+		);
2294
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings'));
2295
+	}
2296
+
2297
+
2298
+
2299
+	/*************        Templates        *************/
2300
+	protected function _template_settings()
2301
+	{
2302
+		$this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso');
2303
+		$this->_template_args['preview_img'] = '<img src="'
2304
+											   . EVENTS_ASSETS_URL
2305
+											   . DS
2306
+											   . 'images'
2307
+											   . DS
2308
+											   . 'caffeinated_template_features.jpg" alt="'
2309
+											   . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2310
+											   . '" />';
2311
+		$this->_template_args['preview_text'] = '<strong>' . esc_html__(
2312
+				'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.',
2313
+				'event_espresso'
2314
+			) . '</strong>';
2315
+		$this->display_admin_caf_preview_page('template_settings_tab');
2316
+	}
2317
+
2318
+
2319
+	/** Event Category Stuff **/
2320
+	/**
2321
+	 * set the _category property with the category object for the loaded page.
2322
+	 *
2323
+	 * @access private
2324
+	 * @return void
2325
+	 */
2326
+	private function _set_category_object()
2327
+	{
2328
+		if (isset($this->_category->id) && ! empty($this->_category->id)) {
2329
+			return;
2330
+		} //already have the category object so get out.
2331
+		//set default category object
2332
+		$this->_set_empty_category_object();
2333
+		//only set if we've got an id
2334
+		if ( ! isset($this->_req_data['EVT_CAT_ID'])) {
2335
+			return;
2336
+		}
2337
+		$category_id = absint($this->_req_data['EVT_CAT_ID']);
2338
+		$term = get_term($category_id, 'espresso_event_categories');
2339
+		if ( ! empty($term)) {
2340
+			$this->_category->category_name = $term->name;
2341
+			$this->_category->category_identifier = $term->slug;
2342
+			$this->_category->category_desc = $term->description;
2343
+			$this->_category->id = $term->term_id;
2344
+			$this->_category->parent = $term->parent;
2345
+		}
2346
+	}
2347
+
2348
+
2349
+
2350
+	private function _set_empty_category_object()
2351
+	{
2352
+		$this->_category = new stdClass();
2353
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2354
+		$this->_category->id = $this->_category->parent = 0;
2355
+	}
2356
+
2357
+
2358
+
2359
+	protected function _category_list_table()
2360
+	{
2361
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2362
+		$this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2363
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2364
+				'add_category',
2365
+				'add_category',
2366
+				array(),
2367
+				'add-new-h2'
2368
+			);
2369
+		$this->display_admin_list_table_page_with_sidebar();
2370
+	}
2371
+
2372
+
2373
+
2374
+	/**
2375
+	 * @param $view
2376
+	 */
2377
+	protected function _category_details($view)
2378
+	{
2379
+		//load formatter helper
2380
+		//load field generator helper
2381
+		$route = $view == 'edit' ? 'update_category' : 'insert_category';
2382
+		$this->_set_add_edit_form_tags($route);
2383
+		$this->_set_category_object();
2384
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
2385
+		$delete_action = 'delete_category';
2386
+		//custom redirect
2387
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(
2388
+			array('action' => 'category_list'),
2389
+			$this->_admin_base_url
2390
+		);
2391
+		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2392
+		//take care of contents
2393
+		$this->_template_args['admin_page_content'] = $this->_category_details_content();
2394
+		$this->display_admin_page_with_sidebar();
2395
+	}
2396
+
2397
+
2398
+
2399
+	/**
2400
+	 * @return mixed
2401
+	 */
2402
+	protected function _category_details_content()
2403
+	{
2404
+		$editor_args['category_desc'] = array(
2405
+			'type'          => 'wp_editor',
2406
+			'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2407
+			'class'         => 'my_editor_custom',
2408
+			'wpeditor_args' => array('media_buttons' => false),
2409
+		);
2410
+		$_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2411
+		$all_terms = get_terms(
2412
+			array('espresso_event_categories'),
2413
+			array('hide_empty' => 0, 'exclude' => array($this->_category->id))
2414
+		);
2415
+		//setup category select for term parents.
2416
+		$category_select_values[] = array(
2417
+			'text' => esc_html__('No Parent', 'event_espresso'),
2418
+			'id'   => 0,
2419
+		);
2420
+		foreach ($all_terms as $term) {
2421
+			$category_select_values[] = array(
2422
+				'text' => $term->name,
2423
+				'id'   => $term->term_id,
2424
+			);
2425
+		}
2426
+		$category_select = EEH_Form_Fields::select_input(
2427
+			'category_parent',
2428
+			$category_select_values,
2429
+			$this->_category->parent
2430
+		);
2431
+		$template_args = array(
2432
+			'category'                 => $this->_category,
2433
+			'category_select'          => $category_select,
2434
+			'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2435
+			'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2436
+			'disable'                  => '',
2437
+			'disabled_message'         => false,
2438
+		);
2439
+		$template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2440
+		return EEH_Template::display_template($template, $template_args, true);
2441
+	}
2442
+
2443
+
2444
+
2445
+	protected function _delete_categories()
2446
+	{
2447
+		$cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID']
2448
+			: (array)$this->_req_data['category_id'];
2449
+		foreach ($cat_ids as $cat_id) {
2450
+			$this->_delete_category($cat_id);
2451
+		}
2452
+		//doesn't matter what page we're coming from... we're going to the same place after delete.
2453
+		$query_args = array(
2454
+			'action' => 'category_list',
2455
+		);
2456
+		$this->_redirect_after_action(0, '', '', $query_args);
2457
+	}
2458
+
2459
+
2460
+
2461
+	/**
2462
+	 * @param $cat_id
2463
+	 */
2464
+	protected function _delete_category($cat_id)
2465
+	{
2466
+		$cat_id = absint($cat_id);
2467
+		wp_delete_term($cat_id, 'espresso_event_categories');
2468
+	}
2469
+
2470
+
2471
+
2472
+	/**
2473
+	 * @param $new_category
2474
+	 */
2475
+	protected function _insert_or_update_category($new_category)
2476
+	{
2477
+		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2478
+		$success = 0; //we already have a success message so lets not send another.
2479
+		if ($cat_id) {
2480
+			$query_args = array(
2481
+				'action'     => 'edit_category',
2482
+				'EVT_CAT_ID' => $cat_id,
2483
+			);
2484
+		} else {
2485
+			$query_args = array('action' => 'add_category');
2486
+		}
2487
+		$this->_redirect_after_action($success, '', '', $query_args, true);
2488
+	}
2489
+
2490
+
2491
+
2492
+	/**
2493
+	 * @param bool $update
2494
+	 * @return bool|mixed|string
2495
+	 */
2496
+	private function _insert_category($update = false)
2497
+	{
2498
+		$cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2499
+		$category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2500
+		$category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2501
+		$category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2502
+		if (empty($category_name)) {
2503
+			$msg = esc_html__('You must add a name for the category.', 'event_espresso');
2504
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2505
+			return false;
2506
+		}
2507
+		$term_args = array(
2508
+			'name'        => $category_name,
2509
+			'description' => $category_desc,
2510
+			'parent'      => $category_parent,
2511
+		);
2512
+		//was the category_identifier input disabled?
2513
+		if (isset($this->_req_data['category_identifier'])) {
2514
+			$term_args['slug'] = $this->_req_data['category_identifier'];
2515
+		}
2516
+		$insert_ids = $update
2517
+			? wp_update_term($cat_id, 'espresso_event_categories', $term_args)
2518
+			: wp_insert_term($category_name, 'espresso_event_categories', $term_args);
2519
+		if ( ! is_array($insert_ids)) {
2520
+			$msg = esc_html__(
2521
+				'An error occurred and the category has not been saved to the database.',
2522
+				'event_espresso'
2523
+			);
2524
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2525
+		} else {
2526
+			$cat_id = $insert_ids['term_id'];
2527
+			$msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name);
2528
+			EE_Error::add_success($msg);
2529
+		}
2530
+		return $cat_id;
2531
+	}
2532
+
2533
+
2534
+
2535
+	/**
2536
+	 * @param int  $per_page
2537
+	 * @param int  $current_page
2538
+	 * @param bool $count
2539
+	 * @return \EE_Base_Class[]|int
2540
+	 */
2541
+	public function get_categories($per_page = 10, $current_page = 1, $count = false)
2542
+	{
2543
+		//testing term stuff
2544
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2545
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2546
+		$limit = ($current_page - 1) * $per_page;
2547
+		$where = array('taxonomy' => 'espresso_event_categories');
2548
+		if (isset($this->_req_data['s'])) {
2549
+			$sstr = '%' . $this->_req_data['s'] . '%';
2550
+			$where['OR'] = array(
2551
+				'Term.name'   => array('LIKE', $sstr),
2552
+				'description' => array('LIKE', $sstr),
2553
+			);
2554
+		}
2555
+		$query_params = array(
2556
+			$where,
2557
+			'order_by'   => array($orderby => $order),
2558
+			'limit'      => $limit . ',' . $per_page,
2559
+			'force_join' => array('Term'),
2560
+		);
2561
+		$categories = $count
2562
+			? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2563
+			: EEM_Term_Taxonomy::instance()->get_all($query_params);
2564
+		return $categories;
2565
+	}
2566
+
2567
+
2568
+
2569
+	/* end category stuff */
2570
+	/**************/
2571 2571
 }
2572 2572
 //end class Events_Admin_Page
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Payment_List_Shortcodes.lib.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Event Espresso
7 7
  * @subpackage messages
8 8
  */
9
-if (!defined('EVENT_ESPRESSO_VERSION') )
9
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
10 10
 	exit('NO direct script access allowed');
11 11
 
12 12
 /**
@@ -32,18 +32,18 @@  discard block
 block discarded – undo
32 32
 		$this->label = __('Payment List Shortcodes', 'event_espresso');
33 33
 		$this->description = __('All shortcodes specific to payment lists', 'event_espresso');
34 34
 		$this->_shortcodes = array(
35
-			'[PAYMENT_LIST_*]' => __('Outputs a list of payment items. Note, this is a dynamic shortcode in that it accepts some attributes for setting certain defaults.  Attributes that are available are:', 'event_espresso') . '<p><ul>' .
36
-				'<li><strong>no_payments</strong>:' . sprintf( __('Indicate with this attribute what will be used if there are no payments present.  Default is: "%sNo approved payments have been received.%s"', 'event_espresso'),  htmlspecialchars('<td class="aln-cntr" colspan="6">'), htmlspecialchars('</td>') ) . '</li>' .
35
+			'[PAYMENT_LIST_*]' => __('Outputs a list of payment items. Note, this is a dynamic shortcode in that it accepts some attributes for setting certain defaults.  Attributes that are available are:', 'event_espresso').'<p><ul>'.
36
+				'<li><strong>no_payments</strong>:'.sprintf(__('Indicate with this attribute what will be used if there are no payments present.  Default is: "%sNo approved payments have been received.%s"', 'event_espresso'), htmlspecialchars('<td class="aln-cntr" colspan="6">'), htmlspecialchars('</td>')).'</li>'.
37 37
 				'</ul></p>'
38 38
 			);
39 39
 	}
40 40
 
41 41
 
42 42
 
43
-	protected function _parser( $shortcode ) {
43
+	protected function _parser($shortcode) {
44 44
 
45
-		if ( strpos( $shortcode, '[PAYMENT_LIST_*' ) !== FALSE ) {
46
-			return $this->_get_payment_list( $shortcode );
45
+		if (strpos($shortcode, '[PAYMENT_LIST_*') !== FALSE) {
46
+			return $this->_get_payment_list($shortcode);
47 47
 		}
48 48
 		return '';
49 49
 	}
@@ -60,32 +60,32 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @return string parsed ticket line item list.
62 62
 	 */
63
-	private function _get_payment_list( $shortcode ) {
63
+	private function _get_payment_list($shortcode) {
64 64
 		$this->_validate_list_requirements();
65 65
 
66 66
 
67
-		if ( ! $this->_data['data'] instanceof EE_Messages_Addressee ) {
67
+		if ( ! $this->_data['data'] instanceof EE_Messages_Addressee) {
68 68
 			return '';
69 69
 		}
70 70
 
71
-		$valid_shortcodes = array( 'payment' );
71
+		$valid_shortcodes = array('payment');
72 72
 
73 73
 		$addressee_obj = $this->_data['data'];
74 74
 		$templates = $this->_extra_data['template'];
75
-		$payments = apply_filters( 'FHEE__Payment_List_Shortcodes___get_payments_list__payments', $addressee_obj->payments );
75
+		$payments = apply_filters('FHEE__Payment_List_Shortcodes___get_payments_list__payments', $addressee_obj->payments);
76 76
 
77 77
 		//let's get any attributes that may be present and set the defaults.
78
-		$atts = $this->_get_shortcode_attrs( $shortcode );
78
+		$atts = $this->_get_shortcode_attrs($shortcode);
79 79
 
80
-		$no_payments_msg = empty( $atts['no_payments'] ) ?  __('No approved payments have been received.','event_espresso') : $atts['no_payments'];
80
+		$no_payments_msg = empty($atts['no_payments']) ? __('No approved payments have been received.', 'event_espresso') : $atts['no_payments'];
81 81
 
82 82
 		//made it here so we have an array of paymnets, so we should have what we need.
83
-		$payment_content = empty( $payments ) ? $no_payments_msg : '';
83
+		$payment_content = empty($payments) ? $no_payments_msg : '';
84 84
 
85 85
 		$payments = (array) $payments;
86 86
 
87
-		foreach ( $payments as $payment ) {
88
-			$payment_content .= $this->_shortcode_helper->parse_payment_list_template( $templates['payment_list'], $payment, $valid_shortcodes, $this->_extra_data );
87
+		foreach ($payments as $payment) {
88
+			$payment_content .= $this->_shortcode_helper->parse_payment_list_template($templates['payment_list'], $payment, $valid_shortcodes, $this->_extra_data);
89 89
 		}
90 90
 
91 91
 		return $payment_content;
Please login to merge, or discard this patch.
core/db_models/helpers/EE_Table_Base.php 2 patches
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -9,164 +9,164 @@
 block discarded – undo
9 9
 abstract class EE_Table_Base
10 10
 {
11 11
 
12
-    /**
13
-     * This holds the table_name without the table prefix.
14
-     *
15
-     * @var string
16
-     */
17
-    var $_table_name;
18
-
19
-
20
-    /**
21
-     * This holds what is used as the alias for the table in queries.
22
-     *
23
-     * @var string
24
-     */
25
-    var $_table_alias;
26
-
27
-
28
-    /**
29
-     * Table's private key column
30
-     *
31
-     * @var string
32
-     */
33
-    protected $_pk_column;
34
-
35
-
36
-    /**
37
-     * Whether this table is a global table (in multisite) or specific to site.
38
-     *
39
-     * @var bool
40
-     */
41
-    protected $_global;
42
-
43
-
44
-
45
-    /**
46
-     * @global wpdb   $wpdb
47
-     * @param string  $table_name with or without wpdb prefix
48
-     * @param string  $pk_column
49
-     * @param boolean $global     whether the table is "global" as in there is only 1 table on an entire multisite
50
-     *                            install, or whether each site on a multisite install has a copy of this table
51
-     */
52
-    function __construct($table_name, $pk_column, $global = false)
53
-    {
54
-        $this->_global = $global;
55
-        $prefix = $this->get_table_prefix();
56
-        //if they added the prefix, let's remove it because we delay adding the prefix until right when its needed.
57
-        if (strpos($table_name, $prefix) === 0) {
58
-            $table_name = ltrim($table_name, $prefix);
59
-        }
60
-        $this->_table_name = $table_name;
61
-        $this->_pk_column = $pk_column;
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * This returns the table prefix for the current model state.
68
-     *
69
-     * @global wpdb $wpdb
70
-     * @return string
71
-     */
72
-    public function get_table_prefix()
73
-    {
74
-        global $wpdb;
75
-        if ($this->_global) {
76
-            $prefix = $wpdb->base_prefix;
77
-        } else {
78
-            $prefix = $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id());
79
-        }
80
-        return $prefix;
81
-    }
82
-
83
-
84
-
85
-    /**
86
-     * Used to set the table_alias property
87
-     *
88
-     * @param string $table_alias
89
-     */
90
-    function _construct_finalize_with_alias($table_alias)
91
-    {
92
-        $this->_table_alias = $table_alias;
93
-    }
94
-
95
-
96
-
97
-    /**
98
-     * Returns the fully qualified table name for the database (includes the table prefix current for the blog).
99
-     *
100
-     * @return string
101
-     */
102
-    function get_table_name()
103
-    {
104
-        return $this->get_table_prefix() . $this->_table_name;
105
-    }
106
-
107
-
108
-
109
-    /**
110
-     * Provides what is currently set as the alias for the table to be used in queries.
111
-     *
112
-     * @return string
113
-     * @throws EE_Error
114
-     */
115
-    function get_table_alias()
116
-    {
117
-        if ( ! $this->_table_alias) {
118
-            throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?");
119
-        }
120
-        return $this->_table_alias;
121
-    }
122
-
123
-
124
-
125
-    /**
126
-     * @return string name of column of PK
127
-     */
128
-    function get_pk_column()
129
-    {
130
-        return $this->_pk_column;
131
-    }
132
-
133
-
134
-
135
-    /**
136
-     * returns a string with the table alias, a period, and the private key's column.
137
-     *
138
-     * @return string
139
-     */
140
-    function get_fully_qualified_pk_column()
141
-    {
142
-        $sql = $this->get_table_alias() . "." . $this->get_pk_column();
143
-        return $sql;
144
-    }
145
-
146
-
147
-
148
-    /**
149
-     * returns the special sql for a inner select with a limit.
150
-     *
151
-     * @return string    SQL select
152
-     */
153
-    public function get_select_join_limit($limit)
154
-    {
155
-        $limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int)$limit;
156
-        $SQL = SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias;
157
-        return $SQL;
158
-    }
159
-
160
-
161
-
162
-    /**
163
-     * Returns whether or not htis is a global table (ie, on multisite there's
164
-     * only one of these tables, on the main blog)
165
-     *
166
-     * @return boolean
167
-     */
168
-    public function is_global()
169
-    {
170
-        return $this->_global;
171
-    }
12
+	/**
13
+	 * This holds the table_name without the table prefix.
14
+	 *
15
+	 * @var string
16
+	 */
17
+	var $_table_name;
18
+
19
+
20
+	/**
21
+	 * This holds what is used as the alias for the table in queries.
22
+	 *
23
+	 * @var string
24
+	 */
25
+	var $_table_alias;
26
+
27
+
28
+	/**
29
+	 * Table's private key column
30
+	 *
31
+	 * @var string
32
+	 */
33
+	protected $_pk_column;
34
+
35
+
36
+	/**
37
+	 * Whether this table is a global table (in multisite) or specific to site.
38
+	 *
39
+	 * @var bool
40
+	 */
41
+	protected $_global;
42
+
43
+
44
+
45
+	/**
46
+	 * @global wpdb   $wpdb
47
+	 * @param string  $table_name with or without wpdb prefix
48
+	 * @param string  $pk_column
49
+	 * @param boolean $global     whether the table is "global" as in there is only 1 table on an entire multisite
50
+	 *                            install, or whether each site on a multisite install has a copy of this table
51
+	 */
52
+	function __construct($table_name, $pk_column, $global = false)
53
+	{
54
+		$this->_global = $global;
55
+		$prefix = $this->get_table_prefix();
56
+		//if they added the prefix, let's remove it because we delay adding the prefix until right when its needed.
57
+		if (strpos($table_name, $prefix) === 0) {
58
+			$table_name = ltrim($table_name, $prefix);
59
+		}
60
+		$this->_table_name = $table_name;
61
+		$this->_pk_column = $pk_column;
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * This returns the table prefix for the current model state.
68
+	 *
69
+	 * @global wpdb $wpdb
70
+	 * @return string
71
+	 */
72
+	public function get_table_prefix()
73
+	{
74
+		global $wpdb;
75
+		if ($this->_global) {
76
+			$prefix = $wpdb->base_prefix;
77
+		} else {
78
+			$prefix = $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id());
79
+		}
80
+		return $prefix;
81
+	}
82
+
83
+
84
+
85
+	/**
86
+	 * Used to set the table_alias property
87
+	 *
88
+	 * @param string $table_alias
89
+	 */
90
+	function _construct_finalize_with_alias($table_alias)
91
+	{
92
+		$this->_table_alias = $table_alias;
93
+	}
94
+
95
+
96
+
97
+	/**
98
+	 * Returns the fully qualified table name for the database (includes the table prefix current for the blog).
99
+	 *
100
+	 * @return string
101
+	 */
102
+	function get_table_name()
103
+	{
104
+		return $this->get_table_prefix() . $this->_table_name;
105
+	}
106
+
107
+
108
+
109
+	/**
110
+	 * Provides what is currently set as the alias for the table to be used in queries.
111
+	 *
112
+	 * @return string
113
+	 * @throws EE_Error
114
+	 */
115
+	function get_table_alias()
116
+	{
117
+		if ( ! $this->_table_alias) {
118
+			throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?");
119
+		}
120
+		return $this->_table_alias;
121
+	}
122
+
123
+
124
+
125
+	/**
126
+	 * @return string name of column of PK
127
+	 */
128
+	function get_pk_column()
129
+	{
130
+		return $this->_pk_column;
131
+	}
132
+
133
+
134
+
135
+	/**
136
+	 * returns a string with the table alias, a period, and the private key's column.
137
+	 *
138
+	 * @return string
139
+	 */
140
+	function get_fully_qualified_pk_column()
141
+	{
142
+		$sql = $this->get_table_alias() . "." . $this->get_pk_column();
143
+		return $sql;
144
+	}
145
+
146
+
147
+
148
+	/**
149
+	 * returns the special sql for a inner select with a limit.
150
+	 *
151
+	 * @return string    SQL select
152
+	 */
153
+	public function get_select_join_limit($limit)
154
+	{
155
+		$limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int)$limit;
156
+		$SQL = SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias;
157
+		return $SQL;
158
+	}
159
+
160
+
161
+
162
+	/**
163
+	 * Returns whether or not htis is a global table (ie, on multisite there's
164
+	 * only one of these tables, on the main blog)
165
+	 *
166
+	 * @return boolean
167
+	 */
168
+	public function is_global()
169
+	{
170
+		return $this->_global;
171
+	}
172 172
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      */
102 102
     function get_table_name()
103 103
     {
104
-        return $this->get_table_prefix() . $this->_table_name;
104
+        return $this->get_table_prefix().$this->_table_name;
105 105
     }
106 106
 
107 107
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      */
140 140
     function get_fully_qualified_pk_column()
141 141
     {
142
-        $sql = $this->get_table_alias() . "." . $this->get_pk_column();
142
+        $sql = $this->get_table_alias().".".$this->get_pk_column();
143 143
         return $sql;
144 144
     }
145 145
 
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public function get_select_join_limit($limit)
154 154
     {
155
-        $limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int)$limit;
156
-        $SQL = SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias;
155
+        $limit = is_array($limit) ? 'LIMIT '.implode(',', array_map('intval', $limit)) : 'LIMIT '.(int) $limit;
156
+        $SQL = SP.'(SELECT * FROM '.$this->_table_name.SP.$limit.') AS '.$this->_table_alias;
157 157
         return $SQL;
158 158
     }
159 159
 
Please login to merge, or discard this patch.