Completed
Branch FET-8394-RULES (1ae5e4)
by
unknown
50:31 queued 37:22
created
core/libraries/form_sections/form_handlers/FormHandler.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -119,19 +119,19 @@  discard block
 block discarded – undo
119 119
 
120 120
 
121 121
 
122
-    /**
123
-     * Form constructor.
124
-     *
125
-     * @param string       $form_name
126
-     * @param string       $admin_name
127
-     * @param string       $slug
128
-     * @param string       $form_action
129
-     * @param string       $form_config
130
-     * @param \EE_Registry $registry
131
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
132
-     * @throws \DomainException
133
-     * @throws \InvalidArgumentException
134
-     */
122
+	/**
123
+	 * Form constructor.
124
+	 *
125
+	 * @param string       $form_name
126
+	 * @param string       $admin_name
127
+	 * @param string       $slug
128
+	 * @param string       $form_action
129
+	 * @param string       $form_config
130
+	 * @param \EE_Registry $registry
131
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
132
+	 * @throws \DomainException
133
+	 * @throws \InvalidArgumentException
134
+	 */
135 135
 	public function __construct(
136 136
 		$form_name,
137 137
 		$admin_name,
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @throws \LogicException
173 173
 	 */
174 174
 	public function form( $for_display = false ) {
175
-        if ( ! $this->formIsValid() ) {
175
+		if ( ! $this->formIsValid() ) {
176 176
 			return null;
177 177
 		}
178 178
 		if ( $for_display ) {
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
 	 * @throws LogicException
196 196
 	 */
197 197
 	public function formIsValid() {
198
-        if ( ! $this->form instanceof \EE_Form_Section_Proper ) {
198
+		if ( ! $this->form instanceof \EE_Form_Section_Proper ) {
199 199
 			static $generated = false;
200 200
 			if ( ! $generated ) {
201 201
 				$generated = true;
202 202
 				$form = $this->generate();
203
-                if ( $form instanceof \EE_Form_Section_Proper) {
204
-                    $this->setForm($form);
205
-                }
203
+				if ( $form instanceof \EE_Form_Section_Proper) {
204
+					$this->setForm($form);
205
+				}
206 206
 			}
207 207
 			return $this->verifyForm();
208 208
 		}
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
 
338 338
 
339 339
 
340
-    /**
341
-     * @param string $submit_btn_text
342
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
343
-     * @throws \InvalidArgumentException
344
-     */
340
+	/**
341
+	 * @param string $submit_btn_text
342
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
343
+	 * @throws \InvalidArgumentException
344
+	 */
345 345
 	public function setSubmitBtnText( $submit_btn_text ) {
346 346
 		if ( ! is_string( $submit_btn_text ) ) {
347 347
 			throw new InvalidDataTypeException( '$submit_btn_text', $submit_btn_text, 'string' );
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 	 * @throws \EE_Error
575 575
 	 */
576 576
 	public function display() {
577
-        $form_html = apply_filters(
577
+		$form_html = apply_filters(
578 578
 			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__before_form',
579 579
 			''
580 580
 		);
@@ -613,11 +613,11 @@  discard block
 block discarded – undo
613 613
 	 */
614 614
 	public function process( $submitted_form_data = array() ) {
615 615
 		if ( ! $this->form()->was_submitted( $submitted_form_data ) ) {
616
-            throw new InvalidFormSubmissionException( $this->form_name );
616
+			throw new InvalidFormSubmissionException( $this->form_name );
617 617
 		}
618
-        $this->form( true )->receive_form_submission( $submitted_form_data );
618
+		$this->form( true )->receive_form_submission( $submitted_form_data );
619 619
 		if ( ! $this->form()->is_valid() ) {
620
-            throw new InvalidFormSubmissionException(
620
+			throw new InvalidFormSubmissionException(
621 621
 				$this->form_name,
622 622
 				sprintf(
623 623
 					__(
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 use EventEspresso\core\exceptions\InvalidDataTypeException;
11 11
 use EventEspresso\core\exceptions\InvalidFormSubmissionException;
12 12
 
13
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
14
-	exit( 'No direct script access allowed' );
13
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
14
+	exit('No direct script access allowed');
15 15
 }
16 16
 
17 17
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  * @author        Brent Christensen
28 28
  * @since         4.9.0
29 29
  */
30
-abstract class FormHandler implements FormHandlerInterface{
30
+abstract class FormHandler implements FormHandlerInterface {
31 31
 
32 32
 	/**
33 33
 	 * will add opening and closing HTML form tags as well as a submit button
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
 		$form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
141 141
 		\EE_Registry $registry
142 142
 	) {
143
-		$this->setFormName( $form_name );
144
-		$this->setAdminName( $admin_name );
145
-		$this->setSlug( $slug );
146
-		$this->setFormAction( $form_action );
147
-		$this->setFormConfig( $form_config );
148
-		$this->setSubmitBtnText( __( 'Submit', 'event_espresso' ) );
143
+		$this->setFormName($form_name);
144
+		$this->setAdminName($admin_name);
145
+		$this->setSlug($slug);
146
+		$this->setFormAction($form_action);
147
+		$this->setFormConfig($form_config);
148
+		$this->setSubmitBtnText(__('Submit', 'event_espresso'));
149 149
 		$this->registry = $registry;
150 150
 	}
151 151
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 	 * @throws \EE_Error
172 172
 	 * @throws \LogicException
173 173
 	 */
174
-	public function form( $for_display = false ) {
175
-        if ( ! $this->formIsValid() ) {
174
+	public function form($for_display = false) {
175
+        if ( ! $this->formIsValid()) {
176 176
 			return null;
177 177
 		}
178
-		if ( $for_display ) {
178
+		if ($for_display) {
179 179
 			$form_config = $this->formConfig();
180 180
 			if (
181 181
 				$form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
@@ -195,12 +195,12 @@  discard block
 block discarded – undo
195 195
 	 * @throws LogicException
196 196
 	 */
197 197
 	public function formIsValid() {
198
-        if ( ! $this->form instanceof \EE_Form_Section_Proper ) {
198
+        if ( ! $this->form instanceof \EE_Form_Section_Proper) {
199 199
 			static $generated = false;
200
-			if ( ! $generated ) {
200
+			if ( ! $generated) {
201 201
 				$generated = true;
202 202
 				$form = $this->generate();
203
-                if ( $form instanceof \EE_Form_Section_Proper) {
203
+                if ($form instanceof \EE_Form_Section_Proper) {
204 204
                     $this->setForm($form);
205 205
                 }
206 206
 			}
@@ -216,12 +216,12 @@  discard block
 block discarded – undo
216 216
 	 * @throws LogicException
217 217
 	 */
218 218
 	public function verifyForm() {
219
-		if ( $this->form instanceof \EE_Form_Section_Proper ) {
219
+		if ($this->form instanceof \EE_Form_Section_Proper) {
220 220
 			return true;
221 221
 		}
222 222
 		throw new LogicException(
223 223
 			sprintf(
224
-				__( 'The "%1$s" form is invalid or missing', 'event_espresso' ),
224
+				__('The "%1$s" form is invalid or missing', 'event_espresso'),
225 225
 				$this->form_name
226 226
 			)
227 227
 		);
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	/**
233 233
 	 * @param \EE_Form_Section_Proper $form
234 234
 	 */
235
-	public function setForm( \EE_Form_Section_Proper $form ) {
235
+	public function setForm(\EE_Form_Section_Proper $form) {
236 236
 		$this->form = $form;
237 237
 	}
238 238
 
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
 	/**
251 251
 	 * @param boolean $displayable
252 252
 	 */
253
-	public function setDisplayable( $displayable = false ) {
254
-		$this->displayable = filter_var( $displayable, FILTER_VALIDATE_BOOLEAN );
253
+	public function setDisplayable($displayable = false) {
254
+		$this->displayable = filter_var($displayable, FILTER_VALIDATE_BOOLEAN);
255 255
 	}
256 256
 
257 257
 
@@ -271,9 +271,9 @@  discard block
 block discarded – undo
271 271
 	 * @param string $form_name
272 272
 	 * @throws InvalidDataTypeException
273 273
 	 */
274
-	public function setFormName( $form_name ) {
275
-		if ( ! is_string( $form_name ) ) {
276
-			throw new InvalidDataTypeException( '$form_name', $form_name, 'string' );
274
+	public function setFormName($form_name) {
275
+		if ( ! is_string($form_name)) {
276
+			throw new InvalidDataTypeException('$form_name', $form_name, 'string');
277 277
 		}
278 278
 		$this->form_name = $form_name;
279 279
 	}
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
 	 * @param string $admin_name
296 296
 	 * @throws InvalidDataTypeException
297 297
 	 */
298
-	public function setAdminName( $admin_name ) {
299
-		if ( ! is_string( $admin_name ) ) {
300
-			throw new InvalidDataTypeException( '$admin_name', $admin_name, 'string' );
298
+	public function setAdminName($admin_name) {
299
+		if ( ! is_string($admin_name)) {
300
+			throw new InvalidDataTypeException('$admin_name', $admin_name, 'string');
301 301
 		}
302 302
 		$this->admin_name = $admin_name;
303 303
 	}
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
 	 * @param string $slug
320 320
 	 * @throws InvalidDataTypeException
321 321
 	 */
322
-	public function setSlug( $slug ) {
323
-		if ( ! is_string( $slug ) ) {
324
-			throw new InvalidDataTypeException( '$slug', $slug, 'string' );
322
+	public function setSlug($slug) {
323
+		if ( ! is_string($slug)) {
324
+			throw new InvalidDataTypeException('$slug', $slug, 'string');
325 325
 		}
326 326
 		$this->slug = $slug;
327 327
 	}
@@ -342,13 +342,13 @@  discard block
 block discarded – undo
342 342
      * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
343 343
      * @throws \InvalidArgumentException
344 344
      */
345
-	public function setSubmitBtnText( $submit_btn_text ) {
346
-		if ( ! is_string( $submit_btn_text ) ) {
347
-			throw new InvalidDataTypeException( '$submit_btn_text', $submit_btn_text, 'string' );
345
+	public function setSubmitBtnText($submit_btn_text) {
346
+		if ( ! is_string($submit_btn_text)) {
347
+			throw new InvalidDataTypeException('$submit_btn_text', $submit_btn_text, 'string');
348 348
 		}
349
-		if ( empty( $submit_btn_text ) ) {
349
+		if (empty($submit_btn_text)) {
350 350
 			throw new InvalidArgumentException(
351
-				__( 'Can not set Submit button text because an empty string was provided.', 'event_espresso' )
351
+				__('Can not set Submit button text because an empty string was provided.', 'event_espresso')
352 352
 			);
353 353
 		}
354 354
 		$this->submit_btn_text = $submit_btn_text;
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
 	 * @return string
361 361
 	 */
362 362
 	public function formAction() {
363
-		return ! empty( $this->form_args )
364
-			? add_query_arg( $this->form_args, $this->form_action )
363
+		return ! empty($this->form_args)
364
+			? add_query_arg($this->form_args, $this->form_action)
365 365
 			: $this->form_action;
366 366
 	}
367 367
 
@@ -371,9 +371,9 @@  discard block
 block discarded – undo
371 371
 	 * @param string $form_action
372 372
 	 * @throws InvalidDataTypeException
373 373
 	 */
374
-	public function setFormAction( $form_action ) {
375
-		if ( ! is_string( $form_action ) ) {
376
-			throw new InvalidDataTypeException( '$form_action', $form_action, 'string' );
374
+	public function setFormAction($form_action) {
375
+		if ( ! is_string($form_action)) {
376
+			throw new InvalidDataTypeException('$form_action', $form_action, 'string');
377 377
 		}
378 378
 		$this->form_action = $form_action;
379 379
 	}
@@ -385,20 +385,20 @@  discard block
 block discarded – undo
385 385
 	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
386 386
 	 * @throws \InvalidArgumentException
387 387
 	 */
388
-	public function addFormActionArgs( $form_args = array() ) {
389
-		if ( is_object( $form_args ) ) {
388
+	public function addFormActionArgs($form_args = array()) {
389
+		if (is_object($form_args)) {
390 390
 			throw new InvalidDataTypeException(
391 391
 				'$form_args',
392 392
 				$form_args,
393 393
 				'anything other than an object was expected.'
394 394
 			);
395 395
 		}
396
-		if ( empty( $form_args ) ) {
396
+		if (empty($form_args)) {
397 397
 			throw new InvalidArgumentException(
398
-				__( 'The redirect arguments can not be an empty array.', 'event_espresso' )
398
+				__('The redirect arguments can not be an empty array.', 'event_espresso')
399 399
 			);
400 400
 		}
401
-		$this->form_args = array_merge( $this->form_args, $form_args );
401
+		$this->form_args = array_merge($this->form_args, $form_args);
402 402
 	}
403 403
 
404 404
 
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 	 * @param string $form_config
417 417
 	 * @throws DomainException
418 418
 	 */
419
-	public function setFormConfig( $form_config ) {
419
+	public function setFormConfig($form_config) {
420 420
 		if (
421 421
 			! in_array(
422 422
 				$form_config,
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 		) {
431 431
 			throw new DomainException(
432 432
 				sprintf(
433
-					__( '"%1$s" is not a valid value for the form config. Please use one of the class constants on \EventEspresso\core\libraries\form_sections\form_handlers\Form', 'event_espresso' ),
433
+					__('"%1$s" is not a valid value for the form config. Please use one of the class constants on \EventEspresso\core\libraries\form_sections\form_handlers\Form', 'event_espresso'),
434 434
 					$form_config
435 435
 				)
436 436
 			);
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 	 * @return boolean
451 451
 	 */
452 452
 	public function initialize() {
453
-		$this->form_has_errors = \EE_Error::has_error( true );
453
+		$this->form_has_errors = \EE_Error::has_error(true);
454 454
 		return true;
455 455
 	}
456 456
 
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 	 * @throws \EE_Error
465 465
 	 */
466 466
 	public function enqueueStylesAndScripts() {
467
-		$this->form( false )->enqueue_js();
467
+		$this->form(false)->enqueue_js();
468 468
 
469 469
 	}
470 470
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 	 *
476 476
 	 * @return EE_Form_Section_Proper
477 477
 	 */
478
-	abstract public function generate() ;
478
+	abstract public function generate();
479 479
 
480 480
 
481 481
 
@@ -485,15 +485,15 @@  discard block
 block discarded – undo
485 485
 	 * @param string $text
486 486
 	 * @return \EE_Submit_Input
487 487
 	 */
488
-	public function generateSubmitButton( $text = '' ) {
489
-		$text = ! empty( $text ) ? $text : $this->submitBtnText();
488
+	public function generateSubmitButton($text = '') {
489
+		$text = ! empty($text) ? $text : $this->submitBtnText();
490 490
 		return new EE_Submit_Input(
491 491
 			array(
492
-				'html_name'             => 'ee-form-submit-' . $this->slug(),
493
-				'html_id'               => 'ee-form-submit-' . $this->slug(),
492
+				'html_name'             => 'ee-form-submit-'.$this->slug(),
493
+				'html_id'               => 'ee-form-submit-'.$this->slug(),
494 494
 				'html_class'            => 'ee-form-submit',
495 495
 				'html_label'            => ' ',
496
-				'other_html_attributes' => ' rel="' . $this->slug() . '"',
496
+				'other_html_attributes' => ' rel="'.$this->slug().'"',
497 497
 				'default'               => $text
498 498
 			)
499 499
 		);
@@ -509,12 +509,12 @@  discard block
 block discarded – undo
509 509
 	 * @throws \LogicException
510 510
 	 * @throws \EE_Error
511 511
 	 */
512
-	public function appendSubmitButton( $text = '' ) {
513
-		if ( $this->form->subsection_exists( $this->slug() . '-submit-btn' ) ) {
512
+	public function appendSubmitButton($text = '') {
513
+		if ($this->form->subsection_exists($this->slug().'-submit-btn')) {
514 514
 			return;
515 515
 		}
516 516
 		$this->form->add_subsections(
517
-			array( $this->slug() . '-submit-btn' => $this->generateSubmitButton( $text ) ),
517
+			array($this->slug().'-submit-btn' => $this->generateSubmitButton($text)),
518 518
 			null,
519 519
 			false
520 520
 		);
@@ -528,18 +528,18 @@  discard block
 block discarded – undo
528 528
 	 * @param string $text
529 529
 	 * @return \EE_Submit_Input
530 530
 	 */
531
-	public function generateCancelButton( $text = '' ) {
531
+	public function generateCancelButton($text = '') {
532 532
 		$cancel_button = new EE_Submit_Input(
533 533
 			array(
534
-				'html_name'             => 'ee-form-submit-' . $this->slug(), // YES! Same name as submit !!!
535
-				'html_id'               => 'ee-cancel-form-' . $this->slug(),
534
+				'html_name'             => 'ee-form-submit-'.$this->slug(), // YES! Same name as submit !!!
535
+				'html_id'               => 'ee-cancel-form-'.$this->slug(),
536 536
 				'html_class'            => 'ee-cancel-form',
537 537
 				'html_label'            => ' ',
538
-				'other_html_attributes' => ' rel="' . $this->slug() . '"',
539
-				'default'               => ! empty( $text ) ? $text : __( 'Cancel', 'event_espresso' )
538
+				'other_html_attributes' => ' rel="'.$this->slug().'"',
539
+				'default'               => ! empty($text) ? $text : __('Cancel', 'event_espresso')
540 540
 			)
541 541
 		);
542
-		$cancel_button->set_button_css_attributes( false );
542
+		$cancel_button->set_button_css_attributes(false);
543 543
 		return $cancel_button;
544 544
 	}
545 545
 
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 		$this->form->add_subsections(
556 556
 			array(
557 557
 				'clear-submit-btn-float' => new \EE_Form_Section_HTML(
558
-					EEH_HTML::div( '', '', 'clear-float' ) . EEH_HTML::divx()
558
+					EEH_HTML::div('', '', 'clear-float').EEH_HTML::divx()
559 559
 				)
560 560
 			),
561 561
 			null,
@@ -583,9 +583,9 @@  discard block
 block discarded – undo
583 583
 			$form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
584 584
 			|| $form_config === FormHandler::ADD_FORM_TAGS_ONLY
585 585
 		) {
586
-			$form_html .= $this->form()->form_open( $this->formAction() );
586
+			$form_html .= $this->form()->form_open($this->formAction());
587 587
 		}
588
-		$form_html .= $this->form( true )->get_html( $this->form_has_errors );
588
+		$form_html .= $this->form(true)->get_html($this->form_has_errors);
589 589
 		if (
590 590
 			$form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
591 591
 			|| $form_config === FormHandler::ADD_FORM_TAGS_ONLY
@@ -611,12 +611,12 @@  discard block
 block discarded – undo
611 611
 	 * @throws \LogicException
612 612
 	 * @throws InvalidFormSubmissionException
613 613
 	 */
614
-	public function process( $submitted_form_data = array() ) {
615
-		if ( ! $this->form()->was_submitted( $submitted_form_data ) ) {
616
-            throw new InvalidFormSubmissionException( $this->form_name );
614
+	public function process($submitted_form_data = array()) {
615
+		if ( ! $this->form()->was_submitted($submitted_form_data)) {
616
+            throw new InvalidFormSubmissionException($this->form_name);
617 617
 		}
618
-        $this->form( true )->receive_form_submission( $submitted_form_data );
619
-		if ( ! $this->form()->is_valid() ) {
618
+        $this->form(true)->receive_form_submission($submitted_form_data);
619
+		if ( ! $this->form()->is_valid()) {
620 620
             throw new InvalidFormSubmissionException(
621 621
 				$this->form_name,
622 622
 				sprintf(
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Registrations_List_Table.class.php 1 patch
Indentation   +830 added lines, -830 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -26,859 +26,859 @@  discard block
 block discarded – undo
26 26
 
27 27
 
28 28
 
29
-    private $_status;
30
-
31
-
32
-
33
-    /**
34
-     * An array of transaction details for the related transaction to the registration being processed.
35
-     * This is set via the _set_related_details method.
36
-     *
37
-     * @var array
38
-     */
39
-    protected $_transaction_details = array();
40
-
41
-
42
-
43
-    /**
44
-     * An array of event details for the related event to the registration being processed.
45
-     * This is set via the _set_related_details method.
46
-     *
47
-     * @var array
48
-     */
49
-    protected $_event_details = array();
50
-
51
-
52
-
53
-    /**
54
-     * @param \Registrations_Admin_Page $admin_page
55
-     */
56
-    public function __construct(Registrations_Admin_Page $admin_page)
57
-    {
58
-        if ( ! empty($_GET['event_id'])) {
59
-            $extra_query_args = array();
60
-            foreach ($admin_page->get_views() as $key => $view_details) {
61
-                $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']);
62
-            }
63
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
64
-        }
65
-        parent::__construct($admin_page);
66
-        $this->_status = $this->_admin_page->get_registration_status_array();
67
-    }
68
-
69
-
70
-
71
-    /**
72
-     *    _setup_data
73
-     *
74
-     * @access protected
75
-     * @return void
76
-     */
77
-    protected function _setup_data()
78
-    {
79
-        $this->_data = $this->_admin_page->get_registrations($this->_per_page);
80
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false);
81
-    }
82
-
83
-
84
-
85
-    /**
86
-     *    _set_properties
87
-     *
88
-     * @access protected
89
-     * @return void
90
-     */
91
-    protected function _set_properties()
92
-    {
93
-        $this->_wp_list_args = array(
94
-            'singular' => __('registration', 'event_espresso'),
95
-            'plural'   => __('registrations', 'event_espresso'),
96
-            'ajax'     => true,
97
-            'screen'   => $this->_admin_page->get_current_screen()->id,
98
-        );
99
-        $ID_column_name = __('ID', 'event_espresso');
100
-        $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
101
-        $ID_column_name .= __('Registrant Name', 'event_espresso');
102
-        $ID_column_name .= '</span> ';
103
-        if (isset($_GET['event_id'])) {
104
-            $this->_columns = array(
105
-                'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
106
-                '_REG_ID'          => $ID_column_name,
107
-                'ATT_fname'        => __('Name', 'event_espresso'),
108
-                'ATT_email'        => __('Email', 'event_espresso'),
109
-                '_REG_date'        => __('Reg Date', 'event_espresso'),
110
-                'PRC_amount'       => __('TKT Price', 'event_espresso'),
111
-                '_REG_final_price' => __('Final Price', 'event_espresso'),
112
-                'TXN_total'        => __('Total Txn', 'event_espresso'),
113
-                'TXN_paid'         => __('Paid', 'event_espresso'),
114
-                'actions'          => __('Actions', 'event_espresso'),
115
-            );
116
-            $this->_bottom_buttons = array(
117
-                'report' => array(
118
-                    'route'         => 'registrations_report',
119
-                    'extra_request' => array(
120
-                        'EVT_ID'     => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
121
-                        'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
122
-                    ),
123
-                ),
124
-            );
125
-        } else {
126
-            $this->_columns = array(
127
-                'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
128
-                '_REG_ID'          => $ID_column_name,
129
-                'ATT_fname'        => __('Name', 'event_espresso'),
130
-                '_REG_date'        => __('TXN Date', 'event_espresso'),
131
-                'event_name'       => __('Event', 'event_espresso'),
132
-                'DTT_EVT_start'    => __('Event Date', 'event_espresso'),
133
-                '_REG_final_price' => __('Price', 'event_espresso'),
134
-                '_REG_paid'        => __('Paid', 'event_espresso'),
135
-                'actions'          => __('Actions', 'event_espresso'),
136
-            );
137
-            $this->_bottom_buttons = array(
138
-                'report_all' => array(
139
-                    'route'         => 'registrations_report',
140
-                    'extra_request' => array(
141
-                        'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
142
-                    ),
143
-                ),
144
-            );
145
-        }
146
-        $this->_bottom_buttons['report_filtered'] = array(
147
-            'route'         => 'registrations_report',
148
-            'extra_request' => array(
149
-                'use_filters' => true,
150
-                'filters'     => array_diff_key($this->_req_data, array_flip(array(
151
-                            'page',
152
-                            'action',
153
-                            'default_nonce',
154
-                        ))),
155
-                'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
156
-            ),
157
-        );
158
-        $this->_primary_column = '_REG_ID';
159
-        $this->_sortable_columns = array(
160
-            '_REG_date'     => array('_REG_date' => true),   //true means its already sorted
161
-            'ATT_fname'     => array('ATT_fname' => false),
162
-            'event_name'    => array('event_name' => false),
163
-            'DTT_EVT_start' => array('DTT_EVT_start' => false),
164
-            '_REG_ID'       => array('_REG_ID' => false),
165
-        );
166
-        $this->_hidden_columns = array();
167
-    }
168
-
169
-
170
-
171
-    /**
172
-     * This simply sets up the row class for the table rows.
173
-     * Allows for easier overriding of child methods for setting up sorting.
174
-     *
175
-     * @param  EE_Registration $item the current item
176
-     * @return string
177
-     */
178
-    protected function _get_row_class($item)
179
-    {
180
-        $class = parent::_get_row_class($item);
181
-        //add status class
182
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
183
-        if ($this->_has_checkbox_column) {
184
-            $class .= ' has-checkbox-column';
185
-        }
186
-        return $class;
187
-    }
188
-
189
-
190
-
191
-    /**
192
-     * Set the $_transaction_details property if not set yet.
193
-     *
194
-     * @param EE_Registration $registration
195
-     * @throws \EE_Error
196
-     */
197
-    protected function _set_related_details(EE_Registration $registration)
198
-    {
199
-        $transaction = $registration->get_first_related('Transaction');
200
-        $status = $transaction instanceof EE_Transaction ? $transaction->status_ID()
201
-            : EEM_Transaction::failed_status_code;
202
-        $this->_transaction_details = array(
203
-            'transaction' => $transaction,
204
-            'status'      => $status,
205
-            'id'          => $transaction instanceof EE_Transaction ? $transaction->ID() : 0,
206
-            'title_attr'  => sprintf(__('View Transaction Details (%s)', 'event_espresso'),
207
-                EEH_Template::pretty_status($status, false, 'sentence')),
208
-        );
209
-        try {
210
-            $event = $registration->event();
211
-        } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
212
-            $event = null;
213
-        }
214
-        $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive;
215
-        $this->_event_details = array(
216
-            'event'      => $event,
217
-            'status'     => $status,
218
-            'id'         => $event instanceof EE_Event ? $event->ID() : 0,
219
-            'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'),
220
-                EEH_Template::pretty_status($status, false, 'sentence')),
221
-        );
222
-    }
223
-
224
-
225
-
226
-    /**
227
-     *    _get_table_filters
228
-     *
229
-     * @access protected
230
-     * @return array
231
-     */
232
-    protected function _get_table_filters()
233
-    {
234
-        $filters = array();
235
-        //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods.
236
-        $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
237
-        $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
238
-        $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : '';
239
-        $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
240
-        $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
241
-        $status = array();
242
-        $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso'));
243
-        foreach ($this->_status as $key => $value) {
244
-            $status[] = array('id' => $key, 'text' => $value);
245
-        }
246
-        if ($this->_view !== 'incomplete') {
247
-            $filters[] = EEH_Form_Fields::select_input('_reg_status', $status,
248
-                isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
249
-                    : '');
250
-        }
251
-        if (isset($this->_req_data['event_id'])) {
252
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
253
-        }
254
-        return $filters;
255
-    }
256
-
257
-
258
-
259
-    /**
260
-     *    _add_view_counts
261
-     *
262
-     * @access protected
263
-     * @return void
264
-     * @throws \EE_Error
265
-     */
266
-    protected function _add_view_counts()
267
-    {
268
-        $this->_views['all']['count'] = $this->_total_registrations();
269
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
270
-        $this->_views['today']['count'] = $this->_total_registrations_today();
271
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations',
272
-            'espresso_registrations_trash_registrations')
273
-        ) {
274
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
275
-            $this->_views['trash']['count'] = $this->_total_registrations('trash');
276
-        }
277
-    }
278
-
279
-
280
-
281
-    /**
282
-     * _total_registrations
283
-     *
284
-     * @access protected
285
-     * @param string $view
286
-     * @return int
287
-     * @throws \EE_Error
288
-     */
289
-    protected function _total_registrations($view = '')
290
-    {
291
-        $_where = array();
292
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
293
-        if ($EVT_ID) {
294
-            $_where['EVT_ID'] = $EVT_ID;
295
-        }
296
-        switch ($view) {
297
-            case 'trash' :
298
-                return EEM_Registration::instance()->count_deleted(array($_where));
299
-                break;
300
-            case 'incomplete' :
301
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
302
-                break;
303
-            default :
304
-                $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
305
-        }
306
-        return EEM_Registration::instance()->count(array($_where));
307
-    }
308
-
309
-
310
-
311
-    /**
312
-     * _total_registrations_this_month
313
-     *
314
-     * @access protected
315
-     * @return int
316
-     * @throws \EE_Error
317
-     */
318
-    protected function _total_registrations_this_month()
319
-    {
320
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
321
-        $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
322
-        $this_year_r = date('Y', current_time('timestamp'));
323
-        $time_start = ' 00:00:00';
324
-        $time_end = ' 23:59:59';
325
-        $this_month_r = date('m', current_time('timestamp'));
326
-        $days_this_month = date('t', current_time('timestamp'));
327
-        //setup date query.
328
-        $beginning_string = EEM_Registration::instance()
329
-                                            ->convert_datetime_for_query('REG_date',
330
-                                                $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
331
-                                                'Y-m-d H:i:s');
332
-        $end_string = EEM_Registration::instance()
333
-                                      ->convert_datetime_for_query('REG_date',
334
-                                          $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
335
-                                          'Y-m-d H:i:s');
336
-        $_where['REG_date'] = array(
337
-            'BETWEEN',
338
-            array(
339
-                $beginning_string,
340
-                $end_string,
341
-            ),
342
-        );
343
-        $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
344
-        return EEM_Registration::instance()->count(array($_where));
345
-    }
346
-
347
-
348
-
349
-    /**
350
-     * _total_registrations_today
351
-     *
352
-     * @access protected
353
-     * @return int
354
-     * @throws \EE_Error
355
-     */
356
-    protected function _total_registrations_today()
357
-    {
358
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
359
-        $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
360
-        $current_date = date('Y-m-d', current_time('timestamp'));
361
-        $time_start = ' 00:00:00';
362
-        $time_end = ' 23:59:59';
363
-        $_where['REG_date'] = array(
364
-            'BETWEEN',
365
-            array(
366
-                EEM_Registration::instance()
367
-                                ->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'),
368
-                EEM_Registration::instance()
369
-                                ->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'),
370
-            ),
371
-        );
372
-        $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
373
-        return EEM_Registration::instance()->count(array($_where));
374
-    }
375
-
376
-
377
-
378
-    /**
379
-     * column_cb
380
-     *
381
-     * @access public
382
-     * @param \EE_Registration $item
383
-     * @return string
384
-     * @throws \EE_Error
385
-     */
386
-    public function column_cb($item)
387
-    {
388
-        /** checkbox/lock **/
389
-        $transaction = $item->get_first_related('Transaction');
390
-        $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0;
391
-        return $payment_count > 0 ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID())
392
-                                    . '<span class="ee-lock-icon"></span>'
393
-            : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID());
394
-    }
395
-
396
-
397
-
398
-    /**
399
-     * column__REG_ID
400
-     *
401
-     * @access public
402
-     * @param \EE_Registration $item
403
-     * @return string
404
-     * @throws \EE_Error
405
-     */
406
-    public function column__REG_ID(EE_Registration $item)
407
-    {
408
-        $attendee = $item->attendee();
409
-        $content = $item->ID();
410
-        $content .= '<div class="show-on-mobile-view-only">';
411
-        $content .= '<br>';
412
-        $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
413
-        $content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
414
-        $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
415
-        $content .= '</div>';
416
-        return $content;
417
-    }
418
-
419
-
420
-
421
-    /**
422
-     * column__REG_date
423
-     *
424
-     * @access public
425
-     * @param \EE_Registration $item
426
-     * @return string
427
-     * @throws \EE_Error
428
-     */
429
-    public function column__REG_date(EE_Registration $item)
430
-    {
431
-        $this->_set_related_details($item);
432
-        //Build row actions
433
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
434
-            'action' => 'view_transaction',
435
-            'TXN_ID' => $this->_transaction_details['id'],
436
-        ), TXN_ADMIN_URL);
437
-        $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
438
-            'espresso_transactions_view_transaction') ? '<a class="ee-status-color-'
439
-                                                        . $this->_transaction_details['status']
440
-                                                        . '" href="'
441
-                                                        . $view_lnk_url
442
-                                                        . '" title="'
443
-                                                        . esc_attr($this->_transaction_details['title_attr'])
444
-                                                        . '">'
445
-                                                        . $item->get_i18n_datetime('REG_date')
446
-                                                        . '</a>' : $item->get_i18n_datetime('REG_date');
447
-        $view_link .= '<br><span class="ee-status-text-small">'
448
-                      . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
449
-                      . '</span>';
450
-        return $view_link;
451
-    }
452
-
453
-
454
-
455
-    /**
456
-     * column_event_name
457
-     *
458
-     * @access public
459
-     * @param \EE_Registration $item
460
-     * @return string
461
-     * @throws \EE_Error
462
-     */
463
-    public function column_event_name(EE_Registration $item)
464
-    {
465
-        $this->_set_related_details($item);
466
-        // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
467
-        $EVT_ID = $item->event_ID();
468
-        $event_name = $item->event_name();
469
-        $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso');
470
-        $event_name = wp_trim_words($event_name, 30, '...');
471
-        if ($EVT_ID) {
472
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $EVT_ID),
473
-                EVENTS_ADMIN_URL);
474
-            $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
475
-                ? '<a class="ee-status-color-'
476
-                  . $this->_event_details['status']
477
-                  . '" href="'
478
-                  . $edit_event_url
479
-                  . '" title="'
480
-                  . esc_attr($this->_event_details['title_attr'])
481
-                  . '">'
482
-                  . $event_name
483
-                  . '</a>' : $event_name;
484
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
485
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
486
-            $actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s',
487
-                'event_espresso'), $event_name);
488
-            $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
489
-        } else {
490
-            $edit_event = $event_name;
491
-            $actions['event_filter'] = '';
492
-        }
493
-        return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
494
-    }
495
-
496
-
497
-
498
-    /**
499
-     * column_DTT_EVT_start
500
-     *
501
-     * @access public
502
-     * @param \EE_Registration $item
503
-     * @return string
504
-     * @throws \EE_Error
505
-     */
506
-    public function column_DTT_EVT_start(EE_Registration $item)
507
-    {
508
-        $datetime_strings = array();
509
-        $ticket = $item->ticket(true);
510
-        if ($ticket instanceof EE_Ticket) {
511
-            $remove_defaults = array('default_where_conditions' => 'none');
512
-            $datetimes = $ticket->datetimes($remove_defaults);
513
-            foreach ($datetimes as $datetime) {
514
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
515
-            }
516
-            return implode("<br />", $datetime_strings);
517
-        } else {
518
-            return __('There is no ticket on this registration', 'event_espresso');
519
-        }
520
-    }
521
-
522
-
523
-
524
-    /**
525
-     * column_ATT_fname
526
-     *
527
-     * @access public
528
-     * @param \EE_Registration $item
529
-     * @return string
530
-     * @throws \EE_Error
531
-     */
532
-    public function column_ATT_fname(EE_Registration $item)
533
-    {
534
-        $attendee = $item->attendee();
535
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
536
-            'action'  => 'view_registration',
537
-            '_REG_ID' => $item->ID(),
538
-        ), REG_ADMIN_URL);
539
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
540
-        $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
541
-            'espresso_registrations_view_registration', $item->ID()) ? '<a href="'
542
-                                                                       . $edit_lnk_url
543
-                                                                       . '" title="'
544
-                                                                       . esc_attr__('View Registration Details',
545
-                'event_espresso')
546
-                                                                       . '">'
547
-                                                                       . $attendee_name
548
-                                                                       . '</a>' : $attendee_name;
549
-        $link .= $item->count() === 1
550
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : '';
551
-        $t = $item->get_first_related('Transaction');
552
-        $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
553
-        //append group count to name
554
-        $link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
555
-        //append reg_code
556
-        $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
557
-        //reg status text for accessibility
558
-        $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false,
559
-                'sentence') . '</span>';
560
-        //trash/restore/delete actions
561
-        $actions = array();
562
-        if ($this->_view !== 'trash'
563
-            && $payment_count === 0
564
-            && EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
565
-                'espresso_registrations_trash_registrations', $item->ID())
566
-        ) {
567
-            $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
568
-                'action'  => 'trash_registrations',
569
-                '_REG_ID' => $item->ID(),
570
-            ), REG_ADMIN_URL);
571
-            $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration',
572
-                    'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
573
-        } elseif ($this->_view === 'trash') {
574
-            // restore registration link
575
-            if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
576
-                'espresso_registrations_restore_registrations', $item->ID())
577
-            ) {
578
-                $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
579
-                    'action'  => 'restore_registrations',
580
-                    '_REG_ID' => $item->ID(),
581
-                ), REG_ADMIN_URL);
582
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration',
583
-                        'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>';
584
-            }
585
-            if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
586
-                'espresso_registrations_ee_delete_registrations', $item->ID())
587
-            ) {
588
-                $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
589
-                    'action'  => 'delete_registrations',
590
-                    '_REG_ID' => $item->ID(),
591
-                ), REG_ADMIN_URL);
592
-                $actions['delete'] = '<a href="'
593
-                                     . $delete_lnk_url
594
-                                     . '" title="'
595
-                                     . esc_attr__('Delete Registration Permanently', 'event_espresso')
596
-                                     . '">'
597
-                                     . __('Delete', 'event_espresso')
598
-                                     . '</a>';
599
-            }
600
-        }
601
-        return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
602
-    }
603
-
604
-
605
-
606
-    /**
607
-     * column_ATT_email
608
-     *
609
-     * @access public
610
-     * @param \EE_Registration $item
611
-     * @return string
612
-     * @throws \EE_Error
613
-     */
614
-    public function column_ATT_email(EE_Registration $item)
615
-    {
616
-        $attendee = $item->get_first_related('Attendee');
617
-        return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso')
618
-            : $attendee->email();
619
-    }
620
-
621
-
622
-
623
-    /**
624
-     * column__REG_count
625
-     *
626
-     * @access public
627
-     * @param \EE_Registration $item
628
-     * @return string
629
-     */
630
-    public function column__REG_count(EE_Registration $item)
631
-    {
632
-        return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
633
-    }
634
-
635
-
636
-
637
-    /**
638
-     * column_PRC_amount
639
-     *
640
-     * @access public
641
-     * @param \EE_Registration $item
642
-     * @return string
643
-     */
644
-    public function column_PRC_amount(EE_Registration $item)
645
-    {
646
-        $ticket = $item->ticket();
647
-        $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'
648
-                                                                              . $ticket->name()
649
-                                                                              . '</span><br />' : '';
650
-        if ($item->final_price() > 0) {
651
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
652
-        } else {
653
-            // free event
654
-            $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
655
-                        . __('free', 'event_espresso')
656
-                        . '</span>';
657
-        }
658
-        return $content;
659
-    }
660
-
661
-
662
-
663
-    /**
664
-     * column__REG_final_price
665
-     *
666
-     * @access public
667
-     * @param \EE_Registration $item
668
-     * @return string
669
-     */
670
-    public function column__REG_final_price(EE_Registration $item)
671
-    {
672
-        $ticket = $item->ticket();
673
-        $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket
674
-            ? ''
675
-            : '<span class="TKT_name">'
676
-              . $ticket->name()
677
-              . '</span><br />';
678
-        $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
679
-        return $content;
680
-    }
681
-
682
-
683
-
684
-    /**
685
-     * column__REG_paid
686
-     *
687
-     * @access public
688
-     * @param \EE_Registration $item
689
-     * @return string
690
-     */
691
-    public function column__REG_paid(EE_Registration $item)
692
-    {
693
-        $payment_method = $item->payment_method();
694
-        $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
695
-            : __('Unknown', 'event_espresso');
696
-        $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
697
-        if ($item->paid() > 0) {
698
-            $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'),
699
-                    $payment_method_name) . '</span>';
700
-        }
701
-        return $content;
702
-    }
703
-
704
-
705
-
706
-    /**
707
-     * column_TXN_total
708
-     *
709
-     * @access public
710
-     * @param \EE_Registration $item
711
-     * @return string
712
-     * @throws \EE_Error
713
-     */
714
-    public function column_TXN_total(EE_Registration $item)
715
-    {
716
-        if ($item->transaction()) {
717
-            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
718
-                'action' => 'view_transaction',
719
-                'TXN_ID' => $item->transaction_ID(),
720
-            ), TXN_ADMIN_URL);
721
-            return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
722
-                'espresso_transactions_view_transaction', $item->transaction_ID())
723
-                ? '<span class="reg-pad-rght"><a class="status-'
724
-                  . $item->transaction()->status_ID()
725
-                  . '" href="'
726
-                  . $view_txn_lnk_url
727
-                  . '"  title="'
728
-                  . esc_attr__('View Transaction', 'event_espresso')
729
-                  . '">'
730
-                  . $item->transaction()->pretty_total()
731
-                  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
732
-        } else {
733
-            return __("None", "event_espresso");
734
-        }
735
-    }
736
-
737
-
738
-
739
-    /**
740
-     * column_TXN_paid
741
-     *
742
-     * @access public
743
-     * @param \EE_Registration $item
744
-     * @return string
745
-     * @throws \EE_Error
746
-     */
747
-    public function column_TXN_paid(EE_Registration $item)
748
-    {
749
-        if ($item->count() === 1) {
750
-            $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance();
751
-            if ($transaction->paid() >= $transaction->total()) {
752
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
753
-            } else {
754
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
755
-                    'action' => 'view_transaction',
756
-                    'TXN_ID' => $item->transaction_ID(),
757
-                ), TXN_ADMIN_URL);
758
-                return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
759
-                    'espresso_transactions_view_transaction', $item->transaction_ID())
760
-                    ? '<span class="reg-pad-rght"><a class="status-'
761
-                      . $transaction->status_ID()
762
-                      . '" href="'
763
-                      . $view_txn_lnk_url
764
-                      . '"  title="'
765
-                      . esc_attr__('View Transaction', 'event_espresso')
766
-                      . '">'
767
-                      . $item->transaction()->pretty_paid()
768
-                      . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
769
-            }
770
-        }
771
-        return '&nbsp;';
772
-    }
773
-
774
-
775
-
776
-    /**
777
-     * column_actions
778
-     *
779
-     * @access public
780
-     * @param \EE_Registration $item
781
-     * @return string
782
-     * @throws \EE_Error
783
-     */
784
-    public function column_actions(EE_Registration $item)
785
-    {
786
-        $actions = array();
787
-        $attendee = $item->attendee();
788
-        $this->_set_related_details($item);
789
-        //Build row actions
790
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
791
-            'action'  => 'view_registration',
792
-            '_REG_ID' => $item->ID(),
793
-        ), REG_ADMIN_URL);
794
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
795
-            'action' => 'edit_attendee',
796
-            'post'   => $item->attendee_ID(),
797
-        ), REG_ADMIN_URL);
798
-        // page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
799
-        //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
800
-        $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
801
-            'action'  => 'resend_registration',
802
-            '_REG_ID' => $item->ID(),
803
-        ), REG_ADMIN_URL, true);
804
-        //Build row actions
805
-        $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
806
-            'espresso_registrations_view_registration', $item->ID()) ? '
29
+	private $_status;
30
+
31
+
32
+
33
+	/**
34
+	 * An array of transaction details for the related transaction to the registration being processed.
35
+	 * This is set via the _set_related_details method.
36
+	 *
37
+	 * @var array
38
+	 */
39
+	protected $_transaction_details = array();
40
+
41
+
42
+
43
+	/**
44
+	 * An array of event details for the related event to the registration being processed.
45
+	 * This is set via the _set_related_details method.
46
+	 *
47
+	 * @var array
48
+	 */
49
+	protected $_event_details = array();
50
+
51
+
52
+
53
+	/**
54
+	 * @param \Registrations_Admin_Page $admin_page
55
+	 */
56
+	public function __construct(Registrations_Admin_Page $admin_page)
57
+	{
58
+		if ( ! empty($_GET['event_id'])) {
59
+			$extra_query_args = array();
60
+			foreach ($admin_page->get_views() as $key => $view_details) {
61
+				$extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']);
62
+			}
63
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
64
+		}
65
+		parent::__construct($admin_page);
66
+		$this->_status = $this->_admin_page->get_registration_status_array();
67
+	}
68
+
69
+
70
+
71
+	/**
72
+	 *    _setup_data
73
+	 *
74
+	 * @access protected
75
+	 * @return void
76
+	 */
77
+	protected function _setup_data()
78
+	{
79
+		$this->_data = $this->_admin_page->get_registrations($this->_per_page);
80
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false);
81
+	}
82
+
83
+
84
+
85
+	/**
86
+	 *    _set_properties
87
+	 *
88
+	 * @access protected
89
+	 * @return void
90
+	 */
91
+	protected function _set_properties()
92
+	{
93
+		$this->_wp_list_args = array(
94
+			'singular' => __('registration', 'event_espresso'),
95
+			'plural'   => __('registrations', 'event_espresso'),
96
+			'ajax'     => true,
97
+			'screen'   => $this->_admin_page->get_current_screen()->id,
98
+		);
99
+		$ID_column_name = __('ID', 'event_espresso');
100
+		$ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
101
+		$ID_column_name .= __('Registrant Name', 'event_espresso');
102
+		$ID_column_name .= '</span> ';
103
+		if (isset($_GET['event_id'])) {
104
+			$this->_columns = array(
105
+				'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
106
+				'_REG_ID'          => $ID_column_name,
107
+				'ATT_fname'        => __('Name', 'event_espresso'),
108
+				'ATT_email'        => __('Email', 'event_espresso'),
109
+				'_REG_date'        => __('Reg Date', 'event_espresso'),
110
+				'PRC_amount'       => __('TKT Price', 'event_espresso'),
111
+				'_REG_final_price' => __('Final Price', 'event_espresso'),
112
+				'TXN_total'        => __('Total Txn', 'event_espresso'),
113
+				'TXN_paid'         => __('Paid', 'event_espresso'),
114
+				'actions'          => __('Actions', 'event_espresso'),
115
+			);
116
+			$this->_bottom_buttons = array(
117
+				'report' => array(
118
+					'route'         => 'registrations_report',
119
+					'extra_request' => array(
120
+						'EVT_ID'     => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
121
+						'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
122
+					),
123
+				),
124
+			);
125
+		} else {
126
+			$this->_columns = array(
127
+				'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
128
+				'_REG_ID'          => $ID_column_name,
129
+				'ATT_fname'        => __('Name', 'event_espresso'),
130
+				'_REG_date'        => __('TXN Date', 'event_espresso'),
131
+				'event_name'       => __('Event', 'event_espresso'),
132
+				'DTT_EVT_start'    => __('Event Date', 'event_espresso'),
133
+				'_REG_final_price' => __('Price', 'event_espresso'),
134
+				'_REG_paid'        => __('Paid', 'event_espresso'),
135
+				'actions'          => __('Actions', 'event_espresso'),
136
+			);
137
+			$this->_bottom_buttons = array(
138
+				'report_all' => array(
139
+					'route'         => 'registrations_report',
140
+					'extra_request' => array(
141
+						'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
142
+					),
143
+				),
144
+			);
145
+		}
146
+		$this->_bottom_buttons['report_filtered'] = array(
147
+			'route'         => 'registrations_report',
148
+			'extra_request' => array(
149
+				'use_filters' => true,
150
+				'filters'     => array_diff_key($this->_req_data, array_flip(array(
151
+							'page',
152
+							'action',
153
+							'default_nonce',
154
+						))),
155
+				'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
156
+			),
157
+		);
158
+		$this->_primary_column = '_REG_ID';
159
+		$this->_sortable_columns = array(
160
+			'_REG_date'     => array('_REG_date' => true),   //true means its already sorted
161
+			'ATT_fname'     => array('ATT_fname' => false),
162
+			'event_name'    => array('event_name' => false),
163
+			'DTT_EVT_start' => array('DTT_EVT_start' => false),
164
+			'_REG_ID'       => array('_REG_ID' => false),
165
+		);
166
+		$this->_hidden_columns = array();
167
+	}
168
+
169
+
170
+
171
+	/**
172
+	 * This simply sets up the row class for the table rows.
173
+	 * Allows for easier overriding of child methods for setting up sorting.
174
+	 *
175
+	 * @param  EE_Registration $item the current item
176
+	 * @return string
177
+	 */
178
+	protected function _get_row_class($item)
179
+	{
180
+		$class = parent::_get_row_class($item);
181
+		//add status class
182
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
183
+		if ($this->_has_checkbox_column) {
184
+			$class .= ' has-checkbox-column';
185
+		}
186
+		return $class;
187
+	}
188
+
189
+
190
+
191
+	/**
192
+	 * Set the $_transaction_details property if not set yet.
193
+	 *
194
+	 * @param EE_Registration $registration
195
+	 * @throws \EE_Error
196
+	 */
197
+	protected function _set_related_details(EE_Registration $registration)
198
+	{
199
+		$transaction = $registration->get_first_related('Transaction');
200
+		$status = $transaction instanceof EE_Transaction ? $transaction->status_ID()
201
+			: EEM_Transaction::failed_status_code;
202
+		$this->_transaction_details = array(
203
+			'transaction' => $transaction,
204
+			'status'      => $status,
205
+			'id'          => $transaction instanceof EE_Transaction ? $transaction->ID() : 0,
206
+			'title_attr'  => sprintf(__('View Transaction Details (%s)', 'event_espresso'),
207
+				EEH_Template::pretty_status($status, false, 'sentence')),
208
+		);
209
+		try {
210
+			$event = $registration->event();
211
+		} catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
212
+			$event = null;
213
+		}
214
+		$status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive;
215
+		$this->_event_details = array(
216
+			'event'      => $event,
217
+			'status'     => $status,
218
+			'id'         => $event instanceof EE_Event ? $event->ID() : 0,
219
+			'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'),
220
+				EEH_Template::pretty_status($status, false, 'sentence')),
221
+		);
222
+	}
223
+
224
+
225
+
226
+	/**
227
+	 *    _get_table_filters
228
+	 *
229
+	 * @access protected
230
+	 * @return array
231
+	 */
232
+	protected function _get_table_filters()
233
+	{
234
+		$filters = array();
235
+		//todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods.
236
+		$cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
237
+		$cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
238
+		$reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : '';
239
+		$filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
240
+		$filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
241
+		$status = array();
242
+		$status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso'));
243
+		foreach ($this->_status as $key => $value) {
244
+			$status[] = array('id' => $key, 'text' => $value);
245
+		}
246
+		if ($this->_view !== 'incomplete') {
247
+			$filters[] = EEH_Form_Fields::select_input('_reg_status', $status,
248
+				isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
249
+					: '');
250
+		}
251
+		if (isset($this->_req_data['event_id'])) {
252
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
253
+		}
254
+		return $filters;
255
+	}
256
+
257
+
258
+
259
+	/**
260
+	 *    _add_view_counts
261
+	 *
262
+	 * @access protected
263
+	 * @return void
264
+	 * @throws \EE_Error
265
+	 */
266
+	protected function _add_view_counts()
267
+	{
268
+		$this->_views['all']['count'] = $this->_total_registrations();
269
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
270
+		$this->_views['today']['count'] = $this->_total_registrations_today();
271
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations',
272
+			'espresso_registrations_trash_registrations')
273
+		) {
274
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
275
+			$this->_views['trash']['count'] = $this->_total_registrations('trash');
276
+		}
277
+	}
278
+
279
+
280
+
281
+	/**
282
+	 * _total_registrations
283
+	 *
284
+	 * @access protected
285
+	 * @param string $view
286
+	 * @return int
287
+	 * @throws \EE_Error
288
+	 */
289
+	protected function _total_registrations($view = '')
290
+	{
291
+		$_where = array();
292
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
293
+		if ($EVT_ID) {
294
+			$_where['EVT_ID'] = $EVT_ID;
295
+		}
296
+		switch ($view) {
297
+			case 'trash' :
298
+				return EEM_Registration::instance()->count_deleted(array($_where));
299
+				break;
300
+			case 'incomplete' :
301
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
302
+				break;
303
+			default :
304
+				$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
305
+		}
306
+		return EEM_Registration::instance()->count(array($_where));
307
+	}
308
+
309
+
310
+
311
+	/**
312
+	 * _total_registrations_this_month
313
+	 *
314
+	 * @access protected
315
+	 * @return int
316
+	 * @throws \EE_Error
317
+	 */
318
+	protected function _total_registrations_this_month()
319
+	{
320
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
321
+		$_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
322
+		$this_year_r = date('Y', current_time('timestamp'));
323
+		$time_start = ' 00:00:00';
324
+		$time_end = ' 23:59:59';
325
+		$this_month_r = date('m', current_time('timestamp'));
326
+		$days_this_month = date('t', current_time('timestamp'));
327
+		//setup date query.
328
+		$beginning_string = EEM_Registration::instance()
329
+											->convert_datetime_for_query('REG_date',
330
+												$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
331
+												'Y-m-d H:i:s');
332
+		$end_string = EEM_Registration::instance()
333
+									  ->convert_datetime_for_query('REG_date',
334
+										  $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
335
+										  'Y-m-d H:i:s');
336
+		$_where['REG_date'] = array(
337
+			'BETWEEN',
338
+			array(
339
+				$beginning_string,
340
+				$end_string,
341
+			),
342
+		);
343
+		$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
344
+		return EEM_Registration::instance()->count(array($_where));
345
+	}
346
+
347
+
348
+
349
+	/**
350
+	 * _total_registrations_today
351
+	 *
352
+	 * @access protected
353
+	 * @return int
354
+	 * @throws \EE_Error
355
+	 */
356
+	protected function _total_registrations_today()
357
+	{
358
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
359
+		$_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
360
+		$current_date = date('Y-m-d', current_time('timestamp'));
361
+		$time_start = ' 00:00:00';
362
+		$time_end = ' 23:59:59';
363
+		$_where['REG_date'] = array(
364
+			'BETWEEN',
365
+			array(
366
+				EEM_Registration::instance()
367
+								->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'),
368
+				EEM_Registration::instance()
369
+								->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'),
370
+			),
371
+		);
372
+		$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
373
+		return EEM_Registration::instance()->count(array($_where));
374
+	}
375
+
376
+
377
+
378
+	/**
379
+	 * column_cb
380
+	 *
381
+	 * @access public
382
+	 * @param \EE_Registration $item
383
+	 * @return string
384
+	 * @throws \EE_Error
385
+	 */
386
+	public function column_cb($item)
387
+	{
388
+		/** checkbox/lock **/
389
+		$transaction = $item->get_first_related('Transaction');
390
+		$payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0;
391
+		return $payment_count > 0 ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID())
392
+									. '<span class="ee-lock-icon"></span>'
393
+			: sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID());
394
+	}
395
+
396
+
397
+
398
+	/**
399
+	 * column__REG_ID
400
+	 *
401
+	 * @access public
402
+	 * @param \EE_Registration $item
403
+	 * @return string
404
+	 * @throws \EE_Error
405
+	 */
406
+	public function column__REG_ID(EE_Registration $item)
407
+	{
408
+		$attendee = $item->attendee();
409
+		$content = $item->ID();
410
+		$content .= '<div class="show-on-mobile-view-only">';
411
+		$content .= '<br>';
412
+		$content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
413
+		$content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
414
+		$content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
415
+		$content .= '</div>';
416
+		return $content;
417
+	}
418
+
419
+
420
+
421
+	/**
422
+	 * column__REG_date
423
+	 *
424
+	 * @access public
425
+	 * @param \EE_Registration $item
426
+	 * @return string
427
+	 * @throws \EE_Error
428
+	 */
429
+	public function column__REG_date(EE_Registration $item)
430
+	{
431
+		$this->_set_related_details($item);
432
+		//Build row actions
433
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
434
+			'action' => 'view_transaction',
435
+			'TXN_ID' => $this->_transaction_details['id'],
436
+		), TXN_ADMIN_URL);
437
+		$view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
438
+			'espresso_transactions_view_transaction') ? '<a class="ee-status-color-'
439
+														. $this->_transaction_details['status']
440
+														. '" href="'
441
+														. $view_lnk_url
442
+														. '" title="'
443
+														. esc_attr($this->_transaction_details['title_attr'])
444
+														. '">'
445
+														. $item->get_i18n_datetime('REG_date')
446
+														. '</a>' : $item->get_i18n_datetime('REG_date');
447
+		$view_link .= '<br><span class="ee-status-text-small">'
448
+					  . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
449
+					  . '</span>';
450
+		return $view_link;
451
+	}
452
+
453
+
454
+
455
+	/**
456
+	 * column_event_name
457
+	 *
458
+	 * @access public
459
+	 * @param \EE_Registration $item
460
+	 * @return string
461
+	 * @throws \EE_Error
462
+	 */
463
+	public function column_event_name(EE_Registration $item)
464
+	{
465
+		$this->_set_related_details($item);
466
+		// page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
467
+		$EVT_ID = $item->event_ID();
468
+		$event_name = $item->event_name();
469
+		$event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso');
470
+		$event_name = wp_trim_words($event_name, 30, '...');
471
+		if ($EVT_ID) {
472
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $EVT_ID),
473
+				EVENTS_ADMIN_URL);
474
+			$edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
475
+				? '<a class="ee-status-color-'
476
+				  . $this->_event_details['status']
477
+				  . '" href="'
478
+				  . $edit_event_url
479
+				  . '" title="'
480
+				  . esc_attr($this->_event_details['title_attr'])
481
+				  . '">'
482
+				  . $event_name
483
+				  . '</a>' : $event_name;
484
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
485
+			$actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
486
+			$actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s',
487
+				'event_espresso'), $event_name);
488
+			$actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
489
+		} else {
490
+			$edit_event = $event_name;
491
+			$actions['event_filter'] = '';
492
+		}
493
+		return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
494
+	}
495
+
496
+
497
+
498
+	/**
499
+	 * column_DTT_EVT_start
500
+	 *
501
+	 * @access public
502
+	 * @param \EE_Registration $item
503
+	 * @return string
504
+	 * @throws \EE_Error
505
+	 */
506
+	public function column_DTT_EVT_start(EE_Registration $item)
507
+	{
508
+		$datetime_strings = array();
509
+		$ticket = $item->ticket(true);
510
+		if ($ticket instanceof EE_Ticket) {
511
+			$remove_defaults = array('default_where_conditions' => 'none');
512
+			$datetimes = $ticket->datetimes($remove_defaults);
513
+			foreach ($datetimes as $datetime) {
514
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
515
+			}
516
+			return implode("<br />", $datetime_strings);
517
+		} else {
518
+			return __('There is no ticket on this registration', 'event_espresso');
519
+		}
520
+	}
521
+
522
+
523
+
524
+	/**
525
+	 * column_ATT_fname
526
+	 *
527
+	 * @access public
528
+	 * @param \EE_Registration $item
529
+	 * @return string
530
+	 * @throws \EE_Error
531
+	 */
532
+	public function column_ATT_fname(EE_Registration $item)
533
+	{
534
+		$attendee = $item->attendee();
535
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
536
+			'action'  => 'view_registration',
537
+			'_REG_ID' => $item->ID(),
538
+		), REG_ADMIN_URL);
539
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
540
+		$link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
541
+			'espresso_registrations_view_registration', $item->ID()) ? '<a href="'
542
+																	   . $edit_lnk_url
543
+																	   . '" title="'
544
+																	   . esc_attr__('View Registration Details',
545
+				'event_espresso')
546
+																	   . '">'
547
+																	   . $attendee_name
548
+																	   . '</a>' : $attendee_name;
549
+		$link .= $item->count() === 1
550
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : '';
551
+		$t = $item->get_first_related('Transaction');
552
+		$payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
553
+		//append group count to name
554
+		$link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
555
+		//append reg_code
556
+		$link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
557
+		//reg status text for accessibility
558
+		$link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false,
559
+				'sentence') . '</span>';
560
+		//trash/restore/delete actions
561
+		$actions = array();
562
+		if ($this->_view !== 'trash'
563
+			&& $payment_count === 0
564
+			&& EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
565
+				'espresso_registrations_trash_registrations', $item->ID())
566
+		) {
567
+			$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
568
+				'action'  => 'trash_registrations',
569
+				'_REG_ID' => $item->ID(),
570
+			), REG_ADMIN_URL);
571
+			$actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration',
572
+					'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
573
+		} elseif ($this->_view === 'trash') {
574
+			// restore registration link
575
+			if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
576
+				'espresso_registrations_restore_registrations', $item->ID())
577
+			) {
578
+				$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
579
+					'action'  => 'restore_registrations',
580
+					'_REG_ID' => $item->ID(),
581
+				), REG_ADMIN_URL);
582
+				$actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration',
583
+						'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>';
584
+			}
585
+			if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
586
+				'espresso_registrations_ee_delete_registrations', $item->ID())
587
+			) {
588
+				$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
589
+					'action'  => 'delete_registrations',
590
+					'_REG_ID' => $item->ID(),
591
+				), REG_ADMIN_URL);
592
+				$actions['delete'] = '<a href="'
593
+									 . $delete_lnk_url
594
+									 . '" title="'
595
+									 . esc_attr__('Delete Registration Permanently', 'event_espresso')
596
+									 . '">'
597
+									 . __('Delete', 'event_espresso')
598
+									 . '</a>';
599
+			}
600
+		}
601
+		return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
602
+	}
603
+
604
+
605
+
606
+	/**
607
+	 * column_ATT_email
608
+	 *
609
+	 * @access public
610
+	 * @param \EE_Registration $item
611
+	 * @return string
612
+	 * @throws \EE_Error
613
+	 */
614
+	public function column_ATT_email(EE_Registration $item)
615
+	{
616
+		$attendee = $item->get_first_related('Attendee');
617
+		return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso')
618
+			: $attendee->email();
619
+	}
620
+
621
+
622
+
623
+	/**
624
+	 * column__REG_count
625
+	 *
626
+	 * @access public
627
+	 * @param \EE_Registration $item
628
+	 * @return string
629
+	 */
630
+	public function column__REG_count(EE_Registration $item)
631
+	{
632
+		return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
633
+	}
634
+
635
+
636
+
637
+	/**
638
+	 * column_PRC_amount
639
+	 *
640
+	 * @access public
641
+	 * @param \EE_Registration $item
642
+	 * @return string
643
+	 */
644
+	public function column_PRC_amount(EE_Registration $item)
645
+	{
646
+		$ticket = $item->ticket();
647
+		$content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'
648
+																			  . $ticket->name()
649
+																			  . '</span><br />' : '';
650
+		if ($item->final_price() > 0) {
651
+			$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
652
+		} else {
653
+			// free event
654
+			$content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
655
+						. __('free', 'event_espresso')
656
+						. '</span>';
657
+		}
658
+		return $content;
659
+	}
660
+
661
+
662
+
663
+	/**
664
+	 * column__REG_final_price
665
+	 *
666
+	 * @access public
667
+	 * @param \EE_Registration $item
668
+	 * @return string
669
+	 */
670
+	public function column__REG_final_price(EE_Registration $item)
671
+	{
672
+		$ticket = $item->ticket();
673
+		$content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket
674
+			? ''
675
+			: '<span class="TKT_name">'
676
+			  . $ticket->name()
677
+			  . '</span><br />';
678
+		$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
679
+		return $content;
680
+	}
681
+
682
+
683
+
684
+	/**
685
+	 * column__REG_paid
686
+	 *
687
+	 * @access public
688
+	 * @param \EE_Registration $item
689
+	 * @return string
690
+	 */
691
+	public function column__REG_paid(EE_Registration $item)
692
+	{
693
+		$payment_method = $item->payment_method();
694
+		$payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
695
+			: __('Unknown', 'event_espresso');
696
+		$content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
697
+		if ($item->paid() > 0) {
698
+			$content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'),
699
+					$payment_method_name) . '</span>';
700
+		}
701
+		return $content;
702
+	}
703
+
704
+
705
+
706
+	/**
707
+	 * column_TXN_total
708
+	 *
709
+	 * @access public
710
+	 * @param \EE_Registration $item
711
+	 * @return string
712
+	 * @throws \EE_Error
713
+	 */
714
+	public function column_TXN_total(EE_Registration $item)
715
+	{
716
+		if ($item->transaction()) {
717
+			$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
718
+				'action' => 'view_transaction',
719
+				'TXN_ID' => $item->transaction_ID(),
720
+			), TXN_ADMIN_URL);
721
+			return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
722
+				'espresso_transactions_view_transaction', $item->transaction_ID())
723
+				? '<span class="reg-pad-rght"><a class="status-'
724
+				  . $item->transaction()->status_ID()
725
+				  . '" href="'
726
+				  . $view_txn_lnk_url
727
+				  . '"  title="'
728
+				  . esc_attr__('View Transaction', 'event_espresso')
729
+				  . '">'
730
+				  . $item->transaction()->pretty_total()
731
+				  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
732
+		} else {
733
+			return __("None", "event_espresso");
734
+		}
735
+	}
736
+
737
+
738
+
739
+	/**
740
+	 * column_TXN_paid
741
+	 *
742
+	 * @access public
743
+	 * @param \EE_Registration $item
744
+	 * @return string
745
+	 * @throws \EE_Error
746
+	 */
747
+	public function column_TXN_paid(EE_Registration $item)
748
+	{
749
+		if ($item->count() === 1) {
750
+			$transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance();
751
+			if ($transaction->paid() >= $transaction->total()) {
752
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
753
+			} else {
754
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
755
+					'action' => 'view_transaction',
756
+					'TXN_ID' => $item->transaction_ID(),
757
+				), TXN_ADMIN_URL);
758
+				return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
759
+					'espresso_transactions_view_transaction', $item->transaction_ID())
760
+					? '<span class="reg-pad-rght"><a class="status-'
761
+					  . $transaction->status_ID()
762
+					  . '" href="'
763
+					  . $view_txn_lnk_url
764
+					  . '"  title="'
765
+					  . esc_attr__('View Transaction', 'event_espresso')
766
+					  . '">'
767
+					  . $item->transaction()->pretty_paid()
768
+					  . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
769
+			}
770
+		}
771
+		return '&nbsp;';
772
+	}
773
+
774
+
775
+
776
+	/**
777
+	 * column_actions
778
+	 *
779
+	 * @access public
780
+	 * @param \EE_Registration $item
781
+	 * @return string
782
+	 * @throws \EE_Error
783
+	 */
784
+	public function column_actions(EE_Registration $item)
785
+	{
786
+		$actions = array();
787
+		$attendee = $item->attendee();
788
+		$this->_set_related_details($item);
789
+		//Build row actions
790
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
791
+			'action'  => 'view_registration',
792
+			'_REG_ID' => $item->ID(),
793
+		), REG_ADMIN_URL);
794
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
795
+			'action' => 'edit_attendee',
796
+			'post'   => $item->attendee_ID(),
797
+		), REG_ADMIN_URL);
798
+		// page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
799
+		//$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
800
+		$resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
801
+			'action'  => 'resend_registration',
802
+			'_REG_ID' => $item->ID(),
803
+		), REG_ADMIN_URL, true);
804
+		//Build row actions
805
+		$actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
806
+			'espresso_registrations_view_registration', $item->ID()) ? '
807 807
 			<li>
808 808
 			<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
809 809
 				<div class="dashicons dashicons-clipboard"></div>
810 810
 			</a>
811 811
 			</li>' : '';
812
-        $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts',
813
-            'espresso_registrations_edit_attendee')
814
-                               && $attendee instanceof EE_Attendee ? '
812
+		$actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts',
813
+			'espresso_registrations_edit_attendee')
814
+							   && $attendee instanceof EE_Attendee ? '
815 815
 			<li>
816 816
 			<a href="' . $edit_lnk_url . '" title="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
817 817
 				<div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
818 818
 			</a>
819 819
 			</li>' : '';
820
-        $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee
821
-                                     && EE_Registry::instance()->CAP->current_user_can('ee_send_message',
822
-            'espresso_registrations_resend_registration', $item->ID()) ? '
820
+		$actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee
821
+									 && EE_Registry::instance()->CAP->current_user_can('ee_send_message',
822
+			'espresso_registrations_resend_registration', $item->ID()) ? '
823 823
 			<li>
824 824
 			<a href="'
825
-                                                                         . $resend_reg_lnk_url
826
-                                                                         . '" title="'
827
-                                                                         . esc_attr__('Resend Registration Details',
828
-                'event_espresso')
829
-                                                                         . '" class="tiny-text">
825
+																		 . $resend_reg_lnk_url
826
+																		 . '" title="'
827
+																		 . esc_attr__('Resend Registration Details',
828
+				'event_espresso')
829
+																		 . '" class="tiny-text">
830 830
 				<div class="dashicons dashicons-email-alt"></div>
831 831
 			</a>
832 832
 			</li>' : '';
833
-        // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
834
-        $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
835
-            'action' => 'view_transaction',
836
-            'TXN_ID' => $this->_transaction_details['id'],
837
-        ), TXN_ADMIN_URL);
838
-        $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
839
-            'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? '
833
+		// page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
834
+		$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
835
+			'action' => 'view_transaction',
836
+			'TXN_ID' => $this->_transaction_details['id'],
837
+		), TXN_ADMIN_URL);
838
+		$actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
839
+			'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? '
840 840
 			<li>
841 841
 			<a class="ee-status-color-'
842
-                                                                                           . $this->_transaction_details['status']
843
-                                                                                           . ' tiny-text" href="'
844
-                                                                                           . $view_txn_lnk_url
845
-                                                                                           . '"  title="'
846
-                                                                                           . $this->_transaction_details['title_attr']
847
-                                                                                           . '">
842
+																						   . $this->_transaction_details['status']
843
+																						   . ' tiny-text" href="'
844
+																						   . $view_txn_lnk_url
845
+																						   . '"  title="'
846
+																						   . $this->_transaction_details['title_attr']
847
+																						   . '">
848 848
 				<div class="dashicons dashicons-cart"></div>
849 849
 			</a>
850 850
 			</li>' : '';
851
-        //invoice link
852
-        $actions['dl_invoice_lnk'] = '';
853
-        $dl_invoice_lnk_url = $item->invoice_url();
854
-        //only show invoice link if message type is active.
855
-        if ($attendee instanceof EE_Attendee
856
-            && $item->is_primary_registrant()
857
-            && EEH_MSG_Template::is_mt_active('invoice')
858
-        ) {
859
-            $actions['dl_invoice_lnk'] = '
851
+		//invoice link
852
+		$actions['dl_invoice_lnk'] = '';
853
+		$dl_invoice_lnk_url = $item->invoice_url();
854
+		//only show invoice link if message type is active.
855
+		if ($attendee instanceof EE_Attendee
856
+			&& $item->is_primary_registrant()
857
+			&& EEH_MSG_Template::is_mt_active('invoice')
858
+		) {
859
+			$actions['dl_invoice_lnk'] = '
860 860
 		<li>
861 861
 			<a title="'
862
-                                         . esc_attr__('View Transaction Invoice', 'event_espresso')
863
-                                         . '" target="_blank" href="'
864
-                                         . $dl_invoice_lnk_url
865
-                                         . '" class="tiny-text">
862
+										 . esc_attr__('View Transaction Invoice', 'event_espresso')
863
+										 . '" target="_blank" href="'
864
+										 . $dl_invoice_lnk_url
865
+										 . '" class="tiny-text">
866 866
 				<span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
867 867
 			</a>
868 868
 		</li>';
869
-        }
870
-        $actions['filtered_messages_link'] = '';
871
-        //message list table link (filtered by REG_ID
872
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
873
-            $actions['filtered_messages_link'] = '<li>'
874
-                                                 . EEH_MSG_Template::get_message_action_link('see_notifications_for',
875
-                    null, array(
876
-                        '_REG_ID' => $item->ID(),
877
-                    ))
878
-                                                 . '</li>';
879
-        }
880
-        $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
881
-        return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
882
-    }
869
+		}
870
+		$actions['filtered_messages_link'] = '';
871
+		//message list table link (filtered by REG_ID
872
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
873
+			$actions['filtered_messages_link'] = '<li>'
874
+												 . EEH_MSG_Template::get_message_action_link('see_notifications_for',
875
+					null, array(
876
+						'_REG_ID' => $item->ID(),
877
+					))
878
+												 . '</li>';
879
+		}
880
+		$actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
881
+		return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
882
+	}
883 883
 
884 884
 }
Please login to merge, or discard this patch.
admin/extend/registrations/EE_Event_Registrations_List_Table.class.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		$this->_columns = array_merge( $columns, $this->_columns );
88 88
 		$this->_primary_column = '_REG_att_checked_in';
89 89
 		if ( ! empty( $evt_id )
90
-		     && EE_Registry::instance()->CAP->current_user_can(
90
+			 && EE_Registry::instance()->CAP->current_user_can(
91 91
 				'ee_read_registrations',
92 92
 				'espresso_registrations_registrations_reports',
93 93
 				$evt_id
@@ -104,28 +104,28 @@  discard block
 block discarded – undo
104 104
 				),
105 105
 			);
106 106
 		}
107
-        $this->_bottom_buttons['report_filtered'] = array(
108
-            'route'         => 'registrations_checkin_report',
109
-            'extra_request' => array(
110
-                'use_filters' => true,
111
-                'filters'     => array_merge(
112
-                    array(
113
-                        'EVT_ID' => $evt_id,
114
-                    ),
115
-                    array_diff_key(
116
-                        $this->_req_data,
117
-                        array_flip(
118
-                            array(
119
-                                'page',
120
-                                'action',
121
-                                'default_nonce',
122
-                            )
123
-                        )
124
-                    )
125
-                ),
126
-                'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
127
-            ),
128
-        );
107
+		$this->_bottom_buttons['report_filtered'] = array(
108
+			'route'         => 'registrations_checkin_report',
109
+			'extra_request' => array(
110
+				'use_filters' => true,
111
+				'filters'     => array_merge(
112
+					array(
113
+						'EVT_ID' => $evt_id,
114
+					),
115
+					array_diff_key(
116
+						$this->_req_data,
117
+						array_flip(
118
+							array(
119
+								'page',
120
+								'action',
121
+								'default_nonce',
122
+							)
123
+						)
124
+					)
125
+				),
126
+				'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
127
+			),
128
+		);
129 129
 		$this->_sortable_columns = array(
130 130
 			//true means its already sorted
131 131
 			'ATT_name' => array( 'ATT_name' => true ),
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
 			if ( count( $this->_dtts_for_event ) > 1 ) {
212 212
 				$dtts[0] = __( 'To toggle check-in status, select a datetime.', 'event_espresso' );
213 213
 				foreach ( $this->_dtts_for_event as $dtt ) {
214
-                    $datetime_string = $dtt->name();
215
-                    $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : '';
214
+					$datetime_string = $dtt->name();
215
+					$datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : '';
216 216
 					$datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string;
217 217
 					$dtts[ $dtt->ID() ] = $datetime_string;
218 218
 				}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 		$checkinstatus = $item->check_in_status_for_datetime( $this->_cur_dtt_id );
307 307
 		$nonce = wp_create_nonce( 'checkin_nonce' );
308 308
 		$toggle_active = ! empty ( $this->_cur_dtt_id )
309
-		                 && EE_Registry::instance()->CAP->current_user_can(
309
+						 && EE_Registry::instance()->CAP->current_user_can(
310 310
 			'ee_edit_checkin',
311 311
 			'espresso_registrations_toggle_checkin_status',
312 312
 			$item->ID()
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
 			: '';
316 316
 		$mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
317 317
 		return '<span class="checkin-icons checkedin-status-' . $checkinstatus . $toggle_active . '"'
318
-		       . ' data-_regid="' . $item->ID() . '"'
319
-		       . ' data-dttid="' . $this->_cur_dtt_id . '"'
320
-		       . ' data-nonce="' . $nonce . '">'
321
-		       . '</span>'
322
-		       . $mobile_view_content;
318
+			   . ' data-_regid="' . $item->ID() . '"'
319
+			   . ' data-dttid="' . $this->_cur_dtt_id . '"'
320
+			   . ' data-nonce="' . $nonce . '">'
321
+			   . '</span>'
322
+			   . $mobile_view_content;
323 323
 	}
324 324
 
325 325
 
@@ -344,8 +344,8 @@  discard block
 block discarded – undo
344 344
 			'espresso_registrations_edit_attendee'
345 345
 		)
346 346
 			? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__( 'Edit Contact', 'event_espresso' ) . '">'
347
-			    . $item->attendee()->full_name()
348
-			    . '</a>'
347
+				. $item->attendee()->full_name()
348
+				. '</a>'
349 349
 			: $item->attendee()->full_name();
350 350
 		$name_link .= $item->count() === 1
351 351
 			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	'
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 			? $latest_related_datetime->ID()
381 381
 			: $DTT_ID;
382 382
 		if ( ! empty( $DTT_ID )
383
-		     && EE_Registry::instance()->CAP->current_user_can(
383
+			 && EE_Registry::instance()->CAP->current_user_can(
384 384
 				'ee_read_checkins',
385 385
 				'espresso_registrations_registration_checkins'
386 386
 			)
@@ -480,15 +480,15 @@  discard block
 block discarded – undo
480 480
 				) ? '
481 481
 				<span class="reg-pad-rght">
482 482
 					<a class="status-'
483
-				    . $item->transaction()->status_ID()
484
-				    . '" href="'
485
-				    . $view_txn_lnk_url
486
-				    . '"  title="'
487
-				    . esc_attr__( 'View Transaction', 'event_espresso' )
488
-				    . '">
483
+					. $item->transaction()->status_ID()
484
+					. '" href="'
485
+					. $view_txn_lnk_url
486
+					. '"  title="'
487
+					. esc_attr__( 'View Transaction', 'event_espresso' )
488
+					. '">
489 489
 						'
490
-				    . $item->transaction()->pretty_paid()
491
-				    . '
490
+					. $item->transaction()->pretty_paid()
491
+					. '
492 492
 					</a>
493 493
 				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
494 494
 			}
@@ -521,12 +521,12 @@  discard block
 block discarded – undo
521 521
 				'ee_read_transaction',
522 522
 				'espresso_transactions_view_transaction'
523 523
 			) ? '<a href="'
524
-			    . $view_txn_url
525
-			    . '" title="'
526
-			    . esc_attr__( 'View Transaction', 'event_espresso' )
527
-			    . '"><span class="reg-pad-rght">'
528
-			    . $txn_total
529
-			    . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
524
+				. $view_txn_url
525
+				. '" title="'
526
+				. esc_attr__( 'View Transaction', 'event_espresso' )
527
+				. '"><span class="reg-pad-rght">'
528
+				. $txn_total
529
+				. '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
530 530
 		} else {
531 531
 			return '<span class="reg-pad-rght"></span>';
532 532
 		}
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -42,51 +42,51 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @param \Registrations_Admin_Page $admin_page
44 44
 	 */
45
-	public function __construct( $admin_page ) {
46
-		parent::__construct( $admin_page );
45
+	public function __construct($admin_page) {
46
+		parent::__construct($admin_page);
47 47
 		$this->_status = $this->_admin_page->get_registration_status_array();
48 48
 	}
49 49
 
50 50
 
51 51
 
52 52
 	protected function _setup_data() {
53
-		$this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( $this->_per_page )
54
-			: $this->_admin_page->get_event_attendees( $this->_per_page, false, true );
53
+		$this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page)
54
+			: $this->_admin_page->get_event_attendees($this->_per_page, false, true);
55 55
 		$this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees(
56 56
 			$this->_per_page,
57 57
 			true
58
-		) : $this->_admin_page->get_event_attendees( $this->_per_page, true, true );
58
+		) : $this->_admin_page->get_event_attendees($this->_per_page, true, true);
59 59
 	}
60 60
 
61 61
 
62 62
 
63 63
 	protected function _set_properties() {
64
-		$evt_id = isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : null;
64
+		$evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
65 65
 		$this->_wp_list_args = array(
66
-			'singular' => __( 'registrant', 'event_espresso' ),
67
-			'plural'   => __( 'registrants', 'event_espresso' ),
66
+			'singular' => __('registrant', 'event_espresso'),
67
+			'plural'   => __('registrants', 'event_espresso'),
68 68
 			'ajax'     => true,
69 69
 			'screen'   => $this->_admin_page->get_current_screen()->id,
70 70
 		);
71 71
 		$columns = array();
72 72
 		//$columns['_Reg_Status'] = '';
73
-		if ( ! empty( $evt_id ) ) {
73
+		if ( ! empty($evt_id)) {
74 74
 			$columns['cb'] = '<input type="checkbox" />'; //Render a checkbox instead of text
75 75
 			$this->_has_checkbox_column = true;
76 76
 		}
77 77
 		$this->_columns = array(
78 78
 			'_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
79
-			'ATT_name'            => __( 'Registrant', 'event_espresso' ),
80
-			'ATT_email'           => __( 'Email Address', 'event_espresso' ),
81
-			'Event'               => __( 'Event', 'event_espresso' ),
82
-			'PRC_name'            => __( 'TKT Option', 'event_espresso' ),
83
-			'_REG_final_price'    => __( 'Price', 'event_espresso' ),
84
-			'TXN_paid'            => __( 'Paid', 'event_espresso' ),
85
-			'TXN_total'           => __( 'Total', 'event_espresso' ),
79
+			'ATT_name'            => __('Registrant', 'event_espresso'),
80
+			'ATT_email'           => __('Email Address', 'event_espresso'),
81
+			'Event'               => __('Event', 'event_espresso'),
82
+			'PRC_name'            => __('TKT Option', 'event_espresso'),
83
+			'_REG_final_price'    => __('Price', 'event_espresso'),
84
+			'TXN_paid'            => __('Paid', 'event_espresso'),
85
+			'TXN_total'           => __('Total', 'event_espresso'),
86 86
 		);
87
-		$this->_columns = array_merge( $columns, $this->_columns );
87
+		$this->_columns = array_merge($columns, $this->_columns);
88 88
 		$this->_primary_column = '_REG_att_checked_in';
89
-		if ( ! empty( $evt_id )
89
+		if ( ! empty($evt_id)
90 90
 		     && EE_Registry::instance()->CAP->current_user_can(
91 91
 				'ee_read_registrations',
92 92
 				'espresso_registrations_registrations_reports',
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 					'extra_request' =>
100 100
 						array(
101 101
 							'EVT_ID'     => $evt_id,
102
-							'return_url' => urlencode( "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" ),
102
+							'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
103 103
 						),
104 104
 				),
105 105
 			);
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
         );
129 129
 		$this->_sortable_columns = array(
130 130
 			//true means its already sorted
131
-			'ATT_name' => array( 'ATT_name' => true ),
132
-			'Event'    => array( 'Event.EVT.Name' => false ),
131
+			'ATT_name' => array('ATT_name' => true),
132
+			'Event'    => array('Event.EVT.Name' => false),
133 133
 		);
134 134
 		$this->_hidden_columns = array();
135
-		$this->_evt = EEM_Event::instance()->get_one_by_ID( $evt_id );
135
+		$this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id);
136 136
 		$this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array();
137 137
 	}
138 138
 
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 	 * @param \EE_Registration $item
143 143
 	 * @return string
144 144
 	 */
145
-	protected function _get_row_class( $item ) {
146
-		$class = parent::_get_row_class( $item );
145
+	protected function _get_row_class($item) {
146
+		$class = parent::_get_row_class($item);
147 147
 		//add status class
148
-		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
149
-		if ( $this->_has_checkbox_column ) {
148
+		$class .= ' ee-status-strip reg-status-'.$item->status_ID();
149
+		if ($this->_has_checkbox_column) {
150 150
 			$class .= ' has-checkbox-column';
151 151
 		}
152 152
 		return $class;
@@ -160,61 +160,61 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	protected function _get_table_filters() {
162 162
 		$filters = $where = array();
163
-		$current_EVT_ID = isset( $this->_req_data['event_id'] ) ? (int) $this->_req_data['event_id'] : 0;
164
-		if ( empty( $this->_dtts_for_event ) || count( $this->_dtts_for_event ) === 1 ) {
163
+		$current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0;
164
+		if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
165 165
 			//this means we don't have an event so let's setup a filter dropdown for all the events to select
166 166
 			//note possible capability restrictions
167
-			if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) {
168
-				$where['status**'] = array( '!=', 'private' );
167
+			if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
168
+				$where['status**'] = array('!=', 'private');
169 169
 			}
170
-			if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
170
+			if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
171 171
 				$where['EVT_wp_user'] = get_current_user_id();
172 172
 			}
173 173
 			$events = EEM_Event::instance()->get_all(
174 174
 				array(
175 175
 					$where,
176
-					'order_by' => array( 'Datetime.DTT_EVT_start' => 'DESC' ),
176
+					'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'),
177 177
 				)
178 178
 			);
179 179
 			$evts[] = array(
180 180
 				'id'   => 0,
181
-				'text' => __( 'To toggle Check-in status, select an event', 'event_espresso' ),
181
+				'text' => __('To toggle Check-in status, select an event', 'event_espresso'),
182 182
 			);
183 183
 			$checked = 'checked';
184 184
 			/** @var EE_Event $evt */
185
-			foreach ( $events as $evt ) {
185
+			foreach ($events as $evt) {
186 186
 				//any registrations for this event?
187
-				if ( ! $evt->get_count_of_all_registrations() ) {
187
+				if ( ! $evt->get_count_of_all_registrations()) {
188 188
 					continue;
189 189
 				}
190 190
 				$evts[] = array(
191 191
 					'id'    => $evt->ID(),
192
-					'text'  => $evt->get( 'EVT_name' ),
192
+					'text'  => $evt->get('EVT_name'),
193 193
 					'class' => $evt->is_expired() ? 'ee-expired-event' : '',
194 194
 				);
195
-				if ( $evt->ID() === $current_EVT_ID && $evt->is_expired() ) {
195
+				if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) {
196 196
 					$checked = '';
197 197
 				}
198 198
 			}
199 199
 			$event_filter = '<div class="ee-event-filter">';
200
-			$event_filter .= EEH_Form_Fields::select_input( 'event_id', $evts, $current_EVT_ID );
200
+			$event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID);
201 201
 			$event_filter .= '<span class="ee-event-filter-toggle">';
202
-			$event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> ';
203
-			$event_filter .= __( 'Hide Expired Events', 'event_espresso' );
202
+			$event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" '.$checked.'> ';
203
+			$event_filter .= __('Hide Expired Events', 'event_espresso');
204 204
 			$event_filter .= '</span>';
205 205
 			$event_filter .= '</div>';
206 206
 			$filters[] = $event_filter;
207 207
 		}
208
-		if ( ! empty( $this->_dtts_for_event ) ) {
208
+		if ( ! empty($this->_dtts_for_event)) {
209 209
 			//DTT datetimes filter
210
-			$this->_cur_dtt_id = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0;
211
-			if ( count( $this->_dtts_for_event ) > 1 ) {
212
-				$dtts[0] = __( 'To toggle check-in status, select a datetime.', 'event_espresso' );
213
-				foreach ( $this->_dtts_for_event as $dtt ) {
210
+			$this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
211
+			if (count($this->_dtts_for_event) > 1) {
212
+				$dtts[0] = __('To toggle check-in status, select a datetime.', 'event_espresso');
213
+				foreach ($this->_dtts_for_event as $dtt) {
214 214
                     $datetime_string = $dtt->name();
215
-                    $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : '';
216
-					$datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string;
217
-					$dtts[ $dtt->ID() ] = $datetime_string;
215
+                    $datetime_string = ! empty($datetime_string) ? ' ('.$datetime_string.')' : '';
216
+					$datetime_string = $dtt->start_date_and_time().' - '.$dtt->end_date_and_time().$datetime_string;
217
+					$dtts[$dtt->ID()] = $datetime_string;
218 218
 				}
219 219
 				$input = new EE_Select_Input(
220 220
 					$dtts,
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 					)
226 226
 				);
227 227
 				$filters[] = $input->get_html_for_input();
228
-				$filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
228
+				$filters[] = '<input type="hidden" name="event_id" value="'.$current_EVT_ID.'">';
229 229
 			}
230 230
 		}
231 231
 		return $filters;
@@ -244,22 +244,22 @@  discard block
 block discarded – undo
244 244
 	 * @throws \EE_Error
245 245
 	 */
246 246
 	protected function _get_total_event_attendees() {
247
-		$EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : false;
247
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
248 248
 		$DTT_ID = $this->_cur_dtt_id;
249 249
 		$query_params = array();
250
-		if ( $EVT_ID ) {
250
+		if ($EVT_ID) {
251 251
 			$query_params[0]['EVT_ID'] = $EVT_ID;
252 252
 		}
253 253
 		//if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
254
-		if ( $DTT_ID ) {
254
+		if ($DTT_ID) {
255 255
 			$query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID;
256 256
 		}
257 257
 		$status_ids_array = apply_filters(
258 258
 			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
259
-			array( EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved )
259
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
260 260
 		);
261
-		$query_params[0]['STS_ID'] = array( 'IN', $status_ids_array );
262
-		return EEM_Registration::instance()->count( $query_params );
261
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
262
+		return EEM_Registration::instance()->count($query_params);
263 263
 	}
264 264
 
265 265
 
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	 * @param \EE_Registration $item
269 269
 	 * @return string
270 270
 	 */
271
-	public function column__Reg_Status( EE_Registration $item ) {
272
-		return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>';
271
+	public function column__Reg_Status(EE_Registration $item) {
272
+		return '<span class="ee-status-strip ee-status-strip-td reg-status-'.$item->status_ID().'"></span>';
273 273
 	}
274 274
 
275 275
 
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 	 * @return string
280 280
 	 * @throws \EE_Error
281 281
 	 */
282
-	public function column_cb( $item ) {
283
-		return sprintf( '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID() );
282
+	public function column_cb($item) {
283
+		return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
284 284
 	}
285 285
 
286 286
 
@@ -292,20 +292,20 @@  discard block
 block discarded – undo
292 292
 	 * @return string
293 293
 	 * @throws \EE_Error
294 294
 	 */
295
-	public function column__REG_att_checked_in( EE_Registration $item ) {
295
+	public function column__REG_att_checked_in(EE_Registration $item) {
296 296
 		$attendee = $item->attendee();
297 297
 		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
298 298
 
299
-		if ( $this->_cur_dtt_id === 0 && count( $this->_dtts_for_event ) === 1 ) {
299
+		if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) {
300 300
 			$latest_related_datetime = $item->get_latest_related_datetime();
301
-			if ( $latest_related_datetime instanceof EE_Datetime ) {
301
+			if ($latest_related_datetime instanceof EE_Datetime) {
302 302
 				$this->_cur_dtt_id = $latest_related_datetime->ID();
303 303
 			}
304 304
 		}
305 305
 
306
-		$checkinstatus = $item->check_in_status_for_datetime( $this->_cur_dtt_id );
307
-		$nonce = wp_create_nonce( 'checkin_nonce' );
308
-		$toggle_active = ! empty ( $this->_cur_dtt_id )
306
+		$checkinstatus = $item->check_in_status_for_datetime($this->_cur_dtt_id);
307
+		$nonce = wp_create_nonce('checkin_nonce');
308
+		$toggle_active = ! empty ($this->_cur_dtt_id)
309 309
 		                 && EE_Registry::instance()->CAP->current_user_can(
310 310
 			'ee_edit_checkin',
311 311
 			'espresso_registrations_toggle_checkin_status',
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
 		)
314 314
 			? ' clickable trigger-checkin'
315 315
 			: '';
316
-		$mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
317
-		return '<span class="checkin-icons checkedin-status-' . $checkinstatus . $toggle_active . '"'
318
-		       . ' data-_regid="' . $item->ID() . '"'
319
-		       . ' data-dttid="' . $this->_cur_dtt_id . '"'
320
-		       . ' data-nonce="' . $nonce . '">'
316
+		$mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>';
317
+		return '<span class="checkin-icons checkedin-status-'.$checkinstatus.$toggle_active.'"'
318
+		       . ' data-_regid="'.$item->ID().'"'
319
+		       . ' data-dttid="'.$this->_cur_dtt_id.'"'
320
+		       . ' data-nonce="'.$nonce.'">'
321 321
 		       . '</span>'
322 322
 		       . $mobile_view_content;
323 323
 	}
@@ -329,21 +329,21 @@  discard block
 block discarded – undo
329 329
 	 * @return mixed|string|void
330 330
 	 * @throws \EE_Error
331 331
 	 */
332
-	public function column_ATT_name( EE_Registration $item ) {
332
+	public function column_ATT_name(EE_Registration $item) {
333 333
 		$attendee = $item->attendee();
334
-		if ( ! $attendee instanceof EE_Attendee ) {
335
-			return __( 'No contact record for this registration.', 'event_espresso' );
334
+		if ( ! $attendee instanceof EE_Attendee) {
335
+			return __('No contact record for this registration.', 'event_espresso');
336 336
 		}
337 337
 		// edit attendee link
338 338
 		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
339
-			array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ),
339
+			array('action' => 'view_registration', '_REG_ID' => $item->ID()),
340 340
 			REG_ADMIN_URL
341 341
 		);
342 342
 		$name_link = EE_Registry::instance()->CAP->current_user_can(
343 343
 			'ee_edit_contacts',
344 344
 			'espresso_registrations_edit_attendee'
345 345
 		)
346
-			? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__( 'Edit Contact', 'event_espresso' ) . '">'
346
+			? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Contact', 'event_espresso').'">'
347 347
 			    . $item->attendee()->full_name()
348 348
 			    . '</a>'
349 349
 			: $item->attendee()->full_name();
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
 			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	'
352 352
 			: '';
353 353
 		//add group details
354
-		$name_link .= '&nbsp;' . sprintf( __( '(%s of %s)', 'event_espresso' ), $item->count(), $item->group_size() );
354
+		$name_link .= '&nbsp;'.sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
355 355
 		//add regcode
356 356
 		$link = EE_Admin_Page::add_query_args_and_nonce(
357
-			array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ),
357
+			array('action' => 'view_registration', '_REG_ID' => $item->ID()),
358 358
 			REG_ADMIN_URL
359 359
 		);
360 360
 		$name_link .= '<br>';
@@ -363,37 +363,37 @@  discard block
 block discarded – undo
363 363
 			'view_registration',
364 364
 			$item->ID()
365 365
 		)
366
-			? '<a href="' . $link . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">'
366
+			? '<a href="'.$link.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
367 367
 			  . $item->reg_code()
368 368
 			  . '</a>'
369 369
 			: $item->reg_code();
370 370
 		//status
371 371
 		$name_link .= '<br><span class="ee-status-text-small">';
372
-		$name_link .= EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' );
372
+		$name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence');
373 373
 		$name_link .= '</span>';
374 374
 		$actions = array();
375 375
 		$DTT_ID = $this->_cur_dtt_id;
376
-		$latest_related_datetime = empty( $DTT_ID ) && ! empty( $this->_req_data['event_id'] ) && $item instanceof EE_Registration
376
+		$latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration
377 377
 			? $item->get_latest_related_datetime()
378 378
 			: null;
379 379
 		$DTT_ID = $latest_related_datetime instanceof EE_Datetime
380 380
 			? $latest_related_datetime->ID()
381 381
 			: $DTT_ID;
382
-		if ( ! empty( $DTT_ID )
382
+		if ( ! empty($DTT_ID)
383 383
 		     && EE_Registry::instance()->CAP->current_user_can(
384 384
 				'ee_read_checkins',
385 385
 				'espresso_registrations_registration_checkins'
386 386
 			)
387 387
 		) {
388 388
 			$checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
389
-				array( 'action' => 'registration_checkins', '_REGID' => $item->ID(), 'DTT_ID' => $DTT_ID )
389
+				array('action' => 'registration_checkins', '_REGID' => $item->ID(), 'DTT_ID' => $DTT_ID)
390 390
 			);
391
-			$actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' . esc_attr__(
391
+			$actions['checkin'] = '<a href="'.$checkin_list_url.'" title="'.esc_attr__(
392 392
 					'View all the check-ins/checkouts for this registrant',
393 393
 					'event_espresso'
394
-				) . '">' . __( 'View', 'event_espresso' ) . '</a>';
394
+				).'">'.__('View', 'event_espresso').'</a>';
395 395
 		}
396
-		return ! empty( $DTT_ID ) ? sprintf( '%1$s %2$s', $name_link, $this->row_actions( $actions ) ) : $name_link;
396
+		return ! empty($DTT_ID) ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions)) : $name_link;
397 397
 	}
398 398
 
399 399
 
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 	 * @param \EE_Registration $item
403 403
 	 * @return string
404 404
 	 */
405
-	public function column_ATT_email( EE_Registration $item ) {
405
+	public function column_ATT_email(EE_Registration $item) {
406 406
 		$attendee = $item->attendee();
407 407
 		return $attendee instanceof EE_Attendee ? $attendee->email() : '';
408 408
 	}
@@ -414,22 +414,22 @@  discard block
 block discarded – undo
414 414
 	 * @return bool|string
415 415
 	 * @throws \EE_Error
416 416
 	 */
417
-	public function column_Event( EE_Registration $item ) {
417
+	public function column_Event(EE_Registration $item) {
418 418
 		try {
419 419
 			$event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event();
420 420
 			$chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
421
-				array( 'action' => 'event_registrations', 'event_id' => $event->ID() ),
421
+				array('action' => 'event_registrations', 'event_id' => $event->ID()),
422 422
 				REG_ADMIN_URL
423 423
 			);
424 424
 			$event_label = EE_Registry::instance()->CAP->current_user_can(
425 425
 				'ee_read_checkins',
426 426
 				'espresso_registrations_registration_checkins'
427
-			) ? '<a href="' . $chkin_lnk_url . '" title="' . esc_attr__(
427
+			) ? '<a href="'.$chkin_lnk_url.'" title="'.esc_attr__(
428 428
 					'View Checkins for this Event',
429 429
 					'event_espresso'
430
-				) . '">' . $event->name() . '</a>' : $event->name();
431
-		} catch ( \EventEspresso\core\exceptions\EntityNotFoundException $e ) {
432
-			$event_label = esc_html__( 'Unknown', 'event_espresso' );
430
+				).'">'.$event->name().'</a>' : $event->name();
431
+		} catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
432
+			$event_label = esc_html__('Unknown', 'event_espresso');
433 433
 		}
434 434
 		return $event_label;
435 435
 	}
@@ -440,8 +440,8 @@  discard block
 block discarded – undo
440 440
 	 * @param \EE_Registration $item
441 441
 	 * @return mixed|string|void
442 442
 	 */
443
-	public function column_PRC_name( EE_Registration $item ) {
444
-		return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __( "Unknown", "event_espresso" );
443
+	public function column_PRC_name(EE_Registration $item) {
444
+		return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __("Unknown", "event_espresso");
445 445
 	}
446 446
 
447 447
 
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
 	 * @param \EE_Registration $item
453 453
 	 * @return string
454 454
 	 */
455
-	public function column__REG_final_price( EE_Registration $item ) {
456
-		return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
455
+	public function column__REG_final_price(EE_Registration $item) {
456
+		return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>';
457 457
 	}
458 458
 
459 459
 
@@ -465,13 +465,13 @@  discard block
 block discarded – undo
465 465
 	 * @return string
466 466
 	 * @throws \EE_Error
467 467
 	 */
468
-	public function column_TXN_paid( EE_Registration $item ) {
469
-		if ( $item->count() === 1 ) {
470
-			if ( $item->transaction()->paid() >= $item->transaction()->total() ) {
468
+	public function column_TXN_paid(EE_Registration $item) {
469
+		if ($item->count() === 1) {
470
+			if ($item->transaction()->paid() >= $item->transaction()->total()) {
471 471
 				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
472 472
 			} else {
473 473
 				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
474
-					array( 'action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID() ),
474
+					array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()),
475 475
 					TXN_ADMIN_URL
476 476
 				);
477 477
 				return EE_Registry::instance()->CAP->current_user_can(
@@ -484,13 +484,13 @@  discard block
 block discarded – undo
484 484
 				    . '" href="'
485 485
 				    . $view_txn_lnk_url
486 486
 				    . '"  title="'
487
-				    . esc_attr__( 'View Transaction', 'event_espresso' )
487
+				    . esc_attr__('View Transaction', 'event_espresso')
488 488
 				    . '">
489 489
 						'
490 490
 				    . $item->transaction()->pretty_paid()
491 491
 				    . '
492 492
 					</a>
493
-				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
493
+				<span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
494 494
 			}
495 495
 		} else {
496 496
 			return '<span class="reg-pad-rght"></span>';
@@ -506,13 +506,13 @@  discard block
 block discarded – undo
506 506
 	 * @return string
507 507
 	 * @throws \EE_Error
508 508
 	 */
509
-	public function column_TXN_total( EE_Registration $item ) {
509
+	public function column_TXN_total(EE_Registration $item) {
510 510
 		$txn = $item->transaction();
511
-		$view_txn_url = add_query_arg( array( 'action' => 'view_transaction', 'TXN_ID' => $txn->ID() ), TXN_ADMIN_URL );
512
-		if ( $item->get( 'REG_count' ) === 1 ) {
511
+		$view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL);
512
+		if ($item->get('REG_count') === 1) {
513 513
 			$line_total_obj = $txn->total_line_item();
514 514
 			$txn_total = $line_total_obj instanceof EE_Line_Item
515
-				? $line_total_obj->get_pretty( 'LIN_total' )
515
+				? $line_total_obj->get_pretty('LIN_total')
516 516
 				: __(
517 517
 					'View Transaction',
518 518
 					'event_espresso'
@@ -523,10 +523,10 @@  discard block
 block discarded – undo
523 523
 			) ? '<a href="'
524 524
 			    . $view_txn_url
525 525
 			    . '" title="'
526
-			    . esc_attr__( 'View Transaction', 'event_espresso' )
526
+			    . esc_attr__('View Transaction', 'event_espresso')
527 527
 			    . '"><span class="reg-pad-rght">'
528 528
 			    . $txn_total
529
-			    . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
529
+			    . '</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>';
530 530
 		} else {
531 531
 			return '<span class="reg-pad-rght"></span>';
532 532
 		}
Please login to merge, or discard this patch.
core/helpers/EEH_Activation.helper.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
      *
614 614
      * @since  4.6.0
615 615
      * @global WPDB $wpdb
616
-     * @return mixed null|int WP_user ID or NULL
616
+     * @return integer|null null|int WP_user ID or NULL
617 617
      */
618 618
     public static function get_default_creator_id()
619 619
     {
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
      * @static
775 775
      * @deprecated instead use TableManager::dropTable()
776 776
      * @param string $table_name
777
-     * @return bool | int
777
+     * @return integer | int
778 778
      */
779 779
     public static function delete_unused_db_table($table_name)
780 780
     {
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
      * @deprecated instead use TableManager::dropIndex()
792 792
      * @param string $table_name
793 793
      * @param string $index_name
794
-     * @return bool | int
794
+     * @return integer | int
795 795
      */
796 796
     public static function drop_index($table_name, $index_name)
797 797
     {
Please login to merge, or discard this patch.
Indentation   +1711 added lines, -1711 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -14,243 +14,243 @@  discard block
 block discarded – undo
14 14
 class EEH_Activation
15 15
 {
16 16
 
17
-    /**
18
-     * constant used to indicate a cron task is no longer in use
19
-     */
20
-    const cron_task_no_longer_in_use = 'no_longer_in_use';
21
-
22
-    /**
23
-     * option name that will indicate whether or not we still
24
-     * need to create EE's folders in the uploads directory
25
-     * (because if EE was installed without file system access,
26
-     * we need to request credentials before we can create them)
27
-     */
28
-    const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete';
29
-
30
-    /**
31
-     * WP_User->ID
32
-     *
33
-     * @var int
34
-     */
35
-    private static $_default_creator_id;
36
-
37
-    /**
38
-     * indicates whether or not we've already verified core's default data during this request,
39
-     * because after migrations are done, any addons activated while in maintenance mode
40
-     * will want to setup their own default data, and they might hook into core's default data
41
-     * and trigger core to setup its default data. In which case they might all ask for core to init its default data.
42
-     * This prevents doing that for EVERY single addon.
43
-     *
44
-     * @var boolean
45
-     */
46
-    protected static $_initialized_db_content_already_in_this_request = false;
47
-
48
-    /**
49
-     * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
50
-     */
51
-    private static $table_analysis;
52
-
53
-    /**
54
-     * @var \EventEspresso\core\services\database\TableManager $table_manager
55
-     */
56
-    private static $table_manager;
57
-
58
-
59
-    /**
60
-     * @return \EventEspresso\core\services\database\TableAnalysis
61
-     */
62
-    public static function getTableAnalysis()
63
-    {
64
-        if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
65
-            self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
66
-        }
67
-        return self::$table_analysis;
68
-    }
69
-
70
-
71
-    /**
72
-     * @return \EventEspresso\core\services\database\TableManager
73
-     */
74
-    public static function getTableManager()
75
-    {
76
-        if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
77
-            self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true);
78
-        }
79
-        return self::$table_manager;
80
-    }
81
-
82
-
83
-    /**
84
-     *    _ensure_table_name_has_prefix
85
-     *
86
-     * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix()
87
-     * @access     public
88
-     * @static
89
-     * @param $table_name
90
-     * @return string
91
-     */
92
-    public static function ensure_table_name_has_prefix($table_name)
93
-    {
94
-        return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name);
95
-    }
96
-
97
-
98
-    /**
99
-     *    system_initialization
100
-     *    ensures the EE configuration settings are loaded with at least default options set
101
-     *    and that all critical EE pages have been generated with the appropriate shortcodes in place
102
-     *
103
-     * @access public
104
-     * @static
105
-     * @return void
106
-     */
107
-    public static function system_initialization()
108
-    {
109
-        EEH_Activation::reset_and_update_config();
110
-        //which is fired BEFORE activation of plugin anyways
111
-        EEH_Activation::verify_default_pages_exist();
112
-    }
113
-
114
-
115
-    /**
116
-     * Sets the database schema and creates folders. This should
117
-     * be called on plugin activation and reactivation
118
-     *
119
-     * @return boolean success, whether the database and folders are setup properly
120
-     * @throws \EE_Error
121
-     */
122
-    public static function initialize_db_and_folders()
123
-    {
124
-        $good_filesystem = EEH_Activation::create_upload_directories();
125
-        $good_db         = EEH_Activation::create_database_tables();
126
-        return $good_filesystem && $good_db;
127
-    }
128
-
129
-
130
-    /**
131
-     * assuming we have an up-to-date database schema, this will populate it
132
-     * with default and initial data. This should be called
133
-     * upon activation of a new plugin, reactivation, and at the end
134
-     * of running migration scripts
135
-     *
136
-     * @throws \EE_Error
137
-     */
138
-    public static function initialize_db_content()
139
-    {
140
-        //let's avoid doing all this logic repeatedly, especially when addons are requesting it
141
-        if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
142
-            return;
143
-        }
144
-        EEH_Activation::$_initialized_db_content_already_in_this_request = true;
145
-
146
-        EEH_Activation::initialize_system_questions();
147
-        EEH_Activation::insert_default_status_codes();
148
-        EEH_Activation::generate_default_message_templates();
149
-        EEH_Activation::create_no_ticket_prices_array();
150
-        EE_Registry::instance()->CAP->init_caps();
151
-
152
-        EEH_Activation::validate_messages_system();
153
-        EEH_Activation::insert_default_payment_methods();
154
-        //in case we've
155
-        EEH_Activation::remove_cron_tasks();
156
-        EEH_Activation::create_cron_tasks();
157
-        // remove all TXN locks since that is being done via extra meta now
158
-        delete_option('ee_locked_transactions');
159
-        //also, check for CAF default db content
160
-        do_action('AHEE__EEH_Activation__initialize_db_content');
161
-        //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
162
-        //which users really won't care about on initial activation
163
-        EE_Error::overwrite_success();
164
-    }
165
-
166
-
167
-    /**
168
-     * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"),
169
-     * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event
170
-     * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use
171
-     * (null)
172
-     *
173
-     * @param string $which_to_include can be 'current' (ones that are currently in use),
174
-     *                                 'old' (only returns ones that should no longer be used),or 'all',
175
-     * @return array
176
-     * @throws \EE_Error
177
-     */
178
-    public static function get_cron_tasks($which_to_include)
179
-    {
180
-        $cron_tasks = apply_filters(
181
-            'FHEE__EEH_Activation__get_cron_tasks',
182
-            array(
183
-                'AHEE__EE_Cron_Tasks__clean_up_junk_transactions'      => 'hourly',
17
+	/**
18
+	 * constant used to indicate a cron task is no longer in use
19
+	 */
20
+	const cron_task_no_longer_in_use = 'no_longer_in_use';
21
+
22
+	/**
23
+	 * option name that will indicate whether or not we still
24
+	 * need to create EE's folders in the uploads directory
25
+	 * (because if EE was installed without file system access,
26
+	 * we need to request credentials before we can create them)
27
+	 */
28
+	const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete';
29
+
30
+	/**
31
+	 * WP_User->ID
32
+	 *
33
+	 * @var int
34
+	 */
35
+	private static $_default_creator_id;
36
+
37
+	/**
38
+	 * indicates whether or not we've already verified core's default data during this request,
39
+	 * because after migrations are done, any addons activated while in maintenance mode
40
+	 * will want to setup their own default data, and they might hook into core's default data
41
+	 * and trigger core to setup its default data. In which case they might all ask for core to init its default data.
42
+	 * This prevents doing that for EVERY single addon.
43
+	 *
44
+	 * @var boolean
45
+	 */
46
+	protected static $_initialized_db_content_already_in_this_request = false;
47
+
48
+	/**
49
+	 * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
50
+	 */
51
+	private static $table_analysis;
52
+
53
+	/**
54
+	 * @var \EventEspresso\core\services\database\TableManager $table_manager
55
+	 */
56
+	private static $table_manager;
57
+
58
+
59
+	/**
60
+	 * @return \EventEspresso\core\services\database\TableAnalysis
61
+	 */
62
+	public static function getTableAnalysis()
63
+	{
64
+		if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
65
+			self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
66
+		}
67
+		return self::$table_analysis;
68
+	}
69
+
70
+
71
+	/**
72
+	 * @return \EventEspresso\core\services\database\TableManager
73
+	 */
74
+	public static function getTableManager()
75
+	{
76
+		if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
77
+			self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true);
78
+		}
79
+		return self::$table_manager;
80
+	}
81
+
82
+
83
+	/**
84
+	 *    _ensure_table_name_has_prefix
85
+	 *
86
+	 * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix()
87
+	 * @access     public
88
+	 * @static
89
+	 * @param $table_name
90
+	 * @return string
91
+	 */
92
+	public static function ensure_table_name_has_prefix($table_name)
93
+	{
94
+		return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name);
95
+	}
96
+
97
+
98
+	/**
99
+	 *    system_initialization
100
+	 *    ensures the EE configuration settings are loaded with at least default options set
101
+	 *    and that all critical EE pages have been generated with the appropriate shortcodes in place
102
+	 *
103
+	 * @access public
104
+	 * @static
105
+	 * @return void
106
+	 */
107
+	public static function system_initialization()
108
+	{
109
+		EEH_Activation::reset_and_update_config();
110
+		//which is fired BEFORE activation of plugin anyways
111
+		EEH_Activation::verify_default_pages_exist();
112
+	}
113
+
114
+
115
+	/**
116
+	 * Sets the database schema and creates folders. This should
117
+	 * be called on plugin activation and reactivation
118
+	 *
119
+	 * @return boolean success, whether the database and folders are setup properly
120
+	 * @throws \EE_Error
121
+	 */
122
+	public static function initialize_db_and_folders()
123
+	{
124
+		$good_filesystem = EEH_Activation::create_upload_directories();
125
+		$good_db         = EEH_Activation::create_database_tables();
126
+		return $good_filesystem && $good_db;
127
+	}
128
+
129
+
130
+	/**
131
+	 * assuming we have an up-to-date database schema, this will populate it
132
+	 * with default and initial data. This should be called
133
+	 * upon activation of a new plugin, reactivation, and at the end
134
+	 * of running migration scripts
135
+	 *
136
+	 * @throws \EE_Error
137
+	 */
138
+	public static function initialize_db_content()
139
+	{
140
+		//let's avoid doing all this logic repeatedly, especially when addons are requesting it
141
+		if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
142
+			return;
143
+		}
144
+		EEH_Activation::$_initialized_db_content_already_in_this_request = true;
145
+
146
+		EEH_Activation::initialize_system_questions();
147
+		EEH_Activation::insert_default_status_codes();
148
+		EEH_Activation::generate_default_message_templates();
149
+		EEH_Activation::create_no_ticket_prices_array();
150
+		EE_Registry::instance()->CAP->init_caps();
151
+
152
+		EEH_Activation::validate_messages_system();
153
+		EEH_Activation::insert_default_payment_methods();
154
+		//in case we've
155
+		EEH_Activation::remove_cron_tasks();
156
+		EEH_Activation::create_cron_tasks();
157
+		// remove all TXN locks since that is being done via extra meta now
158
+		delete_option('ee_locked_transactions');
159
+		//also, check for CAF default db content
160
+		do_action('AHEE__EEH_Activation__initialize_db_content');
161
+		//also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
162
+		//which users really won't care about on initial activation
163
+		EE_Error::overwrite_success();
164
+	}
165
+
166
+
167
+	/**
168
+	 * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"),
169
+	 * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event
170
+	 * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use
171
+	 * (null)
172
+	 *
173
+	 * @param string $which_to_include can be 'current' (ones that are currently in use),
174
+	 *                                 'old' (only returns ones that should no longer be used),or 'all',
175
+	 * @return array
176
+	 * @throws \EE_Error
177
+	 */
178
+	public static function get_cron_tasks($which_to_include)
179
+	{
180
+		$cron_tasks = apply_filters(
181
+			'FHEE__EEH_Activation__get_cron_tasks',
182
+			array(
183
+				'AHEE__EE_Cron_Tasks__clean_up_junk_transactions'      => 'hourly',
184 184
 //				'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions' => EEH_Activation::cron_task_no_longer_in_use, actually this is still in use
185
-                'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use,
186
-                //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates
187
-            )
188
-        );
189
-        if ($which_to_include === 'old') {
190
-            $cron_tasks = array_filter(
191
-                $cron_tasks,
192
-                function ($value) {
193
-                    return $value === EEH_Activation::cron_task_no_longer_in_use;
194
-                }
195
-            );
196
-        } elseif ($which_to_include === 'current') {
197
-            $cron_tasks = array_filter($cron_tasks);
198
-        } elseif (WP_DEBUG && $which_to_include !== 'all') {
199
-            throw new EE_Error(
200
-                sprintf(
201
-                    __(
202
-                        'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".',
203
-                        'event_espresso'
204
-                    ),
205
-                    $which_to_include
206
-                )
207
-            );
208
-        }
209
-        return $cron_tasks;
210
-    }
211
-
212
-
213
-    /**
214
-     * Ensure cron tasks are setup (the removal of crons should be done by remove_crons())
215
-     *
216
-     * @throws \EE_Error
217
-     */
218
-    public static function create_cron_tasks()
219
-    {
220
-
221
-        foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
222
-            if (! wp_next_scheduled($hook_name)) {
223
-                /**
224
-                 * This allows client code to define the initial start timestamp for this schedule.
225
-                 */
226
-                if (is_array($frequency)
227
-                    && count($frequency) === 2
228
-                    && isset($frequency[0], $frequency[1])
229
-                ) {
230
-                    $start_timestamp = $frequency[0];
231
-                    $frequency = $frequency[1];
232
-                } else {
233
-                    $start_timestamp = time();
234
-                }
235
-                wp_schedule_event($start_timestamp, $frequency, $hook_name);
236
-            }
237
-        }
238
-
239
-    }
240
-
241
-
242
-    /**
243
-     * Remove the currently-existing and now-removed cron tasks.
244
-     *
245
-     * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
246
-     * @throws \EE_Error
247
-     */
248
-    public static function remove_cron_tasks($remove_all = true)
249
-    {
250
-        $cron_tasks_to_remove = $remove_all ? 'all' : 'old';
251
-        $crons                = _get_cron_array();
252
-        $crons                = is_array($crons) ? $crons : array();
253
-        /* reminder of what $crons look like:
185
+				'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use,
186
+				//there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates
187
+			)
188
+		);
189
+		if ($which_to_include === 'old') {
190
+			$cron_tasks = array_filter(
191
+				$cron_tasks,
192
+				function ($value) {
193
+					return $value === EEH_Activation::cron_task_no_longer_in_use;
194
+				}
195
+			);
196
+		} elseif ($which_to_include === 'current') {
197
+			$cron_tasks = array_filter($cron_tasks);
198
+		} elseif (WP_DEBUG && $which_to_include !== 'all') {
199
+			throw new EE_Error(
200
+				sprintf(
201
+					__(
202
+						'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".',
203
+						'event_espresso'
204
+					),
205
+					$which_to_include
206
+				)
207
+			);
208
+		}
209
+		return $cron_tasks;
210
+	}
211
+
212
+
213
+	/**
214
+	 * Ensure cron tasks are setup (the removal of crons should be done by remove_crons())
215
+	 *
216
+	 * @throws \EE_Error
217
+	 */
218
+	public static function create_cron_tasks()
219
+	{
220
+
221
+		foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
222
+			if (! wp_next_scheduled($hook_name)) {
223
+				/**
224
+				 * This allows client code to define the initial start timestamp for this schedule.
225
+				 */
226
+				if (is_array($frequency)
227
+					&& count($frequency) === 2
228
+					&& isset($frequency[0], $frequency[1])
229
+				) {
230
+					$start_timestamp = $frequency[0];
231
+					$frequency = $frequency[1];
232
+				} else {
233
+					$start_timestamp = time();
234
+				}
235
+				wp_schedule_event($start_timestamp, $frequency, $hook_name);
236
+			}
237
+		}
238
+
239
+	}
240
+
241
+
242
+	/**
243
+	 * Remove the currently-existing and now-removed cron tasks.
244
+	 *
245
+	 * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
246
+	 * @throws \EE_Error
247
+	 */
248
+	public static function remove_cron_tasks($remove_all = true)
249
+	{
250
+		$cron_tasks_to_remove = $remove_all ? 'all' : 'old';
251
+		$crons                = _get_cron_array();
252
+		$crons                = is_array($crons) ? $crons : array();
253
+		/* reminder of what $crons look like:
254 254
          * Top-level keys are timestamps, and their values are arrays.
255 255
          * The 2nd level arrays have keys with each of the cron task hook names to run at that time
256 256
          * and their values are arrays.
@@ -267,971 +267,971 @@  discard block
 block discarded – undo
267 267
          *					...
268 268
          *      ...
269 269
          */
270
-        $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
271
-        foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
272
-            if (is_array($hooks_to_fire_at_time)) {
273
-                foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
274
-                    if (isset($ee_cron_tasks_to_remove[$hook_name])
275
-                        && is_array($ee_cron_tasks_to_remove[$hook_name])
276
-                    ) {
277
-                        unset($crons[$timestamp][$hook_name]);
278
-                    }
279
-                }
280
-                //also take care of any empty cron timestamps.
281
-                if (empty($hooks_to_fire_at_time)) {
282
-                    unset($crons[$timestamp]);
283
-                }
284
-            }
285
-        }
286
-        _set_cron_array($crons);
287
-    }
288
-
289
-
290
-    /**
291
-     *    CPT_initialization
292
-     *    registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist
293
-     *
294
-     * @access public
295
-     * @static
296
-     * @return void
297
-     */
298
-    public static function CPT_initialization()
299
-    {
300
-        // register Custom Post Types
301
-        EE_Registry::instance()->load_core('Register_CPTs');
302
-        flush_rewrite_rules();
303
-    }
304
-
305
-
306
-
307
-    /**
308
-     *    reset_and_update_config
309
-     * The following code was moved over from EE_Config so that it will no longer run on every request.
310
-     * If there is old calendar config data saved, then it will get converted on activation.
311
-     * This was basically a DMS before we had DMS's, and will get removed after a few more versions.
312
-     *
313
-     * @access public
314
-     * @static
315
-     * @return void
316
-     */
317
-    public static function reset_and_update_config()
318
-    {
319
-        do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
320
-        add_filter(
321
-            'FHEE__EE_Config___load_core_config__config_settings',
322
-            array('EEH_Activation', 'migrate_old_config_data'),
323
-            10,
324
-            3
325
-        );
326
-        //EE_Config::reset();
327
-        if (! EE_Config::logging_enabled()) {
328
-            delete_option(EE_Config::LOG_NAME);
329
-        }
330
-    }
331
-
332
-
333
-    /**
334
-     *    load_calendar_config
335
-     *
336
-     * @access    public
337
-     * @return    void
338
-     */
339
-    public static function load_calendar_config()
340
-    {
341
-        // grab array of all plugin folders and loop thru it
342
-        $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
343
-        if (empty($plugins)) {
344
-            return;
345
-        }
346
-        foreach ($plugins as $plugin_path) {
347
-            // grab plugin folder name from path
348
-            $plugin = basename($plugin_path);
349
-            // drill down to Espresso plugins
350
-            // then to calendar related plugins
351
-            if (
352
-                strpos($plugin, 'espresso') !== false
353
-                || strpos($plugin, 'Espresso') !== false
354
-                || strpos($plugin, 'ee4') !== false
355
-                || strpos($plugin, 'EE4') !== false
356
-                || strpos($plugin, 'calendar') !== false
357
-            ) {
358
-                // this is what we are looking for
359
-                $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
360
-                // does it exist in this folder ?
361
-                if (is_readable($calendar_config)) {
362
-                    // YEAH! let's load it
363
-                    require_once($calendar_config);
364
-                }
365
-            }
366
-        }
367
-    }
368
-
369
-
370
-
371
-    /**
372
-     *    _migrate_old_config_data
373
-     *
374
-     * @access    public
375
-     * @param array|stdClass $settings
376
-     * @param string         $config
377
-     * @param \EE_Config     $EE_Config
378
-     * @return \stdClass
379
-     */
380
-    public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config)
381
-    {
382
-        $convert_from_array = array('addons');
383
-        // in case old settings were saved as an array
384
-        if (is_array($settings) && in_array($config, $convert_from_array)) {
385
-            // convert existing settings to an object
386
-            $config_array = $settings;
387
-            $settings = new stdClass();
388
-            foreach ($config_array as $key => $value) {
389
-                if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
390
-                    $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
391
-                } else {
392
-                    $settings->{$key} = $value;
393
-                }
394
-            }
395
-            add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
396
-        }
397
-        return $settings;
398
-    }
399
-
400
-
401
-    /**
402
-     * deactivate_event_espresso
403
-     *
404
-     * @access public
405
-     * @static
406
-     * @return void
407
-     */
408
-    public static function deactivate_event_espresso()
409
-    {
410
-        // check permissions
411
-        if (current_user_can('activate_plugins')) {
412
-            deactivate_plugins(EE_PLUGIN_BASENAME, true);
413
-        }
414
-    }
415
-
416
-
417
-
418
-
419
-
420
-    /**
421
-     * verify_default_pages_exist
422
-     *
423
-     * @access public
424
-     * @static
425
-     * @return void
426
-     */
427
-    public static function verify_default_pages_exist()
428
-    {
429
-        $critical_page_problem = false;
430
-        $critical_pages = array(
431
-            array(
432
-                'id'   => 'reg_page_id',
433
-                'name' => __('Registration Checkout', 'event_espresso'),
434
-                'post' => null,
435
-                'code' => 'ESPRESSO_CHECKOUT',
436
-            ),
437
-            array(
438
-                'id'   => 'txn_page_id',
439
-                'name' => __('Transactions', 'event_espresso'),
440
-                'post' => null,
441
-                'code' => 'ESPRESSO_TXN_PAGE',
442
-            ),
443
-            array(
444
-                'id'   => 'thank_you_page_id',
445
-                'name' => __('Thank You', 'event_espresso'),
446
-                'post' => null,
447
-                'code' => 'ESPRESSO_THANK_YOU',
448
-            ),
449
-            array(
450
-                'id'   => 'cancel_page_id',
451
-                'name' => __('Registration Cancelled', 'event_espresso'),
452
-                'post' => null,
453
-                'code' => 'ESPRESSO_CANCELLED',
454
-            ),
455
-        );
456
-        $EE_Core_Config = EE_Registry::instance()->CFG->core;
457
-        foreach ($critical_pages as $critical_page) {
458
-            // is critical page ID set in config ?
459
-            if ($EE_Core_Config->{$critical_page['id']} !== false) {
460
-                // attempt to find post by ID
461
-                $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']});
462
-            }
463
-            // no dice?
464
-            if ($critical_page['post'] === null) {
465
-                // attempt to find post by title
466
-                $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
467
-                // still nothing?
468
-                if ($critical_page['post'] === null) {
469
-                    $critical_page = EEH_Activation::create_critical_page($critical_page);
470
-                    // REALLY? Still nothing ??!?!?
471
-                    if ($critical_page['post'] === null) {
472
-                        $msg = __(
473
-                            'The Event Espresso critical page configuration settings could not be updated.',
474
-                            'event_espresso'
475
-                        );
476
-                        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
477
-                        break;
478
-                    }
479
-                }
480
-            }
481
-            // track post_shortcodes
482
-            if ($critical_page['post']) {
483
-                EEH_Activation::_track_critical_page_post_shortcodes($critical_page);
484
-            }
485
-            // check that Post ID matches critical page ID in config
486
-            if (
487
-                isset($critical_page['post']->ID)
488
-                && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
489
-            ) {
490
-                //update Config with post ID
491
-                $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
492
-                if (! EE_Config::instance()->update_espresso_config(false, false)) {
493
-                    $msg = __(
494
-                        'The Event Espresso critical page configuration settings could not be updated.',
495
-                        'event_espresso'
496
-                    );
497
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
498
-                }
499
-            }
500
-            $critical_page_problem =
501
-                ! isset($critical_page['post']->post_status)
502
-                || $critical_page['post']->post_status !== 'publish'
503
-                || strpos($critical_page['post']->post_content, $critical_page['code']) === false
504
-                    ? true
505
-                    : $critical_page_problem;
506
-        }
507
-        if ($critical_page_problem) {
508
-            $msg = sprintf(
509
-                __(
510
-                    'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.',
511
-                    'event_espresso'
512
-                ),
513
-                '<a href="'
514
-                . admin_url('admin.php?page=espresso_general_settings&action=critical_pages')
515
-                . '">'
516
-                . __('Event Espresso Critical Pages Settings', 'event_espresso')
517
-                . '</a>'
518
-            );
519
-            EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
520
-        }
521
-        if (EE_Error::has_notices()) {
522
-            EE_Error::get_notices(false, true, true);
523
-        }
524
-    }
525
-
526
-
527
-
528
-    /**
529
-     * Returns the first post which uses the specified shortcode
530
-     *
531
-     * @param string $ee_shortcode usually one of the critical pages shortcodes, eg
532
-     *                             ESPRESSO_THANK_YOU. So we will search fora post with the content
533
-     *                             "[ESPRESSO_THANK_YOU"
534
-     *                             (we don't search for the closing shortcode bracket because they might have added
535
-     *                             parameter to the shortcode
536
-     * @return WP_Post or NULl
537
-     */
538
-    public static function get_page_by_ee_shortcode($ee_shortcode)
539
-    {
540
-        global $wpdb;
541
-        $shortcode_and_opening_bracket = '[' . $ee_shortcode;
542
-        $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
543
-        if ($post_id) {
544
-            return get_post($post_id);
545
-        } else {
546
-            return null;
547
-        }
548
-    }
549
-
550
-
551
-    /**
552
-     *    This function generates a post for critical espresso pages
553
-     *
554
-     * @access public
555
-     * @static
556
-     * @param array $critical_page
557
-     * @return array
558
-     */
559
-    public static function create_critical_page($critical_page)
560
-    {
561
-
562
-        $post_args = array(
563
-            'post_title'     => $critical_page['name'],
564
-            'post_status'    => 'publish',
565
-            'post_type'      => 'page',
566
-            'comment_status' => 'closed',
567
-            'post_content'   => '[' . $critical_page['code'] . ']',
568
-        );
569
-
570
-        $post_id = wp_insert_post($post_args);
571
-        if (! $post_id) {
572
-            $msg = sprintf(
573
-                __('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
574
-                $critical_page['name']
575
-            );
576
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
577
-            return $critical_page;
578
-        }
579
-        // get newly created post's details
580
-        if (! $critical_page['post'] = get_post($post_id)) {
581
-            $msg = sprintf(
582
-                __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
583
-                $critical_page['name']
584
-            );
585
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
586
-        }
587
-
588
-        return $critical_page;
589
-
590
-    }
591
-
592
-
593
-
594
-
595
-
596
-    /**
597
-     *    This function adds a critical page's shortcode to the post_shortcodes array
598
-     *
599
-     * @access private
600
-     * @static
601
-     * @param array $critical_page
602
-     * @return void
603
-     */
604
-    private static function _track_critical_page_post_shortcodes($critical_page = array())
605
-    {
606
-        // check the goods
607
-        if ( ! $critical_page['post'] instanceof WP_Post) {
608
-            $msg = sprintf(
609
-                __(
610
-                    'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.',
611
-                    'event_espresso'
612
-                ),
613
-                $critical_page['name']
614
-            );
615
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
616
-            return;
617
-        }
618
-        $EE_Core_Config = EE_Registry::instance()->CFG->core;
619
-        // map shortcode to post
620
-        $EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID;
621
-        // and make sure it's NOT added to the WP "Posts Page"
622
-        // name of the WP Posts Page
623
-        $posts_page = EE_Config::get_page_for_posts();
624
-        if (isset($EE_Core_Config->post_shortcodes[$posts_page])) {
625
-            unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]);
626
-        }
627
-        if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) {
628
-            unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]);
629
-        }
630
-        // update post_shortcode CFG
631
-        EE_Config::instance()->update_espresso_config(false, false);
632
-        // verify that saved ID in the config matches the ID for the post the shortcode is on
633
-        if (
634
-            EE_Registry::instance()->CFG->core->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']]
635
-            !== $critical_page['post']->ID
636
-        ) {
637
-            $msg = sprintf(
638
-                __(
639
-                    'The Event Espresso critical page shortcode for the %s page could not be configured properly.',
640
-                    'event_espresso'
641
-                ),
642
-                $critical_page['name']
643
-            );
644
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
645
-        }
646
-    }
647
-
648
-
649
-
650
-    /**
651
-     * Tries to find the oldest admin for this site.  If there are no admins for this site then return NULL.
652
-     * The role being used to check is filterable.
653
-     *
654
-     * @since  4.6.0
655
-     * @global WPDB $wpdb
656
-     * @return mixed null|int WP_user ID or NULL
657
-     */
658
-    public static function get_default_creator_id()
659
-    {
660
-        global $wpdb;
661
-        if ( ! empty(self::$_default_creator_id)) {
662
-            return self::$_default_creator_id;
663
-        }/**/
664
-        $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
665
-        //let's allow pre_filtering for early exits by alternative methods for getting id.  We check for truthy result and if so then exit early.
666
-        $pre_filtered_id = apply_filters(
667
-            'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id',
668
-            false,
669
-            $role_to_check
670
-        );
671
-        if ($pre_filtered_id !== false) {
672
-            return (int)$pre_filtered_id;
673
-        }
674
-        $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
675
-        $query = $wpdb->prepare(
676
-            "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
677
-            '%' . $role_to_check . '%'
678
-        );
679
-        $user_id = $wpdb->get_var($query);
680
-        $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
681
-        if ($user_id && (int)$user_id) {
682
-            self::$_default_creator_id = (int)$user_id;
683
-            return self::$_default_creator_id;
684
-        } else {
685
-            return null;
686
-        }
687
-    }
688
-
689
-
690
-
691
-    /**
692
-     * used by EE and EE addons during plugin activation to create tables.
693
-     * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable,
694
-     * but includes extra logic regarding activations.
695
-     *
696
-     * @access public
697
-     * @static
698
-     * @param string  $table_name              without the $wpdb->prefix
699
-     * @param string  $sql                     SQL for creating the table (contents between brackets in an SQL create
700
-     *                                         table query)
701
-     * @param string  $engine                  like 'ENGINE=MyISAM' or 'ENGINE=InnoDB'
702
-     * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty
703
-     *                                         and new once this function is done (ie, you really do want to CREATE a
704
-     *                                         table, and expect it to be empty once you're done) leave as FALSE when
705
-     *                                         you just want to verify the table exists and matches this definition
706
-     *                                         (and if it HAS data in it you want to leave it be)
707
-     * @return void
708
-     * @throws EE_Error if there are database errors
709
-     */
710
-    public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false)
711
-    {
712
-        if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) {
713
-            return;
714
-        }
715
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
716
-        if ( ! function_exists('dbDelta')) {
717
-            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
718
-        }
719
-        $tableAnalysis = \EEH_Activation::getTableAnalysis();
720
-        $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
721
-        // do we need to first delete an existing version of this table ?
722
-        if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) {
723
-            // ok, delete the table... but ONLY if it's empty
724
-            $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
725
-            // table is NOT empty, are you SURE you want to delete this table ???
726
-            if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
727
-                \EEH_Activation::getTableManager()->dropTable($wp_table_name);
728
-            } else if ( ! $deleted_safely) {
729
-                // so we should be more cautious rather than just dropping tables so easily
730
-                error_log(
731
-                    sprintf(
732
-                        __(
733
-                            'It appears that database table "%1$s" exists when it shouldn\'t, and therefore may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend: %2$s 1. create a new COMPLETE backup of your database, %2$s 2. delete ALL tables from your database, %2$s 3. restore to your previous backup. %2$s If, however, you have not restored to a backup, then somehow your "%3$s" WordPress option could not be read. You can probably ignore this message, but should investigate why that option is being removed.',
734
-                            'event_espresso'
735
-                        ),
736
-                        $wp_table_name,
737
-                        '<br/>',
738
-                        'espresso_db_update'
739
-                    )
740
-                );
741
-            }
742
-        }
743
-        $engine = str_replace('ENGINE=', '', $engine);
744
-        \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine);
745
-    }
746
-
747
-
748
-
749
-    /**
750
-     *    add_column_if_it_doesn't_exist
751
-     *    Checks if this column already exists on the specified table. Handy for addons which want to add a column
752
-     *
753
-     * @access     public
754
-     * @static
755
-     * @deprecated instead use TableManager::addColumn()
756
-     * @param string $table_name  (without "wp_", eg "esp_attendee"
757
-     * @param string $column_name
758
-     * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be
759
-     *                            'VARCHAR(10)'
760
-     * @return bool|int
761
-     */
762
-    public static function add_column_if_it_doesnt_exist(
763
-        $table_name,
764
-        $column_name,
765
-        $column_info = 'INT UNSIGNED NOT NULL'
766
-    ) {
767
-        return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info);
768
-    }
769
-
770
-
771
-    /**
772
-     * get_fields_on_table
773
-     * Gets all the fields on the database table.
774
-     *
775
-     * @access     public
776
-     * @deprecated instead use TableManager::getTableColumns()
777
-     * @static
778
-     * @param string $table_name , without prefixed $wpdb->prefix
779
-     * @return array of database column names
780
-     */
781
-    public static function get_fields_on_table($table_name = null)
782
-    {
783
-        return \EEH_Activation::getTableManager()->getTableColumns($table_name);
784
-    }
785
-
786
-
787
-    /**
788
-     * db_table_is_empty
789
-     *
790
-     * @access     public\
791
-     * @deprecated instead use TableAnalysis::tableIsEmpty()
792
-     * @static
793
-     * @param string $table_name
794
-     * @return bool
795
-     */
796
-    public static function db_table_is_empty($table_name)
797
-    {
798
-        return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name);
799
-    }
800
-
801
-
802
-    /**
803
-     * delete_db_table_if_empty
804
-     *
805
-     * @access public
806
-     * @static
807
-     * @param string $table_name
808
-     * @return bool | int
809
-     */
810
-    public static function delete_db_table_if_empty($table_name)
811
-    {
812
-        if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) {
813
-            return \EEH_Activation::getTableManager()->dropTable($table_name);
814
-        }
815
-        return false;
816
-    }
817
-
818
-
819
-    /**
820
-     * delete_unused_db_table
821
-     *
822
-     * @access     public
823
-     * @static
824
-     * @deprecated instead use TableManager::dropTable()
825
-     * @param string $table_name
826
-     * @return bool | int
827
-     */
828
-    public static function delete_unused_db_table($table_name)
829
-    {
830
-        return \EEH_Activation::getTableManager()->dropTable($table_name);
831
-    }
832
-
833
-
834
-    /**
835
-     * drop_index
836
-     *
837
-     * @access     public
838
-     * @static
839
-     * @deprecated instead use TableManager::dropIndex()
840
-     * @param string $table_name
841
-     * @param string $index_name
842
-     * @return bool | int
843
-     */
844
-    public static function drop_index($table_name, $index_name)
845
-    {
846
-        return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name);
847
-    }
848
-
849
-
850
-
851
-    /**
852
-     * create_database_tables
853
-     *
854
-     * @access public
855
-     * @static
856
-     * @throws EE_Error
857
-     * @return boolean success (whether database is setup properly or not)
858
-     */
859
-    public static function create_database_tables()
860
-    {
861
-        EE_Registry::instance()->load_core('Data_Migration_Manager');
862
-        //find the migration script that sets the database to be compatible with the code
863
-        $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
864
-        if ($dms_name) {
865
-            $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
866
-            $current_data_migration_script->set_migrating(false);
867
-            $current_data_migration_script->schema_changes_before_migration();
868
-            $current_data_migration_script->schema_changes_after_migration();
869
-            if ($current_data_migration_script->get_errors()) {
870
-                if (WP_DEBUG) {
871
-                    foreach ($current_data_migration_script->get_errors() as $error) {
872
-                        EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
873
-                    }
874
-                } else {
875
-                    EE_Error::add_error(
876
-                        __(
877
-                            'There were errors creating the Event Espresso database tables and Event Espresso has been 
270
+		$ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
271
+		foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
272
+			if (is_array($hooks_to_fire_at_time)) {
273
+				foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
274
+					if (isset($ee_cron_tasks_to_remove[$hook_name])
275
+						&& is_array($ee_cron_tasks_to_remove[$hook_name])
276
+					) {
277
+						unset($crons[$timestamp][$hook_name]);
278
+					}
279
+				}
280
+				//also take care of any empty cron timestamps.
281
+				if (empty($hooks_to_fire_at_time)) {
282
+					unset($crons[$timestamp]);
283
+				}
284
+			}
285
+		}
286
+		_set_cron_array($crons);
287
+	}
288
+
289
+
290
+	/**
291
+	 *    CPT_initialization
292
+	 *    registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist
293
+	 *
294
+	 * @access public
295
+	 * @static
296
+	 * @return void
297
+	 */
298
+	public static function CPT_initialization()
299
+	{
300
+		// register Custom Post Types
301
+		EE_Registry::instance()->load_core('Register_CPTs');
302
+		flush_rewrite_rules();
303
+	}
304
+
305
+
306
+
307
+	/**
308
+	 *    reset_and_update_config
309
+	 * The following code was moved over from EE_Config so that it will no longer run on every request.
310
+	 * If there is old calendar config data saved, then it will get converted on activation.
311
+	 * This was basically a DMS before we had DMS's, and will get removed after a few more versions.
312
+	 *
313
+	 * @access public
314
+	 * @static
315
+	 * @return void
316
+	 */
317
+	public static function reset_and_update_config()
318
+	{
319
+		do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
320
+		add_filter(
321
+			'FHEE__EE_Config___load_core_config__config_settings',
322
+			array('EEH_Activation', 'migrate_old_config_data'),
323
+			10,
324
+			3
325
+		);
326
+		//EE_Config::reset();
327
+		if (! EE_Config::logging_enabled()) {
328
+			delete_option(EE_Config::LOG_NAME);
329
+		}
330
+	}
331
+
332
+
333
+	/**
334
+	 *    load_calendar_config
335
+	 *
336
+	 * @access    public
337
+	 * @return    void
338
+	 */
339
+	public static function load_calendar_config()
340
+	{
341
+		// grab array of all plugin folders and loop thru it
342
+		$plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
343
+		if (empty($plugins)) {
344
+			return;
345
+		}
346
+		foreach ($plugins as $plugin_path) {
347
+			// grab plugin folder name from path
348
+			$plugin = basename($plugin_path);
349
+			// drill down to Espresso plugins
350
+			// then to calendar related plugins
351
+			if (
352
+				strpos($plugin, 'espresso') !== false
353
+				|| strpos($plugin, 'Espresso') !== false
354
+				|| strpos($plugin, 'ee4') !== false
355
+				|| strpos($plugin, 'EE4') !== false
356
+				|| strpos($plugin, 'calendar') !== false
357
+			) {
358
+				// this is what we are looking for
359
+				$calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
360
+				// does it exist in this folder ?
361
+				if (is_readable($calendar_config)) {
362
+					// YEAH! let's load it
363
+					require_once($calendar_config);
364
+				}
365
+			}
366
+		}
367
+	}
368
+
369
+
370
+
371
+	/**
372
+	 *    _migrate_old_config_data
373
+	 *
374
+	 * @access    public
375
+	 * @param array|stdClass $settings
376
+	 * @param string         $config
377
+	 * @param \EE_Config     $EE_Config
378
+	 * @return \stdClass
379
+	 */
380
+	public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config)
381
+	{
382
+		$convert_from_array = array('addons');
383
+		// in case old settings were saved as an array
384
+		if (is_array($settings) && in_array($config, $convert_from_array)) {
385
+			// convert existing settings to an object
386
+			$config_array = $settings;
387
+			$settings = new stdClass();
388
+			foreach ($config_array as $key => $value) {
389
+				if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
390
+					$EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
391
+				} else {
392
+					$settings->{$key} = $value;
393
+				}
394
+			}
395
+			add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
396
+		}
397
+		return $settings;
398
+	}
399
+
400
+
401
+	/**
402
+	 * deactivate_event_espresso
403
+	 *
404
+	 * @access public
405
+	 * @static
406
+	 * @return void
407
+	 */
408
+	public static function deactivate_event_espresso()
409
+	{
410
+		// check permissions
411
+		if (current_user_can('activate_plugins')) {
412
+			deactivate_plugins(EE_PLUGIN_BASENAME, true);
413
+		}
414
+	}
415
+
416
+
417
+
418
+
419
+
420
+	/**
421
+	 * verify_default_pages_exist
422
+	 *
423
+	 * @access public
424
+	 * @static
425
+	 * @return void
426
+	 */
427
+	public static function verify_default_pages_exist()
428
+	{
429
+		$critical_page_problem = false;
430
+		$critical_pages = array(
431
+			array(
432
+				'id'   => 'reg_page_id',
433
+				'name' => __('Registration Checkout', 'event_espresso'),
434
+				'post' => null,
435
+				'code' => 'ESPRESSO_CHECKOUT',
436
+			),
437
+			array(
438
+				'id'   => 'txn_page_id',
439
+				'name' => __('Transactions', 'event_espresso'),
440
+				'post' => null,
441
+				'code' => 'ESPRESSO_TXN_PAGE',
442
+			),
443
+			array(
444
+				'id'   => 'thank_you_page_id',
445
+				'name' => __('Thank You', 'event_espresso'),
446
+				'post' => null,
447
+				'code' => 'ESPRESSO_THANK_YOU',
448
+			),
449
+			array(
450
+				'id'   => 'cancel_page_id',
451
+				'name' => __('Registration Cancelled', 'event_espresso'),
452
+				'post' => null,
453
+				'code' => 'ESPRESSO_CANCELLED',
454
+			),
455
+		);
456
+		$EE_Core_Config = EE_Registry::instance()->CFG->core;
457
+		foreach ($critical_pages as $critical_page) {
458
+			// is critical page ID set in config ?
459
+			if ($EE_Core_Config->{$critical_page['id']} !== false) {
460
+				// attempt to find post by ID
461
+				$critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']});
462
+			}
463
+			// no dice?
464
+			if ($critical_page['post'] === null) {
465
+				// attempt to find post by title
466
+				$critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
467
+				// still nothing?
468
+				if ($critical_page['post'] === null) {
469
+					$critical_page = EEH_Activation::create_critical_page($critical_page);
470
+					// REALLY? Still nothing ??!?!?
471
+					if ($critical_page['post'] === null) {
472
+						$msg = __(
473
+							'The Event Espresso critical page configuration settings could not be updated.',
474
+							'event_espresso'
475
+						);
476
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
477
+						break;
478
+					}
479
+				}
480
+			}
481
+			// track post_shortcodes
482
+			if ($critical_page['post']) {
483
+				EEH_Activation::_track_critical_page_post_shortcodes($critical_page);
484
+			}
485
+			// check that Post ID matches critical page ID in config
486
+			if (
487
+				isset($critical_page['post']->ID)
488
+				&& $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
489
+			) {
490
+				//update Config with post ID
491
+				$EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
492
+				if (! EE_Config::instance()->update_espresso_config(false, false)) {
493
+					$msg = __(
494
+						'The Event Espresso critical page configuration settings could not be updated.',
495
+						'event_espresso'
496
+					);
497
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
498
+				}
499
+			}
500
+			$critical_page_problem =
501
+				! isset($critical_page['post']->post_status)
502
+				|| $critical_page['post']->post_status !== 'publish'
503
+				|| strpos($critical_page['post']->post_content, $critical_page['code']) === false
504
+					? true
505
+					: $critical_page_problem;
506
+		}
507
+		if ($critical_page_problem) {
508
+			$msg = sprintf(
509
+				__(
510
+					'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.',
511
+					'event_espresso'
512
+				),
513
+				'<a href="'
514
+				. admin_url('admin.php?page=espresso_general_settings&action=critical_pages')
515
+				. '">'
516
+				. __('Event Espresso Critical Pages Settings', 'event_espresso')
517
+				. '</a>'
518
+			);
519
+			EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
520
+		}
521
+		if (EE_Error::has_notices()) {
522
+			EE_Error::get_notices(false, true, true);
523
+		}
524
+	}
525
+
526
+
527
+
528
+	/**
529
+	 * Returns the first post which uses the specified shortcode
530
+	 *
531
+	 * @param string $ee_shortcode usually one of the critical pages shortcodes, eg
532
+	 *                             ESPRESSO_THANK_YOU. So we will search fora post with the content
533
+	 *                             "[ESPRESSO_THANK_YOU"
534
+	 *                             (we don't search for the closing shortcode bracket because they might have added
535
+	 *                             parameter to the shortcode
536
+	 * @return WP_Post or NULl
537
+	 */
538
+	public static function get_page_by_ee_shortcode($ee_shortcode)
539
+	{
540
+		global $wpdb;
541
+		$shortcode_and_opening_bracket = '[' . $ee_shortcode;
542
+		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
543
+		if ($post_id) {
544
+			return get_post($post_id);
545
+		} else {
546
+			return null;
547
+		}
548
+	}
549
+
550
+
551
+	/**
552
+	 *    This function generates a post for critical espresso pages
553
+	 *
554
+	 * @access public
555
+	 * @static
556
+	 * @param array $critical_page
557
+	 * @return array
558
+	 */
559
+	public static function create_critical_page($critical_page)
560
+	{
561
+
562
+		$post_args = array(
563
+			'post_title'     => $critical_page['name'],
564
+			'post_status'    => 'publish',
565
+			'post_type'      => 'page',
566
+			'comment_status' => 'closed',
567
+			'post_content'   => '[' . $critical_page['code'] . ']',
568
+		);
569
+
570
+		$post_id = wp_insert_post($post_args);
571
+		if (! $post_id) {
572
+			$msg = sprintf(
573
+				__('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
574
+				$critical_page['name']
575
+			);
576
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
577
+			return $critical_page;
578
+		}
579
+		// get newly created post's details
580
+		if (! $critical_page['post'] = get_post($post_id)) {
581
+			$msg = sprintf(
582
+				__('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
583
+				$critical_page['name']
584
+			);
585
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
586
+		}
587
+
588
+		return $critical_page;
589
+
590
+	}
591
+
592
+
593
+
594
+
595
+
596
+	/**
597
+	 *    This function adds a critical page's shortcode to the post_shortcodes array
598
+	 *
599
+	 * @access private
600
+	 * @static
601
+	 * @param array $critical_page
602
+	 * @return void
603
+	 */
604
+	private static function _track_critical_page_post_shortcodes($critical_page = array())
605
+	{
606
+		// check the goods
607
+		if ( ! $critical_page['post'] instanceof WP_Post) {
608
+			$msg = sprintf(
609
+				__(
610
+					'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.',
611
+					'event_espresso'
612
+				),
613
+				$critical_page['name']
614
+			);
615
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
616
+			return;
617
+		}
618
+		$EE_Core_Config = EE_Registry::instance()->CFG->core;
619
+		// map shortcode to post
620
+		$EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID;
621
+		// and make sure it's NOT added to the WP "Posts Page"
622
+		// name of the WP Posts Page
623
+		$posts_page = EE_Config::get_page_for_posts();
624
+		if (isset($EE_Core_Config->post_shortcodes[$posts_page])) {
625
+			unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]);
626
+		}
627
+		if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) {
628
+			unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]);
629
+		}
630
+		// update post_shortcode CFG
631
+		EE_Config::instance()->update_espresso_config(false, false);
632
+		// verify that saved ID in the config matches the ID for the post the shortcode is on
633
+		if (
634
+			EE_Registry::instance()->CFG->core->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']]
635
+			!== $critical_page['post']->ID
636
+		) {
637
+			$msg = sprintf(
638
+				__(
639
+					'The Event Espresso critical page shortcode for the %s page could not be configured properly.',
640
+					'event_espresso'
641
+				),
642
+				$critical_page['name']
643
+			);
644
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
645
+		}
646
+	}
647
+
648
+
649
+
650
+	/**
651
+	 * Tries to find the oldest admin for this site.  If there are no admins for this site then return NULL.
652
+	 * The role being used to check is filterable.
653
+	 *
654
+	 * @since  4.6.0
655
+	 * @global WPDB $wpdb
656
+	 * @return mixed null|int WP_user ID or NULL
657
+	 */
658
+	public static function get_default_creator_id()
659
+	{
660
+		global $wpdb;
661
+		if ( ! empty(self::$_default_creator_id)) {
662
+			return self::$_default_creator_id;
663
+		}/**/
664
+		$role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
665
+		//let's allow pre_filtering for early exits by alternative methods for getting id.  We check for truthy result and if so then exit early.
666
+		$pre_filtered_id = apply_filters(
667
+			'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id',
668
+			false,
669
+			$role_to_check
670
+		);
671
+		if ($pre_filtered_id !== false) {
672
+			return (int)$pre_filtered_id;
673
+		}
674
+		$capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
675
+		$query = $wpdb->prepare(
676
+			"SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
677
+			'%' . $role_to_check . '%'
678
+		);
679
+		$user_id = $wpdb->get_var($query);
680
+		$user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
681
+		if ($user_id && (int)$user_id) {
682
+			self::$_default_creator_id = (int)$user_id;
683
+			return self::$_default_creator_id;
684
+		} else {
685
+			return null;
686
+		}
687
+	}
688
+
689
+
690
+
691
+	/**
692
+	 * used by EE and EE addons during plugin activation to create tables.
693
+	 * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable,
694
+	 * but includes extra logic regarding activations.
695
+	 *
696
+	 * @access public
697
+	 * @static
698
+	 * @param string  $table_name              without the $wpdb->prefix
699
+	 * @param string  $sql                     SQL for creating the table (contents between brackets in an SQL create
700
+	 *                                         table query)
701
+	 * @param string  $engine                  like 'ENGINE=MyISAM' or 'ENGINE=InnoDB'
702
+	 * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty
703
+	 *                                         and new once this function is done (ie, you really do want to CREATE a
704
+	 *                                         table, and expect it to be empty once you're done) leave as FALSE when
705
+	 *                                         you just want to verify the table exists and matches this definition
706
+	 *                                         (and if it HAS data in it you want to leave it be)
707
+	 * @return void
708
+	 * @throws EE_Error if there are database errors
709
+	 */
710
+	public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false)
711
+	{
712
+		if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) {
713
+			return;
714
+		}
715
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
716
+		if ( ! function_exists('dbDelta')) {
717
+			require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
718
+		}
719
+		$tableAnalysis = \EEH_Activation::getTableAnalysis();
720
+		$wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
721
+		// do we need to first delete an existing version of this table ?
722
+		if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) {
723
+			// ok, delete the table... but ONLY if it's empty
724
+			$deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
725
+			// table is NOT empty, are you SURE you want to delete this table ???
726
+			if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
727
+				\EEH_Activation::getTableManager()->dropTable($wp_table_name);
728
+			} else if ( ! $deleted_safely) {
729
+				// so we should be more cautious rather than just dropping tables so easily
730
+				error_log(
731
+					sprintf(
732
+						__(
733
+							'It appears that database table "%1$s" exists when it shouldn\'t, and therefore may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend: %2$s 1. create a new COMPLETE backup of your database, %2$s 2. delete ALL tables from your database, %2$s 3. restore to your previous backup. %2$s If, however, you have not restored to a backup, then somehow your "%3$s" WordPress option could not be read. You can probably ignore this message, but should investigate why that option is being removed.',
734
+							'event_espresso'
735
+						),
736
+						$wp_table_name,
737
+						'<br/>',
738
+						'espresso_db_update'
739
+					)
740
+				);
741
+			}
742
+		}
743
+		$engine = str_replace('ENGINE=', '', $engine);
744
+		\EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine);
745
+	}
746
+
747
+
748
+
749
+	/**
750
+	 *    add_column_if_it_doesn't_exist
751
+	 *    Checks if this column already exists on the specified table. Handy for addons which want to add a column
752
+	 *
753
+	 * @access     public
754
+	 * @static
755
+	 * @deprecated instead use TableManager::addColumn()
756
+	 * @param string $table_name  (without "wp_", eg "esp_attendee"
757
+	 * @param string $column_name
758
+	 * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be
759
+	 *                            'VARCHAR(10)'
760
+	 * @return bool|int
761
+	 */
762
+	public static function add_column_if_it_doesnt_exist(
763
+		$table_name,
764
+		$column_name,
765
+		$column_info = 'INT UNSIGNED NOT NULL'
766
+	) {
767
+		return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info);
768
+	}
769
+
770
+
771
+	/**
772
+	 * get_fields_on_table
773
+	 * Gets all the fields on the database table.
774
+	 *
775
+	 * @access     public
776
+	 * @deprecated instead use TableManager::getTableColumns()
777
+	 * @static
778
+	 * @param string $table_name , without prefixed $wpdb->prefix
779
+	 * @return array of database column names
780
+	 */
781
+	public static function get_fields_on_table($table_name = null)
782
+	{
783
+		return \EEH_Activation::getTableManager()->getTableColumns($table_name);
784
+	}
785
+
786
+
787
+	/**
788
+	 * db_table_is_empty
789
+	 *
790
+	 * @access     public\
791
+	 * @deprecated instead use TableAnalysis::tableIsEmpty()
792
+	 * @static
793
+	 * @param string $table_name
794
+	 * @return bool
795
+	 */
796
+	public static function db_table_is_empty($table_name)
797
+	{
798
+		return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name);
799
+	}
800
+
801
+
802
+	/**
803
+	 * delete_db_table_if_empty
804
+	 *
805
+	 * @access public
806
+	 * @static
807
+	 * @param string $table_name
808
+	 * @return bool | int
809
+	 */
810
+	public static function delete_db_table_if_empty($table_name)
811
+	{
812
+		if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) {
813
+			return \EEH_Activation::getTableManager()->dropTable($table_name);
814
+		}
815
+		return false;
816
+	}
817
+
818
+
819
+	/**
820
+	 * delete_unused_db_table
821
+	 *
822
+	 * @access     public
823
+	 * @static
824
+	 * @deprecated instead use TableManager::dropTable()
825
+	 * @param string $table_name
826
+	 * @return bool | int
827
+	 */
828
+	public static function delete_unused_db_table($table_name)
829
+	{
830
+		return \EEH_Activation::getTableManager()->dropTable($table_name);
831
+	}
832
+
833
+
834
+	/**
835
+	 * drop_index
836
+	 *
837
+	 * @access     public
838
+	 * @static
839
+	 * @deprecated instead use TableManager::dropIndex()
840
+	 * @param string $table_name
841
+	 * @param string $index_name
842
+	 * @return bool | int
843
+	 */
844
+	public static function drop_index($table_name, $index_name)
845
+	{
846
+		return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name);
847
+	}
848
+
849
+
850
+
851
+	/**
852
+	 * create_database_tables
853
+	 *
854
+	 * @access public
855
+	 * @static
856
+	 * @throws EE_Error
857
+	 * @return boolean success (whether database is setup properly or not)
858
+	 */
859
+	public static function create_database_tables()
860
+	{
861
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
862
+		//find the migration script that sets the database to be compatible with the code
863
+		$dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
864
+		if ($dms_name) {
865
+			$current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
866
+			$current_data_migration_script->set_migrating(false);
867
+			$current_data_migration_script->schema_changes_before_migration();
868
+			$current_data_migration_script->schema_changes_after_migration();
869
+			if ($current_data_migration_script->get_errors()) {
870
+				if (WP_DEBUG) {
871
+					foreach ($current_data_migration_script->get_errors() as $error) {
872
+						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
873
+					}
874
+				} else {
875
+					EE_Error::add_error(
876
+						__(
877
+							'There were errors creating the Event Espresso database tables and Event Espresso has been 
878 878
                             deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.',
879
-                            'event_espresso'
880
-                        )
881
-                    );
882
-                }
883
-                return false;
884
-            }
885
-            EE_Data_Migration_Manager::instance()->update_current_database_state_to();
886
-        } else {
887
-            EE_Error::add_error(
888
-                __(
889
-                    'Could not determine most up-to-date data migration script from which to pull database schema
879
+							'event_espresso'
880
+						)
881
+					);
882
+				}
883
+				return false;
884
+			}
885
+			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
886
+		} else {
887
+			EE_Error::add_error(
888
+				__(
889
+					'Could not determine most up-to-date data migration script from which to pull database schema
890 890
                      structure. So database is probably not setup properly',
891
-                    'event_espresso'
892
-                ),
893
-                __FILE__,
894
-                __FUNCTION__,
895
-                __LINE__
896
-            );
897
-            return false;
898
-        }
899
-        return true;
900
-    }
901
-
902
-
903
-
904
-    /**
905
-     * initialize_system_questions
906
-     *
907
-     * @access public
908
-     * @static
909
-     * @return void
910
-     */
911
-    public static function initialize_system_questions()
912
-    {
913
-        // QUESTION GROUPS
914
-        global $wpdb;
915
-        $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group');
916
-        $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
917
-        // what we have
918
-        $question_groups = $wpdb->get_col($SQL);
919
-        // check the response
920
-        $question_groups = is_array($question_groups) ? $question_groups : array();
921
-        // what we should have
922
-        $QSG_systems = array(1, 2);
923
-        // loop thru what we should have and compare to what we have
924
-        foreach ($QSG_systems as $QSG_system) {
925
-            // reset values array
926
-            $QSG_values = array();
927
-            // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
928
-            if (! in_array("$QSG_system", $question_groups)) {
929
-                // add it
930
-                switch ($QSG_system) {
931
-                    case 1:
932
-                        $QSG_values = array(
933
-                            'QSG_name'            => __('Personal Information', 'event_espresso'),
934
-                            'QSG_identifier'      => 'personal-information-' . time(),
935
-                            'QSG_desc'            => '',
936
-                            'QSG_order'           => 1,
937
-                            'QSG_show_group_name' => 1,
938
-                            'QSG_show_group_desc' => 1,
939
-                            'QSG_system'          => EEM_Question_Group::system_personal,
940
-                            'QSG_deleted'         => 0,
941
-                        );
942
-                        break;
943
-                    case 2:
944
-                        $QSG_values = array(
945
-                            'QSG_name'            => __('Address Information', 'event_espresso'),
946
-                            'QSG_identifier'      => 'address-information-' . time(),
947
-                            'QSG_desc'            => '',
948
-                            'QSG_order'           => 2,
949
-                            'QSG_show_group_name' => 1,
950
-                            'QSG_show_group_desc' => 1,
951
-                            'QSG_system'          => EEM_Question_Group::system_address,
952
-                            'QSG_deleted'         => 0,
953
-                        );
954
-                        break;
955
-                }
956
-                // make sure we have some values before inserting them
957
-                if (! empty($QSG_values)) {
958
-                    // insert system question
959
-                    $wpdb->insert(
960
-                        $table_name,
961
-                        $QSG_values,
962
-                        array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
963
-                    );
964
-                    $QSG_IDs[$QSG_system] = $wpdb->insert_id;
965
-                }
966
-            }
967
-        }
968
-        // QUESTIONS
969
-        global $wpdb;
970
-        $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question');
971
-        $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
972
-        // what we have
973
-        $questions = $wpdb->get_col($SQL);
974
-        // what we should have
975
-        $QST_systems = array(
976
-            'fname',
977
-            'lname',
978
-            'email',
979
-            'address',
980
-            'address2',
981
-            'city',
982
-            'country',
983
-            'state',
984
-            'zip',
985
-            'phone',
986
-        );
987
-        $order_for_group_1 = 1;
988
-        $order_for_group_2 = 1;
989
-        // loop thru what we should have and compare to what we have
990
-        foreach ($QST_systems as $QST_system) {
991
-            // reset values array
992
-            $QST_values = array();
993
-            // if we don't have what we should have
994
-            if (! in_array($QST_system, $questions)) {
995
-                // add it
996
-                switch ($QST_system) {
997
-                    case 'fname':
998
-                        $QST_values = array(
999
-                            'QST_display_text'  => __('First Name', 'event_espresso'),
1000
-                            'QST_admin_label'   => __('First Name - System Question', 'event_espresso'),
1001
-                            'QST_system'        => 'fname',
1002
-                            'QST_type'          => 'TEXT',
1003
-                            'QST_required'      => 1,
1004
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1005
-                            'QST_order'         => 1,
1006
-                            'QST_admin_only'    => 0,
1007
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1008
-                            'QST_wp_user'       => self::get_default_creator_id(),
1009
-                            'QST_deleted'       => 0,
1010
-                        );
1011
-                        break;
1012
-                    case 'lname':
1013
-                        $QST_values = array(
1014
-                            'QST_display_text'  => __('Last Name', 'event_espresso'),
1015
-                            'QST_admin_label'   => __('Last Name - System Question', 'event_espresso'),
1016
-                            'QST_system'        => 'lname',
1017
-                            'QST_type'          => 'TEXT',
1018
-                            'QST_required'      => 1,
1019
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1020
-                            'QST_order'         => 2,
1021
-                            'QST_admin_only'    => 0,
1022
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1023
-                            'QST_wp_user'       => self::get_default_creator_id(),
1024
-                            'QST_deleted'       => 0,
1025
-                        );
1026
-                        break;
1027
-                    case 'email':
1028
-                        $QST_values = array(
1029
-                            'QST_display_text'  => __('Email Address', 'event_espresso'),
1030
-                            'QST_admin_label'   => __('Email Address - System Question', 'event_espresso'),
1031
-                            'QST_system'        => 'email',
1032
-                            'QST_type'          => 'EMAIL',
1033
-                            'QST_required'      => 1,
1034
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1035
-                            'QST_order'         => 3,
1036
-                            'QST_admin_only'    => 0,
1037
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1038
-                            'QST_wp_user'       => self::get_default_creator_id(),
1039
-                            'QST_deleted'       => 0,
1040
-                        );
1041
-                        break;
1042
-                    case 'address':
1043
-                        $QST_values = array(
1044
-                            'QST_display_text'  => __('Address', 'event_espresso'),
1045
-                            'QST_admin_label'   => __('Address - System Question', 'event_espresso'),
1046
-                            'QST_system'        => 'address',
1047
-                            'QST_type'          => 'TEXT',
1048
-                            'QST_required'      => 0,
1049
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1050
-                            'QST_order'         => 4,
1051
-                            'QST_admin_only'    => 0,
1052
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1053
-                            'QST_wp_user'       => self::get_default_creator_id(),
1054
-                            'QST_deleted'       => 0,
1055
-                        );
1056
-                        break;
1057
-                    case 'address2':
1058
-                        $QST_values = array(
1059
-                            'QST_display_text'  => __('Address2', 'event_espresso'),
1060
-                            'QST_admin_label'   => __('Address2 - System Question', 'event_espresso'),
1061
-                            'QST_system'        => 'address2',
1062
-                            'QST_type'          => 'TEXT',
1063
-                            'QST_required'      => 0,
1064
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1065
-                            'QST_order'         => 5,
1066
-                            'QST_admin_only'    => 0,
1067
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1068
-                            'QST_wp_user'       => self::get_default_creator_id(),
1069
-                            'QST_deleted'       => 0,
1070
-                        );
1071
-                        break;
1072
-                    case 'city':
1073
-                        $QST_values = array(
1074
-                            'QST_display_text'  => __('City', 'event_espresso'),
1075
-                            'QST_admin_label'   => __('City - System Question', 'event_espresso'),
1076
-                            'QST_system'        => 'city',
1077
-                            'QST_type'          => 'TEXT',
1078
-                            'QST_required'      => 0,
1079
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1080
-                            'QST_order'         => 6,
1081
-                            'QST_admin_only'    => 0,
1082
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1083
-                            'QST_wp_user'       => self::get_default_creator_id(),
1084
-                            'QST_deleted'       => 0,
1085
-                        );
1086
-                        break;
1087
-                    case 'country':
1088
-                        $QST_values = array(
1089
-                            'QST_display_text'  => __('Country', 'event_espresso'),
1090
-                            'QST_admin_label'   => __('Country - System Question', 'event_espresso'),
1091
-                            'QST_system'        => 'country',
1092
-                            'QST_type'          => 'COUNTRY',
1093
-                            'QST_required'      => 0,
1094
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1095
-                            'QST_order'         => 7,
1096
-                            'QST_admin_only'    => 0,
1097
-                            'QST_wp_user'       => self::get_default_creator_id(),
1098
-                            'QST_deleted'       => 0,
1099
-                        );
1100
-                        break;
1101
-                    case 'state':
1102
-                        $QST_values = array(
1103
-                            'QST_display_text'  => __('State/Province', 'event_espresso'),
1104
-                            'QST_admin_label'   => __('State/Province - System Question', 'event_espresso'),
1105
-                            'QST_system'        => 'state',
1106
-                            'QST_type'          => 'STATE',
1107
-                            'QST_required'      => 0,
1108
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1109
-                            'QST_order'         => 8,
1110
-                            'QST_admin_only'    => 0,
1111
-                            'QST_wp_user'       => self::get_default_creator_id(),
1112
-                            'QST_deleted'       => 0,
1113
-                        );
1114
-                        break;
1115
-                    case 'zip':
1116
-                        $QST_values = array(
1117
-                            'QST_display_text'  => __('Zip/Postal Code', 'event_espresso'),
1118
-                            'QST_admin_label'   => __('Zip/Postal Code - System Question', 'event_espresso'),
1119
-                            'QST_system'        => 'zip',
1120
-                            'QST_type'          => 'TEXT',
1121
-                            'QST_required'      => 0,
1122
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1123
-                            'QST_order'         => 9,
1124
-                            'QST_admin_only'    => 0,
1125
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1126
-                            'QST_wp_user'       => self::get_default_creator_id(),
1127
-                            'QST_deleted'       => 0,
1128
-                        );
1129
-                        break;
1130
-                    case 'phone':
1131
-                        $QST_values = array(
1132
-                            'QST_display_text'  => __('Phone Number', 'event_espresso'),
1133
-                            'QST_admin_label'   => __('Phone Number - System Question', 'event_espresso'),
1134
-                            'QST_system'        => 'phone',
1135
-                            'QST_type'          => 'TEXT',
1136
-                            'QST_required'      => 0,
1137
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1138
-                            'QST_order'         => 10,
1139
-                            'QST_admin_only'    => 0,
1140
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1141
-                            'QST_wp_user'       => self::get_default_creator_id(),
1142
-                            'QST_deleted'       => 0,
1143
-                        );
1144
-                        break;
1145
-                }
1146
-                if (! empty($QST_values)) {
1147
-                    // insert system question
1148
-                    $wpdb->insert(
1149
-                        $table_name,
1150
-                        $QST_values,
1151
-                        array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1152
-                    );
1153
-                    $QST_ID = $wpdb->insert_id;
1154
-                    // QUESTION GROUP QUESTIONS
1155
-                    if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1156
-                        $system_question_we_want = EEM_Question_Group::system_personal;
1157
-                    } else {
1158
-                        $system_question_we_want = EEM_Question_Group::system_address;
1159
-                    }
1160
-                    if (isset($QSG_IDs[$system_question_we_want])) {
1161
-                        $QSG_ID = $QSG_IDs[$system_question_we_want];
1162
-                    } else {
1163
-                        $id_col = EEM_Question_Group::instance()
1164
-                                                    ->get_col(array(array('QSG_system' => $system_question_we_want)));
1165
-                        if (is_array($id_col)) {
1166
-                            $QSG_ID = reset($id_col);
1167
-                        } else {
1168
-                            //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1169
-                            EE_Log::instance()->log(
1170
-                                __FILE__,
1171
-                                __FUNCTION__,
1172
-                                sprintf(
1173
-                                    __(
1174
-                                        'Could not associate question %1$s to a question group because no system question
891
+					'event_espresso'
892
+				),
893
+				__FILE__,
894
+				__FUNCTION__,
895
+				__LINE__
896
+			);
897
+			return false;
898
+		}
899
+		return true;
900
+	}
901
+
902
+
903
+
904
+	/**
905
+	 * initialize_system_questions
906
+	 *
907
+	 * @access public
908
+	 * @static
909
+	 * @return void
910
+	 */
911
+	public static function initialize_system_questions()
912
+	{
913
+		// QUESTION GROUPS
914
+		global $wpdb;
915
+		$table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group');
916
+		$SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
917
+		// what we have
918
+		$question_groups = $wpdb->get_col($SQL);
919
+		// check the response
920
+		$question_groups = is_array($question_groups) ? $question_groups : array();
921
+		// what we should have
922
+		$QSG_systems = array(1, 2);
923
+		// loop thru what we should have and compare to what we have
924
+		foreach ($QSG_systems as $QSG_system) {
925
+			// reset values array
926
+			$QSG_values = array();
927
+			// if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
928
+			if (! in_array("$QSG_system", $question_groups)) {
929
+				// add it
930
+				switch ($QSG_system) {
931
+					case 1:
932
+						$QSG_values = array(
933
+							'QSG_name'            => __('Personal Information', 'event_espresso'),
934
+							'QSG_identifier'      => 'personal-information-' . time(),
935
+							'QSG_desc'            => '',
936
+							'QSG_order'           => 1,
937
+							'QSG_show_group_name' => 1,
938
+							'QSG_show_group_desc' => 1,
939
+							'QSG_system'          => EEM_Question_Group::system_personal,
940
+							'QSG_deleted'         => 0,
941
+						);
942
+						break;
943
+					case 2:
944
+						$QSG_values = array(
945
+							'QSG_name'            => __('Address Information', 'event_espresso'),
946
+							'QSG_identifier'      => 'address-information-' . time(),
947
+							'QSG_desc'            => '',
948
+							'QSG_order'           => 2,
949
+							'QSG_show_group_name' => 1,
950
+							'QSG_show_group_desc' => 1,
951
+							'QSG_system'          => EEM_Question_Group::system_address,
952
+							'QSG_deleted'         => 0,
953
+						);
954
+						break;
955
+				}
956
+				// make sure we have some values before inserting them
957
+				if (! empty($QSG_values)) {
958
+					// insert system question
959
+					$wpdb->insert(
960
+						$table_name,
961
+						$QSG_values,
962
+						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
963
+					);
964
+					$QSG_IDs[$QSG_system] = $wpdb->insert_id;
965
+				}
966
+			}
967
+		}
968
+		// QUESTIONS
969
+		global $wpdb;
970
+		$table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question');
971
+		$SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
972
+		// what we have
973
+		$questions = $wpdb->get_col($SQL);
974
+		// what we should have
975
+		$QST_systems = array(
976
+			'fname',
977
+			'lname',
978
+			'email',
979
+			'address',
980
+			'address2',
981
+			'city',
982
+			'country',
983
+			'state',
984
+			'zip',
985
+			'phone',
986
+		);
987
+		$order_for_group_1 = 1;
988
+		$order_for_group_2 = 1;
989
+		// loop thru what we should have and compare to what we have
990
+		foreach ($QST_systems as $QST_system) {
991
+			// reset values array
992
+			$QST_values = array();
993
+			// if we don't have what we should have
994
+			if (! in_array($QST_system, $questions)) {
995
+				// add it
996
+				switch ($QST_system) {
997
+					case 'fname':
998
+						$QST_values = array(
999
+							'QST_display_text'  => __('First Name', 'event_espresso'),
1000
+							'QST_admin_label'   => __('First Name - System Question', 'event_espresso'),
1001
+							'QST_system'        => 'fname',
1002
+							'QST_type'          => 'TEXT',
1003
+							'QST_required'      => 1,
1004
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1005
+							'QST_order'         => 1,
1006
+							'QST_admin_only'    => 0,
1007
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1008
+							'QST_wp_user'       => self::get_default_creator_id(),
1009
+							'QST_deleted'       => 0,
1010
+						);
1011
+						break;
1012
+					case 'lname':
1013
+						$QST_values = array(
1014
+							'QST_display_text'  => __('Last Name', 'event_espresso'),
1015
+							'QST_admin_label'   => __('Last Name - System Question', 'event_espresso'),
1016
+							'QST_system'        => 'lname',
1017
+							'QST_type'          => 'TEXT',
1018
+							'QST_required'      => 1,
1019
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1020
+							'QST_order'         => 2,
1021
+							'QST_admin_only'    => 0,
1022
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1023
+							'QST_wp_user'       => self::get_default_creator_id(),
1024
+							'QST_deleted'       => 0,
1025
+						);
1026
+						break;
1027
+					case 'email':
1028
+						$QST_values = array(
1029
+							'QST_display_text'  => __('Email Address', 'event_espresso'),
1030
+							'QST_admin_label'   => __('Email Address - System Question', 'event_espresso'),
1031
+							'QST_system'        => 'email',
1032
+							'QST_type'          => 'EMAIL',
1033
+							'QST_required'      => 1,
1034
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1035
+							'QST_order'         => 3,
1036
+							'QST_admin_only'    => 0,
1037
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1038
+							'QST_wp_user'       => self::get_default_creator_id(),
1039
+							'QST_deleted'       => 0,
1040
+						);
1041
+						break;
1042
+					case 'address':
1043
+						$QST_values = array(
1044
+							'QST_display_text'  => __('Address', 'event_espresso'),
1045
+							'QST_admin_label'   => __('Address - System Question', 'event_espresso'),
1046
+							'QST_system'        => 'address',
1047
+							'QST_type'          => 'TEXT',
1048
+							'QST_required'      => 0,
1049
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1050
+							'QST_order'         => 4,
1051
+							'QST_admin_only'    => 0,
1052
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1053
+							'QST_wp_user'       => self::get_default_creator_id(),
1054
+							'QST_deleted'       => 0,
1055
+						);
1056
+						break;
1057
+					case 'address2':
1058
+						$QST_values = array(
1059
+							'QST_display_text'  => __('Address2', 'event_espresso'),
1060
+							'QST_admin_label'   => __('Address2 - System Question', 'event_espresso'),
1061
+							'QST_system'        => 'address2',
1062
+							'QST_type'          => 'TEXT',
1063
+							'QST_required'      => 0,
1064
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1065
+							'QST_order'         => 5,
1066
+							'QST_admin_only'    => 0,
1067
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1068
+							'QST_wp_user'       => self::get_default_creator_id(),
1069
+							'QST_deleted'       => 0,
1070
+						);
1071
+						break;
1072
+					case 'city':
1073
+						$QST_values = array(
1074
+							'QST_display_text'  => __('City', 'event_espresso'),
1075
+							'QST_admin_label'   => __('City - System Question', 'event_espresso'),
1076
+							'QST_system'        => 'city',
1077
+							'QST_type'          => 'TEXT',
1078
+							'QST_required'      => 0,
1079
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1080
+							'QST_order'         => 6,
1081
+							'QST_admin_only'    => 0,
1082
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1083
+							'QST_wp_user'       => self::get_default_creator_id(),
1084
+							'QST_deleted'       => 0,
1085
+						);
1086
+						break;
1087
+					case 'country':
1088
+						$QST_values = array(
1089
+							'QST_display_text'  => __('Country', 'event_espresso'),
1090
+							'QST_admin_label'   => __('Country - System Question', 'event_espresso'),
1091
+							'QST_system'        => 'country',
1092
+							'QST_type'          => 'COUNTRY',
1093
+							'QST_required'      => 0,
1094
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1095
+							'QST_order'         => 7,
1096
+							'QST_admin_only'    => 0,
1097
+							'QST_wp_user'       => self::get_default_creator_id(),
1098
+							'QST_deleted'       => 0,
1099
+						);
1100
+						break;
1101
+					case 'state':
1102
+						$QST_values = array(
1103
+							'QST_display_text'  => __('State/Province', 'event_espresso'),
1104
+							'QST_admin_label'   => __('State/Province - System Question', 'event_espresso'),
1105
+							'QST_system'        => 'state',
1106
+							'QST_type'          => 'STATE',
1107
+							'QST_required'      => 0,
1108
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1109
+							'QST_order'         => 8,
1110
+							'QST_admin_only'    => 0,
1111
+							'QST_wp_user'       => self::get_default_creator_id(),
1112
+							'QST_deleted'       => 0,
1113
+						);
1114
+						break;
1115
+					case 'zip':
1116
+						$QST_values = array(
1117
+							'QST_display_text'  => __('Zip/Postal Code', 'event_espresso'),
1118
+							'QST_admin_label'   => __('Zip/Postal Code - System Question', 'event_espresso'),
1119
+							'QST_system'        => 'zip',
1120
+							'QST_type'          => 'TEXT',
1121
+							'QST_required'      => 0,
1122
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1123
+							'QST_order'         => 9,
1124
+							'QST_admin_only'    => 0,
1125
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1126
+							'QST_wp_user'       => self::get_default_creator_id(),
1127
+							'QST_deleted'       => 0,
1128
+						);
1129
+						break;
1130
+					case 'phone':
1131
+						$QST_values = array(
1132
+							'QST_display_text'  => __('Phone Number', 'event_espresso'),
1133
+							'QST_admin_label'   => __('Phone Number - System Question', 'event_espresso'),
1134
+							'QST_system'        => 'phone',
1135
+							'QST_type'          => 'TEXT',
1136
+							'QST_required'      => 0,
1137
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1138
+							'QST_order'         => 10,
1139
+							'QST_admin_only'    => 0,
1140
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1141
+							'QST_wp_user'       => self::get_default_creator_id(),
1142
+							'QST_deleted'       => 0,
1143
+						);
1144
+						break;
1145
+				}
1146
+				if (! empty($QST_values)) {
1147
+					// insert system question
1148
+					$wpdb->insert(
1149
+						$table_name,
1150
+						$QST_values,
1151
+						array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1152
+					);
1153
+					$QST_ID = $wpdb->insert_id;
1154
+					// QUESTION GROUP QUESTIONS
1155
+					if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1156
+						$system_question_we_want = EEM_Question_Group::system_personal;
1157
+					} else {
1158
+						$system_question_we_want = EEM_Question_Group::system_address;
1159
+					}
1160
+					if (isset($QSG_IDs[$system_question_we_want])) {
1161
+						$QSG_ID = $QSG_IDs[$system_question_we_want];
1162
+					} else {
1163
+						$id_col = EEM_Question_Group::instance()
1164
+													->get_col(array(array('QSG_system' => $system_question_we_want)));
1165
+						if (is_array($id_col)) {
1166
+							$QSG_ID = reset($id_col);
1167
+						} else {
1168
+							//ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1169
+							EE_Log::instance()->log(
1170
+								__FILE__,
1171
+								__FUNCTION__,
1172
+								sprintf(
1173
+									__(
1174
+										'Could not associate question %1$s to a question group because no system question
1175 1175
                                          group existed',
1176
-                                        'event_espresso'
1177
-                                    ),
1178
-                                    $QST_ID),
1179
-                                'error');
1180
-                            continue;
1181
-                        }
1182
-                    }
1183
-                    // add system questions to groups
1184
-                    $wpdb->insert(
1185
-                        \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'),
1186
-                        array(
1187
-                            'QSG_ID'    => $QSG_ID,
1188
-                            'QST_ID'    => $QST_ID,
1189
-                            'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++,
1190
-                        ),
1191
-                        array('%d', '%d', '%d')
1192
-                    );
1193
-                }
1194
-            }
1195
-        }
1196
-    }
1197
-
1198
-
1199
-    /**
1200
-     * Makes sure the default payment method (Invoice) is active.
1201
-     * This used to be done automatically as part of constructing the old gateways config
1202
-     *
1203
-     * @throws \EE_Error
1204
-     */
1205
-    public static function insert_default_payment_methods()
1206
-    {
1207
-        if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1208
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
1209
-            EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1210
-        } else {
1211
-            EEM_Payment_Method::instance()->verify_button_urls();
1212
-        }
1213
-    }
1214
-
1215
-    /**
1216
-     * insert_default_status_codes
1217
-     *
1218
-     * @access public
1219
-     * @static
1220
-     * @return void
1221
-     */
1222
-    public static function insert_default_status_codes()
1223
-    {
1224
-
1225
-        global $wpdb;
1226
-
1227
-        if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) {
1228
-
1229
-            $table_name = EEM_Status::instance()->table();
1230
-
1231
-            $SQL = "DELETE FROM $table_name WHERE STS_ID IN ( 'ACT', 'NAC', 'NOP', 'OPN', 'CLS', 'PND', 'ONG', 'SEC', 'DRF', 'DEL', 'DEN', 'EXP', 'RPP', 'RCN', 'RDC', 'RAP', 'RNA', 'RWL', 'TAB', 'TIN', 'TFL', 'TCM', 'TOP', 'PAP', 'PCN', 'PFL', 'PDC', 'EDR', 'ESN', 'PPN', 'RIC', 'MSN', 'MFL', 'MID', 'MRS', 'MIC', 'MDO', 'MEX' );";
1232
-            $wpdb->query($SQL);
1233
-
1234
-            $SQL = "INSERT INTO $table_name
1176
+										'event_espresso'
1177
+									),
1178
+									$QST_ID),
1179
+								'error');
1180
+							continue;
1181
+						}
1182
+					}
1183
+					// add system questions to groups
1184
+					$wpdb->insert(
1185
+						\EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'),
1186
+						array(
1187
+							'QSG_ID'    => $QSG_ID,
1188
+							'QST_ID'    => $QST_ID,
1189
+							'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++,
1190
+						),
1191
+						array('%d', '%d', '%d')
1192
+					);
1193
+				}
1194
+			}
1195
+		}
1196
+	}
1197
+
1198
+
1199
+	/**
1200
+	 * Makes sure the default payment method (Invoice) is active.
1201
+	 * This used to be done automatically as part of constructing the old gateways config
1202
+	 *
1203
+	 * @throws \EE_Error
1204
+	 */
1205
+	public static function insert_default_payment_methods()
1206
+	{
1207
+		if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1208
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
1209
+			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1210
+		} else {
1211
+			EEM_Payment_Method::instance()->verify_button_urls();
1212
+		}
1213
+	}
1214
+
1215
+	/**
1216
+	 * insert_default_status_codes
1217
+	 *
1218
+	 * @access public
1219
+	 * @static
1220
+	 * @return void
1221
+	 */
1222
+	public static function insert_default_status_codes()
1223
+	{
1224
+
1225
+		global $wpdb;
1226
+
1227
+		if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) {
1228
+
1229
+			$table_name = EEM_Status::instance()->table();
1230
+
1231
+			$SQL = "DELETE FROM $table_name WHERE STS_ID IN ( 'ACT', 'NAC', 'NOP', 'OPN', 'CLS', 'PND', 'ONG', 'SEC', 'DRF', 'DEL', 'DEN', 'EXP', 'RPP', 'RCN', 'RDC', 'RAP', 'RNA', 'RWL', 'TAB', 'TIN', 'TFL', 'TCM', 'TOP', 'PAP', 'PCN', 'PFL', 'PDC', 'EDR', 'ESN', 'PPN', 'RIC', 'MSN', 'MFL', 'MID', 'MRS', 'MIC', 'MDO', 'MEX' );";
1232
+			$wpdb->query($SQL);
1233
+
1234
+			$SQL = "INSERT INTO $table_name
1235 1235
 					(STS_ID, STS_code, STS_type, STS_can_edit, STS_desc, STS_open) VALUES
1236 1236
 					('ACT', 'ACTIVE', 'event', 0, NULL, 1),
1237 1237
 					('NAC', 'NOT_ACTIVE', 'event', 0, NULL, 0),
@@ -1271,521 +1271,521 @@  discard block
 block discarded – undo
1271 1271
 					('MID', 'IDLE', 'message', 0, NULL, 1),
1272 1272
 					('MRS', 'RESEND', 'message', 0, NULL, 1),
1273 1273
 					('MIC', 'INCOMPLETE', 'message', 0, NULL, 0);";
1274
-            $wpdb->query($SQL);
1275
-
1276
-        }
1277
-
1278
-    }
1279
-
1280
-
1281
-    /**
1282
-     * create_upload_directories
1283
-     * Creates folders in the uploads directory to facilitate addons and templates
1284
-     *
1285
-     * @access public
1286
-     * @static
1287
-     * @return boolean success of verifying upload directories exist
1288
-     */
1289
-    public static function create_upload_directories()
1290
-    {
1291
-        // Create the required folders
1292
-        $folders = array(
1293
-            EVENT_ESPRESSO_TEMPLATE_DIR,
1294
-            EVENT_ESPRESSO_GATEWAY_DIR,
1295
-            EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1296
-            EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1297
-            EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1298
-        );
1299
-        foreach ($folders as $folder) {
1300
-            try {
1301
-                EEH_File::ensure_folder_exists_and_is_writable($folder);
1302
-                @ chmod($folder, 0755);
1303
-            } catch (EE_Error $e) {
1304
-                EE_Error::add_error(
1305
-                    sprintf(
1306
-                        __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1307
-                        $folder,
1308
-                        '<br />' . $e->getMessage()
1309
-                    ),
1310
-                    __FILE__, __FUNCTION__, __LINE__
1311
-                );
1312
-                //indicate we'll need to fix this later
1313
-                update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1314
-                return false;
1315
-            }
1316
-        }
1317
-        //just add the .htaccess file to the logs directory to begin with. Even if logging
1318
-        //is disabled, there might be activation errors recorded in there
1319
-        EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1320
-        //remember EE's folders are all good
1321
-        delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1322
-        return true;
1323
-    }
1324
-
1325
-    /**
1326
-     * Whether the upload directories need to be fixed or not.
1327
-     * If EE is installed but filesystem access isn't initially available,
1328
-     * we need to get the user's filesystem credentials and THEN create them,
1329
-     * so there might be period of time when EE is installed but its
1330
-     * upload directories aren't available. This indicates such a state
1331
-     *
1332
-     * @return boolean
1333
-     */
1334
-    public static function upload_directories_incomplete()
1335
-    {
1336
-        return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1337
-    }
1338
-
1339
-
1340
-    /**
1341
-     * generate_default_message_templates
1342
-     *
1343
-     * @static
1344
-     * @throws EE_Error
1345
-     * @return bool     true means new templates were created.
1346
-     *                  false means no templates were created.
1347
-     *                  This is NOT an error flag. To check for errors you will want
1348
-     *                  to use either EE_Error or a try catch for an EE_Error exception.
1349
-     */
1350
-    public static function generate_default_message_templates()
1351
-    {
1352
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
1353
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1354
-        /*
1274
+			$wpdb->query($SQL);
1275
+
1276
+		}
1277
+
1278
+	}
1279
+
1280
+
1281
+	/**
1282
+	 * create_upload_directories
1283
+	 * Creates folders in the uploads directory to facilitate addons and templates
1284
+	 *
1285
+	 * @access public
1286
+	 * @static
1287
+	 * @return boolean success of verifying upload directories exist
1288
+	 */
1289
+	public static function create_upload_directories()
1290
+	{
1291
+		// Create the required folders
1292
+		$folders = array(
1293
+			EVENT_ESPRESSO_TEMPLATE_DIR,
1294
+			EVENT_ESPRESSO_GATEWAY_DIR,
1295
+			EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1296
+			EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1297
+			EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1298
+		);
1299
+		foreach ($folders as $folder) {
1300
+			try {
1301
+				EEH_File::ensure_folder_exists_and_is_writable($folder);
1302
+				@ chmod($folder, 0755);
1303
+			} catch (EE_Error $e) {
1304
+				EE_Error::add_error(
1305
+					sprintf(
1306
+						__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1307
+						$folder,
1308
+						'<br />' . $e->getMessage()
1309
+					),
1310
+					__FILE__, __FUNCTION__, __LINE__
1311
+				);
1312
+				//indicate we'll need to fix this later
1313
+				update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1314
+				return false;
1315
+			}
1316
+		}
1317
+		//just add the .htaccess file to the logs directory to begin with. Even if logging
1318
+		//is disabled, there might be activation errors recorded in there
1319
+		EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1320
+		//remember EE's folders are all good
1321
+		delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1322
+		return true;
1323
+	}
1324
+
1325
+	/**
1326
+	 * Whether the upload directories need to be fixed or not.
1327
+	 * If EE is installed but filesystem access isn't initially available,
1328
+	 * we need to get the user's filesystem credentials and THEN create them,
1329
+	 * so there might be period of time when EE is installed but its
1330
+	 * upload directories aren't available. This indicates such a state
1331
+	 *
1332
+	 * @return boolean
1333
+	 */
1334
+	public static function upload_directories_incomplete()
1335
+	{
1336
+		return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1337
+	}
1338
+
1339
+
1340
+	/**
1341
+	 * generate_default_message_templates
1342
+	 *
1343
+	 * @static
1344
+	 * @throws EE_Error
1345
+	 * @return bool     true means new templates were created.
1346
+	 *                  false means no templates were created.
1347
+	 *                  This is NOT an error flag. To check for errors you will want
1348
+	 *                  to use either EE_Error or a try catch for an EE_Error exception.
1349
+	 */
1350
+	public static function generate_default_message_templates()
1351
+	{
1352
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
1353
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1354
+		/*
1355 1355
          * This first method is taking care of ensuring any default messengers
1356 1356
          * that should be made active and have templates generated are done.
1357 1357
          */
1358
-        $new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates(
1359
-            $message_resource_manager
1360
-        );
1361
-        /**
1362
-         * This method is verifying there are no NEW default message types
1363
-         * for ACTIVE messengers that need activated (and corresponding templates setup).
1364
-         */
1365
-        $new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates(
1366
-            $message_resource_manager
1367
-        );
1368
-        //after all is done, let's persist these changes to the db.
1369
-        $message_resource_manager->update_has_activated_messengers_option();
1370
-        $message_resource_manager->update_active_messengers_option();
1371
-        // will return true if either of these are true.  Otherwise will return false.
1372
-        return $new_templates_created_for_message_type || $new_templates_created_for_messenger;
1373
-    }
1374
-
1375
-
1376
-
1377
-    /**
1378
-     * @param \EE_Message_Resource_Manager $message_resource_manager
1379
-     * @return array|bool
1380
-     * @throws \EE_Error
1381
-     */
1382
-    protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates(
1383
-        EE_Message_Resource_Manager $message_resource_manager
1384
-    ) {
1385
-        /** @type EE_messenger[] $active_messengers */
1386
-        $active_messengers = $message_resource_manager->active_messengers();
1387
-        $installed_message_types = $message_resource_manager->installed_message_types();
1388
-        $templates_created = false;
1389
-        foreach ($active_messengers as $active_messenger) {
1390
-            $default_message_type_names_for_messenger = $active_messenger->get_default_message_types();
1391
-            $default_message_type_names_to_activate = array();
1392
-            // looping through each default message type reported by the messenger
1393
-            // and setup the actual message types to activate.
1394
-            foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) {
1395
-                // if already active or has already been activated before we skip
1396
-                // (otherwise we might reactivate something user's intentionally deactivated.)
1397
-                // we also skip if the message type is not installed.
1398
-                if (
1399
-                    $message_resource_manager->has_message_type_been_activated_for_messenger(
1400
-                        $default_message_type_name_for_messenger,
1401
-                        $active_messenger->name
1402
-                    )
1403
-                    || $message_resource_manager->is_message_type_active_for_messenger(
1404
-                        $active_messenger->name,
1405
-                        $default_message_type_name_for_messenger
1406
-                    )
1407
-                    || ! isset($installed_message_types[$default_message_type_name_for_messenger])
1408
-                ) {
1409
-                    continue;
1410
-                }
1411
-                $default_message_type_names_to_activate[] = $default_message_type_name_for_messenger;
1412
-            }
1413
-            //let's activate!
1414
-            $message_resource_manager->ensure_message_types_are_active(
1415
-                $default_message_type_names_to_activate,
1416
-                $active_messenger->name,
1417
-                false
1418
-            );
1419
-            //activate the templates for these message types
1420
-            if ( ! empty($default_message_type_names_to_activate)) {
1421
-                $templates_created = EEH_MSG_Template::generate_new_templates(
1422
-                    $active_messenger->name,
1423
-                    $default_message_type_names_for_messenger,
1424
-                    '',
1425
-                    true
1426
-                );
1427
-            }
1428
-        }
1429
-        return $templates_created;
1430
-    }
1431
-
1432
-
1433
-
1434
-    /**
1435
-     * This will activate and generate default messengers and default message types for those messengers.
1436
-     *
1437
-     * @param EE_message_Resource_Manager $message_resource_manager
1438
-     * @return array|bool  True means there were default messengers and message type templates generated.
1439
-     *                     False means that there were no templates generated
1440
-     *                     (which could simply mean there are no default message types for a messenger).
1441
-     * @throws EE_Error
1442
-     */
1443
-    protected static function _activate_and_generate_default_messengers_and_message_templates(
1444
-        EE_Message_Resource_Manager $message_resource_manager
1445
-    ) {
1446
-        /** @type EE_messenger[] $messengers_to_generate */
1447
-        $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager);
1448
-        $installed_message_types = $message_resource_manager->installed_message_types();
1449
-        $templates_generated = false;
1450
-        foreach ($messengers_to_generate as $messenger_to_generate) {
1451
-            $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types();
1452
-            //verify the default message types match an installed message type.
1453
-            foreach ($default_message_type_names_for_messenger as $key => $name) {
1454
-                if (
1455
-                    ! isset($installed_message_types[$name])
1456
-                    || $message_resource_manager->has_message_type_been_activated_for_messenger(
1457
-                        $name,
1458
-                        $messenger_to_generate->name
1459
-                    )
1460
-                ) {
1461
-                    unset($default_message_type_names_for_messenger[$key]);
1462
-                }
1463
-            }
1464
-            // in previous iterations, the active_messengers option in the db
1465
-            // needed updated before calling create templates. however with the changes this may not be necessary.
1466
-            // This comment is left here just in case we discover that we _do_ need to update before
1467
-            // passing off to create templates (after the refactor is done).
1468
-            // @todo remove this comment when determined not necessary.
1469
-            $message_resource_manager->activate_messenger(
1470
-                $messenger_to_generate->name,
1471
-                $default_message_type_names_for_messenger,
1472
-                false
1473
-            );
1474
-            //create any templates needing created (or will reactivate templates already generated as necessary).
1475
-            if ( ! empty($default_message_type_names_for_messenger)) {
1476
-                $templates_generated = EEH_MSG_Template::generate_new_templates(
1477
-                    $messenger_to_generate->name,
1478
-                    $default_message_type_names_for_messenger,
1479
-                    '',
1480
-                    true
1481
-                );
1482
-            }
1483
-        }
1484
-        return $templates_generated;
1485
-    }
1486
-
1487
-
1488
-    /**
1489
-     * This returns the default messengers to generate templates for on activation of EE.
1490
-     * It considers:
1491
-     * - whether a messenger is already active in the db.
1492
-     * - whether a messenger has been made active at any time in the past.
1493
-     *
1494
-     * @static
1495
-     * @param  EE_Message_Resource_Manager $message_resource_manager
1496
-     * @return EE_messenger[]
1497
-     */
1498
-    protected static function _get_default_messengers_to_generate_on_activation(
1499
-        EE_Message_Resource_Manager $message_resource_manager
1500
-    ) {
1501
-        $active_messengers    = $message_resource_manager->active_messengers();
1502
-        $installed_messengers = $message_resource_manager->installed_messengers();
1503
-        $has_activated        = $message_resource_manager->get_has_activated_messengers_option();
1504
-
1505
-        $messengers_to_generate = array();
1506
-        foreach ($installed_messengers as $installed_messenger) {
1507
-            //if installed messenger is a messenger that should be activated on install
1508
-            //and is not already active
1509
-            //and has never been activated
1510
-            if (
1511
-                ! $installed_messenger->activate_on_install
1512
-                || isset($active_messengers[$installed_messenger->name])
1513
-                || isset($has_activated[$installed_messenger->name])
1514
-            ) {
1515
-                continue;
1516
-            }
1517
-            $messengers_to_generate[$installed_messenger->name] = $installed_messenger;
1518
-        }
1519
-        return $messengers_to_generate;
1520
-    }
1521
-
1522
-
1523
-    /**
1524
-     * This simply validates active message types to ensure they actually match installed
1525
-     * message types.  If there's a mismatch then we deactivate the message type and ensure all related db
1526
-     * rows are set inactive.
1527
-     * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever
1528
-     * EE_Messenger_Resource_Manager is constructed.  Message Types are a bit more resource heavy for validation so they
1529
-     * are still handled in here.
1530
-     *
1531
-     * @since 4.3.1
1532
-     * @return void
1533
-     */
1534
-    public static function validate_messages_system()
1535
-    {
1536
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
1537
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1538
-        $message_resource_manager->validate_active_message_types_are_installed();
1539
-        do_action('AHEE__EEH_Activation__validate_messages_system');
1540
-    }
1541
-
1542
-
1543
-    /**
1544
-     * create_no_ticket_prices_array
1545
-     *
1546
-     * @access public
1547
-     * @static
1548
-     * @return void
1549
-     */
1550
-    public static function create_no_ticket_prices_array()
1551
-    {
1552
-        // this creates an array for tracking events that have no active ticket prices created
1553
-        // this allows us to warn admins of the situation so that it can be corrected
1554
-        $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1555
-        if (! $espresso_no_ticket_prices) {
1556
-            add_option('ee_no_ticket_prices', array(), '', false);
1557
-        }
1558
-    }
1559
-
1560
-
1561
-    /**
1562
-     * plugin_deactivation
1563
-     *
1564
-     * @access public
1565
-     * @static
1566
-     * @return void
1567
-     */
1568
-    public static function plugin_deactivation()
1569
-    {
1570
-    }
1571
-
1572
-
1573
-    /**
1574
-     * Finds all our EE4 custom post types, and deletes them and their associated data
1575
-     * (like post meta or term relations)
1576
-     *
1577
-     * @global wpdb $wpdb
1578
-     * @throws \EE_Error
1579
-     */
1580
-    public static function delete_all_espresso_cpt_data()
1581
-    {
1582
-        global $wpdb;
1583
-        //get all the CPT post_types
1584
-        $ee_post_types = array();
1585
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1586
-            if (method_exists($model_name, 'instance')) {
1587
-                $model_obj = call_user_func(array($model_name, 'instance'));
1588
-                if ($model_obj instanceof EEM_CPT_Base) {
1589
-                    $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1590
-                }
1591
-            }
1592
-        }
1593
-        //get all our CPTs
1594
-        $query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1595
-        $cpt_ids = $wpdb->get_col($query);
1596
-        //delete each post meta and term relations too
1597
-        foreach ($cpt_ids as $post_id) {
1598
-            wp_delete_post($post_id, true);
1599
-        }
1600
-    }
1601
-
1602
-    /**
1603
-     * Deletes all EE custom tables
1604
-     *
1605
-     * @return array
1606
-     */
1607
-    public static function drop_espresso_tables()
1608
-    {
1609
-        $tables = array();
1610
-        // load registry
1611
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1612
-            if (method_exists($model_name, 'instance')) {
1613
-                $model_obj = call_user_func(array($model_name, 'instance'));
1614
-                if ($model_obj instanceof EEM_Base) {
1615
-                    foreach ($model_obj->get_tables() as $table) {
1616
-                        if (strpos($table->get_table_name(), 'esp_')
1617
-                            &&
1618
-                            (
1619
-                                is_main_site()//main site? nuke them all
1620
-                                || ! $table->is_global()//not main site,but not global either. nuke it
1621
-                            )
1622
-                        ) {
1623
-                            $tables[] = $table->get_table_name();
1624
-                        }
1625
-                    }
1626
-                }
1627
-            }
1628
-        }
1629
-
1630
-        //there are some tables whose models were removed.
1631
-        //they should be removed when removing all EE core's data
1632
-        $tables_without_models = array(
1633
-            'esp_promotion',
1634
-            'esp_promotion_applied',
1635
-            'esp_promotion_object',
1636
-            'esp_promotion_rule',
1637
-            'esp_rule',
1638
-        );
1639
-        foreach ($tables_without_models as $table) {
1640
-            $tables[] = $table;
1641
-        }
1642
-        return \EEH_Activation::getTableManager()->dropTables($tables);
1643
-    }
1644
-
1645
-
1646
-
1647
-    /**
1648
-     * Drops all the tables mentioned in a single MYSQL query. Double-checks
1649
-     * each table name provided has a wpdb prefix attached, and that it exists.
1650
-     * Returns the list actually deleted
1651
-     *
1652
-     * @deprecated in 4.9.13. Instead use TableManager::dropTables()
1653
-     * @global WPDB $wpdb
1654
-     * @param array $table_names
1655
-     * @return array of table names which we deleted
1656
-     */
1657
-    public static function drop_tables($table_names)
1658
-    {
1659
-        return \EEH_Activation::getTableManager()->dropTables($table_names);
1660
-    }
1661
-
1662
-
1663
-
1664
-    /**
1665
-     * plugin_uninstall
1666
-     *
1667
-     * @access public
1668
-     * @static
1669
-     * @param bool $remove_all
1670
-     * @return void
1671
-     */
1672
-    public static function delete_all_espresso_tables_and_data($remove_all = true)
1673
-    {
1674
-        global $wpdb;
1675
-        self::drop_espresso_tables();
1676
-        $wp_options_to_delete = array(
1677
-            'ee_no_ticket_prices'                => true,
1678
-            'ee_active_messengers'               => true,
1679
-            'ee_has_activated_messenger'         => true,
1680
-            'ee_flush_rewrite_rules'             => true,
1681
-            'ee_config'                          => false,
1682
-            'ee_data_migration_current_db_state' => true,
1683
-            'ee_data_migration_mapping_'         => false,
1684
-            'ee_data_migration_script_'          => false,
1685
-            'ee_data_migrations'                 => true,
1686
-            'ee_dms_map'                         => false,
1687
-            'ee_notices'                         => true,
1688
-            'lang_file_check_'                   => false,
1689
-            'ee_maintenance_mode'                => true,
1690
-            'ee_ueip_optin'                      => true,
1691
-            'ee_ueip_has_notified'               => true,
1692
-            'ee_plugin_activation_errors'        => true,
1693
-            'ee_id_mapping_from'                 => false,
1694
-            'espresso_persistent_admin_notices'  => true,
1695
-            'ee_encryption_key'                  => true,
1696
-            'pue_force_upgrade_'                 => false,
1697
-            'pue_json_error_'                    => false,
1698
-            'pue_install_key_'                   => false,
1699
-            'pue_verification_error_'            => false,
1700
-            'pu_dismissed_upgrade_'              => false,
1701
-            'external_updates-'                  => false,
1702
-            'ee_extra_data'                      => true,
1703
-            'ee_ssn_'                            => false,
1704
-            'ee_rss_'                            => false,
1705
-            'ee_rte_n_tx_'                       => false,
1706
-            'ee_pers_admin_notices'              => true,
1707
-            'ee_job_parameters_'                 => false,
1708
-            'ee_upload_directories_incomplete'   => true,
1709
-            'ee_verified_db_collations'          => true,
1710
-        );
1711
-        if (is_main_site()) {
1712
-            $wp_options_to_delete['ee_network_config'] = true;
1713
-        }
1714
-        $undeleted_options = array();
1715
-        foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1716
-            if ($no_wildcard) {
1717
-                if ( ! delete_option($option_name)) {
1718
-                    $undeleted_options[] = $option_name;
1719
-                }
1720
-            } else {
1721
-                $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1722
-                foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1723
-                    if ( ! delete_option($option_name_from_wildcard)) {
1724
-                        $undeleted_options[] = $option_name_from_wildcard;
1725
-                    }
1726
-                }
1727
-            }
1728
-        }
1729
-        //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1730
-        remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1731
-        if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1732
-            $db_update_sans_ee4 = array();
1733
-            foreach ($espresso_db_update as $version => $times_activated) {
1734
-                if ((string)$version[0] === '3') {//if its NON EE4
1735
-                    $db_update_sans_ee4[$version] = $times_activated;
1736
-                }
1737
-            }
1738
-            update_option('espresso_db_update', $db_update_sans_ee4);
1739
-        }
1740
-        $errors = '';
1741
-        if ( ! empty($undeleted_options)) {
1742
-            $errors .= sprintf(
1743
-                __('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1744
-                '<br/>',
1745
-                implode(',<br/>', $undeleted_options)
1746
-            );
1747
-        }
1748
-        if ( ! empty($errors)) {
1749
-            EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1750
-        }
1751
-    }
1752
-
1753
-    /**
1754
-     * Gets the mysql error code from the last used query by wpdb
1755
-     *
1756
-     * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
1757
-     */
1758
-    public static function last_wpdb_error_code()
1759
-    {
1760
-        global $wpdb;
1761
-        if ($wpdb->use_mysqli) {
1762
-            return mysqli_errno($wpdb->dbh);
1763
-        } else {
1764
-            return mysql_errno($wpdb->dbh);
1765
-        }
1766
-    }
1767
-
1768
-    /**
1769
-     * Checks that the database table exists. Also works on temporary tables (for unit tests mostly).
1770
-     *
1771
-     * @global wpdb  $wpdb
1772
-     * @deprecated instead use TableAnalysis::tableExists()
1773
-     * @param string $table_name with or without $wpdb->prefix
1774
-     * @return boolean
1775
-     */
1776
-    public static function table_exists($table_name)
1777
-    {
1778
-        return \EEH_Activation::getTableAnalysis()->tableExists($table_name);
1779
-    }
1780
-
1781
-    /**
1782
-     * Resets the cache on EEH_Activation
1783
-     */
1784
-    public static function reset()
1785
-    {
1786
-        self::$_default_creator_id                             = null;
1787
-        self::$_initialized_db_content_already_in_this_request = false;
1788
-    }
1358
+		$new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates(
1359
+			$message_resource_manager
1360
+		);
1361
+		/**
1362
+		 * This method is verifying there are no NEW default message types
1363
+		 * for ACTIVE messengers that need activated (and corresponding templates setup).
1364
+		 */
1365
+		$new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates(
1366
+			$message_resource_manager
1367
+		);
1368
+		//after all is done, let's persist these changes to the db.
1369
+		$message_resource_manager->update_has_activated_messengers_option();
1370
+		$message_resource_manager->update_active_messengers_option();
1371
+		// will return true if either of these are true.  Otherwise will return false.
1372
+		return $new_templates_created_for_message_type || $new_templates_created_for_messenger;
1373
+	}
1374
+
1375
+
1376
+
1377
+	/**
1378
+	 * @param \EE_Message_Resource_Manager $message_resource_manager
1379
+	 * @return array|bool
1380
+	 * @throws \EE_Error
1381
+	 */
1382
+	protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates(
1383
+		EE_Message_Resource_Manager $message_resource_manager
1384
+	) {
1385
+		/** @type EE_messenger[] $active_messengers */
1386
+		$active_messengers = $message_resource_manager->active_messengers();
1387
+		$installed_message_types = $message_resource_manager->installed_message_types();
1388
+		$templates_created = false;
1389
+		foreach ($active_messengers as $active_messenger) {
1390
+			$default_message_type_names_for_messenger = $active_messenger->get_default_message_types();
1391
+			$default_message_type_names_to_activate = array();
1392
+			// looping through each default message type reported by the messenger
1393
+			// and setup the actual message types to activate.
1394
+			foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) {
1395
+				// if already active or has already been activated before we skip
1396
+				// (otherwise we might reactivate something user's intentionally deactivated.)
1397
+				// we also skip if the message type is not installed.
1398
+				if (
1399
+					$message_resource_manager->has_message_type_been_activated_for_messenger(
1400
+						$default_message_type_name_for_messenger,
1401
+						$active_messenger->name
1402
+					)
1403
+					|| $message_resource_manager->is_message_type_active_for_messenger(
1404
+						$active_messenger->name,
1405
+						$default_message_type_name_for_messenger
1406
+					)
1407
+					|| ! isset($installed_message_types[$default_message_type_name_for_messenger])
1408
+				) {
1409
+					continue;
1410
+				}
1411
+				$default_message_type_names_to_activate[] = $default_message_type_name_for_messenger;
1412
+			}
1413
+			//let's activate!
1414
+			$message_resource_manager->ensure_message_types_are_active(
1415
+				$default_message_type_names_to_activate,
1416
+				$active_messenger->name,
1417
+				false
1418
+			);
1419
+			//activate the templates for these message types
1420
+			if ( ! empty($default_message_type_names_to_activate)) {
1421
+				$templates_created = EEH_MSG_Template::generate_new_templates(
1422
+					$active_messenger->name,
1423
+					$default_message_type_names_for_messenger,
1424
+					'',
1425
+					true
1426
+				);
1427
+			}
1428
+		}
1429
+		return $templates_created;
1430
+	}
1431
+
1432
+
1433
+
1434
+	/**
1435
+	 * This will activate and generate default messengers and default message types for those messengers.
1436
+	 *
1437
+	 * @param EE_message_Resource_Manager $message_resource_manager
1438
+	 * @return array|bool  True means there were default messengers and message type templates generated.
1439
+	 *                     False means that there were no templates generated
1440
+	 *                     (which could simply mean there are no default message types for a messenger).
1441
+	 * @throws EE_Error
1442
+	 */
1443
+	protected static function _activate_and_generate_default_messengers_and_message_templates(
1444
+		EE_Message_Resource_Manager $message_resource_manager
1445
+	) {
1446
+		/** @type EE_messenger[] $messengers_to_generate */
1447
+		$messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager);
1448
+		$installed_message_types = $message_resource_manager->installed_message_types();
1449
+		$templates_generated = false;
1450
+		foreach ($messengers_to_generate as $messenger_to_generate) {
1451
+			$default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types();
1452
+			//verify the default message types match an installed message type.
1453
+			foreach ($default_message_type_names_for_messenger as $key => $name) {
1454
+				if (
1455
+					! isset($installed_message_types[$name])
1456
+					|| $message_resource_manager->has_message_type_been_activated_for_messenger(
1457
+						$name,
1458
+						$messenger_to_generate->name
1459
+					)
1460
+				) {
1461
+					unset($default_message_type_names_for_messenger[$key]);
1462
+				}
1463
+			}
1464
+			// in previous iterations, the active_messengers option in the db
1465
+			// needed updated before calling create templates. however with the changes this may not be necessary.
1466
+			// This comment is left here just in case we discover that we _do_ need to update before
1467
+			// passing off to create templates (after the refactor is done).
1468
+			// @todo remove this comment when determined not necessary.
1469
+			$message_resource_manager->activate_messenger(
1470
+				$messenger_to_generate->name,
1471
+				$default_message_type_names_for_messenger,
1472
+				false
1473
+			);
1474
+			//create any templates needing created (or will reactivate templates already generated as necessary).
1475
+			if ( ! empty($default_message_type_names_for_messenger)) {
1476
+				$templates_generated = EEH_MSG_Template::generate_new_templates(
1477
+					$messenger_to_generate->name,
1478
+					$default_message_type_names_for_messenger,
1479
+					'',
1480
+					true
1481
+				);
1482
+			}
1483
+		}
1484
+		return $templates_generated;
1485
+	}
1486
+
1487
+
1488
+	/**
1489
+	 * This returns the default messengers to generate templates for on activation of EE.
1490
+	 * It considers:
1491
+	 * - whether a messenger is already active in the db.
1492
+	 * - whether a messenger has been made active at any time in the past.
1493
+	 *
1494
+	 * @static
1495
+	 * @param  EE_Message_Resource_Manager $message_resource_manager
1496
+	 * @return EE_messenger[]
1497
+	 */
1498
+	protected static function _get_default_messengers_to_generate_on_activation(
1499
+		EE_Message_Resource_Manager $message_resource_manager
1500
+	) {
1501
+		$active_messengers    = $message_resource_manager->active_messengers();
1502
+		$installed_messengers = $message_resource_manager->installed_messengers();
1503
+		$has_activated        = $message_resource_manager->get_has_activated_messengers_option();
1504
+
1505
+		$messengers_to_generate = array();
1506
+		foreach ($installed_messengers as $installed_messenger) {
1507
+			//if installed messenger is a messenger that should be activated on install
1508
+			//and is not already active
1509
+			//and has never been activated
1510
+			if (
1511
+				! $installed_messenger->activate_on_install
1512
+				|| isset($active_messengers[$installed_messenger->name])
1513
+				|| isset($has_activated[$installed_messenger->name])
1514
+			) {
1515
+				continue;
1516
+			}
1517
+			$messengers_to_generate[$installed_messenger->name] = $installed_messenger;
1518
+		}
1519
+		return $messengers_to_generate;
1520
+	}
1521
+
1522
+
1523
+	/**
1524
+	 * This simply validates active message types to ensure they actually match installed
1525
+	 * message types.  If there's a mismatch then we deactivate the message type and ensure all related db
1526
+	 * rows are set inactive.
1527
+	 * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever
1528
+	 * EE_Messenger_Resource_Manager is constructed.  Message Types are a bit more resource heavy for validation so they
1529
+	 * are still handled in here.
1530
+	 *
1531
+	 * @since 4.3.1
1532
+	 * @return void
1533
+	 */
1534
+	public static function validate_messages_system()
1535
+	{
1536
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
1537
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1538
+		$message_resource_manager->validate_active_message_types_are_installed();
1539
+		do_action('AHEE__EEH_Activation__validate_messages_system');
1540
+	}
1541
+
1542
+
1543
+	/**
1544
+	 * create_no_ticket_prices_array
1545
+	 *
1546
+	 * @access public
1547
+	 * @static
1548
+	 * @return void
1549
+	 */
1550
+	public static function create_no_ticket_prices_array()
1551
+	{
1552
+		// this creates an array for tracking events that have no active ticket prices created
1553
+		// this allows us to warn admins of the situation so that it can be corrected
1554
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1555
+		if (! $espresso_no_ticket_prices) {
1556
+			add_option('ee_no_ticket_prices', array(), '', false);
1557
+		}
1558
+	}
1559
+
1560
+
1561
+	/**
1562
+	 * plugin_deactivation
1563
+	 *
1564
+	 * @access public
1565
+	 * @static
1566
+	 * @return void
1567
+	 */
1568
+	public static function plugin_deactivation()
1569
+	{
1570
+	}
1571
+
1572
+
1573
+	/**
1574
+	 * Finds all our EE4 custom post types, and deletes them and their associated data
1575
+	 * (like post meta or term relations)
1576
+	 *
1577
+	 * @global wpdb $wpdb
1578
+	 * @throws \EE_Error
1579
+	 */
1580
+	public static function delete_all_espresso_cpt_data()
1581
+	{
1582
+		global $wpdb;
1583
+		//get all the CPT post_types
1584
+		$ee_post_types = array();
1585
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1586
+			if (method_exists($model_name, 'instance')) {
1587
+				$model_obj = call_user_func(array($model_name, 'instance'));
1588
+				if ($model_obj instanceof EEM_CPT_Base) {
1589
+					$ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1590
+				}
1591
+			}
1592
+		}
1593
+		//get all our CPTs
1594
+		$query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1595
+		$cpt_ids = $wpdb->get_col($query);
1596
+		//delete each post meta and term relations too
1597
+		foreach ($cpt_ids as $post_id) {
1598
+			wp_delete_post($post_id, true);
1599
+		}
1600
+	}
1601
+
1602
+	/**
1603
+	 * Deletes all EE custom tables
1604
+	 *
1605
+	 * @return array
1606
+	 */
1607
+	public static function drop_espresso_tables()
1608
+	{
1609
+		$tables = array();
1610
+		// load registry
1611
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1612
+			if (method_exists($model_name, 'instance')) {
1613
+				$model_obj = call_user_func(array($model_name, 'instance'));
1614
+				if ($model_obj instanceof EEM_Base) {
1615
+					foreach ($model_obj->get_tables() as $table) {
1616
+						if (strpos($table->get_table_name(), 'esp_')
1617
+							&&
1618
+							(
1619
+								is_main_site()//main site? nuke them all
1620
+								|| ! $table->is_global()//not main site,but not global either. nuke it
1621
+							)
1622
+						) {
1623
+							$tables[] = $table->get_table_name();
1624
+						}
1625
+					}
1626
+				}
1627
+			}
1628
+		}
1629
+
1630
+		//there are some tables whose models were removed.
1631
+		//they should be removed when removing all EE core's data
1632
+		$tables_without_models = array(
1633
+			'esp_promotion',
1634
+			'esp_promotion_applied',
1635
+			'esp_promotion_object',
1636
+			'esp_promotion_rule',
1637
+			'esp_rule',
1638
+		);
1639
+		foreach ($tables_without_models as $table) {
1640
+			$tables[] = $table;
1641
+		}
1642
+		return \EEH_Activation::getTableManager()->dropTables($tables);
1643
+	}
1644
+
1645
+
1646
+
1647
+	/**
1648
+	 * Drops all the tables mentioned in a single MYSQL query. Double-checks
1649
+	 * each table name provided has a wpdb prefix attached, and that it exists.
1650
+	 * Returns the list actually deleted
1651
+	 *
1652
+	 * @deprecated in 4.9.13. Instead use TableManager::dropTables()
1653
+	 * @global WPDB $wpdb
1654
+	 * @param array $table_names
1655
+	 * @return array of table names which we deleted
1656
+	 */
1657
+	public static function drop_tables($table_names)
1658
+	{
1659
+		return \EEH_Activation::getTableManager()->dropTables($table_names);
1660
+	}
1661
+
1662
+
1663
+
1664
+	/**
1665
+	 * plugin_uninstall
1666
+	 *
1667
+	 * @access public
1668
+	 * @static
1669
+	 * @param bool $remove_all
1670
+	 * @return void
1671
+	 */
1672
+	public static function delete_all_espresso_tables_and_data($remove_all = true)
1673
+	{
1674
+		global $wpdb;
1675
+		self::drop_espresso_tables();
1676
+		$wp_options_to_delete = array(
1677
+			'ee_no_ticket_prices'                => true,
1678
+			'ee_active_messengers'               => true,
1679
+			'ee_has_activated_messenger'         => true,
1680
+			'ee_flush_rewrite_rules'             => true,
1681
+			'ee_config'                          => false,
1682
+			'ee_data_migration_current_db_state' => true,
1683
+			'ee_data_migration_mapping_'         => false,
1684
+			'ee_data_migration_script_'          => false,
1685
+			'ee_data_migrations'                 => true,
1686
+			'ee_dms_map'                         => false,
1687
+			'ee_notices'                         => true,
1688
+			'lang_file_check_'                   => false,
1689
+			'ee_maintenance_mode'                => true,
1690
+			'ee_ueip_optin'                      => true,
1691
+			'ee_ueip_has_notified'               => true,
1692
+			'ee_plugin_activation_errors'        => true,
1693
+			'ee_id_mapping_from'                 => false,
1694
+			'espresso_persistent_admin_notices'  => true,
1695
+			'ee_encryption_key'                  => true,
1696
+			'pue_force_upgrade_'                 => false,
1697
+			'pue_json_error_'                    => false,
1698
+			'pue_install_key_'                   => false,
1699
+			'pue_verification_error_'            => false,
1700
+			'pu_dismissed_upgrade_'              => false,
1701
+			'external_updates-'                  => false,
1702
+			'ee_extra_data'                      => true,
1703
+			'ee_ssn_'                            => false,
1704
+			'ee_rss_'                            => false,
1705
+			'ee_rte_n_tx_'                       => false,
1706
+			'ee_pers_admin_notices'              => true,
1707
+			'ee_job_parameters_'                 => false,
1708
+			'ee_upload_directories_incomplete'   => true,
1709
+			'ee_verified_db_collations'          => true,
1710
+		);
1711
+		if (is_main_site()) {
1712
+			$wp_options_to_delete['ee_network_config'] = true;
1713
+		}
1714
+		$undeleted_options = array();
1715
+		foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1716
+			if ($no_wildcard) {
1717
+				if ( ! delete_option($option_name)) {
1718
+					$undeleted_options[] = $option_name;
1719
+				}
1720
+			} else {
1721
+				$option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1722
+				foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1723
+					if ( ! delete_option($option_name_from_wildcard)) {
1724
+						$undeleted_options[] = $option_name_from_wildcard;
1725
+					}
1726
+				}
1727
+			}
1728
+		}
1729
+		//also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1730
+		remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1731
+		if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1732
+			$db_update_sans_ee4 = array();
1733
+			foreach ($espresso_db_update as $version => $times_activated) {
1734
+				if ((string)$version[0] === '3') {//if its NON EE4
1735
+					$db_update_sans_ee4[$version] = $times_activated;
1736
+				}
1737
+			}
1738
+			update_option('espresso_db_update', $db_update_sans_ee4);
1739
+		}
1740
+		$errors = '';
1741
+		if ( ! empty($undeleted_options)) {
1742
+			$errors .= sprintf(
1743
+				__('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1744
+				'<br/>',
1745
+				implode(',<br/>', $undeleted_options)
1746
+			);
1747
+		}
1748
+		if ( ! empty($errors)) {
1749
+			EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1750
+		}
1751
+	}
1752
+
1753
+	/**
1754
+	 * Gets the mysql error code from the last used query by wpdb
1755
+	 *
1756
+	 * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
1757
+	 */
1758
+	public static function last_wpdb_error_code()
1759
+	{
1760
+		global $wpdb;
1761
+		if ($wpdb->use_mysqli) {
1762
+			return mysqli_errno($wpdb->dbh);
1763
+		} else {
1764
+			return mysql_errno($wpdb->dbh);
1765
+		}
1766
+	}
1767
+
1768
+	/**
1769
+	 * Checks that the database table exists. Also works on temporary tables (for unit tests mostly).
1770
+	 *
1771
+	 * @global wpdb  $wpdb
1772
+	 * @deprecated instead use TableAnalysis::tableExists()
1773
+	 * @param string $table_name with or without $wpdb->prefix
1774
+	 * @return boolean
1775
+	 */
1776
+	public static function table_exists($table_name)
1777
+	{
1778
+		return \EEH_Activation::getTableAnalysis()->tableExists($table_name);
1779
+	}
1780
+
1781
+	/**
1782
+	 * Resets the cache on EEH_Activation
1783
+	 */
1784
+	public static function reset()
1785
+	{
1786
+		self::$_default_creator_id                             = null;
1787
+		self::$_initialized_db_content_already_in_this_request = false;
1788
+	}
1789 1789
 }
1790 1790
 // End of file EEH_Activation.helper.php
1791 1791
 // Location: /helpers/EEH_Activation.core.php
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public static function getTableAnalysis()
63 63
     {
64
-        if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
64
+        if ( ! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
65 65
             self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
66 66
         }
67 67
         return self::$table_analysis;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public static function getTableManager()
75 75
     {
76
-        if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
76
+        if ( ! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
77 77
             self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true);
78 78
         }
79 79
         return self::$table_manager;
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
         if ($which_to_include === 'old') {
190 190
             $cron_tasks = array_filter(
191 191
                 $cron_tasks,
192
-                function ($value) {
192
+                function($value) {
193 193
                     return $value === EEH_Activation::cron_task_no_longer_in_use;
194 194
                 }
195 195
             );
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
     {
220 220
 
221 221
         foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
222
-            if (! wp_next_scheduled($hook_name)) {
222
+            if ( ! wp_next_scheduled($hook_name)) {
223 223
                 /**
224 224
                  * This allows client code to define the initial start timestamp for this schedule.
225 225
                  */
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
             3
325 325
         );
326 326
         //EE_Config::reset();
327
-        if (! EE_Config::logging_enabled()) {
327
+        if ( ! EE_Config::logging_enabled()) {
328 328
             delete_option(EE_Config::LOG_NAME);
329 329
         }
330 330
     }
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
     public static function load_calendar_config()
340 340
     {
341 341
         // grab array of all plugin folders and loop thru it
342
-        $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
342
+        $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR);
343 343
         if (empty($plugins)) {
344 344
             return;
345 345
         }
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
                 || strpos($plugin, 'calendar') !== false
357 357
             ) {
358 358
                 // this is what we are looking for
359
-                $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
359
+                $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php';
360 360
                 // does it exist in this folder ?
361 361
                 if (is_readable($calendar_config)) {
362 362
                     // YEAH! let's load it
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
             ) {
490 490
                 //update Config with post ID
491 491
                 $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
492
-                if (! EE_Config::instance()->update_espresso_config(false, false)) {
492
+                if ( ! EE_Config::instance()->update_espresso_config(false, false)) {
493 493
                     $msg = __(
494 494
                         'The Event Espresso critical page configuration settings could not be updated.',
495 495
                         'event_espresso'
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
     public static function get_page_by_ee_shortcode($ee_shortcode)
539 539
     {
540 540
         global $wpdb;
541
-        $shortcode_and_opening_bracket = '[' . $ee_shortcode;
541
+        $shortcode_and_opening_bracket = '['.$ee_shortcode;
542 542
         $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
543 543
         if ($post_id) {
544 544
             return get_post($post_id);
@@ -564,11 +564,11 @@  discard block
 block discarded – undo
564 564
             'post_status'    => 'publish',
565 565
             'post_type'      => 'page',
566 566
             'comment_status' => 'closed',
567
-            'post_content'   => '[' . $critical_page['code'] . ']',
567
+            'post_content'   => '['.$critical_page['code'].']',
568 568
         );
569 569
 
570 570
         $post_id = wp_insert_post($post_args);
571
-        if (! $post_id) {
571
+        if ( ! $post_id) {
572 572
             $msg = sprintf(
573 573
                 __('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
574 574
                 $critical_page['name']
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
             return $critical_page;
578 578
         }
579 579
         // get newly created post's details
580
-        if (! $critical_page['post'] = get_post($post_id)) {
580
+        if ( ! $critical_page['post'] = get_post($post_id)) {
581 581
             $msg = sprintf(
582 582
                 __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
583 583
                 $critical_page['name']
@@ -664,17 +664,17 @@  discard block
 block discarded – undo
664 664
             $role_to_check
665 665
         );
666 666
         if ($pre_filtered_id !== false) {
667
-            return (int)$pre_filtered_id;
667
+            return (int) $pre_filtered_id;
668 668
         }
669 669
         $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
670 670
         $query = $wpdb->prepare(
671 671
             "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
672
-            '%' . $role_to_check . '%'
672
+            '%'.$role_to_check.'%'
673 673
         );
674 674
         $user_id = $wpdb->get_var($query);
675 675
         $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
676
-        if ($user_id && (int)$user_id) {
677
-            self::$_default_creator_id = (int)$user_id;
676
+        if ($user_id && (int) $user_id) {
677
+            self::$_default_creator_id = (int) $user_id;
678 678
             return self::$_default_creator_id;
679 679
         } else {
680 680
             return null;
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
         }
710 710
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
711 711
         if ( ! function_exists('dbDelta')) {
712
-            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
712
+            require_once(ABSPATH.'wp-admin/includes/upgrade.php');
713 713
         }
714 714
         $tableAnalysis = \EEH_Activation::getTableAnalysis();
715 715
         $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
@@ -920,13 +920,13 @@  discard block
 block discarded – undo
920 920
             // reset values array
921 921
             $QSG_values = array();
922 922
             // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
923
-            if (! in_array("$QSG_system", $question_groups)) {
923
+            if ( ! in_array("$QSG_system", $question_groups)) {
924 924
                 // add it
925 925
                 switch ($QSG_system) {
926 926
                     case 1:
927 927
                         $QSG_values = array(
928 928
                             'QSG_name'            => __('Personal Information', 'event_espresso'),
929
-                            'QSG_identifier'      => 'personal-information-' . time(),
929
+                            'QSG_identifier'      => 'personal-information-'.time(),
930 930
                             'QSG_desc'            => '',
931 931
                             'QSG_order'           => 1,
932 932
                             'QSG_show_group_name' => 1,
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
                     case 2:
939 939
                         $QSG_values = array(
940 940
                             'QSG_name'            => __('Address Information', 'event_espresso'),
941
-                            'QSG_identifier'      => 'address-information-' . time(),
941
+                            'QSG_identifier'      => 'address-information-'.time(),
942 942
                             'QSG_desc'            => '',
943 943
                             'QSG_order'           => 2,
944 944
                             'QSG_show_group_name' => 1,
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
                         break;
950 950
                 }
951 951
                 // make sure we have some values before inserting them
952
-                if (! empty($QSG_values)) {
952
+                if ( ! empty($QSG_values)) {
953 953
                     // insert system question
954 954
                     $wpdb->insert(
955 955
                         $table_name,
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
             // reset values array
987 987
             $QST_values = array();
988 988
             // if we don't have what we should have
989
-            if (! in_array($QST_system, $questions)) {
989
+            if ( ! in_array($QST_system, $questions)) {
990 990
                 // add it
991 991
                 switch ($QST_system) {
992 992
                     case 'fname':
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
                         );
1139 1139
                         break;
1140 1140
                 }
1141
-                if (! empty($QST_values)) {
1141
+                if ( ! empty($QST_values)) {
1142 1142
                     // insert system question
1143 1143
                     $wpdb->insert(
1144 1144
                         $table_name,
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
      */
1200 1200
     public static function insert_default_payment_methods()
1201 1201
     {
1202
-        if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1202
+        if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1203 1203
             EE_Registry::instance()->load_lib('Payment_Method_Manager');
1204 1204
             EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1205 1205
         } else {
@@ -1287,9 +1287,9 @@  discard block
 block discarded – undo
1287 1287
         $folders = array(
1288 1288
             EVENT_ESPRESSO_TEMPLATE_DIR,
1289 1289
             EVENT_ESPRESSO_GATEWAY_DIR,
1290
-            EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1291
-            EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1292
-            EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1290
+            EVENT_ESPRESSO_UPLOAD_DIR.'logs/',
1291
+            EVENT_ESPRESSO_UPLOAD_DIR.'css/',
1292
+            EVENT_ESPRESSO_UPLOAD_DIR.'tickets/',
1293 1293
         );
1294 1294
         foreach ($folders as $folder) {
1295 1295
             try {
@@ -1300,7 +1300,7 @@  discard block
 block discarded – undo
1300 1300
                     sprintf(
1301 1301
                         __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1302 1302
                         $folder,
1303
-                        '<br />' . $e->getMessage()
1303
+                        '<br />'.$e->getMessage()
1304 1304
                     ),
1305 1305
                     __FILE__, __FUNCTION__, __LINE__
1306 1306
                 );
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
         }
1312 1312
         //just add the .htaccess file to the logs directory to begin with. Even if logging
1313 1313
         //is disabled, there might be activation errors recorded in there
1314
-        EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1314
+        EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/');
1315 1315
         //remember EE's folders are all good
1316 1316
         delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1317 1317
         return true;
@@ -1547,7 +1547,7 @@  discard block
 block discarded – undo
1547 1547
         // this creates an array for tracking events that have no active ticket prices created
1548 1548
         // this allows us to warn admins of the situation so that it can be corrected
1549 1549
         $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1550
-        if (! $espresso_no_ticket_prices) {
1550
+        if ( ! $espresso_no_ticket_prices) {
1551 1551
             add_option('ee_no_ticket_prices', array(), '', false);
1552 1552
         }
1553 1553
     }
@@ -1586,7 +1586,7 @@  discard block
 block discarded – undo
1586 1586
             }
1587 1587
         }
1588 1588
         //get all our CPTs
1589
-        $query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1589
+        $query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")";
1590 1590
         $cpt_ids = $wpdb->get_col($query);
1591 1591
         //delete each post meta and term relations too
1592 1592
         foreach ($cpt_ids as $post_id) {
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
         if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1727 1727
             $db_update_sans_ee4 = array();
1728 1728
             foreach ($espresso_db_update as $version => $times_activated) {
1729
-                if ((string)$version[0] === '3') {//if its NON EE4
1729
+                if ((string) $version[0] === '3') {//if its NON EE4
1730 1730
                     $db_update_sans_ee4[$version] = $times_activated;
1731 1731
                 }
1732 1732
             }
Please login to merge, or discard this patch.
admin_pages/messages/templates/ee_msg_messages_help_tab.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,3 +1,3 @@
 block discarded – undo
1 1
 <h2><?php esc_html_e('What is the Event Espresso Messages System?', 'event_espresso'); ?></h2>
2
-<p><?php printf( esc_html__('The Event Espresso Messages system is a powerful framework that Event Espresso uses to prepare %1$smessages%2$s for different types of use (message types) and delivered by different %1$smessengers%2$s.', 'event_espresso'), '<strong>', '</strong>' ); ?></p>
2
+<p><?php printf(esc_html__('The Event Espresso Messages system is a powerful framework that Event Espresso uses to prepare %1$smessages%2$s for different types of use (message types) and delivered by different %1$smessengers%2$s.', 'event_espresso'), '<strong>', '</strong>'); ?></p>
3 3
 <p><?php esc_html_e('We\'ve intentionally created this framework so that we have as much flexibility as possible for future ideas that we think of (or customers think of) for the kinds of messages that get sent out related to your events.', 'event_espresso'); ?></p>
4 4
\ No newline at end of file
Please login to merge, or discard this patch.
messages/defaults/default/email_payment_cancelled_content.template.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,35 +31,35 @@  discard block
 block discarded – undo
31 31
 						<tbody>
32 32
 							<tr>
33 33
 								<td>
34
-									<h2><?php printf( esc_html__( 'Hello, %s:', 'event_espresso' ), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]' ); ?></h2>
35
-									<p class="lead"><?php printf( esc_html__( 'Your payment was %1$sCANCELLED%2$s for the following transaction and ticket purchases:', 'event_espresso' ), '<strong>', '</strong>'); ?></p>
36
-									<h3><?php esc_html_e( 'Payment Details:', 'event_espresso' ); ?></h3>
34
+									<h2><?php printf(esc_html__('Hello, %s:', 'event_espresso'), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]'); ?></h2>
35
+									<p class="lead"><?php printf(esc_html__('Your payment was %1$sCANCELLED%2$s for the following transaction and ticket purchases:', 'event_espresso'), '<strong>', '</strong>'); ?></p>
36
+									<h3><?php esc_html_e('Payment Details:', 'event_espresso'); ?></h3>
37 37
 									<ul>
38 38
 										<li>
39
-											<strong><?php esc_html_e( 'Payment Status:', 'event_espresso' ); ?></strong> [PAYMENT_STATUS]
39
+											<strong><?php esc_html_e('Payment Status:', 'event_espresso'); ?></strong> [PAYMENT_STATUS]
40 40
 										</li>
41 41
 										<li>
42
-											<strong><?php esc_html_e( 'Transaction ID:', 'event_espresso' ); ?></strong> [TXN_ID]
42
+											<strong><?php esc_html_e('Transaction ID:', 'event_espresso'); ?></strong> [TXN_ID]
43 43
 										</li>
44 44
 										<li>
45
-											<strong><?php esc_html_e( 'Total Cost:', 'event_espresso' ); ?></strong> [TOTAL_COST]
45
+											<strong><?php esc_html_e('Total Cost:', 'event_espresso'); ?></strong> [TOTAL_COST]
46 46
 										</li>
47 47
 										<li>
48
-											<strong><?php esc_html_e( 'Payment Method:', 'event_espresso' ); ?></strong> [PAYMENT_GATEWAY]
48
+											<strong><?php esc_html_e('Payment Method:', 'event_espresso'); ?></strong> [PAYMENT_GATEWAY]
49 49
 										</li>
50 50
 										<li>
51
-											<strong><?php esc_html_e( 'Payment Amount:', 'event_espresso' ); ?></strong> [AMOUNT_PAID]
51
+											<strong><?php esc_html_e('Payment Amount:', 'event_espresso'); ?></strong> [AMOUNT_PAID]
52 52
 										</li>
53 53
 										<li>
54
-											<strong><?php esc_html_e( 'Amount Due:', 'event_espresso' ); ?></strong> [TOTAL_OWING]
54
+											<strong><?php esc_html_e('Amount Due:', 'event_espresso'); ?></strong> [TOTAL_OWING]
55 55
 										</li>
56 56
 									</ul>
57 57
 									<p class="callout">
58
-										<?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?>
58
+										<?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?>
59 59
 									</p>
60 60
 									[EVENT_LIST]
61 61
 									<p class="callout">
62
-										<?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?>
62
+										<?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?>
63 63
 									</p>
64 64
 								</td>
65 65
 							</tr>
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
 									<tbody>
85 85
 										<tr>
86 86
 											<td>
87
-												<h3><?php esc_html_e( 'Connect with Us:', 'event_espresso' ); ?></h3>
88
-												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e( 'Facebook', 'event_espresso' ); ?></a>
89
-												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e( 'Twitter', 'event_espresso' ); ?></a>
90
-												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e( 'Google+', 'event_espresso' ); ?></a>
87
+												<h3><?php esc_html_e('Connect with Us:', 'event_espresso'); ?></h3>
88
+												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e('Facebook', 'event_espresso'); ?></a>
89
+												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e('Twitter', 'event_espresso'); ?></a>
90
+												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e('Google+', 'event_espresso'); ?></a>
91 91
 											</td>
92 92
 										</tr>
93 93
 									</tbody>
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 									<tbody>
98 98
 										<tr>
99 99
 											<td>
100
-												<h3><?php esc_html_e( 'Contact Info:', 'event_espresso' ); ?></h3>
101
-												<?php esc_html_e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong>
102
-												<?php esc_html_e( 'Email:', 'event_espresso' ); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong>
100
+												<h3><?php esc_html_e('Contact Info:', 'event_espresso'); ?></h3>
101
+												<?php esc_html_e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong>
102
+												<?php esc_html_e('Email:', 'event_espresso'); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong>
103 103
 											</td>
104 104
 										</tr>
105 105
 									</tbody>
Please login to merge, or discard this patch.
messages/defaults/default/email_payment_declined_content.template.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,35 +31,35 @@  discard block
 block discarded – undo
31 31
 						<tbody>
32 32
 							<tr>
33 33
 								<td>
34
-									<h2><?php printf( esc_html__( 'Hello, %s:', 'event_espresso' ), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]' ); ?></h2>
35
-									<p class="lead"><?php printf( esc_html__( 'Your payment was %1$sDECLINED%2$s for the following transaction and ticket purchases:', 'event_espresso' ), '<strong>', '</strong>') ?></p>
36
-									<h3><?php esc_html_e( 'Payment Details:', 'event_espresso' ); ?></h3>
34
+									<h2><?php printf(esc_html__('Hello, %s:', 'event_espresso'), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]'); ?></h2>
35
+									<p class="lead"><?php printf(esc_html__('Your payment was %1$sDECLINED%2$s for the following transaction and ticket purchases:', 'event_espresso'), '<strong>', '</strong>') ?></p>
36
+									<h3><?php esc_html_e('Payment Details:', 'event_espresso'); ?></h3>
37 37
 									<ul>
38 38
 										<li>
39
-											<strong><?php esc_html_e( 'Payment Status:', 'event_espresso' ); ?></strong> [PAYMENT_STATUS]
39
+											<strong><?php esc_html_e('Payment Status:', 'event_espresso'); ?></strong> [PAYMENT_STATUS]
40 40
 										</li>
41 41
 										<li>
42
-											<strong><?php esc_html_e( 'Transaction ID:', 'event_espresso' ); ?></strong> [TXN_ID]
42
+											<strong><?php esc_html_e('Transaction ID:', 'event_espresso'); ?></strong> [TXN_ID]
43 43
 										</li>
44 44
 										<li>
45
-											<strong><?php esc_html_e( 'Total Cost:', 'event_espresso' ); ?></strong> [TOTAL_COST]
45
+											<strong><?php esc_html_e('Total Cost:', 'event_espresso'); ?></strong> [TOTAL_COST]
46 46
 										</li>
47 47
 										<li>
48
-											<strong><?php esc_html_e( 'Payment Method:', 'event_espresso' ); ?></strong> [PAYMENT_GATEWAY]
48
+											<strong><?php esc_html_e('Payment Method:', 'event_espresso'); ?></strong> [PAYMENT_GATEWAY]
49 49
 										</li>
50 50
 										<li>
51
-											<strong><?php esc_html_e( 'Payment Amount:', 'event_espresso' ); ?></strong> [AMOUNT_PAID]
51
+											<strong><?php esc_html_e('Payment Amount:', 'event_espresso'); ?></strong> [AMOUNT_PAID]
52 52
 										</li>
53 53
 										<li>
54
-											<strong><?php esc_html_e( 'Amount Due:', 'event_espresso' ); ?></strong> [TOTAL_OWING]
54
+											<strong><?php esc_html_e('Amount Due:', 'event_espresso'); ?></strong> [TOTAL_OWING]
55 55
 										</li>
56 56
 									</ul>
57 57
 									<p class="callout">
58
-										<?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?>
58
+										<?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?>
59 59
 									</p>
60 60
 									[EVENT_LIST]
61 61
 									<p class="callout">
62
-										<?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?>
62
+										<?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?>
63 63
 									</p>
64 64
 								</td>
65 65
 							</tr>
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
 									<tbody>
85 85
 										<tr>
86 86
 											<td>
87
-												<h3><?php esc_html_e( 'Connect with Us:', 'event_espresso' ); ?></h3>
88
-												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e( 'Facebook', 'event_espresso' ); ?></a>
89
-												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e( 'Twitter', 'event_espresso' ); ?></a>
90
-												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e( 'Google+', 'event_espresso' ); ?></a>
87
+												<h3><?php esc_html_e('Connect with Us:', 'event_espresso'); ?></h3>
88
+												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e('Facebook', 'event_espresso'); ?></a>
89
+												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e('Twitter', 'event_espresso'); ?></a>
90
+												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e('Google+', 'event_espresso'); ?></a>
91 91
 											</td>
92 92
 										</tr>
93 93
 									</tbody>
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 									<tbody>
98 98
 										<tr>
99 99
 											<td>
100
-												<h3><?php esc_html_e( 'Contact Info:', 'event_espresso' ); ?></h3>
101
-												<?php esc_html_e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong>
102
-												<?php esc_html_e( 'Email:', 'event_espresso' ); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong>
100
+												<h3><?php esc_html_e('Contact Info:', 'event_espresso'); ?></h3>
101
+												<?php esc_html_e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong>
102
+												<?php esc_html_e('Email:', 'event_espresso'); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong>
103 103
 											</td>
104 104
 										</tr>
105 105
 									</tbody>
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_Loader.core.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -402,21 +402,21 @@
 block discarded – undo
402 402
 		$class_name = $this->_get_classname_for_admin_init_page( $page );
403 403
  		EE_Registry::instance()->load_file( $path, $class_name, 'core' );
404 404
 		if ( ! class_exists( $class_name )) {
405
-            $inner_error_msg = '<br />' . sprintf(
406
-                esc_html__(
407
-                    'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
408
-                    'event_espresso'
409
-                ),
410
-                '<strong>' . $class_name . '</strong>'
411
-            );
405
+			$inner_error_msg = '<br />' . sprintf(
406
+				esc_html__(
407
+					'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
408
+					'event_espresso'
409
+				),
410
+				'<strong>' . $class_name . '</strong>'
411
+			);
412 412
 			$error_msg[] = sprintf( __('Something went wrong with loading the %s admin page.', 'event_espresso' ), $page);
413 413
 			$error_msg[] = $error_msg[0]
414
-                           . "\r\n"
415
-                           . sprintf(
416
-                               esc_html__( 'There is no Init class in place for the %s admin page.', 'event_espresso'),
417
-                               $page
418
-                           )
419
-                           . $inner_error_msg;
414
+						   . "\r\n"
415
+						   . sprintf(
416
+							   esc_html__( 'There is no Init class in place for the %s admin page.', 'event_espresso'),
417
+							   $page
418
+						   )
419
+						   . $inner_error_msg;
420 420
 			throw new EE_Error( implode( '||', $error_msg ));
421 421
 		}
422 422
 		$a = new ReflectionClass($class_name);
Please login to merge, or discard this patch.
Spacing   +124 added lines, -124 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
 /**
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 		//let's do a scan and see what installed pages we have
120 120
 		$this->_get_installed_pages();
121 121
 		//set menus (has to be done on every load - we're not actually loading the page just setting the menus and where they point to).
122
-		add_action('admin_menu', array( $this, 'set_menus' ));
123
-		add_action( 'network_admin_menu', array( $this, 'set_network_menus' ) );
122
+		add_action('admin_menu', array($this, 'set_menus'));
123
+		add_action('network_admin_menu', array($this, 'set_network_menus'));
124 124
 	}
125 125
 
126 126
 
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 	 * @return void
134 134
 	 */
135 135
 	private function _define_caffeinated_constants() {
136
-		if ( ! defined( 'EE_CORE_CAF_ADMIN'  ) ) {
137
-			define( 'EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/');
138
-			define( 'EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/');
139
-			define( 'EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/');
140
-			define( 'EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/');
141
-			define( 'EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/');
142
-			define( 'EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/');
136
+		if ( ! defined('EE_CORE_CAF_ADMIN')) {
137
+			define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH.'caffeinated/admin/');
138
+			define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL.'caffeinated/admin/');
139
+			define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN.'new/');
140
+			define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN.'extend/');
141
+			define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL.'extend/');
142
+			define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN.'hooks/');
143 143
 		}
144 144
 	}
145 145
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 		//set array of EE_Admin_Page_Menu_Group objects
160 160
 		$groups = array(
161
-			'main' => new EE_Admin_Page_Menu_Group( array(
161
+			'main' => new EE_Admin_Page_Menu_Group(array(
162 162
 				'menu_label' => __('Main', 'event_espresso'),
163 163
 				'show_on_menu' => EE_Admin_Page_Menu_Map::NONE,
164 164
 				'menu_slug' => 'main',
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 				'menu_order' => 0,
167 167
 				'parent_slug' => 'espresso_events',
168 168
 				)),
169
-			'management' => new EE_Admin_Page_Menu_Group( array(
169
+			'management' => new EE_Admin_Page_Menu_Group(array(
170 170
 				'menu_label' => __('Management', 'event_espresso'),
171 171
 				'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
172 172
 				'menu_slug' => 'management',
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 				'menu_order' => 10,
175 175
 				'parent_slug' => 'espresso_events'
176 176
 				)),
177
-			'settings' => new EE_Admin_Page_Menu_Group( array(
177
+			'settings' => new EE_Admin_Page_Menu_Group(array(
178 178
 				'menu_label' => __('Settings', 'event_espresso'),
179 179
 				'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
180 180
 				'menu_slug' => 'settings',
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 				'menu_order' => 30,
183 183
 				'parent_slug' => 'espresso_events'
184 184
 				)),
185
-			'templates' => new EE_Admin_Page_Menu_Group( array(
185
+			'templates' => new EE_Admin_Page_Menu_Group(array(
186 186
 				'menu_label' => __('Templates', 'event_espresso'),
187 187
 				'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
188 188
 				'menu_slug' => 'templates',
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 				'menu_order' => 40,
191 191
 				'parent_slug' => 'espresso_events'
192 192
 				)),
193
-			'extras' => new EE_Admin_Page_Menu_Group( array(
193
+			'extras' => new EE_Admin_Page_Menu_Group(array(
194 194
 				'menu_label' => __('Extras', 'event_espresso'),
195 195
 				'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
196 196
 				'menu_slug' => 'extras',
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 				'parent_slug' => 'espresso_events',
200 200
 				'maintenance_mode_parent' => 'espresso_maintenance_settings'
201 201
 				)),
202
-			'tools' => new EE_Admin_Page_Menu_Group( array(
202
+			'tools' => new EE_Admin_Page_Menu_Group(array(
203 203
 				'menu_label' => __("Tools", "event_espresso"),
204 204
 				'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
205 205
 				'menu_slug' => 'tools',
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 				'menu_order' => 60,
208 208
 				'parent_slug' => 'espresso_events'
209 209
 				)),
210
-			'addons' => new EE_Admin_Page_Menu_Group( array(
210
+			'addons' => new EE_Admin_Page_Menu_Group(array(
211 211
 				'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
212 212
 				'menu_label' => __('Add-ons', 'event_espresso'),
213 213
 				'menu_slug' => 'addons',
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 				))
218 218
 			);
219 219
 
220
-		$this->_admin_menu_groups = apply_filters( 'FHEE__EE_Admin_Page_Loader___set_menu_groups__admin_menu_groups', $groups );
220
+		$this->_admin_menu_groups = apply_filters('FHEE__EE_Admin_Page_Loader___set_menu_groups__admin_menu_groups', $groups);
221 221
 	}
222 222
 
223 223
 
@@ -235,10 +235,10 @@  discard block
 block discarded – undo
235 235
 	private function _rearrange_menu_groups() {
236 236
 		$groups = array();
237 237
 		//first let's order the menu groups by their internal menu order (note usort type hinting to ensure the incoming array is EE_Admin_Page_Menu_Map objects )
238
-		usort( $this->_admin_menu_groups, array( $this, '_sort_menu_maps' ) );
239
-		foreach ( $this->_admin_menu_groups as $group ) {
240
-			if ( ! $group instanceof EE_Admin_Page_Menu_Group )
241
-				throw new EE_Error( sprintf( __('Unable to continue sorting the menu groups array because there is an invalid value for the menu groups.  All values in this array are required to be a EE_Admin_Page_Menu_Group object.  Instead there was: %s', 'event_espresso'), print_r($group, TRUE) ) );
238
+		usort($this->_admin_menu_groups, array($this, '_sort_menu_maps'));
239
+		foreach ($this->_admin_menu_groups as $group) {
240
+			if ( ! $group instanceof EE_Admin_Page_Menu_Group)
241
+				throw new EE_Error(sprintf(__('Unable to continue sorting the menu groups array because there is an invalid value for the menu groups.  All values in this array are required to be a EE_Admin_Page_Menu_Group object.  Instead there was: %s', 'event_espresso'), print_r($group, TRUE)));
242 242
 			$groups[$group->menu_slug] = $group;
243 243
 		}
244 244
 		return $groups;
@@ -256,48 +256,48 @@  discard block
 block discarded – undo
256 256
 	 */
257 257
 	private function _get_installed_pages() {
258 258
 		$installed_refs = array();
259
-		$exclude = array( 'assets', 'templates' );
259
+		$exclude = array('assets', 'templates');
260 260
 		// grab everything in the  admin core directory
261
-		$admin_screens = glob( EE_ADMIN_PAGES . '*', GLOB_ONLYDIR );
262
-		if ( $admin_screens ) {
263
-			foreach( $admin_screens as $admin_screen ) {
261
+		$admin_screens = glob(EE_ADMIN_PAGES.'*', GLOB_ONLYDIR);
262
+		if ($admin_screens) {
263
+			foreach ($admin_screens as $admin_screen) {
264 264
 				// files and anything in the exclude array need not apply
265
-				if ( is_dir( $admin_screen ) && ! in_array( basename( $admin_screen ), $exclude )) {
265
+				if (is_dir($admin_screen) && ! in_array(basename($admin_screen), $exclude)) {
266 266
 					// these folders represent the different EE admin pages
267
-					$installed_refs[ basename( $admin_screen ) ] = $admin_screen;
267
+					$installed_refs[basename($admin_screen)] = $admin_screen;
268 268
 				}
269 269
 			}
270 270
 		}
271 271
 
272
-		if ( empty( $installed_refs ) ) {
272
+		if (empty($installed_refs)) {
273 273
 			$error_msg[] = __('There are no EE_Admin pages detected, it looks like EE did not install properly', 'event_espresso');
274
-			$error_msg[] = $error_msg[0] . "\r\n" . sprintf( __('Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.', 'event_espresso'), EE_ADMIN_PAGES );
275
-			throw new EE_Error( implode( '||', $error_msg ));
274
+			$error_msg[] = $error_msg[0]."\r\n".sprintf(__('Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.', 'event_espresso'), EE_ADMIN_PAGES);
275
+			throw new EE_Error(implode('||', $error_msg));
276 276
 		}
277 277
 
278 278
 		//this just checks the caffeinated folder and takes care of setting up any caffeinated stuff.
279 279
 		$installed_refs = $this->_set_caffeinated($installed_refs);
280 280
 		//allow plugins to add in their own pages (note at this point they will need to have an autoloader defined for their class) OR hook into EEH_Autoloader::load_admin_page() to add their path.;
281
-		$installed_refs = apply_filters( 'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', $installed_refs );
282
-		$this->_caffeinated_extends = apply_filters( 'FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends', $this->_caffeinated_extends );
281
+		$installed_refs = apply_filters('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', $installed_refs);
282
+		$this->_caffeinated_extends = apply_filters('FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends', $this->_caffeinated_extends);
283 283
 
284 284
 		//loop through admin pages and setup the $_installed_pages array.
285 285
 		$hooks_ref = array();
286
-		foreach ( $installed_refs as $page => $path ) {
286
+		foreach ($installed_refs as $page => $path) {
287 287
 			// set autoloaders for our admin page classes based on included path information
288
-			EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( $path );
288
+			EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($path);
289 289
 			// build list of installed pages
290
-			$this->_installed_pages[$page] = $this->_load_admin_page( $page, $path );
290
+			$this->_installed_pages[$page] = $this->_load_admin_page($page, $path);
291 291
 			// verify returned object
292
-			if ( $this->_installed_pages[$page] instanceof EE_Admin_Page_Init ) {
293
-				if ( ! $this->_installed_pages[$page]->get_menu_map() instanceof EE_Admin_Page_Menu_Map ) {
292
+			if ($this->_installed_pages[$page] instanceof EE_Admin_Page_Init) {
293
+				if ( ! $this->_installed_pages[$page]->get_menu_map() instanceof EE_Admin_Page_Menu_Map) {
294 294
 					continue;
295 295
 				}
296 296
 
297 297
 				//skip if in full maintenance mode and maintenance_mode_parent is set
298 298
 				$maintenance_mode_parent = $this->_installed_pages[$page]->get_menu_map()->maintenance_mode_parent;
299
-				if ( empty( $maintenance_mode_parent ) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) {
300
-					unset( $installed_refs[$page] );
299
+				if (empty($maintenance_mode_parent) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) {
300
+					unset($installed_refs[$page]);
301 301
 					continue;
302 302
 				}
303 303
 
@@ -305,45 +305,45 @@  discard block
 block discarded – undo
305 305
 				//flag for register hooks on extended pages b/c extended pages use the default INIT.
306 306
 				$extend = FALSE;
307 307
 				//now that we've got the admin_init objects... lets see if there are any caffeinated pages extending the originals.  If there are then let's hook into the init admin filter and load our extend instead.
308
-				if ( isset( $this->_caffeinated_extends[$page] ) ) {
308
+				if (isset($this->_caffeinated_extends[$page])) {
309 309
 					$this->_current_caf_extend_slug = $page;
310
-					$path_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__' . $this->_installed_pages[$page]->get_menu_map()->menu_slug . '_' . $this->_installed_pages[$page]->get_admin_page_name();
311
-					$path_runtime = 'return "' . $this->_caffeinated_extends[$this->_current_caf_extend_slug]["path"] . '";';
312
-					$page_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__' . $this->_installed_pages[$page]->get_menu_map()->menu_slug . '_' . $this->_installed_pages[$page]->get_admin_page_name();
313
-					$page_runtime = 'return "' . $this->_caffeinated_extends[$this->_current_caf_extend_slug]["admin_page"] . '";';
310
+					$path_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__'.$this->_installed_pages[$page]->get_menu_map()->menu_slug.'_'.$this->_installed_pages[$page]->get_admin_page_name();
311
+					$path_runtime = 'return "'.$this->_caffeinated_extends[$this->_current_caf_extend_slug]["path"].'";';
312
+					$page_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__'.$this->_installed_pages[$page]->get_menu_map()->menu_slug.'_'.$this->_installed_pages[$page]->get_admin_page_name();
313
+					$page_runtime = 'return "'.$this->_caffeinated_extends[$this->_current_caf_extend_slug]["admin_page"].'";';
314 314
 
315
-					$hook_function_path = create_function( '$path_to_file', $path_runtime);
316
-					$hook_function_page = create_function( '$admin_page', $page_runtime );
315
+					$hook_function_path = create_function('$path_to_file', $path_runtime);
316
+					$hook_function_page = create_function('$admin_page', $page_runtime);
317 317
 
318
-					add_filter( $path_hook, $hook_function_path );
319
-					add_filter( $page_hook, $hook_function_page );
318
+					add_filter($path_hook, $hook_function_path);
319
+					add_filter($page_hook, $hook_function_page);
320 320
 					$extend = TRUE;
321 321
 				}
322 322
 				//let's do the registered hooks
323
-				$extended_hooks = $this->_installed_pages[$page]->register_hooks( $extend );
323
+				$extended_hooks = $this->_installed_pages[$page]->register_hooks($extend);
324 324
 				$hooks_ref = array_merge($hooks_ref, $extended_hooks);
325 325
 			}
326 326
 		}
327 327
 
328 328
 		//the hooks_ref is all the pages where we have $extended _Hooks files that will extend a class in a different folder.  So we want to make sure we load the file for the parent.
329 329
 		//first make sure we've got unique values
330
-		$hooks_ref = array_unique( $hooks_ref );
330
+		$hooks_ref = array_unique($hooks_ref);
331 331
 		//now let's loop and require!
332
-		foreach ( $hooks_ref as $path ) {
333
-			require_once( $path );
332
+		foreach ($hooks_ref as $path) {
333
+			require_once($path);
334 334
 		}
335 335
 		//make sure we have menu slugs global setup. Used in EE_Admin_Page->page_setup() to ensure we don't do a full class load for an admin page that isn't requested.
336 336
 		global $ee_menu_slugs;
337 337
 		$ee_menu_slugs = $this->_menu_slugs;
338 338
 
339 339
 		//we need to loop again to run any early code
340
-		foreach ( $installed_refs as $page => $path ) {
341
-			if ( $this->_installed_pages[$page] instanceof EE_Admin_Page_Init ) {
340
+		foreach ($installed_refs as $page => $path) {
341
+			if ($this->_installed_pages[$page] instanceof EE_Admin_Page_Init) {
342 342
 				$this->_installed_pages[$page]->do_initial_loads();
343 343
 			}
344 344
 		}
345 345
 
346
-		do_action( 'AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages );
346
+		do_action('AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages);
347 347
 
348 348
 	}
349 349
 
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 	 * @param string $page_slug
356 356
 	 * @return EE_Admin_Page
357 357
 	 */
358
-	public function get_admin_page_object( $page_slug = '' ) {
359
-		if ( isset( $this->_installed_pages[ $page_slug ] )) {
360
-			return $this->_installed_pages[ $page_slug ]->loaded_page_object();
358
+	public function get_admin_page_object($page_slug = '') {
359
+		if (isset($this->_installed_pages[$page_slug])) {
360
+			return $this->_installed_pages[$page_slug]->loaded_page_object();
361 361
 		}
362 362
 		return NULL;
363 363
 	}
@@ -370,9 +370,9 @@  discard block
 block discarded – undo
370 370
 	 * @param $dir_name
371 371
 	 * @return string
372 372
 	 */
373
-	private function _get_classname_for_admin_page( $dir_name = '' ) {
374
-		$class_name = str_replace( '_', ' ', strtolower( $dir_name ));
375
-		return str_replace( ' ', '_', ucwords( $class_name )) . '_Admin_Page';
373
+	private function _get_classname_for_admin_page($dir_name = '') {
374
+		$class_name = str_replace('_', ' ', strtolower($dir_name));
375
+		return str_replace(' ', '_', ucwords($class_name)).'_Admin_Page';
376 376
 	}
377 377
 
378 378
 
@@ -383,9 +383,9 @@  discard block
 block discarded – undo
383 383
 	 * @param $dir_name
384 384
 	 * @return string
385 385
 	 */
386
-	private function _get_classname_for_admin_init_page( $dir_name = '' ) {
387
-		$class_name = str_replace( '_', ' ', strtolower( $dir_name ));
388
-		return str_replace( ' ', '_', ucwords( $class_name )) . '_Admin_Page_Init';
386
+	private function _get_classname_for_admin_init_page($dir_name = '') {
387
+		$class_name = str_replace('_', ' ', strtolower($dir_name));
388
+		return str_replace(' ', '_', ucwords($class_name)).'_Admin_Page_Init';
389 389
 	}
390 390
 
391 391
 
@@ -398,26 +398,26 @@  discard block
 block discarded – undo
398 398
 	 * @throws EE_Error
399 399
 	 * @return object|bool  return page object if valid, bool false if not.
400 400
 	 */
401
-	private function _load_admin_page( $page = '', $path = '' ) {
402
-		$class_name = $this->_get_classname_for_admin_init_page( $page );
403
- 		EE_Registry::instance()->load_file( $path, $class_name, 'core' );
404
-		if ( ! class_exists( $class_name )) {
405
-            $inner_error_msg = '<br />' . sprintf(
401
+	private function _load_admin_page($page = '', $path = '') {
402
+		$class_name = $this->_get_classname_for_admin_init_page($page);
403
+ 		EE_Registry::instance()->load_file($path, $class_name, 'core');
404
+		if ( ! class_exists($class_name)) {
405
+            $inner_error_msg = '<br />'.sprintf(
406 406
                 esc_html__(
407 407
                     'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
408 408
                     'event_espresso'
409 409
                 ),
410
-                '<strong>' . $class_name . '</strong>'
410
+                '<strong>'.$class_name.'</strong>'
411 411
             );
412
-			$error_msg[] = sprintf( __('Something went wrong with loading the %s admin page.', 'event_espresso' ), $page);
412
+			$error_msg[] = sprintf(__('Something went wrong with loading the %s admin page.', 'event_espresso'), $page);
413 413
 			$error_msg[] = $error_msg[0]
414 414
                            . "\r\n"
415 415
                            . sprintf(
416
-                               esc_html__( 'There is no Init class in place for the %s admin page.', 'event_espresso'),
416
+                               esc_html__('There is no Init class in place for the %s admin page.', 'event_espresso'),
417 417
                                $page
418 418
                            )
419 419
                            . $inner_error_msg;
420
-			throw new EE_Error( implode( '||', $error_msg ));
420
+			throw new EE_Error(implode('||', $error_msg));
421 421
 		}
422 422
 		$a = new ReflectionClass($class_name);
423 423
 		return  $a->newInstance();
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
 	public function set_menus() {
437 437
 		//prep the menu pages (sort, group.)
438 438
 		$this->_prep_pages();
439
-		foreach( $this->_prepped_menu_maps as $menu_map ) {
440
-			if ( EE_Registry::instance()->CAP->current_user_can( $menu_map->capability, $menu_map->menu_slug ) ) {
441
-				$menu_map->add_menu_page( FALSE );
439
+		foreach ($this->_prepped_menu_maps as $menu_map) {
440
+			if (EE_Registry::instance()->CAP->current_user_can($menu_map->capability, $menu_map->menu_slug)) {
441
+				$menu_map->add_menu_page(FALSE);
442 442
 			}
443 443
 		}
444 444
 	}
@@ -451,11 +451,11 @@  discard block
 block discarded – undo
451 451
 	 *
452 452
 	 * @return void
453 453
 	 */
454
-	public function set_network_menus(){
454
+	public function set_network_menus() {
455 455
 		$this->_prep_pages();
456
-		foreach( $this->_prepped_menu_maps as $menu_map ) {
457
-			if ( EE_Registry::instance()->CAP->current_user_can( $menu_map->capability, $menu_map->menu_slug ) ) {
458
-				$menu_map->add_menu_page( TRUE );
456
+		foreach ($this->_prepped_menu_maps as $menu_map) {
457
+			if (EE_Registry::instance()->CAP->current_user_can($menu_map->capability, $menu_map->menu_slug)) {
458
+				$menu_map->add_menu_page(TRUE);
459 459
 			}
460 460
 		}
461 461
 	}
@@ -476,22 +476,22 @@  discard block
 block discarded – undo
476 476
 		//rearrange _admin_menu_groups to be indexed by group slug.
477 477
 		$menu_groups = $this->_rearrange_menu_groups();
478 478
 
479
-		foreach( $this->_installed_pages as $page ) {
480
-			if ( $page instanceof EE_Admin_page_Init ) {
479
+		foreach ($this->_installed_pages as $page) {
480
+			if ($page instanceof EE_Admin_page_Init) {
481 481
 				$page_map = $page->get_menu_map();
482 482
 				//if we've got an array then the menu map is in the old format so let's throw a persistent notice that the admin system isn't setup correctly for this item.
483
-				if ( is_array( $page_map ) || empty( $page_map ) ) {
484
-					EE_Error::add_persistent_admin_notice( 'menu_map_warning_' . str_replace(' ', '_', $page->label) . '_' . EVENT_ESPRESSO_VERSION, sprintf( __('The admin page for %s was not correctly setup because it is using an older method for integrating with Event Espresso Core.  This means that full functionality for this component is not available.  This error message usually appears with an Add-on that is out of date.  Make sure you update all your Event Espresso 4 add-ons to the latest version to ensure they have necessary compatibility updates in place.', 'event_espresso' ), $page->label ) );
483
+				if (is_array($page_map) || empty($page_map)) {
484
+					EE_Error::add_persistent_admin_notice('menu_map_warning_'.str_replace(' ', '_', $page->label).'_'.EVENT_ESPRESSO_VERSION, sprintf(__('The admin page for %s was not correctly setup because it is using an older method for integrating with Event Espresso Core.  This means that full functionality for this component is not available.  This error message usually appears with an Add-on that is out of date.  Make sure you update all your Event Espresso 4 add-ons to the latest version to ensure they have necessary compatibility updates in place.', 'event_espresso'), $page->label));
485 485
 					continue;
486 486
 				}
487 487
 
488 488
 				//if page map is NOT a EE_Admin_Page_Menu_Map object then throw error.
489
-				if ( ! $page_map instanceof EE_Admin_Page_Menu_Map ) {
490
-					throw new EE_Error( sprintf( __('The menu map for %s must be an EE_Admin_Page_Menu_Map object.  Instead it is %s.  Please double check that the menu map has been configured correctly.', 'event_espresso'), $page->label, $page_map ) );
489
+				if ( ! $page_map instanceof EE_Admin_Page_Menu_Map) {
490
+					throw new EE_Error(sprintf(__('The menu map for %s must be an EE_Admin_Page_Menu_Map object.  Instead it is %s.  Please double check that the menu map has been configured correctly.', 'event_espresso'), $page->label, $page_map));
491 491
 				}
492 492
 
493 493
 				//use the maintenance_mode_parent property and maintenance mode status to determine if this page even gets added to array.
494
-				if ( empty( $page_map->maintenance_mode_parent ) &&  EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) {
494
+				if (empty($page_map->maintenance_mode_parent) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) {
495 495
 					continue;
496 496
 				}
497 497
 
@@ -500,21 +500,21 @@  discard block
 block discarded – undo
500 500
 			}
501 501
 		}
502 502
 
503
-		if ( empty( $pages_array )) {
504
-			throw new EE_Error(__('Something went wrong when prepping the admin pages', 'event_espresso') );
503
+		if (empty($pages_array)) {
504
+			throw new EE_Error(__('Something went wrong when prepping the admin pages', 'event_espresso'));
505 505
 		}
506 506
 
507 507
 		//let's sort the groups, make sure it's a valid group, add header (if to show).
508
-		foreach ( $pages_array as $group => $menu_maps ) {
508
+		foreach ($pages_array as $group => $menu_maps) {
509 509
 			//valid_group?
510
-			if ( ! array_key_exists( $group, $menu_groups ) )
510
+			if ( ! array_key_exists($group, $menu_groups))
511 511
 				continue;
512 512
 
513 513
 			//sort pages.
514
-			usort( $menu_maps, array( $this, '_sort_menu_maps' ) );
514
+			usort($menu_maps, array($this, '_sort_menu_maps'));
515 515
 
516 516
 			//prepend header
517
-			array_unshift( $menu_maps, $menu_groups[$group] );
517
+			array_unshift($menu_maps, $menu_groups[$group]);
518 518
 
519 519
 			//reset $pages_array with prepped data
520 520
 			$pages_array[$group] = $menu_maps;
@@ -522,9 +522,9 @@  discard block
 block discarded – undo
522 522
 
523 523
 
524 524
 		//now let's setup the _prepped_menu_maps property
525
-		foreach ( $menu_groups as $group => $group_objs ) {
526
-			if ( isset( $pages_array[$group] ) )
527
-				$this->_prepped_menu_maps = array_merge( $this->_prepped_menu_maps, $pages_array[$group] );
525
+		foreach ($menu_groups as $group => $group_objs) {
526
+			if (isset($pages_array[$group]))
527
+				$this->_prepped_menu_maps = array_merge($this->_prepped_menu_maps, $pages_array[$group]);
528 528
 		}/**/
529 529
 
530 530
 	}
@@ -544,10 +544,10 @@  discard block
 block discarded – undo
544 544
 	 * @param array $installed_refs the original installed_refs array that may contain our NEW EE_Admin_Pages to be loaded.
545 545
 	 * @return array
546 546
 	 */
547
-	private function _set_caffeinated( $installed_refs ) {
547
+	private function _set_caffeinated($installed_refs) {
548 548
 
549 549
 		//first let's check if there IS a caffeinated folder. If there is not then lets get out.
550
-		if ( ! is_dir( EE_PLUGIN_DIR_PATH . 'caffeinated' . DS . 'admin' ) || ( defined( 'EE_DECAF' ) && EE_DECAF )) {
550
+		if ( ! is_dir(EE_PLUGIN_DIR_PATH.'caffeinated'.DS.'admin') || (defined('EE_DECAF') && EE_DECAF)) {
551 551
 			return $installed_refs;
552 552
 		}
553 553
 
@@ -556,15 +556,15 @@  discard block
 block discarded – undo
556 556
 		$exclude = array('tickets');
557 557
 
558 558
 		//okay let's setup an "New" pages first (we'll return installed refs later)
559
-		$new_admin_screens = glob( EE_CORE_CAF_ADMIN . 'new/*', GLOB_ONLYDIR );
560
-		if ( $new_admin_screens ) {
561
-			foreach( $new_admin_screens as $admin_screen ) {
559
+		$new_admin_screens = glob(EE_CORE_CAF_ADMIN.'new/*', GLOB_ONLYDIR);
560
+		if ($new_admin_screens) {
561
+			foreach ($new_admin_screens as $admin_screen) {
562 562
 				// files and anything in the exclude array need not apply
563
-				if ( is_dir( $admin_screen ) && ! in_array( basename( $admin_screen ), $exclude )) {
563
+				if (is_dir($admin_screen) && ! in_array(basename($admin_screen), $exclude)) {
564 564
 					// these folders represent the different NEW EE admin pages
565
-					$installed_refs[ basename( $admin_screen ) ] = $admin_screen;
565
+					$installed_refs[basename($admin_screen)] = $admin_screen;
566 566
 					// set autoloaders for our admin page classes based on included path information
567
-					EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( $admin_screen );
567
+					EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($admin_screen);
568 568
 //					$this->_caf_autoloader[] = array(
569 569
 //						'dir' => 'new',
570 570
 //						'folder' => basename( $admin_screen )
@@ -574,18 +574,18 @@  discard block
 block discarded – undo
574 574
 		}
575 575
 
576 576
 		//let's see if there are any EXTENDS to setup in the $_caffeinated_extends array (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page)
577
-		$extends = glob( EE_CORE_CAF_ADMIN . 'extend/*', GLOB_ONLYDIR );
578
-		if ( $extends ) {
579
-			foreach( $extends as $extend ) {
580
-				if ( is_dir( $extend ) ) {
581
-					$extend_ref = basename( $extend );
577
+		$extends = glob(EE_CORE_CAF_ADMIN.'extend/*', GLOB_ONLYDIR);
578
+		if ($extends) {
579
+			foreach ($extends as $extend) {
580
+				if (is_dir($extend)) {
581
+					$extend_ref = basename($extend);
582 582
 					//now let's make sure there is a file that matches the expected format
583
-					$filename = str_replace(' ', '_', ucwords( str_replace('_', ' ', $extend_ref ) ) );
584
-					$filename = 'Extend_' . $filename . '_Admin_Page';
585
-					$this->_caffeinated_extends[$extend_ref]['path'] = str_replace( array( '\\', '/' ), DS, EE_CORE_CAF_ADMIN . 'extend' . DS . $extend_ref . DS . $filename . '.core.php' );
583
+					$filename = str_replace(' ', '_', ucwords(str_replace('_', ' ', $extend_ref)));
584
+					$filename = 'Extend_'.$filename.'_Admin_Page';
585
+					$this->_caffeinated_extends[$extend_ref]['path'] = str_replace(array('\\', '/'), DS, EE_CORE_CAF_ADMIN.'extend'.DS.$extend_ref.DS.$filename.'.core.php');
586 586
 					$this->_caffeinated_extends[$extend_ref]['admin_page'] = $filename;
587 587
 					// set autoloaders for our admin page classes based on included path information
588
-					EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( $extend );
588
+					EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($extend);
589 589
 //					$this->_caf_autoloader[] = array(
590 590
 //						'dir' => 'extend',
591 591
 //						'folder' => $extend_ref
@@ -596,22 +596,22 @@  discard block
 block discarded – undo
596 596
 
597 597
 		//let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!).
598 598
 		$ee_admin_hooks = array();
599
-		$hooks = glob( EE_CORE_CAF_ADMIN . 'hooks/*.class.php' );
600
-		if ( $hooks ) {
601
-			foreach ( $hooks as $hook ) {
602
-				if ( is_readable( $hook ) ) {
599
+		$hooks = glob(EE_CORE_CAF_ADMIN.'hooks/*.class.php');
600
+		if ($hooks) {
601
+			foreach ($hooks as $hook) {
602
+				if (is_readable($hook)) {
603 603
 					require_once $hook;
604
-					$classname = str_replace( EE_CORE_CAF_ADMIN . 'hooks/', '', $hook );
604
+					$classname = str_replace(EE_CORE_CAF_ADMIN.'hooks/', '', $hook);
605 605
 					$classname = str_replace('.class.php', '', $classname);
606
-					if ( class_exists( $classname ) ) {
607
-						$a = new ReflectionClass( $classname );
606
+					if (class_exists($classname)) {
607
+						$a = new ReflectionClass($classname);
608 608
 						$ee_admin_hooks[] = $a->newInstance();
609 609
 					}
610 610
 				}
611 611
 			}
612 612
 		}/**/
613 613
 
614
-		$ee_admin_hooks = apply_filters( 'FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks );
614
+		$ee_admin_hooks = apply_filters('FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks);
615 615
 
616 616
 		return $installed_refs;
617 617
 
@@ -666,8 +666,8 @@  discard block
 block discarded – undo
666 666
 	 * @param  EE_Admin_Page_Menu_Map $b being compared to
667 667
 	 * @return int    sort order
668 668
 	 */
669
-	private function _sort_menu_maps( EE_Admin_Page_Menu_Map $a, EE_Admin_Page_Menu_Map $b ) {
670
-		if ( $a->menu_order == $b->menu_order )
669
+	private function _sort_menu_maps(EE_Admin_Page_Menu_Map $a, EE_Admin_Page_Menu_Map $b) {
670
+		if ($a->menu_order == $b->menu_order)
671 671
 			return 0;
672 672
 		return ($a->menu_order < $b->menu_order) ? -1 : 1;
673 673
 	}
Please login to merge, or discard this patch.
core/helpers/EEH_Qtip_Loader.helper.php 2 patches
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public static function instance() {
34 34
 		// check if class object is instantiated
35
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) {
35
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EEH_Qtip_Loader)) {
36 36
 			self::$_instance = new self();
37 37
 		}
38 38
 		return self::$_instance;
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	private function __construct() {
50 50
 		//let's just make sure this is instantiated in the right place.
51
-		if ( did_action( 'wp_print_styles' ) || did_action( 'admin_head' )) {
52
-			EE_Error::doing_it_wrong( 'EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso' ), '4.1' );
51
+		if (did_action('wp_print_styles') || did_action('admin_head')) {
52
+			EE_Error::doing_it_wrong('EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso'), '4.1');
53 53
 		}
54 54
 	}
55 55
 
@@ -61,27 +61,27 @@  discard block
 block discarded – undo
61 61
 	 * @return void
62 62
 	 */
63 63
 	public function register_and_enqueue() {
64
-		$qtips_js = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.js';
65
-		$qtip_images_loaded = EE_THIRD_PARTY_URL . 'qtip/imagesloaded.pkg.min.js';
66
-		$qtip_map = EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.map';
67
-		$qtipcss = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.css';
64
+		$qtips_js = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.js';
65
+		$qtip_images_loaded = EE_THIRD_PARTY_URL.'qtip/imagesloaded.pkg.min.js';
66
+		$qtip_map = EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.map';
67
+		$qtipcss = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.css';
68 68
 
69
-		wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE );
70
-		wp_register_script('qtip-images-loaded', $qtip_images_loaded, array(), '2.2.0', TRUE );
71
-		wp_register_script('qtip', $qtips_js, array('jquery'), '2.2.0', TRUE );
72
-		wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE );
69
+		wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE);
70
+		wp_register_script('qtip-images-loaded', $qtip_images_loaded, array(), '2.2.0', TRUE);
71
+		wp_register_script('qtip', $qtips_js, array('jquery'), '2.2.0', TRUE);
72
+		wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS.'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE);
73 73
 
74
-		wp_register_style('qtip-css', $qtipcss, array(), '2.2' );
74
+		wp_register_style('qtip-css', $qtipcss, array(), '2.2');
75 75
 
76 76
 		//k now let's see if there are any registered qtips.  If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!)
77
-		if ( !empty( $this->_qtips ) ) {
77
+		if ( ! empty($this->_qtips)) {
78 78
 			wp_enqueue_script('ee-qtip-helper');
79 79
 			wp_enqueue_style('qtip-css');
80 80
 			$qtips = array();
81
-			foreach ( $this->_qtips as $qtip ) {
81
+			foreach ($this->_qtips as $qtip) {
82 82
 				$qts = $qtip->get_tips();
83
-				foreach ( $qts as $qt ) {
84
-					if ( ! $qt instanceof EE_Qtip )
83
+				foreach ($qts as $qt) {
84
+					if ( ! $qt instanceof EE_Qtip)
85 85
 						continue;
86 86
 					$qtips[] = array(
87 87
 						'content_id' => $qt->content_id,
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 						);
91 91
 				}
92 92
 			}
93
-			if ( !empty($qtips) )
94
-				wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) );
93
+			if ( ! empty($qtips))
94
+				wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array('qtips' => $qtips));
95 95
 
96 96
 		} else {
97 97
 			//qtips has been requested without any registration (so assuming its just directly used in the admin).
@@ -113,24 +113,24 @@  discard block
 block discarded – undo
113 113
 	 * @param  string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips]
114 114
 	 * @return void
115 115
 	 */
116
-	public function register( $configname, $paths = array() ) {
116
+	public function register($configname, $paths = array()) {
117 117
 
118 118
 		//let's just make sure this is instantiated in the right place.
119
-		if ( did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts') ) {
120
-			EE_Error::doing_it_wrong( 'EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso' ), '4.1' );
119
+		if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
120
+			EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1');
121 121
 		}
122 122
 
123 123
 		$configname = (array) $configname; //typecast to array
124
-		foreach ( $configname as $config ) {
125
-			$this->_register( $config, $paths );
124
+		foreach ($configname as $config) {
125
+			$this->_register($config, $paths);
126 126
 		}
127 127
 
128 128
 		//hook into appropriate footer
129 129
 		$footer_action = is_admin() ? 'admin_footer' : 'wp_footer';
130
-		add_action($footer_action, array($this, 'setup_qtip'), 10 );
130
+		add_action($footer_action, array($this, 'setup_qtip'), 10);
131 131
 
132 132
 		//make sure we "turn on" qtip js.
133
-		add_filter('FHEE_load_qtip', '__return_true' );
133
+		add_filter('FHEE_load_qtip', '__return_true');
134 134
 	}
135 135
 
136 136
 
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
 	 * @throws EE_Error
145 145
 	 * @return void
146 146
 	 */
147
-	private function _register( $config, $paths ) {
147
+	private function _register($config, $paths) {
148 148
 		//before doing anything we have to make sure that EE_Qtip_Config parent is required.
149
-		EE_Registry::instance()->load_lib( 'Qtip_Config', array(), TRUE );
149
+		EE_Registry::instance()->load_lib('Qtip_Config', array(), TRUE);
150 150
 
151
-		if ( !empty( $paths ) ) {
151
+		if ( ! empty($paths)) {
152 152
 			$paths = (array) $paths;
153
-			foreach ( $paths as $path ) {
154
-				$path = $path . $config . '.lib.php';
155
-				if ( !is_readable($path ) ) {
153
+			foreach ($paths as $path) {
154
+				$path = $path.$config.'.lib.php';
155
+				if ( ! is_readable($path)) {
156 156
 					continue;
157 157
 				} else {
158 158
 					require_once $path;
@@ -161,26 +161,26 @@  discard block
 block discarded – undo
161 161
 		}
162 162
 
163 163
 		//does class exist at this point?  If it does then let's instantiate.  If it doesn't then let's continue with other paths.
164
-		if ( !class_exists($config) ) {
165
-			$path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php';
166
-			if ( !is_readable($path ) ) {
167
-				throw new EE_Error( sprintf( __('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable.  Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config ) );
164
+		if ( ! class_exists($config)) {
165
+			$path = EE_LIBRARIES.'qtips/'.$config.'.lib.php';
166
+			if ( ! is_readable($path)) {
167
+				throw new EE_Error(sprintf(__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable.  Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config));
168 168
 			} else {
169 169
 				require_once $path;
170 170
 			}
171 171
 		}
172 172
 
173 173
 		//now we attempt a class_exists one more time.
174
-		if ( !class_exists( $config ) )
175
-			throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) );
174
+		if ( ! class_exists($config))
175
+			throw new EE_Error(sprintf(__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config));
176 176
 
177 177
 		//made it HERE?  FINALLY, let's get things setup.
178 178
 		$a = new ReflectionClass($config);
179 179
 		$qtip = $a->newInstance();
180 180
 
181 181
 		//verify that $qtip is a valid object
182
-		if ( ! $qtip instanceof EE_Qtip_Config )
183
-			throw new EE_Error( sprintf( esc_html__( 'The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>' ) );
182
+		if ( ! $qtip instanceof EE_Qtip_Config)
183
+			throw new EE_Error(sprintf(esc_html__('The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>'));
184 184
 
185 185
 		$this->_qtips[] = $a->newInstance();
186 186
 
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
 	 * @return void
197 197
 	 */
198 198
 	public function setup_qtip() {
199
-		if ( empty( $this->_qtips ) )
199
+		if (empty($this->_qtips))
200 200
 			return; //no qtips!
201 201
 
202 202
 		$content = array();
203 203
 
204
-		foreach ( $this->_qtips as $qtip ) {
204
+		foreach ($this->_qtips as $qtip) {
205 205
 			$content[] = $this->_generate_content_container($qtip);
206 206
 		}
207 207
 
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
 	private function _generate_content_container($qtip) {
219 219
 		$qts = $qtip->get_tips();
220 220
 		$content = array();
221
-		foreach ( $qts as $qt ) {
222
-			if ( ! $qt instanceof EE_Qtip )
221
+		foreach ($qts as $qt) {
222
+			if ( ! $qt instanceof EE_Qtip)
223 223
 				continue;
224
-			$content[] = '<div class="ee-qtip-helper-content hidden" id="' . $qt->content_id . '">' . $qt->content . '</div>';
224
+			$content[] = '<div class="ee-qtip-helper-content hidden" id="'.$qt->content_id.'">'.$qt->content.'</div>';
225 225
 		}
226 226
 
227 227
 		return implode('<br />', $content);
Please login to merge, or discard this patch.
Braces   +19 added lines, -12 removed lines patch added patch discarded remove patch
@@ -81,8 +81,9 @@  discard block
 block discarded – undo
81 81
 			foreach ( $this->_qtips as $qtip ) {
82 82
 				$qts = $qtip->get_tips();
83 83
 				foreach ( $qts as $qt ) {
84
-					if ( ! $qt instanceof EE_Qtip )
85
-						continue;
84
+					if ( ! $qt instanceof EE_Qtip ) {
85
+											continue;
86
+					}
86 87
 					$qtips[] = array(
87 88
 						'content_id' => $qt->content_id,
88 89
 						'options' => $qt->options,
@@ -90,8 +91,9 @@  discard block
 block discarded – undo
90 91
 						);
91 92
 				}
92 93
 			}
93
-			if ( !empty($qtips) )
94
-				wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) );
94
+			if ( !empty($qtips) ) {
95
+							wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) );
96
+			}
95 97
 
96 98
 		} else {
97 99
 			//qtips has been requested without any registration (so assuming its just directly used in the admin).
@@ -171,16 +173,18 @@  discard block
 block discarded – undo
171 173
 		}
172 174
 
173 175
 		//now we attempt a class_exists one more time.
174
-		if ( !class_exists( $config ) )
175
-			throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) );
176
+		if ( !class_exists( $config ) ) {
177
+					throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) );
178
+		}
176 179
 
177 180
 		//made it HERE?  FINALLY, let's get things setup.
178 181
 		$a = new ReflectionClass($config);
179 182
 		$qtip = $a->newInstance();
180 183
 
181 184
 		//verify that $qtip is a valid object
182
-		if ( ! $qtip instanceof EE_Qtip_Config )
183
-			throw new EE_Error( sprintf( esc_html__( 'The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>' ) );
185
+		if ( ! $qtip instanceof EE_Qtip_Config ) {
186
+					throw new EE_Error( sprintf( esc_html__( 'The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>' ) );
187
+		}
184 188
 
185 189
 		$this->_qtips[] = $a->newInstance();
186 190
 
@@ -196,8 +200,10 @@  discard block
 block discarded – undo
196 200
 	 * @return void
197 201
 	 */
198 202
 	public function setup_qtip() {
199
-		if ( empty( $this->_qtips ) )
200
-			return; //no qtips!
203
+		if ( empty( $this->_qtips ) ) {
204
+					return;
205
+		}
206
+		//no qtips!
201 207
 
202 208
 		$content = array();
203 209
 
@@ -219,8 +225,9 @@  discard block
 block discarded – undo
219 225
 		$qts = $qtip->get_tips();
220 226
 		$content = array();
221 227
 		foreach ( $qts as $qt ) {
222
-			if ( ! $qt instanceof EE_Qtip )
223
-				continue;
228
+			if ( ! $qt instanceof EE_Qtip ) {
229
+							continue;
230
+			}
224 231
 			$content[] = '<div class="ee-qtip-helper-content hidden" id="' . $qt->content_id . '">' . $qt->content . '</div>';
225 232
 		}
226 233
 
Please login to merge, or discard this patch.