Completed
Branch BUG-10626-dst-unit-test (cc62a6)
by
unknown
37:15 queued 23:58
created
form_sections/strategies/normalization/EE_Int_Normalization.strategy.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 
18 18
     /**
19 19
      * @param string $value_to_normalize
20
-     * @return int|mixed|string
20
+     * @return null|integer
21 21
      * @throws \EE_Validation_Error
22 22
      */
23 23
     public function normalize($value_to_normalize)
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
             return null;
35 35
         }
36 36
         if (is_int($value_to_normalize) || is_float($value_to_normalize)) {
37
-            return (int)$value_to_normalize;
37
+            return (int) $value_to_normalize;
38 38
         }
39
-        if (! is_string($value_to_normalize)) {
39
+        if ( ! is_string($value_to_normalize)) {
40 40
             throw new EE_Validation_Error(
41 41
                 sprintf(
42 42
                     __('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
                 // if first match is the negative sign,
60 60
                 // then the number needs to be multiplied by -1 to remain negative
61 61
                 return $matches[1] === '-'
62
-                    ? (int)$matches[2] * -1
63
-                    : (int)$matches[2];
62
+                    ? (int) $matches[2] * -1
63
+                    : (int) $matches[2];
64 64
             }
65 65
         }
66 66
         //find if this input has a int validation strategy
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         }
74 74
         //this really shouldn't ever happen because fields with a int normalization strategy
75 75
         //should also have a int validation strategy, but in case it doesn't use the default
76
-        if (! $validation_error_message) {
76
+        if ( ! $validation_error_message) {
77 77
             $default_validation_strategy = new EE_Int_Validation_Strategy();
78 78
             $validation_error_message = $default_validation_strategy->get_validation_error_message();
79 79
         }
Please login to merge, or discard this patch.
Indentation   +75 added lines, -75 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
 
@@ -15,89 +15,89 @@  discard block
 block discarded – undo
15 15
 class EE_Int_Normalization extends EE_Normalization_Strategy_Base
16 16
 {
17 17
 
18
-    /*
18
+	/*
19 19
      * regex pattern that matches for the following:
20 20
      *      * optional negative sign
21 21
      *      * one or more digits
22 22
      */
23
-    const REGEX = '/^(-?)(\d+)(?:\.0+)?$/';
23
+	const REGEX = '/^(-?)(\d+)(?:\.0+)?$/';
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * @param string $value_to_normalize
29
-     * @return int|mixed|string
30
-     * @throws \EE_Validation_Error
31
-     */
32
-    public function normalize($value_to_normalize)
33
-    {
34
-        if ($value_to_normalize === null) {
35
-            return null;
36
-        }
37
-        if (is_int($value_to_normalize) || is_float($value_to_normalize)) {
38
-            return (int)$value_to_normalize;
39
-        }
40
-        if (! is_string($value_to_normalize)) {
41
-            throw new EE_Validation_Error(
42
-                sprintf(
43
-                    __('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
44
-                    print_r($value_to_normalize, true),
45
-                    gettype($value_to_normalize)
46
-                )
47
-            );
48
-        }
49
-        $value_to_normalize = filter_var(
50
-            $value_to_normalize,
51
-            FILTER_SANITIZE_NUMBER_FLOAT,
52
-            FILTER_FLAG_ALLOW_FRACTION
53
-        );
54
-        if ($value_to_normalize === '') {
55
-            return null;
56
-        }
57
-        $matches = array();
58
-        if (preg_match(EE_Int_Normalization::REGEX, $value_to_normalize, $matches)) {
59
-            if (count($matches) === 3) {
60
-                // if first match is the negative sign,
61
-                // then the number needs to be multiplied by -1 to remain negative
62
-                return $matches[1] === '-'
63
-                    ? (int)$matches[2] * -1
64
-                    : (int)$matches[2];
65
-            }
66
-        }
67
-        //find if this input has a int validation strategy
68
-        //in which case, use its message
69
-        $validation_error_message = null;
70
-        foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
71
-            if ($validation_strategy instanceof EE_Int_Validation_Strategy) {
72
-                $validation_error_message = $validation_strategy->get_validation_error_message();
73
-            }
74
-        }
75
-        //this really shouldn't ever happen because fields with a int normalization strategy
76
-        //should also have a int validation strategy, but in case it doesn't use the default
77
-        if (! $validation_error_message) {
78
-            $default_validation_strategy = new EE_Int_Validation_Strategy();
79
-            $validation_error_message = $default_validation_strategy->get_validation_error_message();
80
-        }
81
-        throw new EE_Validation_Error($validation_error_message, 'numeric_only');
82
-    }
27
+	/**
28
+	 * @param string $value_to_normalize
29
+	 * @return int|mixed|string
30
+	 * @throws \EE_Validation_Error
31
+	 */
32
+	public function normalize($value_to_normalize)
33
+	{
34
+		if ($value_to_normalize === null) {
35
+			return null;
36
+		}
37
+		if (is_int($value_to_normalize) || is_float($value_to_normalize)) {
38
+			return (int)$value_to_normalize;
39
+		}
40
+		if (! is_string($value_to_normalize)) {
41
+			throw new EE_Validation_Error(
42
+				sprintf(
43
+					__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
44
+					print_r($value_to_normalize, true),
45
+					gettype($value_to_normalize)
46
+				)
47
+			);
48
+		}
49
+		$value_to_normalize = filter_var(
50
+			$value_to_normalize,
51
+			FILTER_SANITIZE_NUMBER_FLOAT,
52
+			FILTER_FLAG_ALLOW_FRACTION
53
+		);
54
+		if ($value_to_normalize === '') {
55
+			return null;
56
+		}
57
+		$matches = array();
58
+		if (preg_match(EE_Int_Normalization::REGEX, $value_to_normalize, $matches)) {
59
+			if (count($matches) === 3) {
60
+				// if first match is the negative sign,
61
+				// then the number needs to be multiplied by -1 to remain negative
62
+				return $matches[1] === '-'
63
+					? (int)$matches[2] * -1
64
+					: (int)$matches[2];
65
+			}
66
+		}
67
+		//find if this input has a int validation strategy
68
+		//in which case, use its message
69
+		$validation_error_message = null;
70
+		foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
71
+			if ($validation_strategy instanceof EE_Int_Validation_Strategy) {
72
+				$validation_error_message = $validation_strategy->get_validation_error_message();
73
+			}
74
+		}
75
+		//this really shouldn't ever happen because fields with a int normalization strategy
76
+		//should also have a int validation strategy, but in case it doesn't use the default
77
+		if (! $validation_error_message) {
78
+			$default_validation_strategy = new EE_Int_Validation_Strategy();
79
+			$validation_error_message = $default_validation_strategy->get_validation_error_message();
80
+		}
81
+		throw new EE_Validation_Error($validation_error_message, 'numeric_only');
82
+	}
83 83
 
84 84
 
85 85
 
86
-    /**
87
-     * Converts the int into a string for use in teh html form
88
-     *
89
-     * @param int $normalized_value
90
-     * @return string
91
-     */
92
-    public function unnormalize($normalized_value)
93
-    {
94
-        if ($normalized_value === null || $normalized_value === '') {
95
-            return '';
96
-        }
97
-        if (empty($normalized_value)) {
98
-            return '0';
99
-        }
100
-        return "$normalized_value";
101
-    }
86
+	/**
87
+	 * Converts the int into a string for use in teh html form
88
+	 *
89
+	 * @param int $normalized_value
90
+	 * @return string
91
+	 */
92
+	public function unnormalize($normalized_value)
93
+	{
94
+		if ($normalized_value === null || $normalized_value === '') {
95
+			return '';
96
+		}
97
+		if (empty($normalized_value)) {
98
+			return '0';
99
+		}
100
+		return "$normalized_value";
101
+	}
102 102
 }
103 103
 // End of file EE_Int_Normalization.strategy.php
Please login to merge, or discard this patch.
form_sections/strategies/validation/EE_Int_Validation_Strategy.strategy.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,14 +33,14 @@
 block discarded – undo
33 33
 	 * @return array
34 34
 	 */
35 35
 	function get_jquery_validation_rule_array(){
36
-        return array(
37
-            'number'=>true,
38
-            'step' => 1,
39
-            'messages' => array(
40
-                'number' => $this->get_validation_error_message(),
41
-                'step' => $this->get_validation_error_message()
42
-            )
43
-        );
36
+		return array(
37
+			'number'=>true,
38
+			'step' => 1,
39
+			'messages' => array(
40
+				'number' => $this->get_validation_error_message(),
41
+				'step' => $this->get_validation_error_message()
42
+			)
43
+		);
44 44
 	}
45 45
 }
46 46
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,16 +6,16 @@  discard block
 block discarded – undo
6 6
  * @subpackage	Expression package is undefined on line 19, column 19 in Templates/Scripting/PHPClass.php.
7 7
  * @author				Mike Nelson
8 8
  */
9
-class EE_Int_Validation_Strategy extends EE_Validation_Strategy_Base{
9
+class EE_Int_Validation_Strategy extends EE_Validation_Strategy_Base {
10 10
 
11 11
 	/**
12 12
 	 * @param null $validation_error_message
13 13
 	 */
14
-	public function __construct( $validation_error_message = NULL ) {
15
-		if( ! $validation_error_message ){
14
+	public function __construct($validation_error_message = NULL) {
15
+		if ( ! $validation_error_message) {
16 16
 			$validation_error_message = __("Only digits are allowed.", "event_espresso");
17 17
 		}
18
-		parent::__construct( $validation_error_message );
18
+		parent::__construct($validation_error_message);
19 19
 	}
20 20
 
21 21
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * @return array
34 34
 	 */
35
-	function get_jquery_validation_rule_array(){
35
+	function get_jquery_validation_rule_array() {
36 36
         return array(
37 37
             'number'=>true,
38 38
             'step' => 1,
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
         $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
475 475
         $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
476 476
         global $ee_menu_slugs;
477
-        $ee_menu_slugs = (array)$ee_menu_slugs;
477
+        $ee_menu_slugs = (array) $ee_menu_slugs;
478 478
         if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
479 479
             return;
480 480
         }
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
         //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
490 490
         $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
491 491
         $this->_current_view = $this->_req_action;
492
-        $this->_req_nonce = $this->_req_action . '_nonce';
492
+        $this->_req_nonce = $this->_req_action.'_nonce';
493 493
         $this->_define_page_props();
494 494
         $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
495 495
         //default things
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
             $this->_extend_page_config_for_cpt();
511 511
         }
512 512
         //filter routes and page_config so addons can add their stuff. Filtering done per class
513
-        $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
514
-        $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
513
+        $this->_page_routes = apply_filters('FHEE__'.get_class($this).'__page_setup__page_routes', $this->_page_routes, $this);
514
+        $this->_page_config = apply_filters('FHEE__'.get_class($this).'__page_setup__page_config', $this->_page_config, $this);
515 515
         //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
516
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
517
-            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
516
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
517
+            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view), 10, 2);
518 518
         }
519 519
         //next route only if routing enabled
520 520
         if ($this->_routing && ! defined('DOING_AJAX')) {
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
             if ($this->_is_UI_request) {
525 525
                 //admin_init stuff - global, all views for this page class, specific view
526 526
                 add_action('admin_init', array($this, 'admin_init'), 10);
527
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
528
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
527
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
528
+                    add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15);
529 529
                 }
530 530
             } else {
531 531
                 //hijack regular WP loading and route admin request immediately
@@ -545,17 +545,17 @@  discard block
 block discarded – undo
545 545
      */
546 546
     private function _do_other_page_hooks()
547 547
     {
548
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
548
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array());
549 549
         foreach ($registered_pages as $page) {
550 550
             //now let's setup the file name and class that should be present
551 551
             $classname = str_replace('.class.php', '', $page);
552 552
             //autoloaders should take care of loading file
553 553
             if ( ! class_exists($classname)) {
554
-                $error_msg[] = sprintf( esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
554
+                $error_msg[] = sprintf(esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
555 555
                 $error_msg[] = $error_msg[0]
556 556
                                . "\r\n"
557
-                               . sprintf( esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
558
-                                'event_espresso'), $page, '<br />', '<strong>' . $classname . '</strong>');
557
+                               . sprintf(esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
558
+                                'event_espresso'), $page, '<br />', '<strong>'.$classname.'</strong>');
559 559
                 throw new EE_Error(implode('||', $error_msg));
560 560
             }
561 561
             $a = new ReflectionClass($classname);
@@ -591,13 +591,13 @@  discard block
 block discarded – undo
591 591
         //load admin_notices - global, page class, and view specific
592 592
         add_action('admin_notices', array($this, 'admin_notices_global'), 5);
593 593
         add_action('admin_notices', array($this, 'admin_notices'), 10);
594
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
595
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
594
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
595
+            add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15);
596 596
         }
597 597
         //load network admin_notices - global, page class, and view specific
598 598
         add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
599
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
600
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
599
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
600
+            add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view));
601 601
         }
602 602
         //this will save any per_page screen options if they are present
603 603
         $this->_set_per_page_screen_options();
@@ -609,8 +609,8 @@  discard block
 block discarded – undo
609 609
         //add screen options - global, page child class, and view specific
610 610
         $this->_add_global_screen_options();
611 611
         $this->_add_screen_options();
612
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
613
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
612
+        if (method_exists($this, '_add_screen_options_'.$this->_current_view)) {
613
+            call_user_func(array($this, '_add_screen_options_'.$this->_current_view));
614 614
         }
615 615
         //add help tab(s) and tours- set via page_config and qtips.
616 616
         $this->_add_help_tour();
@@ -619,31 +619,31 @@  discard block
 block discarded – undo
619 619
         //add feature_pointers - global, page child class, and view specific
620 620
         $this->_add_feature_pointers();
621 621
         $this->_add_global_feature_pointers();
622
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
623
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
622
+        if (method_exists($this, '_add_feature_pointer_'.$this->_current_view)) {
623
+            call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view));
624 624
         }
625 625
         //enqueue scripts/styles - global, page class, and view specific
626 626
         add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
627 627
         add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
628
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
629
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
628
+        if (method_exists($this, 'load_scripts_styles_'.$this->_current_view)) {
629
+            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15);
630 630
         }
631 631
         add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
632 632
         //admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
633 633
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
634 634
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
635
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
636
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
635
+        if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view)) {
636
+            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101);
637 637
         }
638 638
         //admin footer scripts
639 639
         add_action('admin_footer', array($this, 'admin_footer_global'), 99);
640 640
         add_action('admin_footer', array($this, 'admin_footer'), 100);
641
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
642
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
641
+        if (method_exists($this, 'admin_footer_'.$this->_current_view)) {
642
+            add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101);
643 643
         }
644 644
         do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
645 645
         //targeted hook
646
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
646
+        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action);
647 647
     }
648 648
 
649 649
 
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
             // user error msg
720 720
             $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
721 721
             // developer error msg
722
-            $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
722
+            $error_msg .= '||'.$error_msg.__(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
723 723
             throw new EE_Error($error_msg);
724 724
         }
725 725
         // and that the requested page route exists
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
             // user error msg
731 731
             $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
732 732
             // developer error msg
733
-            $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
733
+            $error_msg .= '||'.$error_msg.sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
734 734
             throw new EE_Error($error_msg);
735 735
         }
736 736
         // and that a default route exists
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
             // user error msg
739 739
             $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
740 740
             // developer error msg
741
-            $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
741
+            $error_msg .= '||'.$error_msg.__(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
742 742
             throw new EE_Error($error_msg);
743 743
         }
744 744
         //first lets' catch if the UI request has EVER been set.
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
             // user error msg
768 768
             $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
769 769
             // developer error msg
770
-            $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
770
+            $error_msg .= '||'.$error_msg.sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
771 771
             throw new EE_Error($error_msg);
772 772
         }
773 773
     }
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
             // these are not the droids you are looking for !!!
790 790
             $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
791 791
             if (WP_DEBUG) {
792
-                $msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
792
+                $msg .= "\n  ".sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
793 793
             }
794 794
             if ( ! defined('DOING_AJAX')) {
795 795
                 wp_die($msg);
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
                 if (strpos($key, 'nonce') !== false) {
968 968
                     continue;
969 969
                 }
970
-                $args['wp_referer[' . $key . ']'] = $value;
970
+                $args['wp_referer['.$key.']'] = $value;
971 971
             }
972 972
         }
973 973
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
                     if ($tour instanceof EE_Help_Tour_final_stop) {
1014 1014
                         continue;
1015 1015
                     }
1016
-                    $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1016
+                    $tb[] = '<button id="trigger-tour-'.$tour->get_slug().'" class="button-primary trigger-ee-help-tour">'.$tour->get_label().'</button>';
1017 1017
                 }
1018 1018
                 $tour_buttons .= implode('<br />', $tb);
1019 1019
                 $tour_buttons .= '</div></div>';
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
                     throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1026 1026
                             'event_espresso'), $config['help_sidebar'], get_class($this)));
1027 1027
                 }
1028
-                $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1028
+                $content = apply_filters('FHEE__'.get_class($this).'__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1029 1029
                 $content .= $tour_buttons; //add help tour buttons.
1030 1030
                 //do we have any help tours setup?  Cause if we do we want to add the buttons
1031 1031
                 $this->_current_screen->set_help_sidebar($content);
@@ -1038,13 +1038,13 @@  discard block
 block discarded – undo
1038 1038
             if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1039 1039
                 $_ht['id'] = $this->page_slug;
1040 1040
                 $_ht['title'] = __('Help Tours', 'event_espresso');
1041
-                $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1041
+                $_ht['content'] = '<p>'.__('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso').'</p>';
1042 1042
                 $this->_current_screen->add_help_tab($_ht);
1043 1043
             }/**/
1044 1044
             if ( ! isset($config['help_tabs'])) {
1045 1045
                 return;
1046 1046
             } //no help tabs for this route
1047
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1047
+            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1048 1048
                 //we're here so there ARE help tabs!
1049 1049
                 //make sure we've got what we need
1050 1050
                 if ( ! isset($cfg['title'])) {
@@ -1059,9 +1059,9 @@  discard block
 block discarded – undo
1059 1059
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1060 1060
                     //second priority goes to filename
1061 1061
                 } else if ( ! empty($cfg['filename'])) {
1062
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1062
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1063 1063
                     //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1064
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1064
+                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tabs/'.$cfg['filename'].'.help_tab.php' : $file_path;
1065 1065
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1066 1066
                     if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1067 1067
                         EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
                     return;
1081 1081
                 }
1082 1082
                 //setup config array for help tab method
1083
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1083
+                $id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1084 1084
                 $_ht = array(
1085 1085
                         'id'       => $id,
1086 1086
                         'title'    => $cfg['title'],
@@ -1118,9 +1118,9 @@  discard block
 block discarded – undo
1118 1118
             }
1119 1119
             if (isset($config['help_tour'])) {
1120 1120
                 foreach ($config['help_tour'] as $tour) {
1121
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1121
+                    $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php';
1122 1122
                     //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1123
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1123
+                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tours/'.$tour.'.class.php' : $file_path;
1124 1124
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1125 1125
                     if ( ! is_readable($file_path)) {
1126 1126
                         EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'),
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
                     require_once $file_path;
1131 1131
                     if ( ! class_exists($tour)) {
1132 1132
                         $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1133
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1133
+                        $error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1134 1134
                                         'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1135 1135
                         throw new EE_Error(implode('||', $error_msg));
1136 1136
                     }
@@ -1162,11 +1162,11 @@  discard block
 block discarded – undo
1162 1162
     protected function _add_qtips()
1163 1163
     {
1164 1164
         if (isset($this->_route_config['qtips'])) {
1165
-            $qtips = (array)$this->_route_config['qtips'];
1165
+            $qtips = (array) $this->_route_config['qtips'];
1166 1166
             //load qtip loader
1167 1167
             $path = array(
1168
-                    $this->_get_dir() . '/qtips/',
1169
-                    EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1168
+                    $this->_get_dir().'/qtips/',
1169
+                    EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1170 1170
             );
1171 1171
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1172 1172
         }
@@ -1196,11 +1196,11 @@  discard block
 block discarded – undo
1196 1196
             if ( ! $this->check_user_access($slug, true)) {
1197 1197
                 continue;
1198 1198
             } //no nav tab becasue current user does not have access.
1199
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1199
+            $css_class = isset($config['css_class']) ? $config['css_class'].' ' : '';
1200 1200
             $this->_nav_tabs[$slug] = array(
1201 1201
                     'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1202 1202
                     'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1203
-                    'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1203
+                    'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class,
1204 1204
                     'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1205 1205
             );
1206 1206
             $i++;
@@ -1263,11 +1263,11 @@  discard block
 block discarded – undo
1263 1263
             $capability = empty($capability) ? 'manage_options' : $capability;
1264 1264
         }
1265 1265
         $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1266
-        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1266
+        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug.'_'.$route_to_check, $id)) && ! defined('DOING_AJAX')) {
1267 1267
             if ($verify_only) {
1268 1268
                 return false;
1269 1269
             } else {
1270
-                if ( is_user_logged_in() ) {
1270
+                if (is_user_logged_in()) {
1271 1271
                     wp_die(__('You do not have access to this route.', 'event_espresso'));
1272 1272
                 } else {
1273 1273
                     return false;
@@ -1359,7 +1359,7 @@  discard block
 block discarded – undo
1359 1359
     public function admin_footer_global()
1360 1360
     {
1361 1361
         //dialog container for dialog helper
1362
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1362
+        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n";
1363 1363
         $d_cont .= '<div class="ee-notices"></div>';
1364 1364
         $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1365 1365
         $d_cont .= '</div>';
@@ -1369,7 +1369,7 @@  discard block
 block discarded – undo
1369 1369
             echo implode('<br />', $this->_help_tour[$this->_req_action]);
1370 1370
         }
1371 1371
         //current set timezone for timezone js
1372
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1372
+        echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>';
1373 1373
     }
1374 1374
 
1375 1375
 
@@ -1394,7 +1394,7 @@  discard block
 block discarded – undo
1394 1394
     {
1395 1395
         $content = '';
1396 1396
         $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1397
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1397
+        $template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php';
1398 1398
         //loop through the array and setup content
1399 1399
         foreach ($help_array as $trigger => $help) {
1400 1400
             //make sure the array is setup properly
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
     private function _get_help_content()
1429 1429
     {
1430 1430
         //what is the method we're looking for?
1431
-        $method_name = '_help_popup_content_' . $this->_req_action;
1431
+        $method_name = '_help_popup_content_'.$this->_req_action;
1432 1432
         //if method doesn't exist let's get out.
1433 1433
         if ( ! method_exists($this, $method_name)) {
1434 1434
             return array();
@@ -1472,8 +1472,8 @@  discard block
 block discarded – undo
1472 1472
             $help_content = $this->_set_help_popup_content($help_array, false);
1473 1473
         }
1474 1474
         //let's setup the trigger
1475
-        $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1476
-        $content = $content . $help_content;
1475
+        $content = '<a class="ee-dialog" href="?height='.$dimensions[0].'&width='.$dimensions[1].'&inlineId='.$trigger_id.'" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1476
+        $content = $content.$help_content;
1477 1477
         if ($display) {
1478 1478
             echo $content;
1479 1479
         } else {
@@ -1533,27 +1533,27 @@  discard block
 block discarded – undo
1533 1533
             add_action('admin_head', array($this, 'add_xdebug_style'));
1534 1534
         }
1535 1535
         // register all styles
1536
-        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1537
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1536
+        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1537
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1538 1538
         //helpers styles
1539
-        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1539
+        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1540 1540
         /** SCRIPTS **/
1541 1541
         //register all scripts
1542
-        wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1543
-        wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1544
-        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1542
+        wp_register_script('ee-dialog', EE_ADMIN_URL.'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1543
+        wp_register_script('ee_admin_js', EE_ADMIN_URL.'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1544
+        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1545 1545
         add_filter('FHEE_load_joyride', '__return_true');
1546 1546
         //script for sorting tables
1547
-        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1547
+        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL."assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1548 1548
         //script for parsing uri's
1549
-        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1549
+        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1550 1550
         //and parsing associative serialized form elements
1551
-        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1551
+        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1552 1552
         //helpers scripts
1553
-        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1554
-        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1555
-        wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1556
-        wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1553
+        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1554
+        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1555
+        wp_register_script('ee-moment', EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1556
+        wp_register_script('ee-datepicker', EE_ADMIN_URL.'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1557 1557
         //google charts
1558 1558
         wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1559 1559
         // ENQUEUE ALL BASICS BY DEFAULT
@@ -1577,7 +1577,7 @@  discard block
 block discarded – undo
1577 1577
          */
1578 1578
         if ( ! empty($this->_help_tour)) {
1579 1579
             //register the js for kicking things off
1580
-            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1580
+            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL.'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1581 1581
             //setup tours for the js tour object
1582 1582
             foreach ($this->_help_tour['tours'] as $tour) {
1583 1583
                 $tours[] = array(
@@ -1672,17 +1672,17 @@  discard block
 block discarded – undo
1672 1672
             return;
1673 1673
         } //not a list_table view so get out.
1674 1674
         //list table functions are per view specific (because some admin pages might have more than one listtable!)
1675
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1675
+        if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === false) {
1676 1676
             //user error msg
1677 1677
             $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1678 1678
             //developer error msg
1679
-            $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1680
-                            $this->_req_action, '_set_list_table_views_' . $this->_req_action);
1679
+            $error_msg .= '||'.sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1680
+                            $this->_req_action, '_set_list_table_views_'.$this->_req_action);
1681 1681
             throw new EE_Error($error_msg);
1682 1682
         }
1683 1683
         //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1684
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1685
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1684
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action, $this->_views);
1685
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
1686 1686
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1687 1687
         $this->_set_list_table_view();
1688 1688
         $this->_set_list_table_object();
@@ -1757,7 +1757,7 @@  discard block
 block discarded – undo
1757 1757
             // check for current view
1758 1758
             $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1759 1759
             $query_args['action'] = $this->_req_action;
1760
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1760
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
1761 1761
             $query_args['status'] = $view['slug'];
1762 1762
             //merge any other arguments sent in.
1763 1763
             if (isset($extra_query_args[$view['slug']])) {
@@ -1795,14 +1795,14 @@  discard block
 block discarded – undo
1795 1795
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
1796 1796
         foreach ($values as $value) {
1797 1797
             if ($value < $max_entries) {
1798
-                $selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1798
+                $selected = $value == $per_page ? ' selected="'.$per_page.'"' : '';
1799 1799
                 $entries_per_page_dropdown .= '
1800
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
1800
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
1801 1801
             }
1802 1802
         }
1803
-        $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1803
+        $selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : '';
1804 1804
         $entries_per_page_dropdown .= '
1805
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
1805
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
1806 1806
         $entries_per_page_dropdown .= '
1807 1807
 					</select>
1808 1808
 					entries
@@ -1824,7 +1824,7 @@  discard block
 block discarded – undo
1824 1824
     public function _set_search_attributes()
1825 1825
     {
1826 1826
         $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1827
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1827
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
1828 1828
     }
1829 1829
 
1830 1830
     /*** END LIST TABLE METHODS **/
@@ -1862,7 +1862,7 @@  discard block
 block discarded – undo
1862 1862
                     // user error msg
1863 1863
                     $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1864 1864
                     // developer error msg
1865
-                    $error_msg .= '||' . sprintf(
1865
+                    $error_msg .= '||'.sprintf(
1866 1866
                                     __(
1867 1867
                                             'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
1868 1868
                                             'event_espresso'
@@ -1892,15 +1892,15 @@  discard block
 block discarded – undo
1892 1892
                 && is_array($this->_route_config['columns'])
1893 1893
                 && count($this->_route_config['columns']) === 2
1894 1894
         ) {
1895
-            add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1895
+            add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1]));
1896 1896
             $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1897 1897
             $screen_id = $this->_current_screen->id;
1898
-            $screen_columns = (int)get_user_option("screen_layout_$screen_id");
1898
+            $screen_columns = (int) get_user_option("screen_layout_$screen_id");
1899 1899
             $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1900
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1900
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
1901 1901
             $this->_template_args['current_page'] = $this->_wp_page_slug;
1902 1902
             $this->_template_args['screen'] = $this->_current_screen;
1903
-            $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1903
+            $this->_column_template_path = EE_ADMIN_TEMPLATE.'admin_details_metabox_column_wrapper.template.php';
1904 1904
             //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
1905 1905
             $this->_route_config['has_metaboxes'] = true;
1906 1906
         }
@@ -1947,7 +1947,7 @@  discard block
 block discarded – undo
1947 1947
      */
1948 1948
     public function espresso_ratings_request()
1949 1949
     {
1950
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1950
+        $template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php';
1951 1951
         EEH_Template::display_template($template_path, array());
1952 1952
     }
1953 1953
 
@@ -1955,18 +1955,18 @@  discard block
 block discarded – undo
1955 1955
 
1956 1956
     public static function cached_rss_display($rss_id, $url)
1957 1957
     {
1958
-        $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1958
+        $loading = '<p class="widget-loading hide-if-no-js">'.__('Loading&#8230;').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>';
1959 1959
         $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1960
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
1961
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1962
-        $post = '</div>' . "\n";
1963
-        $cache_key = 'ee_rss_' . md5($rss_id);
1960
+        $pre = '<div class="espresso-rss-display">'."\n\t";
1961
+        $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>';
1962
+        $post = '</div>'."\n";
1963
+        $cache_key = 'ee_rss_'.md5($rss_id);
1964 1964
         if (false != ($output = get_transient($cache_key))) {
1965
-            echo $pre . $output . $post;
1965
+            echo $pre.$output.$post;
1966 1966
             return true;
1967 1967
         }
1968 1968
         if ( ! $doing_ajax) {
1969
-            echo $pre . $loading . $post;
1969
+            echo $pre.$loading.$post;
1970 1970
             return false;
1971 1971
         }
1972 1972
         ob_start();
@@ -2025,7 +2025,7 @@  discard block
 block discarded – undo
2025 2025
 
2026 2026
     public function espresso_sponsors_post_box()
2027 2027
     {
2028
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2028
+        $templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php';
2029 2029
         EEH_Template::display_template($templatepath);
2030 2030
     }
2031 2031
 
@@ -2033,7 +2033,7 @@  discard block
 block discarded – undo
2033 2033
 
2034 2034
     private function _publish_post_box()
2035 2035
     {
2036
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2036
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2037 2037
         //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2038 2038
         if ( ! empty($this->_labels['publishbox'])) {
2039 2039
             $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
@@ -2050,7 +2050,7 @@  discard block
 block discarded – undo
2050 2050
     {
2051 2051
         //if we have extra content set let's add it in if not make sure its empty
2052 2052
         $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2053
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2053
+        $template_path = EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php';
2054 2054
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2055 2055
     }
2056 2056
 
@@ -2219,7 +2219,7 @@  discard block
 block discarded – undo
2219 2219
         //if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2220 2220
         $call_back_func = $create_func ? create_function('$post, $metabox',
2221 2221
                 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2222
-        add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2222
+        add_meta_box(str_replace('_', '-', $action).'-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2223 2223
     }
2224 2224
 
2225 2225
 
@@ -2299,10 +2299,10 @@  discard block
 block discarded – undo
2299 2299
                 ? 'poststuff'
2300 2300
                 : 'espresso-default-admin';
2301 2301
         $template_path = $sidebar
2302
-                ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2303
-                : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2302
+                ? EE_ADMIN_TEMPLATE.'admin_details_wrapper.template.php'
2303
+                : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2304 2304
         if (defined('DOING_AJAX') && DOING_AJAX) {
2305
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2305
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2306 2306
         }
2307 2307
         $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2308 2308
         $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
@@ -2348,7 +2348,7 @@  discard block
 block discarded – undo
2348 2348
                         true
2349 2349
                 )
2350 2350
                 : $this->_template_args['preview_action_button'];
2351
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2351
+        $template_path = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php';
2352 2352
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2353 2353
                 $template_path,
2354 2354
                 $this->_template_args,
@@ -2399,7 +2399,7 @@  discard block
 block discarded – undo
2399 2399
         //setup search attributes
2400 2400
         $this->_set_search_attributes();
2401 2401
         $this->_template_args['current_page'] = $this->_wp_page_slug;
2402
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2402
+        $template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2403 2403
         $this->_template_args['table_url'] = defined('DOING_AJAX')
2404 2404
                 ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2405 2405
                 : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
@@ -2409,29 +2409,29 @@  discard block
 block discarded – undo
2409 2409
         $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2410 2410
         if ( ! empty($ajax_sorting_callback)) {
2411 2411
             $sortable_list_table_form_fields = wp_nonce_field(
2412
-                    $ajax_sorting_callback . '_nonce',
2413
-                    $ajax_sorting_callback . '_nonce',
2412
+                    $ajax_sorting_callback.'_nonce',
2413
+                    $ajax_sorting_callback.'_nonce',
2414 2414
                     false,
2415 2415
                     false
2416 2416
             );
2417 2417
             //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2418 2418
             //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2419
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2420
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2419
+            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'.$this->page_slug.'" />';
2420
+            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'.$ajax_sorting_callback.'" />';
2421 2421
         } else {
2422 2422
             $sortable_list_table_form_fields = '';
2423 2423
         }
2424 2424
         $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2425 2425
         $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2426
-        $nonce_ref = $this->_req_action . '_nonce';
2427
-        $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2426
+        $nonce_ref = $this->_req_action.'_nonce';
2427
+        $hidden_form_fields .= '<input type="hidden" name="'.$nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">';
2428 2428
         $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2429 2429
         //display message about search results?
2430 2430
         $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2431
-                ? '<p class="ee-search-results">' . sprintf(
2431
+                ? '<p class="ee-search-results">'.sprintf(
2432 2432
                         esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2433 2433
                         trim($this->_req_data['s'], '%')
2434
-                ) . '</p>'
2434
+                ).'</p>'
2435 2435
                 : '';
2436 2436
         // filter before_list_table template arg
2437 2437
         $this->_template_args['before_list_table'] = apply_filters(
@@ -2505,8 +2505,8 @@  discard block
 block discarded – undo
2505 2505
      */
2506 2506
     protected function _display_legend($items)
2507 2507
     {
2508
-        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2509
-        $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2508
+        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this);
2509
+        $legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php';
2510 2510
         return EEH_Template::display_template($legend_template, $this->_template_args, true);
2511 2511
     }
2512 2512
 
@@ -2598,15 +2598,15 @@  discard block
 block discarded – undo
2598 2598
         $this->_nav_tabs = $this->_get_main_nav_tabs();
2599 2599
         $this->_template_args['nav_tabs'] = $this->_nav_tabs;
2600 2600
         $this->_template_args['admin_page_title'] = $this->_admin_page_title;
2601
-        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2601
+        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view,
2602 2602
                 isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2603
-        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2603
+        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view,
2604 2604
                 isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2605 2605
         $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2606 2606
         // load settings page wrapper template
2607
-        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2607
+        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE.'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php';
2608 2608
         //about page?
2609
-        $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2609
+        $template_path = $about ? EE_ADMIN_TEMPLATE.'about_admin_wrapper.template.php' : $template_path;
2610 2610
         if (defined('DOING_AJAX')) {
2611 2611
             $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2612 2612
             $this->_return_json();
@@ -2678,20 +2678,20 @@  discard block
 block discarded – undo
2678 2678
     protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2679 2679
     {
2680 2680
         //make sure $text and $actions are in an array
2681
-        $text = (array)$text;
2682
-        $actions = (array)$actions;
2681
+        $text = (array) $text;
2682
+        $actions = (array) $actions;
2683 2683
         $referrer_url = empty($referrer) ? '' : $referrer;
2684
-        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2685
-                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2684
+        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$_SERVER['REQUEST_URI'].'" />'
2685
+                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$referrer.'" />';
2686 2686
         $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2687 2687
         $default_names = array('save', 'save_and_close');
2688 2688
         //add in a hidden index for the current page (so save and close redirects properly)
2689 2689
         $this->_template_args['save_buttons'] = $referrer_url;
2690 2690
         foreach ($button_text as $key => $button) {
2691 2691
             $ref = $default_names[$key];
2692
-            $id = $this->_current_view . '_' . $ref;
2692
+            $id = $this->_current_view.'_'.$ref;
2693 2693
             $name = ! empty($actions) ? $actions[$key] : $ref;
2694
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2694
+            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '.$ref.'" value="'.$button.'" name="'.$name.'" id="'.$id.'" />';
2695 2695
             if ( ! $both) {
2696 2696
                 break;
2697 2697
             }
@@ -2727,15 +2727,15 @@  discard block
 block discarded – undo
2727 2727
     {
2728 2728
         if (empty($route)) {
2729 2729
             $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2730
-            $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2731
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2730
+            $dev_msg = $user_msg."\n".sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2731
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
2732 2732
         }
2733 2733
         // open form
2734
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2734
+        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'.$this->_admin_base_url.'" id="'.$route.'_event_form" >';
2735 2735
         // add nonce
2736
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2736
+        $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
2737 2737
         //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2738
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2738
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
2739 2739
         // add REQUIRED form action
2740 2740
         $hidden_fields = array(
2741 2741
                 'action' => array('type' => 'hidden', 'value' => $route),
@@ -2745,8 +2745,8 @@  discard block
 block discarded – undo
2745 2745
         // generate form fields
2746 2746
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2747 2747
         // add fields to form
2748
-        foreach ((array)$form_fields as $field_name => $form_field) {
2749
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2748
+        foreach ((array) $form_fields as $field_name => $form_field) {
2749
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
2750 2750
         }
2751 2751
         // close form
2752 2752
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -2827,7 +2827,7 @@  discard block
 block discarded – undo
2827 2827
          * @param array $query_args       The original query_args array coming into the
2828 2828
          *                                method.
2829 2829
          */
2830
-        do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2830
+        do_action('AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action, $query_args);
2831 2831
         //calculate where we're going (if we have a "save and close" button pushed)
2832 2832
         if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2833 2833
             // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
@@ -2843,7 +2843,7 @@  discard block
 block discarded – undo
2843 2843
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
2844 2844
                 //is there a wp_referer array in our _default_route_query_args property?
2845 2845
                 if ($query_param == 'wp_referer') {
2846
-                    $query_value = (array)$query_value;
2846
+                    $query_value = (array) $query_value;
2847 2847
                     foreach ($query_value as $reference => $value) {
2848 2848
                         if (strpos($reference, 'nonce') !== false) {
2849 2849
                             continue;
@@ -2869,11 +2869,11 @@  discard block
 block discarded – undo
2869 2869
         // if redirecting to anything other than the main page, add a nonce
2870 2870
         if (isset($query_args['action'])) {
2871 2871
             // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2872
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2872
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
2873 2873
         }
2874 2874
         //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
2875
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2876
-        $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2875
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
2876
+        $redirect_url = apply_filters('FHEE_redirect_'.$classname.$this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2877 2877
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2878 2878
         if (defined('DOING_AJAX')) {
2879 2879
             $default_data = array(
@@ -3003,7 +3003,7 @@  discard block
 block discarded – undo
3003 3003
         $args = array(
3004 3004
                 'label'   => $this->_admin_page_title,
3005 3005
                 'default' => 10,
3006
-                'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3006
+                'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3007 3007
         );
3008 3008
         //ONLY add the screen option if the user has access to it.
3009 3009
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3036,8 +3036,8 @@  discard block
 block discarded – undo
3036 3036
             $map_option = $option;
3037 3037
             $option = str_replace('-', '_', $option);
3038 3038
             switch ($map_option) {
3039
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3040
-                    $value = (int)$value;
3039
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3040
+                    $value = (int) $value;
3041 3041
                     if ($value < 1 || $value > 999) {
3042 3042
                         return;
3043 3043
                     }
@@ -3064,7 +3064,7 @@  discard block
 block discarded – undo
3064 3064
      */
3065 3065
     public function set_template_args($data)
3066 3066
     {
3067
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3067
+        $this->_template_args = array_merge($this->_template_args, (array) $data);
3068 3068
     }
3069 3069
 
3070 3070
 
@@ -3086,12 +3086,12 @@  discard block
 block discarded – undo
3086 3086
             $this->_verify_route($route);
3087 3087
         }
3088 3088
         //now let's set the string for what kind of transient we're setting
3089
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3089
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3090 3090
         $data = $notices ? array('notices' => $data) : $data;
3091 3091
         //is there already a transient for this route?  If there is then let's ADD to that transient
3092 3092
         $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3093 3093
         if ($existing) {
3094
-            $data = array_merge((array)$data, (array)$existing);
3094
+            $data = array_merge((array) $data, (array) $existing);
3095 3095
         }
3096 3096
         if (is_multisite() && is_network_admin()) {
3097 3097
             set_site_transient($transient, $data, 8);
@@ -3112,7 +3112,7 @@  discard block
 block discarded – undo
3112 3112
     {
3113 3113
         $user_id = get_current_user_id();
3114 3114
         $route = ! $route ? $this->_req_action : $route;
3115
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3115
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3116 3116
         $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3117 3117
         //delete transient after retrieval (just in case it hasn't expired);
3118 3118
         if (is_multisite() && is_network_admin()) {
@@ -3353,7 +3353,7 @@  discard block
 block discarded – undo
3353 3353
      */
3354 3354
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3355 3355
     {
3356
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3356
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3357 3357
     }
3358 3358
 
3359 3359
 
@@ -3367,7 +3367,7 @@  discard block
 block discarded – undo
3367 3367
      */
3368 3368
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3369 3369
     {
3370
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3370
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3371 3371
     }
3372 3372
 
3373 3373
 
Please login to merge, or discard this patch.
Indentation   +3299 added lines, -3299 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\interfaces\InterminableInterface;
2 2
 
3 3
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('No direct script access allowed');
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 /**
7 7
  * Event Espresso
@@ -30,2114 +30,2114 @@  discard block
 block discarded – undo
30 30
 {
31 31
 
32 32
 
33
-    //set in _init_page_props()
34
-    public $page_slug;
33
+	//set in _init_page_props()
34
+	public $page_slug;
35 35
 
36
-    public $page_label;
36
+	public $page_label;
37 37
 
38
-    public $page_folder;
38
+	public $page_folder;
39 39
 
40
-    //set in define_page_props()
41
-    protected $_admin_base_url;
40
+	//set in define_page_props()
41
+	protected $_admin_base_url;
42 42
 
43
-    protected $_admin_base_path;
43
+	protected $_admin_base_path;
44 44
 
45
-    protected $_admin_page_title;
45
+	protected $_admin_page_title;
46 46
 
47
-    protected $_labels;
47
+	protected $_labels;
48 48
 
49 49
 
50
-    //set early within EE_Admin_Init
51
-    protected $_wp_page_slug;
50
+	//set early within EE_Admin_Init
51
+	protected $_wp_page_slug;
52 52
 
53
-    //navtabs
54
-    protected $_nav_tabs;
53
+	//navtabs
54
+	protected $_nav_tabs;
55 55
 
56
-    protected $_default_nav_tab_name;
56
+	protected $_default_nav_tab_name;
57 57
 
58
-    //helptourstops
59
-    protected $_help_tour = array();
58
+	//helptourstops
59
+	protected $_help_tour = array();
60 60
 
61 61
 
62
-    //template variables (used by templates)
63
-    protected $_template_path;
62
+	//template variables (used by templates)
63
+	protected $_template_path;
64 64
 
65
-    protected $_column_template_path;
65
+	protected $_column_template_path;
66 66
 
67
-    /**
68
-     * @var array $_template_args
69
-     */
70
-    protected $_template_args = array();
67
+	/**
68
+	 * @var array $_template_args
69
+	 */
70
+	protected $_template_args = array();
71 71
 
72
-    /**
73
-     * this will hold the list table object for a given view.
74
-     *
75
-     * @var EE_Admin_List_Table $_list_table_object
76
-     */
77
-    protected $_list_table_object;
72
+	/**
73
+	 * this will hold the list table object for a given view.
74
+	 *
75
+	 * @var EE_Admin_List_Table $_list_table_object
76
+	 */
77
+	protected $_list_table_object;
78 78
 
79
-    //bools
80
-    protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
79
+	//bools
80
+	protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
81 81
 
82
-    protected $_routing;
82
+	protected $_routing;
83 83
 
84
-    //list table args
85
-    protected $_view;
84
+	//list table args
85
+	protected $_view;
86 86
 
87
-    protected $_views;
87
+	protected $_views;
88 88
 
89 89
 
90
-    //action => method pairs used for routing incoming requests
91
-    protected $_page_routes;
90
+	//action => method pairs used for routing incoming requests
91
+	protected $_page_routes;
92 92
 
93
-    protected $_page_config;
93
+	protected $_page_config;
94 94
 
95
-    //the current page route and route config
96
-    protected $_route;
95
+	//the current page route and route config
96
+	protected $_route;
97 97
 
98
-    protected $_route_config;
98
+	protected $_route_config;
99 99
 
100
-    /**
101
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
102
-     * actions.
103
-     *
104
-     * @since 4.6.x
105
-     * @var array.
106
-     */
107
-    protected $_default_route_query_args;
100
+	/**
101
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
102
+	 * actions.
103
+	 *
104
+	 * @since 4.6.x
105
+	 * @var array.
106
+	 */
107
+	protected $_default_route_query_args;
108 108
 
109
-    //set via request page and action args.
110
-    protected $_current_page;
109
+	//set via request page and action args.
110
+	protected $_current_page;
111 111
 
112
-    protected $_current_view;
112
+	protected $_current_view;
113 113
 
114
-    protected $_current_page_view_url;
114
+	protected $_current_page_view_url;
115 115
 
116
-    //sanitized request action (and nonce)
117
-    /**
118
-     * @var string $_req_action
119
-     */
120
-    protected $_req_action;
116
+	//sanitized request action (and nonce)
117
+	/**
118
+	 * @var string $_req_action
119
+	 */
120
+	protected $_req_action;
121 121
 
122
-    /**
123
-     * @var string $_req_nonce
124
-     */
125
-    protected $_req_nonce;
122
+	/**
123
+	 * @var string $_req_nonce
124
+	 */
125
+	protected $_req_nonce;
126 126
 
127
-    //search related
128
-    protected $_search_btn_label;
127
+	//search related
128
+	protected $_search_btn_label;
129 129
 
130
-    protected $_search_box_callback;
130
+	protected $_search_box_callback;
131 131
 
132
-    /**
133
-     * WP Current Screen object
134
-     *
135
-     * @var WP_Screen
136
-     */
137
-    protected $_current_screen;
132
+	/**
133
+	 * WP Current Screen object
134
+	 *
135
+	 * @var WP_Screen
136
+	 */
137
+	protected $_current_screen;
138 138
 
139
-    //for holding EE_Admin_Hooks object when needed (set via set_hook_object())
140
-    protected $_hook_obj;
139
+	//for holding EE_Admin_Hooks object when needed (set via set_hook_object())
140
+	protected $_hook_obj;
141 141
 
142
-    //for holding incoming request data
143
-    protected $_req_data;
142
+	//for holding incoming request data
143
+	protected $_req_data;
144 144
 
145
-    // yes / no array for admin form fields
146
-    protected $_yes_no_values = array();
147
-
148
-    //some default things shared by all child classes
149
-    protected $_default_espresso_metaboxes;
150
-
151
-    /**
152
-     *    EE_Registry Object
153
-     *
154
-     * @var    EE_Registry
155
-     * @access    protected
156
-     */
157
-    protected $EE = null;
158
-
159
-
160
-
161
-    /**
162
-     * This is just a property that flags whether the given route is a caffeinated route or not.
163
-     *
164
-     * @var boolean
165
-     */
166
-    protected $_is_caf = false;
167
-
168
-
169
-
170
-    /**
171
-     * @Constructor
172
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
173
-     * @access public
174
-     */
175
-    public function __construct($routing = true)
176
-    {
177
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
178
-            $this->_is_caf = true;
179
-        }
180
-        $this->_yes_no_values = array(
181
-                array('id' => true, 'text' => __('Yes', 'event_espresso')),
182
-                array('id' => false, 'text' => __('No', 'event_espresso')),
183
-        );
184
-        //set the _req_data property.
185
-        $this->_req_data = array_merge($_GET, $_POST);
186
-        //routing enabled?
187
-        $this->_routing = $routing;
188
-        //set initial page props (child method)
189
-        $this->_init_page_props();
190
-        //set global defaults
191
-        $this->_set_defaults();
192
-        //set early because incoming requests could be ajax related and we need to register those hooks.
193
-        $this->_global_ajax_hooks();
194
-        $this->_ajax_hooks();
195
-        //other_page_hooks have to be early too.
196
-        $this->_do_other_page_hooks();
197
-        //This just allows us to have extending classes do something specific
198
-        // before the parent constructor runs _page_setup().
199
-        if (method_exists($this, '_before_page_setup')) {
200
-            $this->_before_page_setup();
201
-        }
202
-        //set up page dependencies
203
-        $this->_page_setup();
204
-    }
205
-
206
-
207
-
208
-    /**
209
-     * _init_page_props
210
-     * Child classes use to set at least the following properties:
211
-     * $page_slug.
212
-     * $page_label.
213
-     *
214
-     * @abstract
215
-     * @access protected
216
-     * @return void
217
-     */
218
-    abstract protected function _init_page_props();
219
-
220
-
221
-
222
-    /**
223
-     * _ajax_hooks
224
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
225
-     * Note: within the ajax callback methods.
226
-     *
227
-     * @abstract
228
-     * @access protected
229
-     * @return void
230
-     */
231
-    abstract protected function _ajax_hooks();
232
-
233
-
234
-
235
-    /**
236
-     * _define_page_props
237
-     * child classes define page properties in here.  Must include at least:
238
-     * $_admin_base_url = base_url for all admin pages
239
-     * $_admin_page_title = default admin_page_title for admin pages
240
-     * $_labels = array of default labels for various automatically generated elements:
241
-     *    array(
242
-     *        'buttons' => array(
243
-     *            'add' => __('label for add new button'),
244
-     *            'edit' => __('label for edit button'),
245
-     *            'delete' => __('label for delete button')
246
-     *            )
247
-     *        )
248
-     *
249
-     * @abstract
250
-     * @access protected
251
-     * @return void
252
-     */
253
-    abstract protected function _define_page_props();
254
-
255
-
256
-
257
-    /**
258
-     * _set_page_routes
259
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also have a 'default'
260
-     * route. Here's the format
261
-     * $this->_page_routes = array(
262
-     *        'default' => array(
263
-     *            'func' => '_default_method_handling_route',
264
-     *            'args' => array('array','of','args'),
265
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing)
266
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a headers route after.  The string you enter here should match the defined route reference for a headers sent route.
267
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access this route.
268
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks).
269
-     *        ),
270
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method.
271
-     *        )
272
-     * )
273
-     *
274
-     * @abstract
275
-     * @access protected
276
-     * @return void
277
-     */
278
-    abstract protected function _set_page_routes();
279
-
280
-
281
-
282
-    /**
283
-     * _set_page_config
284
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the array corresponds to the page_route for the loaded page.
285
-     * Format:
286
-     * $this->_page_config = array(
287
-     *        'default' => array(
288
-     *            'labels' => array(
289
-     *                'buttons' => array(
290
-     *                    'add' => __('label for adding item'),
291
-     *                    'edit' => __('label for editing item'),
292
-     *                    'delete' => __('label for deleting item')
293
-     *                ),
294
-     *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
295
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the page. If this isn't present then the defaults will be used as set for the $this->_labels in _define_page_props() method
296
-     *            'nav' => array(
297
-     *                'label' => __('Label for Tab', 'event_espresso').
298
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
299
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
300
-     *                'order' => 10, //required to indicate tab position.
301
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter.
302
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
303
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages.
304
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added later.  We just use
305
-     *            this flag to make sure the necessary js gets enqueued on page load.
306
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
307
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The array indicates the max number of columns (4) and the default number of columns on page load (2).  There is an option
308
-     *            in the "screen_options" dropdown that is setup so users can pick what columns they want to display.
309
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
310
-     *                'tab_id' => array(
311
-     *                    'title' => 'tab_title',
312
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting help tab content.  The fallback if it isn't present is to try a the callback.  Filename should match a file in the admin
313
-     *                    folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php)
314
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will attempt to use the callback which should match the name of a method in the class
315
-     *                    ),
316
-     *                'tab2_id' => array(
317
-     *                    'title' => 'tab2 title',
318
-     *                    'filename' => 'file_name_2'
319
-     *                    'callback' => 'callback_method_for_content',
320
-     *                 ),
321
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the help tab area on an admin page. @link http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
322
-     *            'help_tour' => array(
323
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located in a folder for this admin page named "help_tours", a file name matching the key given here
324
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
325
-     *            ),
326
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is true if it isn't present).  To remove the requirement for a nonce check when this route is visited just set
327
-     *            'require_nonce' to FALSE
328
-     *            )
329
-     * )
330
-     *
331
-     * @abstract
332
-     * @access protected
333
-     * @return void
334
-     */
335
-    abstract protected function _set_page_config();
336
-
337
-
338
-
339
-
340
-
341
-    /** end sample help_tour methods **/
342
-    /**
343
-     * _add_screen_options
344
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
345
-     * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view.
346
-     *
347
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
348
-     *         see also WP_Screen object documents...
349
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
350
-     * @abstract
351
-     * @access protected
352
-     * @return void
353
-     */
354
-    abstract protected function _add_screen_options();
355
-
356
-
357
-
358
-    /**
359
-     * _add_feature_pointers
360
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
361
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view.
362
-     * Note: this is just a placeholder for now.  Implementation will come down the road
363
-     * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
364
-     *
365
-     * @link   http://eamann.com/tech/wordpress-portland/
366
-     * @abstract
367
-     * @access protected
368
-     * @return void
369
-     */
370
-    abstract protected function _add_feature_pointers();
371
-
372
-
373
-
374
-    /**
375
-     * load_scripts_styles
376
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific scripts/styles
377
-     * per view by putting them in a dynamic function in this format (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
378
-     *
379
-     * @abstract
380
-     * @access public
381
-     * @return void
382
-     */
383
-    abstract public function load_scripts_styles();
384
-
385
-
386
-
387
-    /**
388
-     * admin_init
389
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to all pages/views loaded by child class.
390
-     *
391
-     * @abstract
392
-     * @access public
393
-     * @return void
394
-     */
395
-    abstract public function admin_init();
396
-
397
-
398
-
399
-    /**
400
-     * admin_notices
401
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to all pages/views loaded by child class.
402
-     *
403
-     * @abstract
404
-     * @access public
405
-     * @return void
406
-     */
407
-    abstract public function admin_notices();
408
-
409
-
410
-
411
-    /**
412
-     * admin_footer_scripts
413
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class.
414
-     *
415
-     * @access public
416
-     * @return void
417
-     */
418
-    abstract public function admin_footer_scripts();
419
-
420
-
421
-
422
-    /**
423
-     * admin_footer
424
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will apply to all pages/views loaded by child class.
425
-     *
426
-     * @access  public
427
-     * @return void
428
-     */
429
-    public function admin_footer()
430
-    {
431
-    }
432
-
433
-
434
-
435
-    /**
436
-     * _global_ajax_hooks
437
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
438
-     * Note: within the ajax callback methods.
439
-     *
440
-     * @abstract
441
-     * @access protected
442
-     * @return void
443
-     */
444
-    protected function _global_ajax_hooks()
445
-    {
446
-        //for lazy loading of metabox content
447
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
448
-    }
449
-
450
-
451
-
452
-    public function ajax_metabox_content()
453
-    {
454
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
455
-        $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
456
-        self::cached_rss_display($contentid, $url);
457
-        wp_die();
458
-    }
459
-
460
-
461
-
462
-    /**
463
-     * _page_setup
464
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested doesn't match the object.
465
-     *
466
-     * @final
467
-     * @access protected
468
-     * @return void
469
-     */
470
-    final protected function _page_setup()
471
-    {
472
-        //requires?
473
-        //admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
474
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
475
-        //next verify if we need to load anything...
476
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
477
-        $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
478
-        global $ee_menu_slugs;
479
-        $ee_menu_slugs = (array)$ee_menu_slugs;
480
-        if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
481
-            return;
482
-        }
483
-        // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
484
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
485
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action'];
486
-        }
487
-        // then set blank or -1 action values to 'default'
488
-        $this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
489
-        //if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.  This covers cases where we're coming in from a list table that isn't on the default route.
490
-        $this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
491
-        //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
492
-        $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
493
-        $this->_current_view = $this->_req_action;
494
-        $this->_req_nonce = $this->_req_action . '_nonce';
495
-        $this->_define_page_props();
496
-        $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
497
-        //default things
498
-        $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box');
499
-        //set page configs
500
-        $this->_set_page_routes();
501
-        $this->_set_page_config();
502
-        //let's include any referrer data in our default_query_args for this route for "stickiness".
503
-        if (isset($this->_req_data['wp_referer'])) {
504
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
505
-        }
506
-        //for caffeinated and other extended functionality.  If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays
507
-        if (method_exists($this, '_extend_page_config')) {
508
-            $this->_extend_page_config();
509
-        }
510
-        //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays.
511
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
512
-            $this->_extend_page_config_for_cpt();
513
-        }
514
-        //filter routes and page_config so addons can add their stuff. Filtering done per class
515
-        $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
516
-        $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
517
-        //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
518
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
519
-            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
520
-        }
521
-        //next route only if routing enabled
522
-        if ($this->_routing && ! defined('DOING_AJAX')) {
523
-            $this->_verify_routes();
524
-            //next let's just check user_access and kill if no access
525
-            $this->check_user_access();
526
-            if ($this->_is_UI_request) {
527
-                //admin_init stuff - global, all views for this page class, specific view
528
-                add_action('admin_init', array($this, 'admin_init'), 10);
529
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
530
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
531
-                }
532
-            } else {
533
-                //hijack regular WP loading and route admin request immediately
534
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
535
-                $this->route_admin_request();
536
-            }
537
-        }
538
-    }
539
-
540
-
541
-
542
-    /**
543
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
544
-     *
545
-     * @access private
546
-     * @return void
547
-     */
548
-    private function _do_other_page_hooks()
549
-    {
550
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
551
-        foreach ($registered_pages as $page) {
552
-            //now let's setup the file name and class that should be present
553
-            $classname = str_replace('.class.php', '', $page);
554
-            //autoloaders should take care of loading file
555
-            if ( ! class_exists($classname)) {
556
-                $error_msg[] = sprintf( esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
557
-                $error_msg[] = $error_msg[0]
558
-                               . "\r\n"
559
-                               . sprintf( esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
560
-                                'event_espresso'), $page, '<br />', '<strong>' . $classname . '</strong>');
561
-                throw new EE_Error(implode('||', $error_msg));
562
-            }
563
-            $a = new ReflectionClass($classname);
564
-            //notice we are passing the instance of this class to the hook object.
565
-            $hookobj[] = $a->newInstance($this);
566
-        }
567
-    }
568
-
569
-
570
-
571
-    public function load_page_dependencies()
572
-    {
573
-        try {
574
-            $this->_load_page_dependencies();
575
-        } catch (EE_Error $e) {
576
-            $e->get_error();
577
-        }
578
-    }
579
-
580
-
581
-
582
-    /**
583
-     * load_page_dependencies
584
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
585
-     *
586
-     * @access public
587
-     * @return void
588
-     */
589
-    protected function _load_page_dependencies()
590
-    {
591
-        //let's set the current_screen and screen options to override what WP set
592
-        $this->_current_screen = get_current_screen();
593
-        //load admin_notices - global, page class, and view specific
594
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
595
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
596
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
597
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
598
-        }
599
-        //load network admin_notices - global, page class, and view specific
600
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
601
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
602
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
603
-        }
604
-        //this will save any per_page screen options if they are present
605
-        $this->_set_per_page_screen_options();
606
-        //setup list table properties
607
-        $this->_set_list_table();
608
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.  However in some cases the metaboxes will need to be added within a route handling callback.
609
-        $this->_add_registered_meta_boxes();
610
-        $this->_add_screen_columns();
611
-        //add screen options - global, page child class, and view specific
612
-        $this->_add_global_screen_options();
613
-        $this->_add_screen_options();
614
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
615
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
616
-        }
617
-        //add help tab(s) and tours- set via page_config and qtips.
618
-        $this->_add_help_tour();
619
-        $this->_add_help_tabs();
620
-        $this->_add_qtips();
621
-        //add feature_pointers - global, page child class, and view specific
622
-        $this->_add_feature_pointers();
623
-        $this->_add_global_feature_pointers();
624
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
625
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
626
-        }
627
-        //enqueue scripts/styles - global, page class, and view specific
628
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
629
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
630
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
631
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
632
-        }
633
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
634
-        //admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
635
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
636
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
637
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
638
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
639
-        }
640
-        //admin footer scripts
641
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
642
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
643
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
644
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
645
-        }
646
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
647
-        //targeted hook
648
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
649
-    }
650
-
651
-
652
-
653
-    /**
654
-     * _set_defaults
655
-     * This sets some global defaults for class properties.
656
-     */
657
-    private function _set_defaults()
658
-    {
659
-        $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
660
-        $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
661
-        $this->default_nav_tab_name = 'overview';
662
-        //init template args
663
-        $this->_template_args = array(
664
-                'admin_page_header'  => '',
665
-                'admin_page_content' => '',
666
-                'post_body_content'  => '',
667
-                'before_list_table'  => '',
668
-                'after_list_table'   => '',
669
-        );
670
-    }
671
-
672
-
673
-
674
-    /**
675
-     * route_admin_request
676
-     *
677
-     * @see    _route_admin_request()
678
-     * @access public
679
-     * @return void|exception error
680
-     */
681
-    public function route_admin_request()
682
-    {
683
-        try {
684
-            $this->_route_admin_request();
685
-        } catch (EE_Error $e) {
686
-            $e->get_error();
687
-        }
688
-    }
689
-
690
-
691
-
692
-    public function set_wp_page_slug($wp_page_slug)
693
-    {
694
-        $this->_wp_page_slug = $wp_page_slug;
695
-        //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
696
-        if (is_network_admin()) {
697
-            $this->_wp_page_slug .= '-network';
698
-        }
699
-    }
700
-
701
-
702
-
703
-    /**
704
-     * _verify_routes
705
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so we know if we need to drop out.
706
-     *
707
-     * @access protected
708
-     * @return void
709
-     */
710
-    protected function _verify_routes()
711
-    {
712
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
713
-        if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
714
-            return false;
715
-        }
716
-        $this->_route = false;
717
-        $func = false;
718
-        $args = array();
719
-        // check that the page_routes array is not empty
720
-        if (empty($this->_page_routes)) {
721
-            // user error msg
722
-            $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
723
-            // developer error msg
724
-            $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
725
-            throw new EE_Error($error_msg);
726
-        }
727
-        // and that the requested page route exists
728
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
729
-            $this->_route = $this->_page_routes[$this->_req_action];
730
-            $this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array();
731
-        } else {
732
-            // user error msg
733
-            $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
734
-            // developer error msg
735
-            $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
736
-            throw new EE_Error($error_msg);
737
-        }
738
-        // and that a default route exists
739
-        if ( ! array_key_exists('default', $this->_page_routes)) {
740
-            // user error msg
741
-            $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
742
-            // developer error msg
743
-            $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
744
-            throw new EE_Error($error_msg);
745
-        }
746
-        //first lets' catch if the UI request has EVER been set.
747
-        if ($this->_is_UI_request === null) {
748
-            //lets set if this is a UI request or not.
749
-            $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false;
750
-            //wait a minute... we might have a noheader in the route array
751
-            $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request;
752
-        }
753
-        $this->_set_current_labels();
754
-    }
755
-
756
-
757
-
758
-    /**
759
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
760
-     *
761
-     * @param  string $route the route name we're verifying
762
-     * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
763
-     */
764
-    protected function _verify_route($route)
765
-    {
766
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
767
-            return true;
768
-        } else {
769
-            // user error msg
770
-            $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
771
-            // developer error msg
772
-            $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
773
-            throw new EE_Error($error_msg);
774
-        }
775
-    }
776
-
777
-
778
-
779
-    /**
780
-     * perform nonce verification
781
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces using this method (and save retyping!)
782
-     *
783
-     * @param  string $nonce     The nonce sent
784
-     * @param  string $nonce_ref The nonce reference string (name0)
785
-     * @return mixed (bool|die)
786
-     */
787
-    protected function _verify_nonce($nonce, $nonce_ref)
788
-    {
789
-        // verify nonce against expected value
790
-        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
791
-            // these are not the droids you are looking for !!!
792
-            $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
793
-            if (WP_DEBUG) {
794
-                $msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
795
-            }
796
-            if ( ! defined('DOING_AJAX')) {
797
-                wp_die($msg);
798
-            } else {
799
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
800
-                $this->_return_json();
801
-            }
802
-        }
803
-    }
804
-
805
-
806
-
807
-    /**
808
-     * _route_admin_request()
809
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
810
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
811
-     * in the page routes and then will try to load the corresponding method.
812
-     *
813
-     * @access protected
814
-     * @return void
815
-     * @throws \EE_Error
816
-     */
817
-    protected function _route_admin_request()
818
-    {
819
-        if ( ! $this->_is_UI_request) {
820
-            $this->_verify_routes();
821
-        }
822
-        $nonce_check = isset($this->_route_config['require_nonce'])
823
-            ? $this->_route_config['require_nonce']
824
-            : true;
825
-        if ($this->_req_action !== 'default' && $nonce_check) {
826
-            // set nonce from post data
827
-            $nonce = isset($this->_req_data[$this->_req_nonce])
828
-                ? sanitize_text_field($this->_req_data[$this->_req_nonce])
829
-                : '';
830
-            $this->_verify_nonce($nonce, $this->_req_nonce);
831
-        }
832
-        //set the nav_tabs array but ONLY if this is  UI_request
833
-        if ($this->_is_UI_request) {
834
-            $this->_set_nav_tabs();
835
-        }
836
-        // grab callback function
837
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
838
-        // check if callback has args
839
-        $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
840
-        $error_msg = '';
841
-        // action right before calling route
842
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
843
-        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
844
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
845
-        }
846
-        // right before calling the route, let's remove _wp_http_referer from the
847
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
848
-        $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
849
-        if ( ! empty($func)) {
850
-            if (is_array($func)) {
851
-                list($class, $method) = $func;
852
-            } else if (strpos($func, '::') !== false) {
853
-                list($class, $method) = explode('::', $func);
854
-            } else {
855
-                $class = $this;
856
-                $method = $func;
857
-            }
858
-            if ( ! (is_object($class) && $class === $this)) {
859
-                // send along this admin page object for access by addons.
860
-                $args['admin_page_object'] = $this;
861
-            }
862
-
863
-            if (
864
-                //is it a method on a class that doesn't work?
865
-                (
866
-                    (
867
-                        method_exists($class, $method)
868
-                        && call_user_func_array(array($class, $method), $args) === false
869
-                    )
870
-                    && (
871
-                        //is it a standalone function that doesn't work?
872
-                        function_exists($method)
873
-                        && call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false
874
-                    )
875
-                )
876
-                || (
877
-                    //is it neither a class method NOR a standalone function?
878
-                    ! method_exists($class, $method)
879
-                    && ! function_exists($method)
880
-                )
881
-            ) {
882
-                // user error msg
883
-                $error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
884
-                // developer error msg
885
-                $error_msg .= '||';
886
-                $error_msg .= sprintf(
887
-                    __(
888
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
889
-                        'event_espresso'
890
-                    ),
891
-                    $method
892
-                );
893
-            }
894
-            if ( ! empty($error_msg)) {
895
-                throw new EE_Error($error_msg);
896
-            }
897
-        }
898
-        //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route.
899
-        //now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
900
-        if ($this->_is_UI_request === false
901
-            && is_array($this->_route)
902
-            && ! empty($this->_route['headers_sent_route'])
903
-        ) {
904
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
905
-        }
906
-    }
907
-
908
-
909
-
910
-    /**
911
-     * This method just allows the resetting of page properties in the case where a no headers
912
-     * route redirects to a headers route in its route config.
913
-     *
914
-     * @since   4.3.0
915
-     * @param  string $new_route New (non header) route to redirect to.
916
-     * @return   void
917
-     */
918
-    protected function _reset_routing_properties($new_route)
919
-    {
920
-        $this->_is_UI_request = true;
921
-        //now we set the current route to whatever the headers_sent_route is set at
922
-        $this->_req_data['action'] = $new_route;
923
-        //rerun page setup
924
-        $this->_page_setup();
925
-    }
926
-
927
-
928
-
929
-    /**
930
-     * _add_query_arg
931
-     * adds nonce to array of arguments then calls WP add_query_arg function
932
-     *(internally just uses EEH_URL's function with the same name)
933
-     *
934
-     * @access public
935
-     * @param array  $args
936
-     * @param string $url
937
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the generated
938
-     *                                        url in an associative array indexed by the key 'wp_referer';
939
-     *                                        Example usage:
940
-     *                                        If the current page is:
941
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
942
-     *                                        &action=default&event_id=20&month_range=March%202015
943
-     *                                        &_wpnonce=5467821
944
-     *                                        and you call:
945
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
946
-     *                                        array(
947
-     *                                        'action' => 'resend_something',
948
-     *                                        'page=>espresso_registrations'
949
-     *                                        ),
950
-     *                                        $some_url,
951
-     *                                        true
952
-     *                                        );
953
-     *                                        It will produce a url in this structure:
954
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
955
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
956
-     *                                        month_range]=March%202015
957
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
958
-     * @return string
959
-     */
960
-    public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false)
961
-    {
962
-        //if there is a _wp_http_referer include the values from the request but only if sticky = true
963
-        if ($sticky) {
964
-            $request = $_REQUEST;
965
-            unset($request['_wp_http_referer']);
966
-            unset($request['wp_referer']);
967
-            foreach ($request as $key => $value) {
968
-                //do not add nonces
969
-                if (strpos($key, 'nonce') !== false) {
970
-                    continue;
971
-                }
972
-                $args['wp_referer[' . $key . ']'] = $value;
973
-            }
974
-        }
975
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
976
-    }
977
-
978
-
979
-
980
-    /**
981
-     * This returns a generated link that will load the related help tab.
982
-     *
983
-     * @param  string $help_tab_id the id for the connected help tab
984
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
985
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
986
-     * @uses EEH_Template::get_help_tab_link()
987
-     * @return string              generated link
988
-     */
989
-    protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
990
-    {
991
-        return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text);
992
-    }
993
-
994
-
995
-
996
-    /**
997
-     * _add_help_tabs
998
-     * Note child classes define their help tabs within the page_config array.
999
-     *
1000
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1001
-     * @access protected
1002
-     * @return void
1003
-     */
1004
-    protected function _add_help_tabs()
1005
-    {
1006
-        $tour_buttons = '';
1007
-        if (isset($this->_page_config[$this->_req_action])) {
1008
-            $config = $this->_page_config[$this->_req_action];
1009
-            //is there a help tour for the current route?  if there is let's setup the tour buttons
1010
-            if (isset($this->_help_tour[$this->_req_action])) {
1011
-                $tb = array();
1012
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1013
-                foreach ($this->_help_tour['tours'] as $tour) {
1014
-                    //if this is the end tour then we don't need to setup a button
1015
-                    if ($tour instanceof EE_Help_Tour_final_stop) {
1016
-                        continue;
1017
-                    }
1018
-                    $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1019
-                }
1020
-                $tour_buttons .= implode('<br />', $tb);
1021
-                $tour_buttons .= '</div></div>';
1022
-            }
1023
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1024
-            if (is_array($config) && isset($config['help_sidebar'])) {
1025
-                //check that the callback given is valid
1026
-                if ( ! method_exists($this, $config['help_sidebar'])) {
1027
-                    throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1028
-                            'event_espresso'), $config['help_sidebar'], get_class($this)));
1029
-                }
1030
-                $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1031
-                $content .= $tour_buttons; //add help tour buttons.
1032
-                //do we have any help tours setup?  Cause if we do we want to add the buttons
1033
-                $this->_current_screen->set_help_sidebar($content);
1034
-            }
1035
-            //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1036
-            if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1037
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1038
-            }
1039
-            //handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1040
-            if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1041
-                $_ht['id'] = $this->page_slug;
1042
-                $_ht['title'] = __('Help Tours', 'event_espresso');
1043
-                $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1044
-                $this->_current_screen->add_help_tab($_ht);
1045
-            }/**/
1046
-            if ( ! isset($config['help_tabs'])) {
1047
-                return;
1048
-            } //no help tabs for this route
1049
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1050
-                //we're here so there ARE help tabs!
1051
-                //make sure we've got what we need
1052
-                if ( ! isset($cfg['title'])) {
1053
-                    throw new EE_Error(__('The _page_config array is not set up properly for help tabs.  It is missing a title', 'event_espresso'));
1054
-                }
1055
-                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1056
-                    throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1057
-                            'event_espresso'));
1058
-                }
1059
-                //first priority goes to content.
1060
-                if ( ! empty($cfg['content'])) {
1061
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1062
-                    //second priority goes to filename
1063
-                } else if ( ! empty($cfg['filename'])) {
1064
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1065
-                    //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1066
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1067
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1068
-                    if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1069
-                        EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1070
-                                'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__);
1071
-                        return;
1072
-                    }
1073
-                    $template_args['admin_page_obj'] = $this;
1074
-                    $content = EEH_Template::display_template($file_path, $template_args, true);
1075
-                } else {
1076
-                    $content = '';
1077
-                }
1078
-                //check if callback is valid
1079
-                if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1080
-                    EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1081
-                            'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__);
1082
-                    return;
1083
-                }
1084
-                //setup config array for help tab method
1085
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1086
-                $_ht = array(
1087
-                        'id'       => $id,
1088
-                        'title'    => $cfg['title'],
1089
-                        'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1090
-                        'content'  => $content,
1091
-                );
1092
-                $this->_current_screen->add_help_tab($_ht);
1093
-            }
1094
-        }
1095
-    }
1096
-
1097
-
1098
-
1099
-    /**
1100
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is an array with properties for setting up usage of the joyride plugin
1101
-     *
1102
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1103
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments
1104
-     * @access protected
1105
-     * @return void
1106
-     */
1107
-    protected function _add_help_tour()
1108
-    {
1109
-        $tours = array();
1110
-        $this->_help_tour = array();
1111
-        //exit early if help tours are turned off globally
1112
-        if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) {
1113
-            return;
1114
-        }
1115
-        //loop through _page_config to find any help_tour defined
1116
-        foreach ($this->_page_config as $route => $config) {
1117
-            //we're only going to set things up for this route
1118
-            if ($route !== $this->_req_action) {
1119
-                continue;
1120
-            }
1121
-            if (isset($config['help_tour'])) {
1122
-                foreach ($config['help_tour'] as $tour) {
1123
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1124
-                    //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1125
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1126
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1127
-                    if ( ! is_readable($file_path)) {
1128
-                        EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'),
1129
-                                $file_path, $tour), __FILE__, __FUNCTION__, __LINE__);
1130
-                        return;
1131
-                    }
1132
-                    require_once $file_path;
1133
-                    if ( ! class_exists($tour)) {
1134
-                        $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1135
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1136
-                                        'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1137
-                        throw new EE_Error(implode('||', $error_msg));
1138
-                    }
1139
-                    $a = new ReflectionClass($tour);
1140
-                    $tour_obj = $a->newInstance($this->_is_caf);
1141
-                    $tours[] = $tour_obj;
1142
-                    $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1143
-                }
1144
-                //let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1145
-                $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1146
-                $tours[] = $end_stop_tour;
1147
-                $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1148
-            }
1149
-        }
1150
-        if ( ! empty($tours)) {
1151
-            $this->_help_tour['tours'] = $tours;
1152
-        }
1153
-        //thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1154
-    }
1155
-
1156
-
1157
-
1158
-    /**
1159
-     * This simply sets up any qtips that have been defined in the page config
1160
-     *
1161
-     * @access protected
1162
-     * @return void
1163
-     */
1164
-    protected function _add_qtips()
1165
-    {
1166
-        if (isset($this->_route_config['qtips'])) {
1167
-            $qtips = (array)$this->_route_config['qtips'];
1168
-            //load qtip loader
1169
-            $path = array(
1170
-                    $this->_get_dir() . '/qtips/',
1171
-                    EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1172
-            );
1173
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1174
-        }
1175
-    }
1176
-
1177
-
1178
-
1179
-    /**
1180
-     * _set_nav_tabs
1181
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you wish to add additional tabs or modify accordingly.
1182
-     *
1183
-     * @access protected
1184
-     * @return void
1185
-     */
1186
-    protected function _set_nav_tabs()
1187
-    {
1188
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1189
-        $i = 0;
1190
-        foreach ($this->_page_config as $slug => $config) {
1191
-            if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) {
1192
-                continue;
1193
-            } //no nav tab for this config
1194
-            //check for persistent flag
1195
-            if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1196
-                continue;
1197
-            } //nav tab is only to appear when route requested.
1198
-            if ( ! $this->check_user_access($slug, true)) {
1199
-                continue;
1200
-            } //no nav tab becasue current user does not have access.
1201
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1202
-            $this->_nav_tabs[$slug] = array(
1203
-                    'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1204
-                    'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1205
-                    'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1206
-                    'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1207
-            );
1208
-            $i++;
1209
-        }
1210
-        //if $this->_nav_tabs is empty then lets set the default
1211
-        if (empty($this->_nav_tabs)) {
1212
-            $this->_nav_tabs[$this->default_nav_tab_name] = array(
1213
-                    'url'       => $this->admin_base_url,
1214
-                    'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1215
-                    'css_class' => 'nav-tab-active',
1216
-                    'order'     => 10,
1217
-            );
1218
-        }
1219
-        //now let's sort the tabs according to order
1220
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1221
-    }
1222
-
1223
-
1224
-
1225
-    /**
1226
-     * _set_current_labels
1227
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array
1228
-     *
1229
-     * @access private
1230
-     * @return void
1231
-     */
1232
-    private function _set_current_labels()
1233
-    {
1234
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1235
-            foreach ($this->_route_config['labels'] as $label => $text) {
1236
-                if (is_array($text)) {
1237
-                    foreach ($text as $sublabel => $subtext) {
1238
-                        $this->_labels[$label][$sublabel] = $subtext;
1239
-                    }
1240
-                } else {
1241
-                    $this->_labels[$label] = $text;
1242
-                }
1243
-            }
1244
-        }
1245
-    }
1246
-
1247
-
1248
-
1249
-    /**
1250
-     *        verifies user access for this admin page
1251
-     *
1252
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1253
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just return false if verify fail.
1254
-     * @return        BOOL|wp_die()
1255
-     */
1256
-    public function check_user_access($route_to_check = '', $verify_only = false)
1257
-    {
1258
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1259
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1260
-        $capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability'])
1261
-                ? $this->_page_routes[$route_to_check]['capability'] : null;
1262
-        if (empty($capability) && empty($route_to_check)) {
1263
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability'];
1264
-        } else {
1265
-            $capability = empty($capability) ? 'manage_options' : $capability;
1266
-        }
1267
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1268
-        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1269
-            if ($verify_only) {
1270
-                return false;
1271
-            } else {
1272
-                if ( is_user_logged_in() ) {
1273
-                    wp_die(__('You do not have access to this route.', 'event_espresso'));
1274
-                } else {
1275
-                    return false;
1276
-                }
1277
-            }
1278
-        }
1279
-        return true;
1280
-    }
1281
-
1282
-
1283
-
1284
-    /**
1285
-     * admin_init_global
1286
-     * This runs all the code that we want executed within the WP admin_init hook.
1287
-     * This method executes for ALL EE Admin pages.
1288
-     *
1289
-     * @access public
1290
-     * @return void
1291
-     */
1292
-    public function admin_init_global()
1293
-    {
1294
-    }
1295
-
1296
-
1297
-
1298
-    /**
1299
-     * wp_loaded_global
1300
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an EE_Admin page and will execute on every EE Admin Page load
1301
-     *
1302
-     * @access public
1303
-     * @return void
1304
-     */
1305
-    public function wp_loaded()
1306
-    {
1307
-    }
1308
-
1309
-
1310
-
1311
-    /**
1312
-     * admin_notices
1313
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on ALL EE_Admin pages.
1314
-     *
1315
-     * @access public
1316
-     * @return void
1317
-     */
1318
-    public function admin_notices_global()
1319
-    {
1320
-        $this->_display_no_javascript_warning();
1321
-        $this->_display_espresso_notices();
1322
-    }
1323
-
1324
-
1325
-
1326
-    public function network_admin_notices_global()
1327
-    {
1328
-        $this->_display_no_javascript_warning();
1329
-        $this->_display_espresso_notices();
1330
-    }
1331
-
1332
-
1333
-
1334
-    /**
1335
-     * admin_footer_scripts_global
1336
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages.
1337
-     *
1338
-     * @access public
1339
-     * @return void
1340
-     */
1341
-    public function admin_footer_scripts_global()
1342
-    {
1343
-        $this->_add_admin_page_ajax_loading_img();
1344
-        $this->_add_admin_page_overlay();
1345
-        //if metaboxes are present we need to add the nonce field
1346
-        if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) {
1347
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1348
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1349
-        }
1350
-    }
1351
-
1352
-
1353
-
1354
-    /**
1355
-     * admin_footer_global
1356
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages.
1357
-     *
1358
-     * @access  public
1359
-     * @return  void
1360
-     */
1361
-    public function admin_footer_global()
1362
-    {
1363
-        //dialog container for dialog helper
1364
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1365
-        $d_cont .= '<div class="ee-notices"></div>';
1366
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1367
-        $d_cont .= '</div>';
1368
-        echo $d_cont;
1369
-        //help tour stuff?
1370
-        if (isset($this->_help_tour[$this->_req_action])) {
1371
-            echo implode('<br />', $this->_help_tour[$this->_req_action]);
1372
-        }
1373
-        //current set timezone for timezone js
1374
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1375
-    }
1376
-
1377
-
1378
-
1379
-    /**
1380
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then we'll use the retrieved array to output the content using the template.
1381
-     * For child classes:
1382
-     * If you want to have help popups then in your templates or your content you set "triggers" for the content using the "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method for
1383
-     * the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content for the
1384
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1385
-     *    'help_trigger_id' => array(
1386
-     *        'title' => __('localized title for popup', 'event_espresso'),
1387
-     *        'content' => __('localized content for popup', 'event_espresso')
1388
-     *    )
1389
-     * );
1390
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1391
-     *
1392
-     * @access protected
1393
-     * @return string content
1394
-     */
1395
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1396
-    {
1397
-        $content = '';
1398
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1399
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1400
-        //loop through the array and setup content
1401
-        foreach ($help_array as $trigger => $help) {
1402
-            //make sure the array is setup properly
1403
-            if ( ! isset($help['title']) || ! isset($help['content'])) {
1404
-                throw new EE_Error(__('Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1405
-                        'event_espresso'));
1406
-            }
1407
-            //we're good so let'd setup the template vars and then assign parsed template content to our content.
1408
-            $template_args = array(
1409
-                    'help_popup_id'      => $trigger,
1410
-                    'help_popup_title'   => $help['title'],
1411
-                    'help_popup_content' => $help['content'],
1412
-            );
1413
-            $content .= EEH_Template::display_template($template_path, $template_args, true);
1414
-        }
1415
-        if ($display) {
1416
-            echo $content;
1417
-        } else {
1418
-            return $content;
1419
-        }
1420
-    }
1421
-
1422
-
1423
-
1424
-    /**
1425
-     * All this does is retrive the help content array if set by the EE_Admin_Page child
1426
-     *
1427
-     * @access private
1428
-     * @return array properly formatted array for help popup content
1429
-     */
1430
-    private function _get_help_content()
1431
-    {
1432
-        //what is the method we're looking for?
1433
-        $method_name = '_help_popup_content_' . $this->_req_action;
1434
-        //if method doesn't exist let's get out.
1435
-        if ( ! method_exists($this, $method_name)) {
1436
-            return array();
1437
-        }
1438
-        //k we're good to go let's retrieve the help array
1439
-        $help_array = call_user_func(array($this, $method_name));
1440
-        //make sure we've got an array!
1441
-        if ( ! is_array($help_array)) {
1442
-            throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso'));
1443
-        }
1444
-        return $help_array;
1445
-    }
1446
-
1447
-
1448
-
1449
-    /**
1450
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1451
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1452
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1453
-     *
1454
-     * @access protected
1455
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1456
-     * @param boolean $display    if false then we return the trigger string
1457
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1458
-     * @return string
1459
-     */
1460
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1461
-    {
1462
-        if (defined('DOING_AJAX')) {
1463
-            return;
1464
-        }
1465
-        //let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1466
-        $help_array = $this->_get_help_content();
1467
-        $help_content = '';
1468
-        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1469
-            $help_array[$trigger_id] = array(
1470
-                    'title'   => __('Missing Content', 'event_espresso'),
1471
-                    'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1472
-                            'event_espresso'),
1473
-            );
1474
-            $help_content = $this->_set_help_popup_content($help_array, false);
1475
-        }
1476
-        //let's setup the trigger
1477
-        $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1478
-        $content = $content . $help_content;
1479
-        if ($display) {
1480
-            echo $content;
1481
-        } else {
1482
-            return $content;
1483
-        }
1484
-    }
1485
-
1486
-
1487
-
1488
-    /**
1489
-     * _add_global_screen_options
1490
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1491
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1492
-     *
1493
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1494
-     *         see also WP_Screen object documents...
1495
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1496
-     * @abstract
1497
-     * @access private
1498
-     * @return void
1499
-     */
1500
-    private function _add_global_screen_options()
1501
-    {
1502
-    }
1503
-
1504
-
1505
-
1506
-    /**
1507
-     * _add_global_feature_pointers
1508
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1509
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1510
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1511
-     *
1512
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
1513
-     * @link   http://eamann.com/tech/wordpress-portland/
1514
-     * @abstract
1515
-     * @access protected
1516
-     * @return void
1517
-     */
1518
-    private function _add_global_feature_pointers()
1519
-    {
1520
-    }
1521
-
1522
-
1523
-
1524
-    /**
1525
-     * load_global_scripts_styles
1526
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1527
-     *
1528
-     * @return void
1529
-     */
1530
-    public function load_global_scripts_styles()
1531
-    {
1532
-        /** STYLES **/
1533
-        // add debugging styles
1534
-        if (WP_DEBUG) {
1535
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1536
-        }
1537
-        // register all styles
1538
-        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1539
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1540
-        //helpers styles
1541
-        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1542
-        /** SCRIPTS **/
1543
-        //register all scripts
1544
-        wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1545
-        wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1546
-        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1547
-        add_filter('FHEE_load_joyride', '__return_true');
1548
-        //script for sorting tables
1549
-        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1550
-        //script for parsing uri's
1551
-        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1552
-        //and parsing associative serialized form elements
1553
-        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1554
-        //helpers scripts
1555
-        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1556
-        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1557
-        wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1558
-        wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1559
-        //google charts
1560
-        wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1561
-        // ENQUEUE ALL BASICS BY DEFAULT
1562
-        wp_enqueue_style('ee-admin-css');
1563
-        wp_enqueue_script('ee_admin_js');
1564
-        wp_enqueue_script('ee-accounting');
1565
-        wp_enqueue_script('jquery-validate');
1566
-        //taking care of metaboxes
1567
-        if (
1568
-            empty($this->_cpt_route)
1569
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1570
-        ) {
1571
-            wp_enqueue_script('dashboard');
1572
-        }
1573
-        // LOCALIZED DATA
1574
-        //localize script for ajax lazy loading
1575
-        $lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content'));
1576
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1577
-        /**
1578
-         * help tour stuff
1579
-         */
1580
-        if ( ! empty($this->_help_tour)) {
1581
-            //register the js for kicking things off
1582
-            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1583
-            //setup tours for the js tour object
1584
-            foreach ($this->_help_tour['tours'] as $tour) {
1585
-                $tours[] = array(
1586
-                        'id'      => $tour->get_slug(),
1587
-                        'options' => $tour->get_options(),
1588
-                );
1589
-            }
1590
-            wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1591
-            //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1592
-        }
1593
-    }
1594
-
1595
-
1596
-
1597
-    /**
1598
-     *        admin_footer_scripts_eei18n_js_strings
1599
-     *
1600
-     * @access        public
1601
-     * @return        void
1602
-     */
1603
-    public function admin_footer_scripts_eei18n_js_strings()
1604
-    {
1605
-        EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1606
-        EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso');
1607
-        EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso');
1608
-        EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso');
1609
-        EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso');
1610
-        EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso');
1611
-        EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1612
-        EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso');
1613
-        EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso');
1614
-        EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso');
1615
-        EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso');
1616
-        EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso');
1617
-        EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso');
1618
-        EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso');
1619
-        EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso');
1620
-        EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso');
1621
-        EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso');
1622
-        EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso');
1623
-        EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1624
-        EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso');
1625
-        EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso');
1626
-        EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso');
1627
-        EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso');
1628
-        EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso');
1629
-        EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso');
1630
-        EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso');
1631
-        EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso');
1632
-        EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso');
1633
-        EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso');
1634
-        EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso');
1635
-        EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso');
1636
-        EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso');
1637
-        EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso');
1638
-        EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso');
1639
-        EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso');
1640
-        EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso');
1641
-        EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso');
1642
-        EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso');
1643
-        EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso');
1644
-        EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso');
1645
-    }
1646
-
1647
-
1648
-
1649
-    /**
1650
-     *        load enhanced xdebug styles for ppl with failing eyesight
1651
-     *
1652
-     * @access        public
1653
-     * @return        void
1654
-     */
1655
-    public function add_xdebug_style()
1656
-    {
1657
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1658
-    }
1659
-
1660
-
1661
-    /************************/
1662
-    /** LIST TABLE METHODS **/
1663
-    /************************/
1664
-    /**
1665
-     * this sets up the list table if the current view requires it.
1666
-     *
1667
-     * @access protected
1668
-     * @return void
1669
-     */
1670
-    protected function _set_list_table()
1671
-    {
1672
-        //first is this a list_table view?
1673
-        if ( ! isset($this->_route_config['list_table'])) {
1674
-            return;
1675
-        } //not a list_table view so get out.
1676
-        //list table functions are per view specific (because some admin pages might have more than one listtable!)
1677
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1678
-            //user error msg
1679
-            $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1680
-            //developer error msg
1681
-            $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1682
-                            $this->_req_action, '_set_list_table_views_' . $this->_req_action);
1683
-            throw new EE_Error($error_msg);
1684
-        }
1685
-        //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1686
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1687
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1688
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1689
-        $this->_set_list_table_view();
1690
-        $this->_set_list_table_object();
1691
-    }
1692
-
1693
-
1694
-
1695
-    /**
1696
-     *        set current view for List Table
1697
-     *
1698
-     * @access public
1699
-     * @return array
1700
-     */
1701
-    protected function _set_list_table_view()
1702
-    {
1703
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1704
-        // looking at active items or dumpster diving ?
1705
-        if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
1706
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1707
-        } else {
1708
-            $this->_view = sanitize_key($this->_req_data['status']);
1709
-        }
1710
-    }
1711
-
1712
-
1713
-
1714
-    /**
1715
-     * _set_list_table_object
1716
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1717
-     *
1718
-     * @throws \EE_Error
1719
-     */
1720
-    protected function _set_list_table_object()
1721
-    {
1722
-        if (isset($this->_route_config['list_table'])) {
1723
-            if ( ! class_exists($this->_route_config['list_table'])) {
1724
-                throw new EE_Error(
1725
-                        sprintf(
1726
-                                __(
1727
-                                        'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
1728
-                                        'event_espresso'
1729
-                                ),
1730
-                                $this->_route_config['list_table'],
1731
-                                get_class($this)
1732
-                        )
1733
-                );
1734
-            }
1735
-            $list_table = $this->_route_config['list_table'];
1736
-            $this->_list_table_object = new $list_table($this);
1737
-        }
1738
-    }
1739
-
1740
-
1741
-
1742
-    /**
1743
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
1744
-     *
1745
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
1746
-     *                                                    urls.  The array should be indexed by the view it is being
1747
-     *                                                    added to.
1748
-     * @return array
1749
-     */
1750
-    public function get_list_table_view_RLs($extra_query_args = array())
1751
-    {
1752
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1753
-        if (empty($this->_views)) {
1754
-            $this->_views = array();
1755
-        }
1756
-        // cycle thru views
1757
-        foreach ($this->_views as $key => $view) {
1758
-            $query_args = array();
1759
-            // check for current view
1760
-            $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1761
-            $query_args['action'] = $this->_req_action;
1762
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1763
-            $query_args['status'] = $view['slug'];
1764
-            //merge any other arguments sent in.
1765
-            if (isset($extra_query_args[$view['slug']])) {
1766
-                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
1767
-            }
1768
-            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1769
-        }
1770
-        return $this->_views;
1771
-    }
1772
-
1773
-
1774
-
1775
-    /**
1776
-     * _entries_per_page_dropdown
1777
-     * generates a drop down box for selecting the number of visiable rows in an admin page list table
1778
-     *
1779
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it.
1780
-     * @access protected
1781
-     * @param int $max_entries total number of rows in the table
1782
-     * @return string
1783
-     */
1784
-    protected function _entries_per_page_dropdown($max_entries = false)
1785
-    {
1786
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1787
-        $values = array(10, 25, 50, 100);
1788
-        $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
1789
-        if ($max_entries) {
1790
-            $values[] = $max_entries;
1791
-            sort($values);
1792
-        }
1793
-        $entries_per_page_dropdown = '
145
+	// yes / no array for admin form fields
146
+	protected $_yes_no_values = array();
147
+
148
+	//some default things shared by all child classes
149
+	protected $_default_espresso_metaboxes;
150
+
151
+	/**
152
+	 *    EE_Registry Object
153
+	 *
154
+	 * @var    EE_Registry
155
+	 * @access    protected
156
+	 */
157
+	protected $EE = null;
158
+
159
+
160
+
161
+	/**
162
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
163
+	 *
164
+	 * @var boolean
165
+	 */
166
+	protected $_is_caf = false;
167
+
168
+
169
+
170
+	/**
171
+	 * @Constructor
172
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
173
+	 * @access public
174
+	 */
175
+	public function __construct($routing = true)
176
+	{
177
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
178
+			$this->_is_caf = true;
179
+		}
180
+		$this->_yes_no_values = array(
181
+				array('id' => true, 'text' => __('Yes', 'event_espresso')),
182
+				array('id' => false, 'text' => __('No', 'event_espresso')),
183
+		);
184
+		//set the _req_data property.
185
+		$this->_req_data = array_merge($_GET, $_POST);
186
+		//routing enabled?
187
+		$this->_routing = $routing;
188
+		//set initial page props (child method)
189
+		$this->_init_page_props();
190
+		//set global defaults
191
+		$this->_set_defaults();
192
+		//set early because incoming requests could be ajax related and we need to register those hooks.
193
+		$this->_global_ajax_hooks();
194
+		$this->_ajax_hooks();
195
+		//other_page_hooks have to be early too.
196
+		$this->_do_other_page_hooks();
197
+		//This just allows us to have extending classes do something specific
198
+		// before the parent constructor runs _page_setup().
199
+		if (method_exists($this, '_before_page_setup')) {
200
+			$this->_before_page_setup();
201
+		}
202
+		//set up page dependencies
203
+		$this->_page_setup();
204
+	}
205
+
206
+
207
+
208
+	/**
209
+	 * _init_page_props
210
+	 * Child classes use to set at least the following properties:
211
+	 * $page_slug.
212
+	 * $page_label.
213
+	 *
214
+	 * @abstract
215
+	 * @access protected
216
+	 * @return void
217
+	 */
218
+	abstract protected function _init_page_props();
219
+
220
+
221
+
222
+	/**
223
+	 * _ajax_hooks
224
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
225
+	 * Note: within the ajax callback methods.
226
+	 *
227
+	 * @abstract
228
+	 * @access protected
229
+	 * @return void
230
+	 */
231
+	abstract protected function _ajax_hooks();
232
+
233
+
234
+
235
+	/**
236
+	 * _define_page_props
237
+	 * child classes define page properties in here.  Must include at least:
238
+	 * $_admin_base_url = base_url for all admin pages
239
+	 * $_admin_page_title = default admin_page_title for admin pages
240
+	 * $_labels = array of default labels for various automatically generated elements:
241
+	 *    array(
242
+	 *        'buttons' => array(
243
+	 *            'add' => __('label for add new button'),
244
+	 *            'edit' => __('label for edit button'),
245
+	 *            'delete' => __('label for delete button')
246
+	 *            )
247
+	 *        )
248
+	 *
249
+	 * @abstract
250
+	 * @access protected
251
+	 * @return void
252
+	 */
253
+	abstract protected function _define_page_props();
254
+
255
+
256
+
257
+	/**
258
+	 * _set_page_routes
259
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also have a 'default'
260
+	 * route. Here's the format
261
+	 * $this->_page_routes = array(
262
+	 *        'default' => array(
263
+	 *            'func' => '_default_method_handling_route',
264
+	 *            'args' => array('array','of','args'),
265
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing)
266
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a headers route after.  The string you enter here should match the defined route reference for a headers sent route.
267
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access this route.
268
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks).
269
+	 *        ),
270
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method.
271
+	 *        )
272
+	 * )
273
+	 *
274
+	 * @abstract
275
+	 * @access protected
276
+	 * @return void
277
+	 */
278
+	abstract protected function _set_page_routes();
279
+
280
+
281
+
282
+	/**
283
+	 * _set_page_config
284
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the array corresponds to the page_route for the loaded page.
285
+	 * Format:
286
+	 * $this->_page_config = array(
287
+	 *        'default' => array(
288
+	 *            'labels' => array(
289
+	 *                'buttons' => array(
290
+	 *                    'add' => __('label for adding item'),
291
+	 *                    'edit' => __('label for editing item'),
292
+	 *                    'delete' => __('label for deleting item')
293
+	 *                ),
294
+	 *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
295
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the page. If this isn't present then the defaults will be used as set for the $this->_labels in _define_page_props() method
296
+	 *            'nav' => array(
297
+	 *                'label' => __('Label for Tab', 'event_espresso').
298
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
299
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
300
+	 *                'order' => 10, //required to indicate tab position.
301
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter.
302
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
303
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages.
304
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added later.  We just use
305
+	 *            this flag to make sure the necessary js gets enqueued on page load.
306
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
307
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The array indicates the max number of columns (4) and the default number of columns on page load (2).  There is an option
308
+	 *            in the "screen_options" dropdown that is setup so users can pick what columns they want to display.
309
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
310
+	 *                'tab_id' => array(
311
+	 *                    'title' => 'tab_title',
312
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting help tab content.  The fallback if it isn't present is to try a the callback.  Filename should match a file in the admin
313
+	 *                    folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php)
314
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will attempt to use the callback which should match the name of a method in the class
315
+	 *                    ),
316
+	 *                'tab2_id' => array(
317
+	 *                    'title' => 'tab2 title',
318
+	 *                    'filename' => 'file_name_2'
319
+	 *                    'callback' => 'callback_method_for_content',
320
+	 *                 ),
321
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the help tab area on an admin page. @link http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
322
+	 *            'help_tour' => array(
323
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located in a folder for this admin page named "help_tours", a file name matching the key given here
324
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
325
+	 *            ),
326
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is true if it isn't present).  To remove the requirement for a nonce check when this route is visited just set
327
+	 *            'require_nonce' to FALSE
328
+	 *            )
329
+	 * )
330
+	 *
331
+	 * @abstract
332
+	 * @access protected
333
+	 * @return void
334
+	 */
335
+	abstract protected function _set_page_config();
336
+
337
+
338
+
339
+
340
+
341
+	/** end sample help_tour methods **/
342
+	/**
343
+	 * _add_screen_options
344
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
345
+	 * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view.
346
+	 *
347
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
348
+	 *         see also WP_Screen object documents...
349
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
350
+	 * @abstract
351
+	 * @access protected
352
+	 * @return void
353
+	 */
354
+	abstract protected function _add_screen_options();
355
+
356
+
357
+
358
+	/**
359
+	 * _add_feature_pointers
360
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
361
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view.
362
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
363
+	 * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
364
+	 *
365
+	 * @link   http://eamann.com/tech/wordpress-portland/
366
+	 * @abstract
367
+	 * @access protected
368
+	 * @return void
369
+	 */
370
+	abstract protected function _add_feature_pointers();
371
+
372
+
373
+
374
+	/**
375
+	 * load_scripts_styles
376
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific scripts/styles
377
+	 * per view by putting them in a dynamic function in this format (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
378
+	 *
379
+	 * @abstract
380
+	 * @access public
381
+	 * @return void
382
+	 */
383
+	abstract public function load_scripts_styles();
384
+
385
+
386
+
387
+	/**
388
+	 * admin_init
389
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to all pages/views loaded by child class.
390
+	 *
391
+	 * @abstract
392
+	 * @access public
393
+	 * @return void
394
+	 */
395
+	abstract public function admin_init();
396
+
397
+
398
+
399
+	/**
400
+	 * admin_notices
401
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to all pages/views loaded by child class.
402
+	 *
403
+	 * @abstract
404
+	 * @access public
405
+	 * @return void
406
+	 */
407
+	abstract public function admin_notices();
408
+
409
+
410
+
411
+	/**
412
+	 * admin_footer_scripts
413
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class.
414
+	 *
415
+	 * @access public
416
+	 * @return void
417
+	 */
418
+	abstract public function admin_footer_scripts();
419
+
420
+
421
+
422
+	/**
423
+	 * admin_footer
424
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will apply to all pages/views loaded by child class.
425
+	 *
426
+	 * @access  public
427
+	 * @return void
428
+	 */
429
+	public function admin_footer()
430
+	{
431
+	}
432
+
433
+
434
+
435
+	/**
436
+	 * _global_ajax_hooks
437
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
438
+	 * Note: within the ajax callback methods.
439
+	 *
440
+	 * @abstract
441
+	 * @access protected
442
+	 * @return void
443
+	 */
444
+	protected function _global_ajax_hooks()
445
+	{
446
+		//for lazy loading of metabox content
447
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
448
+	}
449
+
450
+
451
+
452
+	public function ajax_metabox_content()
453
+	{
454
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
455
+		$url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
456
+		self::cached_rss_display($contentid, $url);
457
+		wp_die();
458
+	}
459
+
460
+
461
+
462
+	/**
463
+	 * _page_setup
464
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested doesn't match the object.
465
+	 *
466
+	 * @final
467
+	 * @access protected
468
+	 * @return void
469
+	 */
470
+	final protected function _page_setup()
471
+	{
472
+		//requires?
473
+		//admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
474
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
475
+		//next verify if we need to load anything...
476
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
477
+		$this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
478
+		global $ee_menu_slugs;
479
+		$ee_menu_slugs = (array)$ee_menu_slugs;
480
+		if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
481
+			return;
482
+		}
483
+		// becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
484
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
485
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action'];
486
+		}
487
+		// then set blank or -1 action values to 'default'
488
+		$this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
489
+		//if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.  This covers cases where we're coming in from a list table that isn't on the default route.
490
+		$this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
491
+		//however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
492
+		$this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
493
+		$this->_current_view = $this->_req_action;
494
+		$this->_req_nonce = $this->_req_action . '_nonce';
495
+		$this->_define_page_props();
496
+		$this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
497
+		//default things
498
+		$this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box');
499
+		//set page configs
500
+		$this->_set_page_routes();
501
+		$this->_set_page_config();
502
+		//let's include any referrer data in our default_query_args for this route for "stickiness".
503
+		if (isset($this->_req_data['wp_referer'])) {
504
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
505
+		}
506
+		//for caffeinated and other extended functionality.  If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays
507
+		if (method_exists($this, '_extend_page_config')) {
508
+			$this->_extend_page_config();
509
+		}
510
+		//for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays.
511
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
512
+			$this->_extend_page_config_for_cpt();
513
+		}
514
+		//filter routes and page_config so addons can add their stuff. Filtering done per class
515
+		$this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
516
+		$this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
517
+		//if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
518
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
519
+			add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
520
+		}
521
+		//next route only if routing enabled
522
+		if ($this->_routing && ! defined('DOING_AJAX')) {
523
+			$this->_verify_routes();
524
+			//next let's just check user_access and kill if no access
525
+			$this->check_user_access();
526
+			if ($this->_is_UI_request) {
527
+				//admin_init stuff - global, all views for this page class, specific view
528
+				add_action('admin_init', array($this, 'admin_init'), 10);
529
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
530
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
531
+				}
532
+			} else {
533
+				//hijack regular WP loading and route admin request immediately
534
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
535
+				$this->route_admin_request();
536
+			}
537
+		}
538
+	}
539
+
540
+
541
+
542
+	/**
543
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
544
+	 *
545
+	 * @access private
546
+	 * @return void
547
+	 */
548
+	private function _do_other_page_hooks()
549
+	{
550
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
551
+		foreach ($registered_pages as $page) {
552
+			//now let's setup the file name and class that should be present
553
+			$classname = str_replace('.class.php', '', $page);
554
+			//autoloaders should take care of loading file
555
+			if ( ! class_exists($classname)) {
556
+				$error_msg[] = sprintf( esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
557
+				$error_msg[] = $error_msg[0]
558
+							   . "\r\n"
559
+							   . sprintf( esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
560
+								'event_espresso'), $page, '<br />', '<strong>' . $classname . '</strong>');
561
+				throw new EE_Error(implode('||', $error_msg));
562
+			}
563
+			$a = new ReflectionClass($classname);
564
+			//notice we are passing the instance of this class to the hook object.
565
+			$hookobj[] = $a->newInstance($this);
566
+		}
567
+	}
568
+
569
+
570
+
571
+	public function load_page_dependencies()
572
+	{
573
+		try {
574
+			$this->_load_page_dependencies();
575
+		} catch (EE_Error $e) {
576
+			$e->get_error();
577
+		}
578
+	}
579
+
580
+
581
+
582
+	/**
583
+	 * load_page_dependencies
584
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
585
+	 *
586
+	 * @access public
587
+	 * @return void
588
+	 */
589
+	protected function _load_page_dependencies()
590
+	{
591
+		//let's set the current_screen and screen options to override what WP set
592
+		$this->_current_screen = get_current_screen();
593
+		//load admin_notices - global, page class, and view specific
594
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
595
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
596
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
597
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
598
+		}
599
+		//load network admin_notices - global, page class, and view specific
600
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
601
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
602
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
603
+		}
604
+		//this will save any per_page screen options if they are present
605
+		$this->_set_per_page_screen_options();
606
+		//setup list table properties
607
+		$this->_set_list_table();
608
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.  However in some cases the metaboxes will need to be added within a route handling callback.
609
+		$this->_add_registered_meta_boxes();
610
+		$this->_add_screen_columns();
611
+		//add screen options - global, page child class, and view specific
612
+		$this->_add_global_screen_options();
613
+		$this->_add_screen_options();
614
+		if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
615
+			call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
616
+		}
617
+		//add help tab(s) and tours- set via page_config and qtips.
618
+		$this->_add_help_tour();
619
+		$this->_add_help_tabs();
620
+		$this->_add_qtips();
621
+		//add feature_pointers - global, page child class, and view specific
622
+		$this->_add_feature_pointers();
623
+		$this->_add_global_feature_pointers();
624
+		if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
625
+			call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
626
+		}
627
+		//enqueue scripts/styles - global, page class, and view specific
628
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
629
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
630
+		if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
631
+			add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
632
+		}
633
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
634
+		//admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
635
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
636
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
637
+		if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
638
+			add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
639
+		}
640
+		//admin footer scripts
641
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
642
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
643
+		if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
644
+			add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
645
+		}
646
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
647
+		//targeted hook
648
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
649
+	}
650
+
651
+
652
+
653
+	/**
654
+	 * _set_defaults
655
+	 * This sets some global defaults for class properties.
656
+	 */
657
+	private function _set_defaults()
658
+	{
659
+		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
660
+		$this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
661
+		$this->default_nav_tab_name = 'overview';
662
+		//init template args
663
+		$this->_template_args = array(
664
+				'admin_page_header'  => '',
665
+				'admin_page_content' => '',
666
+				'post_body_content'  => '',
667
+				'before_list_table'  => '',
668
+				'after_list_table'   => '',
669
+		);
670
+	}
671
+
672
+
673
+
674
+	/**
675
+	 * route_admin_request
676
+	 *
677
+	 * @see    _route_admin_request()
678
+	 * @access public
679
+	 * @return void|exception error
680
+	 */
681
+	public function route_admin_request()
682
+	{
683
+		try {
684
+			$this->_route_admin_request();
685
+		} catch (EE_Error $e) {
686
+			$e->get_error();
687
+		}
688
+	}
689
+
690
+
691
+
692
+	public function set_wp_page_slug($wp_page_slug)
693
+	{
694
+		$this->_wp_page_slug = $wp_page_slug;
695
+		//if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
696
+		if (is_network_admin()) {
697
+			$this->_wp_page_slug .= '-network';
698
+		}
699
+	}
700
+
701
+
702
+
703
+	/**
704
+	 * _verify_routes
705
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so we know if we need to drop out.
706
+	 *
707
+	 * @access protected
708
+	 * @return void
709
+	 */
710
+	protected function _verify_routes()
711
+	{
712
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
713
+		if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
714
+			return false;
715
+		}
716
+		$this->_route = false;
717
+		$func = false;
718
+		$args = array();
719
+		// check that the page_routes array is not empty
720
+		if (empty($this->_page_routes)) {
721
+			// user error msg
722
+			$error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
723
+			// developer error msg
724
+			$error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
725
+			throw new EE_Error($error_msg);
726
+		}
727
+		// and that the requested page route exists
728
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
729
+			$this->_route = $this->_page_routes[$this->_req_action];
730
+			$this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array();
731
+		} else {
732
+			// user error msg
733
+			$error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
734
+			// developer error msg
735
+			$error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
736
+			throw new EE_Error($error_msg);
737
+		}
738
+		// and that a default route exists
739
+		if ( ! array_key_exists('default', $this->_page_routes)) {
740
+			// user error msg
741
+			$error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
742
+			// developer error msg
743
+			$error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
744
+			throw new EE_Error($error_msg);
745
+		}
746
+		//first lets' catch if the UI request has EVER been set.
747
+		if ($this->_is_UI_request === null) {
748
+			//lets set if this is a UI request or not.
749
+			$this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false;
750
+			//wait a minute... we might have a noheader in the route array
751
+			$this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request;
752
+		}
753
+		$this->_set_current_labels();
754
+	}
755
+
756
+
757
+
758
+	/**
759
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
760
+	 *
761
+	 * @param  string $route the route name we're verifying
762
+	 * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
763
+	 */
764
+	protected function _verify_route($route)
765
+	{
766
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
767
+			return true;
768
+		} else {
769
+			// user error msg
770
+			$error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
771
+			// developer error msg
772
+			$error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
773
+			throw new EE_Error($error_msg);
774
+		}
775
+	}
776
+
777
+
778
+
779
+	/**
780
+	 * perform nonce verification
781
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces using this method (and save retyping!)
782
+	 *
783
+	 * @param  string $nonce     The nonce sent
784
+	 * @param  string $nonce_ref The nonce reference string (name0)
785
+	 * @return mixed (bool|die)
786
+	 */
787
+	protected function _verify_nonce($nonce, $nonce_ref)
788
+	{
789
+		// verify nonce against expected value
790
+		if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
791
+			// these are not the droids you are looking for !!!
792
+			$msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
793
+			if (WP_DEBUG) {
794
+				$msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
795
+			}
796
+			if ( ! defined('DOING_AJAX')) {
797
+				wp_die($msg);
798
+			} else {
799
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
800
+				$this->_return_json();
801
+			}
802
+		}
803
+	}
804
+
805
+
806
+
807
+	/**
808
+	 * _route_admin_request()
809
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
810
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
811
+	 * in the page routes and then will try to load the corresponding method.
812
+	 *
813
+	 * @access protected
814
+	 * @return void
815
+	 * @throws \EE_Error
816
+	 */
817
+	protected function _route_admin_request()
818
+	{
819
+		if ( ! $this->_is_UI_request) {
820
+			$this->_verify_routes();
821
+		}
822
+		$nonce_check = isset($this->_route_config['require_nonce'])
823
+			? $this->_route_config['require_nonce']
824
+			: true;
825
+		if ($this->_req_action !== 'default' && $nonce_check) {
826
+			// set nonce from post data
827
+			$nonce = isset($this->_req_data[$this->_req_nonce])
828
+				? sanitize_text_field($this->_req_data[$this->_req_nonce])
829
+				: '';
830
+			$this->_verify_nonce($nonce, $this->_req_nonce);
831
+		}
832
+		//set the nav_tabs array but ONLY if this is  UI_request
833
+		if ($this->_is_UI_request) {
834
+			$this->_set_nav_tabs();
835
+		}
836
+		// grab callback function
837
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
838
+		// check if callback has args
839
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
840
+		$error_msg = '';
841
+		// action right before calling route
842
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
843
+		if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
844
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
845
+		}
846
+		// right before calling the route, let's remove _wp_http_referer from the
847
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
848
+		$_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
849
+		if ( ! empty($func)) {
850
+			if (is_array($func)) {
851
+				list($class, $method) = $func;
852
+			} else if (strpos($func, '::') !== false) {
853
+				list($class, $method) = explode('::', $func);
854
+			} else {
855
+				$class = $this;
856
+				$method = $func;
857
+			}
858
+			if ( ! (is_object($class) && $class === $this)) {
859
+				// send along this admin page object for access by addons.
860
+				$args['admin_page_object'] = $this;
861
+			}
862
+
863
+			if (
864
+				//is it a method on a class that doesn't work?
865
+				(
866
+					(
867
+						method_exists($class, $method)
868
+						&& call_user_func_array(array($class, $method), $args) === false
869
+					)
870
+					&& (
871
+						//is it a standalone function that doesn't work?
872
+						function_exists($method)
873
+						&& call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false
874
+					)
875
+				)
876
+				|| (
877
+					//is it neither a class method NOR a standalone function?
878
+					! method_exists($class, $method)
879
+					&& ! function_exists($method)
880
+				)
881
+			) {
882
+				// user error msg
883
+				$error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
884
+				// developer error msg
885
+				$error_msg .= '||';
886
+				$error_msg .= sprintf(
887
+					__(
888
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
889
+						'event_espresso'
890
+					),
891
+					$method
892
+				);
893
+			}
894
+			if ( ! empty($error_msg)) {
895
+				throw new EE_Error($error_msg);
896
+			}
897
+		}
898
+		//if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route.
899
+		//now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
900
+		if ($this->_is_UI_request === false
901
+			&& is_array($this->_route)
902
+			&& ! empty($this->_route['headers_sent_route'])
903
+		) {
904
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
905
+		}
906
+	}
907
+
908
+
909
+
910
+	/**
911
+	 * This method just allows the resetting of page properties in the case where a no headers
912
+	 * route redirects to a headers route in its route config.
913
+	 *
914
+	 * @since   4.3.0
915
+	 * @param  string $new_route New (non header) route to redirect to.
916
+	 * @return   void
917
+	 */
918
+	protected function _reset_routing_properties($new_route)
919
+	{
920
+		$this->_is_UI_request = true;
921
+		//now we set the current route to whatever the headers_sent_route is set at
922
+		$this->_req_data['action'] = $new_route;
923
+		//rerun page setup
924
+		$this->_page_setup();
925
+	}
926
+
927
+
928
+
929
+	/**
930
+	 * _add_query_arg
931
+	 * adds nonce to array of arguments then calls WP add_query_arg function
932
+	 *(internally just uses EEH_URL's function with the same name)
933
+	 *
934
+	 * @access public
935
+	 * @param array  $args
936
+	 * @param string $url
937
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the generated
938
+	 *                                        url in an associative array indexed by the key 'wp_referer';
939
+	 *                                        Example usage:
940
+	 *                                        If the current page is:
941
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
942
+	 *                                        &action=default&event_id=20&month_range=March%202015
943
+	 *                                        &_wpnonce=5467821
944
+	 *                                        and you call:
945
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
946
+	 *                                        array(
947
+	 *                                        'action' => 'resend_something',
948
+	 *                                        'page=>espresso_registrations'
949
+	 *                                        ),
950
+	 *                                        $some_url,
951
+	 *                                        true
952
+	 *                                        );
953
+	 *                                        It will produce a url in this structure:
954
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
955
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
956
+	 *                                        month_range]=March%202015
957
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
958
+	 * @return string
959
+	 */
960
+	public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false)
961
+	{
962
+		//if there is a _wp_http_referer include the values from the request but only if sticky = true
963
+		if ($sticky) {
964
+			$request = $_REQUEST;
965
+			unset($request['_wp_http_referer']);
966
+			unset($request['wp_referer']);
967
+			foreach ($request as $key => $value) {
968
+				//do not add nonces
969
+				if (strpos($key, 'nonce') !== false) {
970
+					continue;
971
+				}
972
+				$args['wp_referer[' . $key . ']'] = $value;
973
+			}
974
+		}
975
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
976
+	}
977
+
978
+
979
+
980
+	/**
981
+	 * This returns a generated link that will load the related help tab.
982
+	 *
983
+	 * @param  string $help_tab_id the id for the connected help tab
984
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
985
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
986
+	 * @uses EEH_Template::get_help_tab_link()
987
+	 * @return string              generated link
988
+	 */
989
+	protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
990
+	{
991
+		return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text);
992
+	}
993
+
994
+
995
+
996
+	/**
997
+	 * _add_help_tabs
998
+	 * Note child classes define their help tabs within the page_config array.
999
+	 *
1000
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1001
+	 * @access protected
1002
+	 * @return void
1003
+	 */
1004
+	protected function _add_help_tabs()
1005
+	{
1006
+		$tour_buttons = '';
1007
+		if (isset($this->_page_config[$this->_req_action])) {
1008
+			$config = $this->_page_config[$this->_req_action];
1009
+			//is there a help tour for the current route?  if there is let's setup the tour buttons
1010
+			if (isset($this->_help_tour[$this->_req_action])) {
1011
+				$tb = array();
1012
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1013
+				foreach ($this->_help_tour['tours'] as $tour) {
1014
+					//if this is the end tour then we don't need to setup a button
1015
+					if ($tour instanceof EE_Help_Tour_final_stop) {
1016
+						continue;
1017
+					}
1018
+					$tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1019
+				}
1020
+				$tour_buttons .= implode('<br />', $tb);
1021
+				$tour_buttons .= '</div></div>';
1022
+			}
1023
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1024
+			if (is_array($config) && isset($config['help_sidebar'])) {
1025
+				//check that the callback given is valid
1026
+				if ( ! method_exists($this, $config['help_sidebar'])) {
1027
+					throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1028
+							'event_espresso'), $config['help_sidebar'], get_class($this)));
1029
+				}
1030
+				$content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1031
+				$content .= $tour_buttons; //add help tour buttons.
1032
+				//do we have any help tours setup?  Cause if we do we want to add the buttons
1033
+				$this->_current_screen->set_help_sidebar($content);
1034
+			}
1035
+			//if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1036
+			if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1037
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1038
+			}
1039
+			//handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1040
+			if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1041
+				$_ht['id'] = $this->page_slug;
1042
+				$_ht['title'] = __('Help Tours', 'event_espresso');
1043
+				$_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1044
+				$this->_current_screen->add_help_tab($_ht);
1045
+			}/**/
1046
+			if ( ! isset($config['help_tabs'])) {
1047
+				return;
1048
+			} //no help tabs for this route
1049
+			foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1050
+				//we're here so there ARE help tabs!
1051
+				//make sure we've got what we need
1052
+				if ( ! isset($cfg['title'])) {
1053
+					throw new EE_Error(__('The _page_config array is not set up properly for help tabs.  It is missing a title', 'event_espresso'));
1054
+				}
1055
+				if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1056
+					throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1057
+							'event_espresso'));
1058
+				}
1059
+				//first priority goes to content.
1060
+				if ( ! empty($cfg['content'])) {
1061
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1062
+					//second priority goes to filename
1063
+				} else if ( ! empty($cfg['filename'])) {
1064
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1065
+					//it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1066
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1067
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1068
+					if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1069
+						EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1070
+								'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__);
1071
+						return;
1072
+					}
1073
+					$template_args['admin_page_obj'] = $this;
1074
+					$content = EEH_Template::display_template($file_path, $template_args, true);
1075
+				} else {
1076
+					$content = '';
1077
+				}
1078
+				//check if callback is valid
1079
+				if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1080
+					EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1081
+							'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__);
1082
+					return;
1083
+				}
1084
+				//setup config array for help tab method
1085
+				$id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1086
+				$_ht = array(
1087
+						'id'       => $id,
1088
+						'title'    => $cfg['title'],
1089
+						'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1090
+						'content'  => $content,
1091
+				);
1092
+				$this->_current_screen->add_help_tab($_ht);
1093
+			}
1094
+		}
1095
+	}
1096
+
1097
+
1098
+
1099
+	/**
1100
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is an array with properties for setting up usage of the joyride plugin
1101
+	 *
1102
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1103
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments
1104
+	 * @access protected
1105
+	 * @return void
1106
+	 */
1107
+	protected function _add_help_tour()
1108
+	{
1109
+		$tours = array();
1110
+		$this->_help_tour = array();
1111
+		//exit early if help tours are turned off globally
1112
+		if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) {
1113
+			return;
1114
+		}
1115
+		//loop through _page_config to find any help_tour defined
1116
+		foreach ($this->_page_config as $route => $config) {
1117
+			//we're only going to set things up for this route
1118
+			if ($route !== $this->_req_action) {
1119
+				continue;
1120
+			}
1121
+			if (isset($config['help_tour'])) {
1122
+				foreach ($config['help_tour'] as $tour) {
1123
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1124
+					//let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1125
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1126
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1127
+					if ( ! is_readable($file_path)) {
1128
+						EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'),
1129
+								$file_path, $tour), __FILE__, __FUNCTION__, __LINE__);
1130
+						return;
1131
+					}
1132
+					require_once $file_path;
1133
+					if ( ! class_exists($tour)) {
1134
+						$error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1135
+						$error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1136
+										'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1137
+						throw new EE_Error(implode('||', $error_msg));
1138
+					}
1139
+					$a = new ReflectionClass($tour);
1140
+					$tour_obj = $a->newInstance($this->_is_caf);
1141
+					$tours[] = $tour_obj;
1142
+					$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1143
+				}
1144
+				//let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1145
+				$end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1146
+				$tours[] = $end_stop_tour;
1147
+				$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1148
+			}
1149
+		}
1150
+		if ( ! empty($tours)) {
1151
+			$this->_help_tour['tours'] = $tours;
1152
+		}
1153
+		//thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1154
+	}
1155
+
1156
+
1157
+
1158
+	/**
1159
+	 * This simply sets up any qtips that have been defined in the page config
1160
+	 *
1161
+	 * @access protected
1162
+	 * @return void
1163
+	 */
1164
+	protected function _add_qtips()
1165
+	{
1166
+		if (isset($this->_route_config['qtips'])) {
1167
+			$qtips = (array)$this->_route_config['qtips'];
1168
+			//load qtip loader
1169
+			$path = array(
1170
+					$this->_get_dir() . '/qtips/',
1171
+					EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1172
+			);
1173
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1174
+		}
1175
+	}
1176
+
1177
+
1178
+
1179
+	/**
1180
+	 * _set_nav_tabs
1181
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you wish to add additional tabs or modify accordingly.
1182
+	 *
1183
+	 * @access protected
1184
+	 * @return void
1185
+	 */
1186
+	protected function _set_nav_tabs()
1187
+	{
1188
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1189
+		$i = 0;
1190
+		foreach ($this->_page_config as $slug => $config) {
1191
+			if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) {
1192
+				continue;
1193
+			} //no nav tab for this config
1194
+			//check for persistent flag
1195
+			if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1196
+				continue;
1197
+			} //nav tab is only to appear when route requested.
1198
+			if ( ! $this->check_user_access($slug, true)) {
1199
+				continue;
1200
+			} //no nav tab becasue current user does not have access.
1201
+			$css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1202
+			$this->_nav_tabs[$slug] = array(
1203
+					'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1204
+					'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1205
+					'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1206
+					'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1207
+			);
1208
+			$i++;
1209
+		}
1210
+		//if $this->_nav_tabs is empty then lets set the default
1211
+		if (empty($this->_nav_tabs)) {
1212
+			$this->_nav_tabs[$this->default_nav_tab_name] = array(
1213
+					'url'       => $this->admin_base_url,
1214
+					'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1215
+					'css_class' => 'nav-tab-active',
1216
+					'order'     => 10,
1217
+			);
1218
+		}
1219
+		//now let's sort the tabs according to order
1220
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1221
+	}
1222
+
1223
+
1224
+
1225
+	/**
1226
+	 * _set_current_labels
1227
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array
1228
+	 *
1229
+	 * @access private
1230
+	 * @return void
1231
+	 */
1232
+	private function _set_current_labels()
1233
+	{
1234
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1235
+			foreach ($this->_route_config['labels'] as $label => $text) {
1236
+				if (is_array($text)) {
1237
+					foreach ($text as $sublabel => $subtext) {
1238
+						$this->_labels[$label][$sublabel] = $subtext;
1239
+					}
1240
+				} else {
1241
+					$this->_labels[$label] = $text;
1242
+				}
1243
+			}
1244
+		}
1245
+	}
1246
+
1247
+
1248
+
1249
+	/**
1250
+	 *        verifies user access for this admin page
1251
+	 *
1252
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1253
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just return false if verify fail.
1254
+	 * @return        BOOL|wp_die()
1255
+	 */
1256
+	public function check_user_access($route_to_check = '', $verify_only = false)
1257
+	{
1258
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1259
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1260
+		$capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability'])
1261
+				? $this->_page_routes[$route_to_check]['capability'] : null;
1262
+		if (empty($capability) && empty($route_to_check)) {
1263
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability'];
1264
+		} else {
1265
+			$capability = empty($capability) ? 'manage_options' : $capability;
1266
+		}
1267
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1268
+		if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1269
+			if ($verify_only) {
1270
+				return false;
1271
+			} else {
1272
+				if ( is_user_logged_in() ) {
1273
+					wp_die(__('You do not have access to this route.', 'event_espresso'));
1274
+				} else {
1275
+					return false;
1276
+				}
1277
+			}
1278
+		}
1279
+		return true;
1280
+	}
1281
+
1282
+
1283
+
1284
+	/**
1285
+	 * admin_init_global
1286
+	 * This runs all the code that we want executed within the WP admin_init hook.
1287
+	 * This method executes for ALL EE Admin pages.
1288
+	 *
1289
+	 * @access public
1290
+	 * @return void
1291
+	 */
1292
+	public function admin_init_global()
1293
+	{
1294
+	}
1295
+
1296
+
1297
+
1298
+	/**
1299
+	 * wp_loaded_global
1300
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an EE_Admin page and will execute on every EE Admin Page load
1301
+	 *
1302
+	 * @access public
1303
+	 * @return void
1304
+	 */
1305
+	public function wp_loaded()
1306
+	{
1307
+	}
1308
+
1309
+
1310
+
1311
+	/**
1312
+	 * admin_notices
1313
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on ALL EE_Admin pages.
1314
+	 *
1315
+	 * @access public
1316
+	 * @return void
1317
+	 */
1318
+	public function admin_notices_global()
1319
+	{
1320
+		$this->_display_no_javascript_warning();
1321
+		$this->_display_espresso_notices();
1322
+	}
1323
+
1324
+
1325
+
1326
+	public function network_admin_notices_global()
1327
+	{
1328
+		$this->_display_no_javascript_warning();
1329
+		$this->_display_espresso_notices();
1330
+	}
1331
+
1332
+
1333
+
1334
+	/**
1335
+	 * admin_footer_scripts_global
1336
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages.
1337
+	 *
1338
+	 * @access public
1339
+	 * @return void
1340
+	 */
1341
+	public function admin_footer_scripts_global()
1342
+	{
1343
+		$this->_add_admin_page_ajax_loading_img();
1344
+		$this->_add_admin_page_overlay();
1345
+		//if metaboxes are present we need to add the nonce field
1346
+		if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) {
1347
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1348
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1349
+		}
1350
+	}
1351
+
1352
+
1353
+
1354
+	/**
1355
+	 * admin_footer_global
1356
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages.
1357
+	 *
1358
+	 * @access  public
1359
+	 * @return  void
1360
+	 */
1361
+	public function admin_footer_global()
1362
+	{
1363
+		//dialog container for dialog helper
1364
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1365
+		$d_cont .= '<div class="ee-notices"></div>';
1366
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1367
+		$d_cont .= '</div>';
1368
+		echo $d_cont;
1369
+		//help tour stuff?
1370
+		if (isset($this->_help_tour[$this->_req_action])) {
1371
+			echo implode('<br />', $this->_help_tour[$this->_req_action]);
1372
+		}
1373
+		//current set timezone for timezone js
1374
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1375
+	}
1376
+
1377
+
1378
+
1379
+	/**
1380
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then we'll use the retrieved array to output the content using the template.
1381
+	 * For child classes:
1382
+	 * If you want to have help popups then in your templates or your content you set "triggers" for the content using the "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method for
1383
+	 * the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content for the
1384
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1385
+	 *    'help_trigger_id' => array(
1386
+	 *        'title' => __('localized title for popup', 'event_espresso'),
1387
+	 *        'content' => __('localized content for popup', 'event_espresso')
1388
+	 *    )
1389
+	 * );
1390
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1391
+	 *
1392
+	 * @access protected
1393
+	 * @return string content
1394
+	 */
1395
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1396
+	{
1397
+		$content = '';
1398
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1399
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1400
+		//loop through the array and setup content
1401
+		foreach ($help_array as $trigger => $help) {
1402
+			//make sure the array is setup properly
1403
+			if ( ! isset($help['title']) || ! isset($help['content'])) {
1404
+				throw new EE_Error(__('Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1405
+						'event_espresso'));
1406
+			}
1407
+			//we're good so let'd setup the template vars and then assign parsed template content to our content.
1408
+			$template_args = array(
1409
+					'help_popup_id'      => $trigger,
1410
+					'help_popup_title'   => $help['title'],
1411
+					'help_popup_content' => $help['content'],
1412
+			);
1413
+			$content .= EEH_Template::display_template($template_path, $template_args, true);
1414
+		}
1415
+		if ($display) {
1416
+			echo $content;
1417
+		} else {
1418
+			return $content;
1419
+		}
1420
+	}
1421
+
1422
+
1423
+
1424
+	/**
1425
+	 * All this does is retrive the help content array if set by the EE_Admin_Page child
1426
+	 *
1427
+	 * @access private
1428
+	 * @return array properly formatted array for help popup content
1429
+	 */
1430
+	private function _get_help_content()
1431
+	{
1432
+		//what is the method we're looking for?
1433
+		$method_name = '_help_popup_content_' . $this->_req_action;
1434
+		//if method doesn't exist let's get out.
1435
+		if ( ! method_exists($this, $method_name)) {
1436
+			return array();
1437
+		}
1438
+		//k we're good to go let's retrieve the help array
1439
+		$help_array = call_user_func(array($this, $method_name));
1440
+		//make sure we've got an array!
1441
+		if ( ! is_array($help_array)) {
1442
+			throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso'));
1443
+		}
1444
+		return $help_array;
1445
+	}
1446
+
1447
+
1448
+
1449
+	/**
1450
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1451
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1452
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1453
+	 *
1454
+	 * @access protected
1455
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1456
+	 * @param boolean $display    if false then we return the trigger string
1457
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1458
+	 * @return string
1459
+	 */
1460
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1461
+	{
1462
+		if (defined('DOING_AJAX')) {
1463
+			return;
1464
+		}
1465
+		//let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1466
+		$help_array = $this->_get_help_content();
1467
+		$help_content = '';
1468
+		if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1469
+			$help_array[$trigger_id] = array(
1470
+					'title'   => __('Missing Content', 'event_espresso'),
1471
+					'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1472
+							'event_espresso'),
1473
+			);
1474
+			$help_content = $this->_set_help_popup_content($help_array, false);
1475
+		}
1476
+		//let's setup the trigger
1477
+		$content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1478
+		$content = $content . $help_content;
1479
+		if ($display) {
1480
+			echo $content;
1481
+		} else {
1482
+			return $content;
1483
+		}
1484
+	}
1485
+
1486
+
1487
+
1488
+	/**
1489
+	 * _add_global_screen_options
1490
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1491
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1492
+	 *
1493
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1494
+	 *         see also WP_Screen object documents...
1495
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1496
+	 * @abstract
1497
+	 * @access private
1498
+	 * @return void
1499
+	 */
1500
+	private function _add_global_screen_options()
1501
+	{
1502
+	}
1503
+
1504
+
1505
+
1506
+	/**
1507
+	 * _add_global_feature_pointers
1508
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1509
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1510
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1511
+	 *
1512
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
1513
+	 * @link   http://eamann.com/tech/wordpress-portland/
1514
+	 * @abstract
1515
+	 * @access protected
1516
+	 * @return void
1517
+	 */
1518
+	private function _add_global_feature_pointers()
1519
+	{
1520
+	}
1521
+
1522
+
1523
+
1524
+	/**
1525
+	 * load_global_scripts_styles
1526
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1527
+	 *
1528
+	 * @return void
1529
+	 */
1530
+	public function load_global_scripts_styles()
1531
+	{
1532
+		/** STYLES **/
1533
+		// add debugging styles
1534
+		if (WP_DEBUG) {
1535
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1536
+		}
1537
+		// register all styles
1538
+		wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1539
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1540
+		//helpers styles
1541
+		wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1542
+		/** SCRIPTS **/
1543
+		//register all scripts
1544
+		wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1545
+		wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1546
+		wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1547
+		add_filter('FHEE_load_joyride', '__return_true');
1548
+		//script for sorting tables
1549
+		wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1550
+		//script for parsing uri's
1551
+		wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1552
+		//and parsing associative serialized form elements
1553
+		wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1554
+		//helpers scripts
1555
+		wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1556
+		wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1557
+		wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1558
+		wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1559
+		//google charts
1560
+		wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1561
+		// ENQUEUE ALL BASICS BY DEFAULT
1562
+		wp_enqueue_style('ee-admin-css');
1563
+		wp_enqueue_script('ee_admin_js');
1564
+		wp_enqueue_script('ee-accounting');
1565
+		wp_enqueue_script('jquery-validate');
1566
+		//taking care of metaboxes
1567
+		if (
1568
+			empty($this->_cpt_route)
1569
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1570
+		) {
1571
+			wp_enqueue_script('dashboard');
1572
+		}
1573
+		// LOCALIZED DATA
1574
+		//localize script for ajax lazy loading
1575
+		$lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content'));
1576
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1577
+		/**
1578
+		 * help tour stuff
1579
+		 */
1580
+		if ( ! empty($this->_help_tour)) {
1581
+			//register the js for kicking things off
1582
+			wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1583
+			//setup tours for the js tour object
1584
+			foreach ($this->_help_tour['tours'] as $tour) {
1585
+				$tours[] = array(
1586
+						'id'      => $tour->get_slug(),
1587
+						'options' => $tour->get_options(),
1588
+				);
1589
+			}
1590
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1591
+			//admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1592
+		}
1593
+	}
1594
+
1595
+
1596
+
1597
+	/**
1598
+	 *        admin_footer_scripts_eei18n_js_strings
1599
+	 *
1600
+	 * @access        public
1601
+	 * @return        void
1602
+	 */
1603
+	public function admin_footer_scripts_eei18n_js_strings()
1604
+	{
1605
+		EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1606
+		EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso');
1607
+		EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso');
1608
+		EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso');
1609
+		EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso');
1610
+		EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso');
1611
+		EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1612
+		EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso');
1613
+		EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso');
1614
+		EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso');
1615
+		EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso');
1616
+		EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso');
1617
+		EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso');
1618
+		EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso');
1619
+		EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso');
1620
+		EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso');
1621
+		EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso');
1622
+		EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso');
1623
+		EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1624
+		EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso');
1625
+		EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso');
1626
+		EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso');
1627
+		EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso');
1628
+		EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso');
1629
+		EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso');
1630
+		EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso');
1631
+		EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso');
1632
+		EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso');
1633
+		EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso');
1634
+		EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso');
1635
+		EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso');
1636
+		EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso');
1637
+		EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso');
1638
+		EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso');
1639
+		EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso');
1640
+		EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso');
1641
+		EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso');
1642
+		EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso');
1643
+		EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso');
1644
+		EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso');
1645
+	}
1646
+
1647
+
1648
+
1649
+	/**
1650
+	 *        load enhanced xdebug styles for ppl with failing eyesight
1651
+	 *
1652
+	 * @access        public
1653
+	 * @return        void
1654
+	 */
1655
+	public function add_xdebug_style()
1656
+	{
1657
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1658
+	}
1659
+
1660
+
1661
+	/************************/
1662
+	/** LIST TABLE METHODS **/
1663
+	/************************/
1664
+	/**
1665
+	 * this sets up the list table if the current view requires it.
1666
+	 *
1667
+	 * @access protected
1668
+	 * @return void
1669
+	 */
1670
+	protected function _set_list_table()
1671
+	{
1672
+		//first is this a list_table view?
1673
+		if ( ! isset($this->_route_config['list_table'])) {
1674
+			return;
1675
+		} //not a list_table view so get out.
1676
+		//list table functions are per view specific (because some admin pages might have more than one listtable!)
1677
+		if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1678
+			//user error msg
1679
+			$error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1680
+			//developer error msg
1681
+			$error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1682
+							$this->_req_action, '_set_list_table_views_' . $this->_req_action);
1683
+			throw new EE_Error($error_msg);
1684
+		}
1685
+		//let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1686
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1687
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1688
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1689
+		$this->_set_list_table_view();
1690
+		$this->_set_list_table_object();
1691
+	}
1692
+
1693
+
1694
+
1695
+	/**
1696
+	 *        set current view for List Table
1697
+	 *
1698
+	 * @access public
1699
+	 * @return array
1700
+	 */
1701
+	protected function _set_list_table_view()
1702
+	{
1703
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1704
+		// looking at active items or dumpster diving ?
1705
+		if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
1706
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1707
+		} else {
1708
+			$this->_view = sanitize_key($this->_req_data['status']);
1709
+		}
1710
+	}
1711
+
1712
+
1713
+
1714
+	/**
1715
+	 * _set_list_table_object
1716
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1717
+	 *
1718
+	 * @throws \EE_Error
1719
+	 */
1720
+	protected function _set_list_table_object()
1721
+	{
1722
+		if (isset($this->_route_config['list_table'])) {
1723
+			if ( ! class_exists($this->_route_config['list_table'])) {
1724
+				throw new EE_Error(
1725
+						sprintf(
1726
+								__(
1727
+										'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
1728
+										'event_espresso'
1729
+								),
1730
+								$this->_route_config['list_table'],
1731
+								get_class($this)
1732
+						)
1733
+				);
1734
+			}
1735
+			$list_table = $this->_route_config['list_table'];
1736
+			$this->_list_table_object = new $list_table($this);
1737
+		}
1738
+	}
1739
+
1740
+
1741
+
1742
+	/**
1743
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
1744
+	 *
1745
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
1746
+	 *                                                    urls.  The array should be indexed by the view it is being
1747
+	 *                                                    added to.
1748
+	 * @return array
1749
+	 */
1750
+	public function get_list_table_view_RLs($extra_query_args = array())
1751
+	{
1752
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1753
+		if (empty($this->_views)) {
1754
+			$this->_views = array();
1755
+		}
1756
+		// cycle thru views
1757
+		foreach ($this->_views as $key => $view) {
1758
+			$query_args = array();
1759
+			// check for current view
1760
+			$this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1761
+			$query_args['action'] = $this->_req_action;
1762
+			$query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1763
+			$query_args['status'] = $view['slug'];
1764
+			//merge any other arguments sent in.
1765
+			if (isset($extra_query_args[$view['slug']])) {
1766
+				$query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
1767
+			}
1768
+			$this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1769
+		}
1770
+		return $this->_views;
1771
+	}
1772
+
1773
+
1774
+
1775
+	/**
1776
+	 * _entries_per_page_dropdown
1777
+	 * generates a drop down box for selecting the number of visiable rows in an admin page list table
1778
+	 *
1779
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it.
1780
+	 * @access protected
1781
+	 * @param int $max_entries total number of rows in the table
1782
+	 * @return string
1783
+	 */
1784
+	protected function _entries_per_page_dropdown($max_entries = false)
1785
+	{
1786
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1787
+		$values = array(10, 25, 50, 100);
1788
+		$per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
1789
+		if ($max_entries) {
1790
+			$values[] = $max_entries;
1791
+			sort($values);
1792
+		}
1793
+		$entries_per_page_dropdown = '
1794 1794
 			<div id="entries-per-page-dv" class="alignleft actions">
1795 1795
 				<label class="hide-if-no-js">
1796 1796
 					Show
1797 1797
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
1798
-        foreach ($values as $value) {
1799
-            if ($value < $max_entries) {
1800
-                $selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1801
-                $entries_per_page_dropdown .= '
1798
+		foreach ($values as $value) {
1799
+			if ($value < $max_entries) {
1800
+				$selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1801
+				$entries_per_page_dropdown .= '
1802 1802
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
1803
-            }
1804
-        }
1805
-        $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1806
-        $entries_per_page_dropdown .= '
1803
+			}
1804
+		}
1805
+		$selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1806
+		$entries_per_page_dropdown .= '
1807 1807
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
1808
-        $entries_per_page_dropdown .= '
1808
+		$entries_per_page_dropdown .= '
1809 1809
 					</select>
1810 1810
 					entries
1811 1811
 				</label>
1812 1812
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
1813 1813
 			</div>
1814 1814
 		';
1815
-        return $entries_per_page_dropdown;
1816
-    }
1817
-
1818
-
1819
-
1820
-    /**
1821
-     *        _set_search_attributes
1822
-     *
1823
-     * @access        protected
1824
-     * @return        void
1825
-     */
1826
-    public function _set_search_attributes()
1827
-    {
1828
-        $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1829
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1830
-    }
1831
-
1832
-    /*** END LIST TABLE METHODS **/
1833
-    /*****************************/
1834
-    /**
1835
-     *        _add_registered_metaboxes
1836
-     *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
1837
-     *
1838
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
1839
-     * @access private
1840
-     * @return void
1841
-     */
1842
-    private function _add_registered_meta_boxes()
1843
-    {
1844
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1845
-        //we only add meta boxes if the page_route calls for it
1846
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
1847
-            && is_array(
1848
-                    $this->_route_config['metaboxes']
1849
-            )
1850
-        ) {
1851
-            // this simply loops through the callbacks provided
1852
-            // and checks if there is a corresponding callback registered by the child
1853
-            // if there is then we go ahead and process the metabox loader.
1854
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
1855
-                // first check for Closures
1856
-                if ($metabox_callback instanceof Closure) {
1857
-                    $result = $metabox_callback();
1858
-                } else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
1859
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
1860
-                } else {
1861
-                    $result = call_user_func(array($this, &$metabox_callback));
1862
-                }
1863
-                if ($result === false) {
1864
-                    // user error msg
1865
-                    $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1866
-                    // developer error msg
1867
-                    $error_msg .= '||' . sprintf(
1868
-                                    __(
1869
-                                            'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
1870
-                                            'event_espresso'
1871
-                                    ),
1872
-                                    $metabox_callback
1873
-                            );
1874
-                    throw new EE_Error($error_msg);
1875
-                }
1876
-            }
1877
-        }
1878
-    }
1879
-
1880
-
1881
-
1882
-    /**
1883
-     * _add_screen_columns
1884
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as the dynamic column template and we'll setup the column options for the page.
1885
-     *
1886
-     * @access private
1887
-     * @return void
1888
-     */
1889
-    private function _add_screen_columns()
1890
-    {
1891
-        if (
1892
-                is_array($this->_route_config)
1893
-                && isset($this->_route_config['columns'])
1894
-                && is_array($this->_route_config['columns'])
1895
-                && count($this->_route_config['columns']) === 2
1896
-        ) {
1897
-            add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1898
-            $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1899
-            $screen_id = $this->_current_screen->id;
1900
-            $screen_columns = (int)get_user_option("screen_layout_$screen_id");
1901
-            $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1902
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1903
-            $this->_template_args['current_page'] = $this->_wp_page_slug;
1904
-            $this->_template_args['screen'] = $this->_current_screen;
1905
-            $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1906
-            //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
1907
-            $this->_route_config['has_metaboxes'] = true;
1908
-        }
1909
-    }
1910
-
1911
-
1912
-
1913
-    /**********************************/
1914
-    /** GLOBALLY AVAILABLE METABOXES **/
1915
-    /**
1916
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply referencing the callback in the _page_config array property.  This way you can be very specific about what pages these get
1917
-     * loaded on.
1918
-     */
1919
-    private function _espresso_news_post_box()
1920
-    {
1921
-        $news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso'));
1922
-        add_meta_box('espresso_news_post_box', $news_box_title, array(
1923
-                $this,
1924
-                'espresso_news_post_box',
1925
-        ), $this->_wp_page_slug, 'side');
1926
-    }
1927
-
1928
-
1929
-
1930
-    /**
1931
-     * Code for setting up espresso ratings request metabox.
1932
-     */
1933
-    protected function _espresso_ratings_request()
1934
-    {
1935
-        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
1936
-            return '';
1937
-        }
1938
-        $ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso'));
1939
-        add_meta_box('espresso_ratings_request', $ratings_box_title, array(
1940
-                $this,
1941
-                'espresso_ratings_request',
1942
-        ), $this->_wp_page_slug, 'side');
1943
-    }
1944
-
1945
-
1946
-
1947
-    /**
1948
-     * Code for setting up espresso ratings request metabox content.
1949
-     */
1950
-    public function espresso_ratings_request()
1951
-    {
1952
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1953
-        EEH_Template::display_template($template_path, array());
1954
-    }
1955
-
1956
-
1957
-
1958
-    public static function cached_rss_display($rss_id, $url)
1959
-    {
1960
-        $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1961
-        $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1962
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
1963
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1964
-        $post = '</div>' . "\n";
1965
-        $cache_key = 'ee_rss_' . md5($rss_id);
1966
-        if (false != ($output = get_transient($cache_key))) {
1967
-            echo $pre . $output . $post;
1968
-            return true;
1969
-        }
1970
-        if ( ! $doing_ajax) {
1971
-            echo $pre . $loading . $post;
1972
-            return false;
1973
-        }
1974
-        ob_start();
1975
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
1976
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
1977
-        return true;
1978
-    }
1979
-
1980
-
1981
-
1982
-    public function espresso_news_post_box()
1983
-    {
1984
-        ?>
1815
+		return $entries_per_page_dropdown;
1816
+	}
1817
+
1818
+
1819
+
1820
+	/**
1821
+	 *        _set_search_attributes
1822
+	 *
1823
+	 * @access        protected
1824
+	 * @return        void
1825
+	 */
1826
+	public function _set_search_attributes()
1827
+	{
1828
+		$this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1829
+		$this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1830
+	}
1831
+
1832
+	/*** END LIST TABLE METHODS **/
1833
+	/*****************************/
1834
+	/**
1835
+	 *        _add_registered_metaboxes
1836
+	 *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
1837
+	 *
1838
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
1839
+	 * @access private
1840
+	 * @return void
1841
+	 */
1842
+	private function _add_registered_meta_boxes()
1843
+	{
1844
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1845
+		//we only add meta boxes if the page_route calls for it
1846
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
1847
+			&& is_array(
1848
+					$this->_route_config['metaboxes']
1849
+			)
1850
+		) {
1851
+			// this simply loops through the callbacks provided
1852
+			// and checks if there is a corresponding callback registered by the child
1853
+			// if there is then we go ahead and process the metabox loader.
1854
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
1855
+				// first check for Closures
1856
+				if ($metabox_callback instanceof Closure) {
1857
+					$result = $metabox_callback();
1858
+				} else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
1859
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
1860
+				} else {
1861
+					$result = call_user_func(array($this, &$metabox_callback));
1862
+				}
1863
+				if ($result === false) {
1864
+					// user error msg
1865
+					$error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1866
+					// developer error msg
1867
+					$error_msg .= '||' . sprintf(
1868
+									__(
1869
+											'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
1870
+											'event_espresso'
1871
+									),
1872
+									$metabox_callback
1873
+							);
1874
+					throw new EE_Error($error_msg);
1875
+				}
1876
+			}
1877
+		}
1878
+	}
1879
+
1880
+
1881
+
1882
+	/**
1883
+	 * _add_screen_columns
1884
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as the dynamic column template and we'll setup the column options for the page.
1885
+	 *
1886
+	 * @access private
1887
+	 * @return void
1888
+	 */
1889
+	private function _add_screen_columns()
1890
+	{
1891
+		if (
1892
+				is_array($this->_route_config)
1893
+				&& isset($this->_route_config['columns'])
1894
+				&& is_array($this->_route_config['columns'])
1895
+				&& count($this->_route_config['columns']) === 2
1896
+		) {
1897
+			add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1898
+			$this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1899
+			$screen_id = $this->_current_screen->id;
1900
+			$screen_columns = (int)get_user_option("screen_layout_$screen_id");
1901
+			$total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1902
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1903
+			$this->_template_args['current_page'] = $this->_wp_page_slug;
1904
+			$this->_template_args['screen'] = $this->_current_screen;
1905
+			$this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1906
+			//finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
1907
+			$this->_route_config['has_metaboxes'] = true;
1908
+		}
1909
+	}
1910
+
1911
+
1912
+
1913
+	/**********************************/
1914
+	/** GLOBALLY AVAILABLE METABOXES **/
1915
+	/**
1916
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply referencing the callback in the _page_config array property.  This way you can be very specific about what pages these get
1917
+	 * loaded on.
1918
+	 */
1919
+	private function _espresso_news_post_box()
1920
+	{
1921
+		$news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso'));
1922
+		add_meta_box('espresso_news_post_box', $news_box_title, array(
1923
+				$this,
1924
+				'espresso_news_post_box',
1925
+		), $this->_wp_page_slug, 'side');
1926
+	}
1927
+
1928
+
1929
+
1930
+	/**
1931
+	 * Code for setting up espresso ratings request metabox.
1932
+	 */
1933
+	protected function _espresso_ratings_request()
1934
+	{
1935
+		if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
1936
+			return '';
1937
+		}
1938
+		$ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso'));
1939
+		add_meta_box('espresso_ratings_request', $ratings_box_title, array(
1940
+				$this,
1941
+				'espresso_ratings_request',
1942
+		), $this->_wp_page_slug, 'side');
1943
+	}
1944
+
1945
+
1946
+
1947
+	/**
1948
+	 * Code for setting up espresso ratings request metabox content.
1949
+	 */
1950
+	public function espresso_ratings_request()
1951
+	{
1952
+		$template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1953
+		EEH_Template::display_template($template_path, array());
1954
+	}
1955
+
1956
+
1957
+
1958
+	public static function cached_rss_display($rss_id, $url)
1959
+	{
1960
+		$loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1961
+		$doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1962
+		$pre = '<div class="espresso-rss-display">' . "\n\t";
1963
+		$pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1964
+		$post = '</div>' . "\n";
1965
+		$cache_key = 'ee_rss_' . md5($rss_id);
1966
+		if (false != ($output = get_transient($cache_key))) {
1967
+			echo $pre . $output . $post;
1968
+			return true;
1969
+		}
1970
+		if ( ! $doing_ajax) {
1971
+			echo $pre . $loading . $post;
1972
+			return false;
1973
+		}
1974
+		ob_start();
1975
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
1976
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
1977
+		return true;
1978
+	}
1979
+
1980
+
1981
+
1982
+	public function espresso_news_post_box()
1983
+	{
1984
+		?>
1985 1985
         <div class="padding">
1986 1986
             <div id="espresso_news_post_box_content" class="infolinks">
1987 1987
                 <?php
1988
-                // Get RSS Feed(s)
1989
-                $feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/');
1990
-                $url = urlencode($feed_url);
1991
-                self::cached_rss_display('espresso_news_post_box_content', $url);
1992
-                ?>
1988
+				// Get RSS Feed(s)
1989
+				$feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/');
1990
+				$url = urlencode($feed_url);
1991
+				self::cached_rss_display('espresso_news_post_box_content', $url);
1992
+				?>
1993 1993
             </div>
1994 1994
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
1995 1995
         </div>
1996 1996
         <?php
1997
-    }
1998
-
1999
-
2000
-
2001
-    private function _espresso_links_post_box()
2002
-    {
2003
-        //Hiding until we actually have content to put in here...
2004
-        //add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2005
-    }
2006
-
2007
-
2008
-
2009
-    public function espresso_links_post_box()
2010
-    {
2011
-        //Hiding until we actually have content to put in here...
2012
-        //$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2013
-        //EEH_Template::display_template( $templatepath );
2014
-    }
2015
-
2016
-
2017
-
2018
-    protected function _espresso_sponsors_post_box()
2019
-    {
2020
-        $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2021
-        if ($show_sponsors) {
2022
-            add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side');
2023
-        }
2024
-    }
2025
-
2026
-
2027
-
2028
-    public function espresso_sponsors_post_box()
2029
-    {
2030
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2031
-        EEH_Template::display_template($templatepath);
2032
-    }
2033
-
2034
-
2035
-
2036
-    private function _publish_post_box()
2037
-    {
2038
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2039
-        //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2040
-        if ( ! empty($this->_labels['publishbox'])) {
2041
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
2042
-        } else {
2043
-            $box_label = __('Publish', 'event_espresso');
2044
-        }
2045
-        $box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this);
2046
-        add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high');
2047
-    }
2048
-
2049
-
2050
-
2051
-    public function editor_overview()
2052
-    {
2053
-        //if we have extra content set let's add it in if not make sure its empty
2054
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2055
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2056
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2057
-    }
2058
-
2059
-
2060
-    /** end of globally available metaboxes section **/
2061
-    /*************************************************/
2062
-    /**
2063
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2064
-     * protected method.
2065
-     *
2066
-     * @see   $this->_set_publish_post_box_vars for param details
2067
-     * @since 4.6.0
2068
-     */
2069
-    public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true)
2070
-    {
2071
-        $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2072
-    }
2073
-
2074
-
2075
-
2076
-    /**
2077
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2078
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2079
-     * save, and save and close buttons to work properly, then you will want to include a
2080
-     * values for the name and id arguments.
2081
-     *
2082
-     * @todo  Add in validation for name/id arguments.
2083
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2084
-     * @param    int     $id                      id attached to the item published
2085
-     * @param    string  $delete                  page route callback for the delete action
2086
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2087
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button
2088
-     * @throws \EE_Error
2089
-     */
2090
-    protected function _set_publish_post_box_vars(
2091
-            $name = '',
2092
-            $id = 0,
2093
-            $delete = '',
2094
-            $save_close_redirect_URL = '',
2095
-            $both_btns = true
2096
-    ) {
2097
-        // if Save & Close, use a custom redirect URL or default to the main page?
2098
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url;
2099
-        // create the Save & Close and Save buttons
2100
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2101
-        //if we have extra content set let's add it in if not make sure its empty
2102
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2103
-        if ($delete && ! empty($id)) {
2104
-            //make sure we have a default if just true is sent.
2105
-            $delete = ! empty($delete) ? $delete : 'delete';
2106
-            $delete_link_args = array($name => $id);
2107
-            $delete = $this->get_action_link_or_button(
2108
-                    $delete,
2109
-                    $delete,
2110
-                    $delete_link_args,
2111
-                    'submitdelete deletion',
2112
-                    '',
2113
-                    false
2114
-            );
2115
-        }
2116
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2117
-        if ( ! empty($name) && ! empty($id)) {
2118
-            $hidden_field_arr[$name] = array(
2119
-                    'type'  => 'hidden',
2120
-                    'value' => $id,
2121
-            );
2122
-            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2123
-        } else {
2124
-            $hf = '';
2125
-        }
2126
-        // add hidden field
2127
-        $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2128
-    }
2129
-
2130
-
2131
-
2132
-    /**
2133
-     *        displays an error message to ppl who have javascript disabled
2134
-     *
2135
-     * @access        private
2136
-     * @return        string
2137
-     */
2138
-    private function _display_no_javascript_warning()
2139
-    {
2140
-        ?>
1997
+	}
1998
+
1999
+
2000
+
2001
+	private function _espresso_links_post_box()
2002
+	{
2003
+		//Hiding until we actually have content to put in here...
2004
+		//add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2005
+	}
2006
+
2007
+
2008
+
2009
+	public function espresso_links_post_box()
2010
+	{
2011
+		//Hiding until we actually have content to put in here...
2012
+		//$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2013
+		//EEH_Template::display_template( $templatepath );
2014
+	}
2015
+
2016
+
2017
+
2018
+	protected function _espresso_sponsors_post_box()
2019
+	{
2020
+		$show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2021
+		if ($show_sponsors) {
2022
+			add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side');
2023
+		}
2024
+	}
2025
+
2026
+
2027
+
2028
+	public function espresso_sponsors_post_box()
2029
+	{
2030
+		$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2031
+		EEH_Template::display_template($templatepath);
2032
+	}
2033
+
2034
+
2035
+
2036
+	private function _publish_post_box()
2037
+	{
2038
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2039
+		//if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2040
+		if ( ! empty($this->_labels['publishbox'])) {
2041
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
2042
+		} else {
2043
+			$box_label = __('Publish', 'event_espresso');
2044
+		}
2045
+		$box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this);
2046
+		add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high');
2047
+	}
2048
+
2049
+
2050
+
2051
+	public function editor_overview()
2052
+	{
2053
+		//if we have extra content set let's add it in if not make sure its empty
2054
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2055
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2056
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2057
+	}
2058
+
2059
+
2060
+	/** end of globally available metaboxes section **/
2061
+	/*************************************************/
2062
+	/**
2063
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2064
+	 * protected method.
2065
+	 *
2066
+	 * @see   $this->_set_publish_post_box_vars for param details
2067
+	 * @since 4.6.0
2068
+	 */
2069
+	public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true)
2070
+	{
2071
+		$this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2072
+	}
2073
+
2074
+
2075
+
2076
+	/**
2077
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2078
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2079
+	 * save, and save and close buttons to work properly, then you will want to include a
2080
+	 * values for the name and id arguments.
2081
+	 *
2082
+	 * @todo  Add in validation for name/id arguments.
2083
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2084
+	 * @param    int     $id                      id attached to the item published
2085
+	 * @param    string  $delete                  page route callback for the delete action
2086
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2087
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button
2088
+	 * @throws \EE_Error
2089
+	 */
2090
+	protected function _set_publish_post_box_vars(
2091
+			$name = '',
2092
+			$id = 0,
2093
+			$delete = '',
2094
+			$save_close_redirect_URL = '',
2095
+			$both_btns = true
2096
+	) {
2097
+		// if Save & Close, use a custom redirect URL or default to the main page?
2098
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url;
2099
+		// create the Save & Close and Save buttons
2100
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2101
+		//if we have extra content set let's add it in if not make sure its empty
2102
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2103
+		if ($delete && ! empty($id)) {
2104
+			//make sure we have a default if just true is sent.
2105
+			$delete = ! empty($delete) ? $delete : 'delete';
2106
+			$delete_link_args = array($name => $id);
2107
+			$delete = $this->get_action_link_or_button(
2108
+					$delete,
2109
+					$delete,
2110
+					$delete_link_args,
2111
+					'submitdelete deletion',
2112
+					'',
2113
+					false
2114
+			);
2115
+		}
2116
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2117
+		if ( ! empty($name) && ! empty($id)) {
2118
+			$hidden_field_arr[$name] = array(
2119
+					'type'  => 'hidden',
2120
+					'value' => $id,
2121
+			);
2122
+			$hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2123
+		} else {
2124
+			$hf = '';
2125
+		}
2126
+		// add hidden field
2127
+		$this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2128
+	}
2129
+
2130
+
2131
+
2132
+	/**
2133
+	 *        displays an error message to ppl who have javascript disabled
2134
+	 *
2135
+	 * @access        private
2136
+	 * @return        string
2137
+	 */
2138
+	private function _display_no_javascript_warning()
2139
+	{
2140
+		?>
2141 2141
         <noscript>
2142 2142
             <div id="no-js-message" class="error">
2143 2143
                 <p style="font-size:1.3em;">
@@ -2147,1267 +2147,1267 @@  discard block
 block discarded – undo
2147 2147
             </div>
2148 2148
         </noscript>
2149 2149
         <?php
2150
-    }
2150
+	}
2151 2151
 
2152 2152
 
2153 2153
 
2154
-    /**
2155
-     *        displays espresso success and/or error notices
2156
-     *
2157
-     * @access        private
2158
-     * @return        string
2159
-     */
2160
-    private function _display_espresso_notices()
2161
-    {
2162
-        $notices = $this->_get_transient(true);
2163
-        echo stripslashes($notices);
2164
-    }
2154
+	/**
2155
+	 *        displays espresso success and/or error notices
2156
+	 *
2157
+	 * @access        private
2158
+	 * @return        string
2159
+	 */
2160
+	private function _display_espresso_notices()
2161
+	{
2162
+		$notices = $this->_get_transient(true);
2163
+		echo stripslashes($notices);
2164
+	}
2165 2165
 
2166 2166
 
2167 2167
 
2168
-    /**
2169
-     *        spinny things pacify the masses
2170
-     *
2171
-     * @access private
2172
-     * @return string
2173
-     */
2174
-    protected function _add_admin_page_ajax_loading_img()
2175
-    {
2176
-        ?>
2168
+	/**
2169
+	 *        spinny things pacify the masses
2170
+	 *
2171
+	 * @access private
2172
+	 * @return string
2173
+	 */
2174
+	protected function _add_admin_page_ajax_loading_img()
2175
+	{
2176
+		?>
2177 2177
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2178 2178
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php esc_html_e('loading...', 'event_espresso'); ?></span>
2179 2179
         </div>
2180 2180
         <?php
2181
-    }
2181
+	}
2182 2182
 
2183 2183
 
2184 2184
 
2185
-    /**
2186
-     *        add admin page overlay for modal boxes
2187
-     *
2188
-     * @access private
2189
-     * @return string
2190
-     */
2191
-    protected function _add_admin_page_overlay()
2192
-    {
2193
-        ?>
2185
+	/**
2186
+	 *        add admin page overlay for modal boxes
2187
+	 *
2188
+	 * @access private
2189
+	 * @return string
2190
+	 */
2191
+	protected function _add_admin_page_overlay()
2192
+	{
2193
+		?>
2194 2194
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2195 2195
         <?php
2196
-    }
2197
-
2198
-
2199
-
2200
-    /**
2201
-     * facade for add_meta_box
2202
-     *
2203
-     * @param string  $action        where the metabox get's displayed
2204
-     * @param string  $title         Title of Metabox (output in metabox header)
2205
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback instead of the one created in here.
2206
-     * @param array   $callback_args an array of args supplied for the metabox
2207
-     * @param string  $column        what metabox column
2208
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2209
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box.
2210
-     */
2211
-    public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true)
2212
-    {
2213
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2214
-        //if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2215
-        if (empty($callback_args) && $create_func) {
2216
-            $callback_args = array(
2217
-                    'template_path' => $this->_template_path,
2218
-                    'template_args' => $this->_template_args,
2219
-            );
2220
-        }
2221
-        //if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2222
-        $call_back_func = $create_func ? create_function('$post, $metabox',
2223
-                'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2224
-        add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2225
-    }
2226
-
2227
-
2228
-
2229
-    /**
2230
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2231
-     *
2232
-     * @return [type] [description]
2233
-     */
2234
-    public function display_admin_page_with_metabox_columns()
2235
-    {
2236
-        $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2237
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true);
2238
-        //the final wrapper
2239
-        $this->admin_page_wrapper();
2240
-    }
2241
-
2242
-
2243
-
2244
-    /**
2245
-     *        generates  HTML wrapper for an admin details page
2246
-     *
2247
-     * @access public
2248
-     * @return void
2249
-     */
2250
-    public function display_admin_page_with_sidebar()
2251
-    {
2252
-        $this->_display_admin_page(true);
2253
-    }
2254
-
2255
-
2256
-
2257
-    /**
2258
-     *        generates  HTML wrapper for an admin details page (except no sidebar)
2259
-     *
2260
-     * @access public
2261
-     * @return void
2262
-     */
2263
-    public function display_admin_page_with_no_sidebar()
2264
-    {
2265
-        $this->_display_admin_page();
2266
-    }
2267
-
2268
-
2269
-
2270
-    /**
2271
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2272
-     *
2273
-     * @access public
2274
-     * @return void
2275
-     */
2276
-    public function display_about_admin_page()
2277
-    {
2278
-        $this->_display_admin_page(false, true);
2279
-    }
2280
-
2281
-
2282
-
2283
-    /**
2284
-     * display_admin_page
2285
-     * contains the code for actually displaying an admin page
2286
-     *
2287
-     * @access private
2288
-     * @param  boolean $sidebar true with sidebar, false without
2289
-     * @param  boolean $about   use the about admin wrapper instead of the default.
2290
-     * @return void
2291
-     */
2292
-    private function _display_admin_page($sidebar = false, $about = false)
2293
-    {
2294
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2295
-        //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2296
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2297
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2298
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2299
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2300
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2301
-                ? 'poststuff'
2302
-                : 'espresso-default-admin';
2303
-        $template_path = $sidebar
2304
-                ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2305
-                : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2306
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2307
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2308
-        }
2309
-        $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2310
-        $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
2311
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '';
2312
-        $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '';
2313
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2314
-        // the final template wrapper
2315
-        $this->admin_page_wrapper($about);
2316
-    }
2317
-
2318
-
2319
-
2320
-    /**
2321
-     * This is used to display caf preview pages.
2322
-     *
2323
-     * @since 4.3.2
2324
-     * @param string $utm_campaign_source what is the key used for google analytics link
2325
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2326
-     * @return void
2327
-     * @throws \EE_Error
2328
-     */
2329
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2330
-    {
2331
-        //let's generate a default preview action button if there isn't one already present.
2332
-        $this->_labels['buttons']['buy_now'] = __('Upgrade to Event Espresso 4 Right Now', 'event_espresso');
2333
-        $buy_now_url = add_query_arg(
2334
-                array(
2335
-                        'ee_ver'       => 'ee4',
2336
-                        'utm_source'   => 'ee4_plugin_admin',
2337
-                        'utm_medium'   => 'link',
2338
-                        'utm_campaign' => $utm_campaign_source,
2339
-                        'utm_content'  => 'buy_now_button',
2340
-                ),
2341
-                'http://eventespresso.com/pricing/'
2342
-        );
2343
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2344
-                ? $this->get_action_link_or_button(
2345
-                        '',
2346
-                        'buy_now',
2347
-                        array(),
2348
-                        'button-primary button-large',
2349
-                        $buy_now_url,
2350
-                        true
2351
-                )
2352
-                : $this->_template_args['preview_action_button'];
2353
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2354
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2355
-                $template_path,
2356
-                $this->_template_args,
2357
-                true
2358
-        );
2359
-        $this->_display_admin_page($display_sidebar);
2360
-    }
2361
-
2362
-
2363
-
2364
-    /**
2365
-     * display_admin_list_table_page_with_sidebar
2366
-     * generates HTML wrapper for an admin_page with list_table
2367
-     *
2368
-     * @access public
2369
-     * @return void
2370
-     */
2371
-    public function display_admin_list_table_page_with_sidebar()
2372
-    {
2373
-        $this->_display_admin_list_table_page(true);
2374
-    }
2375
-
2376
-
2377
-
2378
-    /**
2379
-     * display_admin_list_table_page_with_no_sidebar
2380
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2381
-     *
2382
-     * @access public
2383
-     * @return void
2384
-     */
2385
-    public function display_admin_list_table_page_with_no_sidebar()
2386
-    {
2387
-        $this->_display_admin_list_table_page();
2388
-    }
2389
-
2390
-
2391
-
2392
-    /**
2393
-     * generates html wrapper for an admin_list_table page
2394
-     *
2395
-     * @access private
2396
-     * @param boolean $sidebar whether to display with sidebar or not.
2397
-     * @return void
2398
-     */
2399
-    private function _display_admin_list_table_page($sidebar = false)
2400
-    {
2401
-        //setup search attributes
2402
-        $this->_set_search_attributes();
2403
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2404
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2405
-        $this->_template_args['table_url'] = defined('DOING_AJAX')
2406
-                ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2407
-                : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2408
-        $this->_template_args['list_table'] = $this->_list_table_object;
2409
-        $this->_template_args['current_route'] = $this->_req_action;
2410
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2411
-        $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2412
-        if ( ! empty($ajax_sorting_callback)) {
2413
-            $sortable_list_table_form_fields = wp_nonce_field(
2414
-                    $ajax_sorting_callback . '_nonce',
2415
-                    $ajax_sorting_callback . '_nonce',
2416
-                    false,
2417
-                    false
2418
-            );
2419
-            //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2420
-            //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2421
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2422
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2423
-        } else {
2424
-            $sortable_list_table_form_fields = '';
2425
-        }
2426
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2427
-        $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2428
-        $nonce_ref = $this->_req_action . '_nonce';
2429
-        $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2430
-        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2431
-        //display message about search results?
2432
-        $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2433
-                ? '<p class="ee-search-results">' . sprintf(
2434
-                        esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2435
-                        trim($this->_req_data['s'], '%')
2436
-                ) . '</p>'
2437
-                : '';
2438
-        // filter before_list_table template arg
2439
-        $this->_template_args['before_list_table'] = apply_filters(
2440
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2441
-            $this->_template_args['before_list_table'],
2442
-            $this->page_slug,
2443
-            $this->_req_data,
2444
-            $this->_req_action
2445
-        );
2446
-        // convert to array and filter again
2447
-        // arrays are easier to inject new items in a specific location,
2448
-        // but would not be backwards compatible, so we have to add a new filter
2449
-        $this->_template_args['before_list_table'] = implode(
2450
-            " \n",
2451
-            (array) apply_filters(
2452
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2453
-                (array) $this->_template_args['before_list_table'],
2454
-                $this->page_slug,
2455
-                $this->_req_data,
2456
-                $this->_req_action
2457
-            )
2458
-        );
2459
-        // filter after_list_table template arg
2460
-        $this->_template_args['after_list_table'] = apply_filters(
2461
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2462
-            $this->_template_args['after_list_table'],
2463
-            $this->page_slug,
2464
-            $this->_req_data,
2465
-            $this->_req_action
2466
-        );
2467
-        // convert to array and filter again
2468
-        // arrays are easier to inject new items in a specific location,
2469
-        // but would not be backwards compatible, so we have to add a new filter
2470
-        $this->_template_args['after_list_table'] = implode(
2471
-            " \n",
2472
-            (array) apply_filters(
2473
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2474
-                (array) $this->_template_args['after_list_table'],
2475
-                $this->page_slug,
2476
-                $this->_req_data,
2477
-                $this->_req_action
2478
-            )
2479
-        );
2480
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2481
-                $template_path,
2482
-                $this->_template_args,
2483
-                true
2484
-        );
2485
-        // the final template wrapper
2486
-        if ($sidebar) {
2487
-            $this->display_admin_page_with_sidebar();
2488
-        } else {
2489
-            $this->display_admin_page_with_no_sidebar();
2490
-        }
2491
-    }
2492
-
2493
-
2494
-
2495
-    /**
2496
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the html string for the legend.
2497
-     * $items are expected in an array in the following format:
2498
-     * $legend_items = array(
2499
-     *        'item_id' => array(
2500
-     *            'icon' => 'http://url_to_icon_being_described.png',
2501
-     *            'desc' => __('localized description of item');
2502
-     *        )
2503
-     * );
2504
-     *
2505
-     * @param  array $items see above for format of array
2506
-     * @return string        html string of legend
2507
-     */
2508
-    protected function _display_legend($items)
2509
-    {
2510
-        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2511
-        $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2512
-        return EEH_Template::display_template($legend_template, $this->_template_args, true);
2513
-    }
2514
-
2515
-
2516
-    /**
2517
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2518
-     * The returned json object is created from an array in the following format:
2519
-     * array(
2520
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2521
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
2522
-     *  'notices' => '', // - contains any EE_Error formatted notices
2523
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
2524
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any
2525
-     *  specific template args that might be included in here)
2526
-     * )
2527
-     * The json object is populated by whatever is set in the $_template_args property.
2528
-     *
2529
-     * @param bool  $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed.
2530
-     * @param array $notices_arguments  Use this to pass any additional args on to the _process_notices.
2531
-     * @return void
2532
-     */
2533
-    protected function _return_json($sticky_notices = false, $notices_arguments = array())
2534
-    {
2535
-        //make sure any EE_Error notices have been handled.
2536
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
2537
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
2538
-        unset($this->_template_args['data']);
2539
-        $json = array(
2540
-                'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2541
-                'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2542
-                'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2543
-                'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2544
-                'notices'   => EE_Error::get_notices(),
2545
-                'content'   => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '',
2546
-                'data'      => array_merge($data, array('template_args' => $this->_template_args)),
2547
-                'isEEajax'  => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2548
-        );
2549
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
2550
-        if (null === error_get_last() || ! headers_sent()) {
2551
-            header('Content-Type: application/json; charset=UTF-8');
2552
-        }
2553
-        echo wp_json_encode($json);
2554
-
2555
-        exit();
2556
-    }
2557
-
2558
-
2559
-
2560
-    /**
2561
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2562
-     *
2563
-     * @return void
2564
-     * @throws EE_Error
2565
-     */
2566
-    public function return_json()
2567
-    {
2568
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2569
-            $this->_return_json();
2570
-        } else {
2571
-            throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__));
2572
-        }
2573
-    }
2574
-
2575
-
2576
-
2577
-    /**
2578
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
2579
-     *
2580
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
2581
-     * @access   public
2582
-     */
2583
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
2584
-    {
2585
-        $this->_hook_obj = $hook_obj;
2586
-    }
2587
-
2588
-
2589
-
2590
-    /**
2591
-     *        generates  HTML wrapper with Tabbed nav for an admin page
2592
-     *
2593
-     * @access public
2594
-     * @param  boolean $about whether to use the special about page wrapper or default.
2595
-     * @return void
2596
-     */
2597
-    public function admin_page_wrapper($about = false)
2598
-    {
2599
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2600
-        $this->_nav_tabs = $this->_get_main_nav_tabs();
2601
-        $this->_template_args['nav_tabs'] = $this->_nav_tabs;
2602
-        $this->_template_args['admin_page_title'] = $this->_admin_page_title;
2603
-        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2604
-                isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2605
-        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2606
-                isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2607
-        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2608
-        // load settings page wrapper template
2609
-        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2610
-        //about page?
2611
-        $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2612
-        if (defined('DOING_AJAX')) {
2613
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2614
-            $this->_return_json();
2615
-        } else {
2616
-            EEH_Template::display_template($template_path, $this->_template_args);
2617
-        }
2618
-    }
2619
-
2620
-
2621
-
2622
-    /**
2623
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
2624
-     *
2625
-     * @return string html
2626
-     */
2627
-    protected function _get_main_nav_tabs()
2628
-    {
2629
-        //let's generate the html using the EEH_Tabbed_Content helper.  We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array)
2630
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
2631
-    }
2632
-
2633
-
2634
-
2635
-    /**
2636
-     *        sort nav tabs
2637
-     *
2638
-     * @access public
2639
-     * @param $a
2640
-     * @param $b
2641
-     * @return int
2642
-     */
2643
-    private function _sort_nav_tabs($a, $b)
2644
-    {
2645
-        if ($a['order'] == $b['order']) {
2646
-            return 0;
2647
-        }
2648
-        return ($a['order'] < $b['order']) ? -1 : 1;
2649
-    }
2650
-
2651
-
2652
-
2653
-    /**
2654
-     *    generates HTML for the forms used on admin pages
2655
-     *
2656
-     * @access protected
2657
-     * @param    array $input_vars - array of input field details
2658
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to use)
2659
-     * @return string
2660
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
2661
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
2662
-     */
2663
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
2664
-    {
2665
-        $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars);
2666
-        return $content;
2667
-    }
2668
-
2669
-
2670
-
2671
-    /**
2672
-     * generates the "Save" and "Save & Close" buttons for edit forms
2673
-     *
2674
-     * @access protected
2675
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save & Close" button.
2676
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close')
2677
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button).  We can also use this to just dump default actions by submitting some other value.
2678
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling).
2679
-     */
2680
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2681
-    {
2682
-        //make sure $text and $actions are in an array
2683
-        $text = (array)$text;
2684
-        $actions = (array)$actions;
2685
-        $referrer_url = empty($referrer) ? '' : $referrer;
2686
-        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2687
-                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2688
-        $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2689
-        $default_names = array('save', 'save_and_close');
2690
-        //add in a hidden index for the current page (so save and close redirects properly)
2691
-        $this->_template_args['save_buttons'] = $referrer_url;
2692
-        foreach ($button_text as $key => $button) {
2693
-            $ref = $default_names[$key];
2694
-            $id = $this->_current_view . '_' . $ref;
2695
-            $name = ! empty($actions) ? $actions[$key] : $ref;
2696
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2697
-            if ( ! $both) {
2698
-                break;
2699
-            }
2700
-        }
2701
-    }
2702
-
2703
-
2704
-
2705
-    /**
2706
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
2707
-     *
2708
-     * @see   $this->_set_add_edit_form_tags() for details on params
2709
-     * @since 4.6.0
2710
-     * @param string $route
2711
-     * @param array  $additional_hidden_fields
2712
-     */
2713
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2714
-    {
2715
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
2716
-    }
2717
-
2718
-
2719
-
2720
-    /**
2721
-     * set form open and close tags on add/edit pages.
2722
-     *
2723
-     * @access protected
2724
-     * @param string $route                    the route you want the form to direct to
2725
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
2726
-     * @return void
2727
-     */
2728
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2729
-    {
2730
-        if (empty($route)) {
2731
-            $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2732
-            $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2733
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2734
-        }
2735
-        // open form
2736
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2737
-        // add nonce
2738
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2739
-        //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2740
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2741
-        // add REQUIRED form action
2742
-        $hidden_fields = array(
2743
-                'action' => array('type' => 'hidden', 'value' => $route),
2744
-        );
2745
-        // merge arrays
2746
-        $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields;
2747
-        // generate form fields
2748
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2749
-        // add fields to form
2750
-        foreach ((array)$form_fields as $field_name => $form_field) {
2751
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2752
-        }
2753
-        // close form
2754
-        $this->_template_args['after_admin_page_content'] = '</form>';
2755
-    }
2756
-
2757
-
2758
-
2759
-    /**
2760
-     * Public Wrapper for _redirect_after_action() method since its
2761
-     * discovered it would be useful for external code to have access.
2762
-     *
2763
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
2764
-     * @since 4.5.0
2765
-     */
2766
-    public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2767
-    {
2768
-        $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
2769
-    }
2770
-
2771
-
2772
-
2773
-    /**
2774
-     *    _redirect_after_action
2775
-     *
2776
-     * @param int    $success            - whether success was for two or more records, or just one, or none
2777
-     * @param string $what               - what the action was performed on
2778
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
2779
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin action is completed
2780
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show.
2781
-     * @access protected
2782
-     * @return void
2783
-     */
2784
-    protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2785
-    {
2786
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2787
-        //class name for actions/filters.
2788
-        $classname = get_class($this);
2789
-        //set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url
2790
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
2791
-        $notices = EE_Error::get_notices(false);
2792
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
2793
-        if ( ! $override_overwrite || ! empty($notices['errors'])) {
2794
-            EE_Error::overwrite_success();
2795
-        }
2796
-        if ( ! empty($what) && ! empty($action_desc)) {
2797
-            // how many records affected ? more than one record ? or just one ?
2798
-            if ($success > 1 && empty($notices['errors'])) {
2799
-                // set plural msg
2800
-                EE_Error::add_success(
2801
-                        sprintf(
2802
-                                __('The "%s" have been successfully %s.', 'event_espresso'),
2803
-                                $what,
2804
-                                $action_desc
2805
-                        ),
2806
-                        __FILE__, __FUNCTION__, __LINE__
2807
-                );
2808
-            } else if ($success == 1 && empty($notices['errors'])) {
2809
-                // set singular msg
2810
-                EE_Error::add_success(
2811
-                        sprintf(
2812
-                                __('The "%s" has been successfully %s.', 'event_espresso'),
2813
-                                $what,
2814
-                                $action_desc
2815
-                        ),
2816
-                        __FILE__, __FUNCTION__, __LINE__
2817
-                );
2818
-            }
2819
-        }
2820
-        // check that $query_args isn't something crazy
2821
-        if ( ! is_array($query_args)) {
2822
-            $query_args = array();
2823
-        }
2824
-        /**
2825
-         * Allow injecting actions before the query_args are modified for possible different
2826
-         * redirections on save and close actions
2827
-         *
2828
-         * @since 4.2.0
2829
-         * @param array $query_args       The original query_args array coming into the
2830
-         *                                method.
2831
-         */
2832
-        do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2833
-        //calculate where we're going (if we have a "save and close" button pushed)
2834
-        if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2835
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
2836
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
2837
-            // regenerate query args array from referrer URL
2838
-            parse_str($parsed_url['query'], $query_args);
2839
-            // correct page and action will be in the query args now
2840
-            $redirect_url = admin_url('admin.php');
2841
-        }
2842
-        //merge any default query_args set in _default_route_query_args property
2843
-        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
2844
-            $args_to_merge = array();
2845
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
2846
-                //is there a wp_referer array in our _default_route_query_args property?
2847
-                if ($query_param == 'wp_referer') {
2848
-                    $query_value = (array)$query_value;
2849
-                    foreach ($query_value as $reference => $value) {
2850
-                        if (strpos($reference, 'nonce') !== false) {
2851
-                            continue;
2852
-                        }
2853
-                        //finally we will override any arguments in the referer with
2854
-                        //what might be set on the _default_route_query_args array.
2855
-                        if (isset($this->_default_route_query_args[$reference])) {
2856
-                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
2857
-                        } else {
2858
-                            $args_to_merge[$reference] = urlencode($value);
2859
-                        }
2860
-                    }
2861
-                    continue;
2862
-                }
2863
-                $args_to_merge[$query_param] = $query_value;
2864
-            }
2865
-            //now let's merge these arguments but override with what was specifically sent in to the
2866
-            //redirect.
2867
-            $query_args = array_merge($args_to_merge, $query_args);
2868
-        }
2869
-        $this->_process_notices($query_args);
2870
-        // generate redirect url
2871
-        // if redirecting to anything other than the main page, add a nonce
2872
-        if (isset($query_args['action'])) {
2873
-            // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2874
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2875
-        }
2876
-        //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
2877
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2878
-        $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2879
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2880
-        if (defined('DOING_AJAX')) {
2881
-            $default_data = array(
2882
-                    'close'        => true,
2883
-                    'redirect_url' => $redirect_url,
2884
-                    'where'        => 'main',
2885
-                    'what'         => 'append',
2886
-            );
2887
-            $this->_template_args['success'] = $success;
2888
-            $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data;
2889
-            $this->_return_json();
2890
-        }
2891
-        wp_safe_redirect($redirect_url);
2892
-        exit();
2893
-    }
2894
-
2895
-
2896
-
2897
-    /**
2898
-     * process any notices before redirecting (or returning ajax request)
2899
-     * This method sets the $this->_template_args['notices'] attribute;
2900
-     *
2901
-     * @param  array $query_args        any query args that need to be used for notice transient ('action')
2902
-     * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet.
2903
-     * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice.
2904
-     * @return void
2905
-     */
2906
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
2907
-    {
2908
-        //first let's set individual error properties if doing_ajax and the properties aren't already set.
2909
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2910
-            $notices = EE_Error::get_notices(false);
2911
-            if (empty($this->_template_args['success'])) {
2912
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
2913
-            }
2914
-            if (empty($this->_template_args['errors'])) {
2915
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
2916
-            }
2917
-            if (empty($this->_template_args['attention'])) {
2918
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
2919
-            }
2920
-        }
2921
-        $this->_template_args['notices'] = EE_Error::get_notices();
2922
-        //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
2923
-        if ( ! defined('DOING_AJAX') || $sticky_notices) {
2924
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
2925
-            $this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
2926
-        }
2927
-    }
2928
-
2929
-
2930
-
2931
-    /**
2932
-     * get_action_link_or_button
2933
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
2934
-     *
2935
-     * @param string $action        use this to indicate which action the url is generated with.
2936
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key) property.
2937
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
2938
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
2939
-     * @param string $base_url      If this is not provided
2940
-     *                              the _admin_base_url will be used as the default for the button base_url.
2941
-     *                              Otherwise this value will be used.
2942
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
2943
-     * @return string
2944
-     * @throws \EE_Error
2945
-     */
2946
-    public function get_action_link_or_button(
2947
-            $action,
2948
-            $type = 'add',
2949
-            $extra_request = array(),
2950
-            $class = 'button-primary',
2951
-            $base_url = '',
2952
-            $exclude_nonce = false
2953
-    ) {
2954
-        //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
2955
-        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
2956
-            throw new EE_Error(
2957
-                    sprintf(
2958
-                            __(
2959
-                                    'There is no page route for given action for the button.  This action was given: %s',
2960
-                                    'event_espresso'
2961
-                            ),
2962
-                            $action
2963
-                    )
2964
-            );
2965
-        }
2966
-        if ( ! isset($this->_labels['buttons'][$type])) {
2967
-            throw new EE_Error(
2968
-                    sprintf(
2969
-                            __(
2970
-                                    'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
2971
-                                    'event_espresso'
2972
-                            ),
2973
-                            $type
2974
-                    )
2975
-            );
2976
-        }
2977
-        //finally check user access for this button.
2978
-        $has_access = $this->check_user_access($action, true);
2979
-        if ( ! $has_access) {
2980
-            return '';
2981
-        }
2982
-        $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
2983
-        $query_args = array(
2984
-                'action' => $action,
2985
-        );
2986
-        //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
2987
-        if ( ! empty($extra_request)) {
2988
-            $query_args = array_merge($extra_request, $query_args);
2989
-        }
2990
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
2991
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
2992
-    }
2993
-
2994
-
2995
-
2996
-    /**
2997
-     * _per_page_screen_option
2998
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
2999
-     *
3000
-     * @return void
3001
-     */
3002
-    protected function _per_page_screen_option()
3003
-    {
3004
-        $option = 'per_page';
3005
-        $args = array(
3006
-                'label'   => $this->_admin_page_title,
3007
-                'default' => 10,
3008
-                'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3009
-        );
3010
-        //ONLY add the screen option if the user has access to it.
3011
-        if ($this->check_user_access($this->_current_view, true)) {
3012
-            add_screen_option($option, $args);
3013
-        }
3014
-    }
3015
-
3016
-
3017
-
3018
-    /**
3019
-     * set_per_page_screen_option
3020
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3021
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu.
3022
-     *
3023
-     * @access private
3024
-     * @return void
3025
-     */
3026
-    private function _set_per_page_screen_options()
3027
-    {
3028
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3029
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3030
-            if ( ! $user = wp_get_current_user()) {
3031
-                return;
3032
-            }
3033
-            $option = $_POST['wp_screen_options']['option'];
3034
-            $value = $_POST['wp_screen_options']['value'];
3035
-            if ($option != sanitize_key($option)) {
3036
-                return;
3037
-            }
3038
-            $map_option = $option;
3039
-            $option = str_replace('-', '_', $option);
3040
-            switch ($map_option) {
3041
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3042
-                    $value = (int)$value;
3043
-                    if ($value < 1 || $value > 999) {
3044
-                        return;
3045
-                    }
3046
-                    break;
3047
-                default:
3048
-                    $value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value);
3049
-                    if (false === $value) {
3050
-                        return;
3051
-                    }
3052
-                    break;
3053
-            }
3054
-            update_user_meta($user->ID, $option, $value);
3055
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3056
-            exit;
3057
-        }
3058
-    }
3059
-
3060
-
3061
-
3062
-    /**
3063
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3064
-     *
3065
-     * @param array $data array that will be assigned to template args.
3066
-     */
3067
-    public function set_template_args($data)
3068
-    {
3069
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3070
-    }
3071
-
3072
-
3073
-
3074
-    /**
3075
-     * This makes available the WP transient system for temporarily moving data between routes
3076
-     *
3077
-     * @access protected
3078
-     * @param string $route             the route that should receive the transient
3079
-     * @param array  $data              the data that gets sent
3080
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a normal route transient.
3081
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used when we are adding a transient before page_routes have been defined.
3082
-     * @return void
3083
-     */
3084
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3085
-    {
3086
-        $user_id = get_current_user_id();
3087
-        if ( ! $skip_route_verify) {
3088
-            $this->_verify_route($route);
3089
-        }
3090
-        //now let's set the string for what kind of transient we're setting
3091
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3092
-        $data = $notices ? array('notices' => $data) : $data;
3093
-        //is there already a transient for this route?  If there is then let's ADD to that transient
3094
-        $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3095
-        if ($existing) {
3096
-            $data = array_merge((array)$data, (array)$existing);
3097
-        }
3098
-        if (is_multisite() && is_network_admin()) {
3099
-            set_site_transient($transient, $data, 8);
3100
-        } else {
3101
-            set_transient($transient, $data, 8);
3102
-        }
3103
-    }
3104
-
3105
-
3106
-
3107
-    /**
3108
-     * this retrieves the temporary transient that has been set for moving data between routes.
3109
-     *
3110
-     * @param bool $notices true we get notices transient. False we just return normal route transient
3111
-     * @return mixed data
3112
-     */
3113
-    protected function _get_transient($notices = false, $route = false)
3114
-    {
3115
-        $user_id = get_current_user_id();
3116
-        $route = ! $route ? $this->_req_action : $route;
3117
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3118
-        $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3119
-        //delete transient after retrieval (just in case it hasn't expired);
3120
-        if (is_multisite() && is_network_admin()) {
3121
-            delete_site_transient($transient);
3122
-        } else {
3123
-            delete_transient($transient);
3124
-        }
3125
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3126
-    }
3127
-
3128
-
3129
-
3130
-    /**
3131
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but would not be called later.
3132
-     * This will be assigned to run on a specific EE Admin page. (place the method in the default route callback on the EE_Admin page you want it run.)
3133
-     *
3134
-     * @return void
3135
-     */
3136
-    protected function _transient_garbage_collection()
3137
-    {
3138
-        global $wpdb;
3139
-        //retrieve all existing transients
3140
-        $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3141
-        if ($results = $wpdb->get_results($query)) {
3142
-            foreach ($results as $result) {
3143
-                $transient = str_replace('_transient_', '', $result->option_name);
3144
-                get_transient($transient);
3145
-                if (is_multisite() && is_network_admin()) {
3146
-                    get_site_transient($transient);
3147
-                }
3148
-            }
3149
-        }
3150
-    }
3151
-
3152
-
3153
-
3154
-    /**
3155
-     * get_view
3156
-     *
3157
-     * @access public
3158
-     * @return string content of _view property
3159
-     */
3160
-    public function get_view()
3161
-    {
3162
-        return $this->_view;
3163
-    }
3164
-
3165
-
3166
-
3167
-    /**
3168
-     * getter for the protected $_views property
3169
-     *
3170
-     * @return array
3171
-     */
3172
-    public function get_views()
3173
-    {
3174
-        return $this->_views;
3175
-    }
3176
-
3177
-
3178
-
3179
-    /**
3180
-     * get_current_page
3181
-     *
3182
-     * @access public
3183
-     * @return string _current_page property value
3184
-     */
3185
-    public function get_current_page()
3186
-    {
3187
-        return $this->_current_page;
3188
-    }
3189
-
3190
-
3191
-
3192
-    /**
3193
-     * get_current_view
3194
-     *
3195
-     * @access public
3196
-     * @return string _current_view property value
3197
-     */
3198
-    public function get_current_view()
3199
-    {
3200
-        return $this->_current_view;
3201
-    }
3202
-
3203
-
3204
-
3205
-    /**
3206
-     * get_current_screen
3207
-     *
3208
-     * @access public
3209
-     * @return object The current WP_Screen object
3210
-     */
3211
-    public function get_current_screen()
3212
-    {
3213
-        return $this->_current_screen;
3214
-    }
3215
-
3216
-
3217
-
3218
-    /**
3219
-     * get_current_page_view_url
3220
-     *
3221
-     * @access public
3222
-     * @return string This returns the url for the current_page_view.
3223
-     */
3224
-    public function get_current_page_view_url()
3225
-    {
3226
-        return $this->_current_page_view_url;
3227
-    }
3228
-
3229
-
3230
-
3231
-    /**
3232
-     * just returns the _req_data property
3233
-     *
3234
-     * @return array
3235
-     */
3236
-    public function get_request_data()
3237
-    {
3238
-        return $this->_req_data;
3239
-    }
3240
-
3241
-
3242
-
3243
-    /**
3244
-     * returns the _req_data protected property
3245
-     *
3246
-     * @return string
3247
-     */
3248
-    public function get_req_action()
3249
-    {
3250
-        return $this->_req_action;
3251
-    }
3252
-
3253
-
3254
-
3255
-    /**
3256
-     * @return bool  value of $_is_caf property
3257
-     */
3258
-    public function is_caf()
3259
-    {
3260
-        return $this->_is_caf;
3261
-    }
3262
-
3263
-
3264
-
3265
-    /**
3266
-     * @return mixed
3267
-     */
3268
-    public function default_espresso_metaboxes()
3269
-    {
3270
-        return $this->_default_espresso_metaboxes;
3271
-    }
3272
-
3273
-
3274
-
3275
-    /**
3276
-     * @return mixed
3277
-     */
3278
-    public function admin_base_url()
3279
-    {
3280
-        return $this->_admin_base_url;
3281
-    }
3282
-
3283
-
3284
-
3285
-    /**
3286
-     * @return mixed
3287
-     */
3288
-    public function wp_page_slug()
3289
-    {
3290
-        return $this->_wp_page_slug;
3291
-    }
3292
-
3293
-
3294
-
3295
-    /**
3296
-     * updates  espresso configuration settings
3297
-     *
3298
-     * @access    protected
3299
-     * @param string                   $tab
3300
-     * @param EE_Config_Base|EE_Config $config
3301
-     * @param string                   $file file where error occurred
3302
-     * @param string                   $func function  where error occurred
3303
-     * @param string                   $line line no where error occurred
3304
-     * @return boolean
3305
-     */
3306
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3307
-    {
3308
-        //remove any options that are NOT going to be saved with the config settings.
3309
-        if (isset($config->core->ee_ueip_optin)) {
3310
-            $config->core->ee_ueip_has_notified = true;
3311
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3312
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3313
-            update_option('ee_ueip_has_notified', true);
3314
-        }
3315
-        // and save it (note we're also doing the network save here)
3316
-        $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3317
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3318
-        if ($config_saved && $net_saved) {
3319
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3320
-            return true;
3321
-        } else {
3322
-            EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3323
-            return false;
3324
-        }
3325
-    }
3326
-
3327
-
3328
-
3329
-    /**
3330
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3331
-     *
3332
-     * @return array
3333
-     */
3334
-    public function get_yes_no_values()
3335
-    {
3336
-        return $this->_yes_no_values;
3337
-    }
3338
-
3339
-
3340
-
3341
-    protected function _get_dir()
3342
-    {
3343
-        $reflector = new ReflectionClass(get_class($this));
3344
-        return dirname($reflector->getFileName());
3345
-    }
3346
-
3347
-
3348
-
3349
-    /**
3350
-     * A helper for getting a "next link".
3351
-     *
3352
-     * @param string $url   The url to link to
3353
-     * @param string $class The class to use.
3354
-     * @return string
3355
-     */
3356
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3357
-    {
3358
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3359
-    }
3360
-
3361
-
3362
-
3363
-    /**
3364
-     * A helper for getting a "previous link".
3365
-     *
3366
-     * @param string $url   The url to link to
3367
-     * @param string $class The class to use.
3368
-     * @return string
3369
-     */
3370
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3371
-    {
3372
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3373
-    }
3374
-
3375
-
3376
-
3377
-
3378
-
3379
-
3380
-
3381
-    //below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3382
-    /**
3383
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the _req_data
3384
-     * array.
3385
-     *
3386
-     * @return bool success/fail
3387
-     */
3388
-    protected function _process_resend_registration()
3389
-    {
3390
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3391
-        do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data);
3392
-        return $this->_template_args['success'];
3393
-    }
3394
-
3395
-
3396
-
3397
-    /**
3398
-     * This automatically processes any payment message notifications when manual payment has been applied.
3399
-     *
3400
-     * @access protected
3401
-     * @param \EE_Payment $payment
3402
-     * @return bool success/fail
3403
-     */
3404
-    protected function _process_payment_notification(EE_Payment $payment)
3405
-    {
3406
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3407
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3408
-        $this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment);
3409
-        return $this->_template_args['success'];
3410
-    }
2196
+	}
2197
+
2198
+
2199
+
2200
+	/**
2201
+	 * facade for add_meta_box
2202
+	 *
2203
+	 * @param string  $action        where the metabox get's displayed
2204
+	 * @param string  $title         Title of Metabox (output in metabox header)
2205
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback instead of the one created in here.
2206
+	 * @param array   $callback_args an array of args supplied for the metabox
2207
+	 * @param string  $column        what metabox column
2208
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2209
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box.
2210
+	 */
2211
+	public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true)
2212
+	{
2213
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2214
+		//if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2215
+		if (empty($callback_args) && $create_func) {
2216
+			$callback_args = array(
2217
+					'template_path' => $this->_template_path,
2218
+					'template_args' => $this->_template_args,
2219
+			);
2220
+		}
2221
+		//if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2222
+		$call_back_func = $create_func ? create_function('$post, $metabox',
2223
+				'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2224
+		add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2225
+	}
2226
+
2227
+
2228
+
2229
+	/**
2230
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2231
+	 *
2232
+	 * @return [type] [description]
2233
+	 */
2234
+	public function display_admin_page_with_metabox_columns()
2235
+	{
2236
+		$this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2237
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true);
2238
+		//the final wrapper
2239
+		$this->admin_page_wrapper();
2240
+	}
2241
+
2242
+
2243
+
2244
+	/**
2245
+	 *        generates  HTML wrapper for an admin details page
2246
+	 *
2247
+	 * @access public
2248
+	 * @return void
2249
+	 */
2250
+	public function display_admin_page_with_sidebar()
2251
+	{
2252
+		$this->_display_admin_page(true);
2253
+	}
2254
+
2255
+
2256
+
2257
+	/**
2258
+	 *        generates  HTML wrapper for an admin details page (except no sidebar)
2259
+	 *
2260
+	 * @access public
2261
+	 * @return void
2262
+	 */
2263
+	public function display_admin_page_with_no_sidebar()
2264
+	{
2265
+		$this->_display_admin_page();
2266
+	}
2267
+
2268
+
2269
+
2270
+	/**
2271
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2272
+	 *
2273
+	 * @access public
2274
+	 * @return void
2275
+	 */
2276
+	public function display_about_admin_page()
2277
+	{
2278
+		$this->_display_admin_page(false, true);
2279
+	}
2280
+
2281
+
2282
+
2283
+	/**
2284
+	 * display_admin_page
2285
+	 * contains the code for actually displaying an admin page
2286
+	 *
2287
+	 * @access private
2288
+	 * @param  boolean $sidebar true with sidebar, false without
2289
+	 * @param  boolean $about   use the about admin wrapper instead of the default.
2290
+	 * @return void
2291
+	 */
2292
+	private function _display_admin_page($sidebar = false, $about = false)
2293
+	{
2294
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2295
+		//custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2296
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2297
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2298
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2299
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2300
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2301
+				? 'poststuff'
2302
+				: 'espresso-default-admin';
2303
+		$template_path = $sidebar
2304
+				? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2305
+				: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2306
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2307
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2308
+		}
2309
+		$template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2310
+		$this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
2311
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '';
2312
+		$this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '';
2313
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2314
+		// the final template wrapper
2315
+		$this->admin_page_wrapper($about);
2316
+	}
2317
+
2318
+
2319
+
2320
+	/**
2321
+	 * This is used to display caf preview pages.
2322
+	 *
2323
+	 * @since 4.3.2
2324
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2325
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2326
+	 * @return void
2327
+	 * @throws \EE_Error
2328
+	 */
2329
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2330
+	{
2331
+		//let's generate a default preview action button if there isn't one already present.
2332
+		$this->_labels['buttons']['buy_now'] = __('Upgrade to Event Espresso 4 Right Now', 'event_espresso');
2333
+		$buy_now_url = add_query_arg(
2334
+				array(
2335
+						'ee_ver'       => 'ee4',
2336
+						'utm_source'   => 'ee4_plugin_admin',
2337
+						'utm_medium'   => 'link',
2338
+						'utm_campaign' => $utm_campaign_source,
2339
+						'utm_content'  => 'buy_now_button',
2340
+				),
2341
+				'http://eventespresso.com/pricing/'
2342
+		);
2343
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2344
+				? $this->get_action_link_or_button(
2345
+						'',
2346
+						'buy_now',
2347
+						array(),
2348
+						'button-primary button-large',
2349
+						$buy_now_url,
2350
+						true
2351
+				)
2352
+				: $this->_template_args['preview_action_button'];
2353
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2354
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2355
+				$template_path,
2356
+				$this->_template_args,
2357
+				true
2358
+		);
2359
+		$this->_display_admin_page($display_sidebar);
2360
+	}
2361
+
2362
+
2363
+
2364
+	/**
2365
+	 * display_admin_list_table_page_with_sidebar
2366
+	 * generates HTML wrapper for an admin_page with list_table
2367
+	 *
2368
+	 * @access public
2369
+	 * @return void
2370
+	 */
2371
+	public function display_admin_list_table_page_with_sidebar()
2372
+	{
2373
+		$this->_display_admin_list_table_page(true);
2374
+	}
2375
+
2376
+
2377
+
2378
+	/**
2379
+	 * display_admin_list_table_page_with_no_sidebar
2380
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2381
+	 *
2382
+	 * @access public
2383
+	 * @return void
2384
+	 */
2385
+	public function display_admin_list_table_page_with_no_sidebar()
2386
+	{
2387
+		$this->_display_admin_list_table_page();
2388
+	}
2389
+
2390
+
2391
+
2392
+	/**
2393
+	 * generates html wrapper for an admin_list_table page
2394
+	 *
2395
+	 * @access private
2396
+	 * @param boolean $sidebar whether to display with sidebar or not.
2397
+	 * @return void
2398
+	 */
2399
+	private function _display_admin_list_table_page($sidebar = false)
2400
+	{
2401
+		//setup search attributes
2402
+		$this->_set_search_attributes();
2403
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2404
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2405
+		$this->_template_args['table_url'] = defined('DOING_AJAX')
2406
+				? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2407
+				: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2408
+		$this->_template_args['list_table'] = $this->_list_table_object;
2409
+		$this->_template_args['current_route'] = $this->_req_action;
2410
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2411
+		$ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2412
+		if ( ! empty($ajax_sorting_callback)) {
2413
+			$sortable_list_table_form_fields = wp_nonce_field(
2414
+					$ajax_sorting_callback . '_nonce',
2415
+					$ajax_sorting_callback . '_nonce',
2416
+					false,
2417
+					false
2418
+			);
2419
+			//			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2420
+			//			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2421
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2422
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2423
+		} else {
2424
+			$sortable_list_table_form_fields = '';
2425
+		}
2426
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2427
+		$hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2428
+		$nonce_ref = $this->_req_action . '_nonce';
2429
+		$hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2430
+		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2431
+		//display message about search results?
2432
+		$this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2433
+				? '<p class="ee-search-results">' . sprintf(
2434
+						esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2435
+						trim($this->_req_data['s'], '%')
2436
+				) . '</p>'
2437
+				: '';
2438
+		// filter before_list_table template arg
2439
+		$this->_template_args['before_list_table'] = apply_filters(
2440
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2441
+			$this->_template_args['before_list_table'],
2442
+			$this->page_slug,
2443
+			$this->_req_data,
2444
+			$this->_req_action
2445
+		);
2446
+		// convert to array and filter again
2447
+		// arrays are easier to inject new items in a specific location,
2448
+		// but would not be backwards compatible, so we have to add a new filter
2449
+		$this->_template_args['before_list_table'] = implode(
2450
+			" \n",
2451
+			(array) apply_filters(
2452
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2453
+				(array) $this->_template_args['before_list_table'],
2454
+				$this->page_slug,
2455
+				$this->_req_data,
2456
+				$this->_req_action
2457
+			)
2458
+		);
2459
+		// filter after_list_table template arg
2460
+		$this->_template_args['after_list_table'] = apply_filters(
2461
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2462
+			$this->_template_args['after_list_table'],
2463
+			$this->page_slug,
2464
+			$this->_req_data,
2465
+			$this->_req_action
2466
+		);
2467
+		// convert to array and filter again
2468
+		// arrays are easier to inject new items in a specific location,
2469
+		// but would not be backwards compatible, so we have to add a new filter
2470
+		$this->_template_args['after_list_table'] = implode(
2471
+			" \n",
2472
+			(array) apply_filters(
2473
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2474
+				(array) $this->_template_args['after_list_table'],
2475
+				$this->page_slug,
2476
+				$this->_req_data,
2477
+				$this->_req_action
2478
+			)
2479
+		);
2480
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2481
+				$template_path,
2482
+				$this->_template_args,
2483
+				true
2484
+		);
2485
+		// the final template wrapper
2486
+		if ($sidebar) {
2487
+			$this->display_admin_page_with_sidebar();
2488
+		} else {
2489
+			$this->display_admin_page_with_no_sidebar();
2490
+		}
2491
+	}
2492
+
2493
+
2494
+
2495
+	/**
2496
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the html string for the legend.
2497
+	 * $items are expected in an array in the following format:
2498
+	 * $legend_items = array(
2499
+	 *        'item_id' => array(
2500
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2501
+	 *            'desc' => __('localized description of item');
2502
+	 *        )
2503
+	 * );
2504
+	 *
2505
+	 * @param  array $items see above for format of array
2506
+	 * @return string        html string of legend
2507
+	 */
2508
+	protected function _display_legend($items)
2509
+	{
2510
+		$this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2511
+		$legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2512
+		return EEH_Template::display_template($legend_template, $this->_template_args, true);
2513
+	}
2514
+
2515
+
2516
+	/**
2517
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2518
+	 * The returned json object is created from an array in the following format:
2519
+	 * array(
2520
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2521
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
2522
+	 *  'notices' => '', // - contains any EE_Error formatted notices
2523
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
2524
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any
2525
+	 *  specific template args that might be included in here)
2526
+	 * )
2527
+	 * The json object is populated by whatever is set in the $_template_args property.
2528
+	 *
2529
+	 * @param bool  $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed.
2530
+	 * @param array $notices_arguments  Use this to pass any additional args on to the _process_notices.
2531
+	 * @return void
2532
+	 */
2533
+	protected function _return_json($sticky_notices = false, $notices_arguments = array())
2534
+	{
2535
+		//make sure any EE_Error notices have been handled.
2536
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
2537
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
2538
+		unset($this->_template_args['data']);
2539
+		$json = array(
2540
+				'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2541
+				'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2542
+				'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2543
+				'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2544
+				'notices'   => EE_Error::get_notices(),
2545
+				'content'   => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '',
2546
+				'data'      => array_merge($data, array('template_args' => $this->_template_args)),
2547
+				'isEEajax'  => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2548
+		);
2549
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
2550
+		if (null === error_get_last() || ! headers_sent()) {
2551
+			header('Content-Type: application/json; charset=UTF-8');
2552
+		}
2553
+		echo wp_json_encode($json);
2554
+
2555
+		exit();
2556
+	}
2557
+
2558
+
2559
+
2560
+	/**
2561
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2562
+	 *
2563
+	 * @return void
2564
+	 * @throws EE_Error
2565
+	 */
2566
+	public function return_json()
2567
+	{
2568
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2569
+			$this->_return_json();
2570
+		} else {
2571
+			throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__));
2572
+		}
2573
+	}
2574
+
2575
+
2576
+
2577
+	/**
2578
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
2579
+	 *
2580
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
2581
+	 * @access   public
2582
+	 */
2583
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
2584
+	{
2585
+		$this->_hook_obj = $hook_obj;
2586
+	}
2587
+
2588
+
2589
+
2590
+	/**
2591
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
2592
+	 *
2593
+	 * @access public
2594
+	 * @param  boolean $about whether to use the special about page wrapper or default.
2595
+	 * @return void
2596
+	 */
2597
+	public function admin_page_wrapper($about = false)
2598
+	{
2599
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2600
+		$this->_nav_tabs = $this->_get_main_nav_tabs();
2601
+		$this->_template_args['nav_tabs'] = $this->_nav_tabs;
2602
+		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
2603
+		$this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2604
+				isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2605
+		$this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2606
+				isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2607
+		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2608
+		// load settings page wrapper template
2609
+		$template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2610
+		//about page?
2611
+		$template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2612
+		if (defined('DOING_AJAX')) {
2613
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2614
+			$this->_return_json();
2615
+		} else {
2616
+			EEH_Template::display_template($template_path, $this->_template_args);
2617
+		}
2618
+	}
2619
+
2620
+
2621
+
2622
+	/**
2623
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
2624
+	 *
2625
+	 * @return string html
2626
+	 */
2627
+	protected function _get_main_nav_tabs()
2628
+	{
2629
+		//let's generate the html using the EEH_Tabbed_Content helper.  We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array)
2630
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
2631
+	}
2632
+
2633
+
2634
+
2635
+	/**
2636
+	 *        sort nav tabs
2637
+	 *
2638
+	 * @access public
2639
+	 * @param $a
2640
+	 * @param $b
2641
+	 * @return int
2642
+	 */
2643
+	private function _sort_nav_tabs($a, $b)
2644
+	{
2645
+		if ($a['order'] == $b['order']) {
2646
+			return 0;
2647
+		}
2648
+		return ($a['order'] < $b['order']) ? -1 : 1;
2649
+	}
2650
+
2651
+
2652
+
2653
+	/**
2654
+	 *    generates HTML for the forms used on admin pages
2655
+	 *
2656
+	 * @access protected
2657
+	 * @param    array $input_vars - array of input field details
2658
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to use)
2659
+	 * @return string
2660
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
2661
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
2662
+	 */
2663
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
2664
+	{
2665
+		$content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars);
2666
+		return $content;
2667
+	}
2668
+
2669
+
2670
+
2671
+	/**
2672
+	 * generates the "Save" and "Save & Close" buttons for edit forms
2673
+	 *
2674
+	 * @access protected
2675
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save & Close" button.
2676
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close')
2677
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button).  We can also use this to just dump default actions by submitting some other value.
2678
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling).
2679
+	 */
2680
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2681
+	{
2682
+		//make sure $text and $actions are in an array
2683
+		$text = (array)$text;
2684
+		$actions = (array)$actions;
2685
+		$referrer_url = empty($referrer) ? '' : $referrer;
2686
+		$referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2687
+				: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2688
+		$button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2689
+		$default_names = array('save', 'save_and_close');
2690
+		//add in a hidden index for the current page (so save and close redirects properly)
2691
+		$this->_template_args['save_buttons'] = $referrer_url;
2692
+		foreach ($button_text as $key => $button) {
2693
+			$ref = $default_names[$key];
2694
+			$id = $this->_current_view . '_' . $ref;
2695
+			$name = ! empty($actions) ? $actions[$key] : $ref;
2696
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2697
+			if ( ! $both) {
2698
+				break;
2699
+			}
2700
+		}
2701
+	}
2702
+
2703
+
2704
+
2705
+	/**
2706
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
2707
+	 *
2708
+	 * @see   $this->_set_add_edit_form_tags() for details on params
2709
+	 * @since 4.6.0
2710
+	 * @param string $route
2711
+	 * @param array  $additional_hidden_fields
2712
+	 */
2713
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2714
+	{
2715
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
2716
+	}
2717
+
2718
+
2719
+
2720
+	/**
2721
+	 * set form open and close tags on add/edit pages.
2722
+	 *
2723
+	 * @access protected
2724
+	 * @param string $route                    the route you want the form to direct to
2725
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
2726
+	 * @return void
2727
+	 */
2728
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2729
+	{
2730
+		if (empty($route)) {
2731
+			$user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2732
+			$dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2733
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2734
+		}
2735
+		// open form
2736
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2737
+		// add nonce
2738
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2739
+		//		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2740
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2741
+		// add REQUIRED form action
2742
+		$hidden_fields = array(
2743
+				'action' => array('type' => 'hidden', 'value' => $route),
2744
+		);
2745
+		// merge arrays
2746
+		$hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields;
2747
+		// generate form fields
2748
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2749
+		// add fields to form
2750
+		foreach ((array)$form_fields as $field_name => $form_field) {
2751
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2752
+		}
2753
+		// close form
2754
+		$this->_template_args['after_admin_page_content'] = '</form>';
2755
+	}
2756
+
2757
+
2758
+
2759
+	/**
2760
+	 * Public Wrapper for _redirect_after_action() method since its
2761
+	 * discovered it would be useful for external code to have access.
2762
+	 *
2763
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
2764
+	 * @since 4.5.0
2765
+	 */
2766
+	public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2767
+	{
2768
+		$this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
2769
+	}
2770
+
2771
+
2772
+
2773
+	/**
2774
+	 *    _redirect_after_action
2775
+	 *
2776
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
2777
+	 * @param string $what               - what the action was performed on
2778
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
2779
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin action is completed
2780
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show.
2781
+	 * @access protected
2782
+	 * @return void
2783
+	 */
2784
+	protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2785
+	{
2786
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2787
+		//class name for actions/filters.
2788
+		$classname = get_class($this);
2789
+		//set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url
2790
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
2791
+		$notices = EE_Error::get_notices(false);
2792
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
2793
+		if ( ! $override_overwrite || ! empty($notices['errors'])) {
2794
+			EE_Error::overwrite_success();
2795
+		}
2796
+		if ( ! empty($what) && ! empty($action_desc)) {
2797
+			// how many records affected ? more than one record ? or just one ?
2798
+			if ($success > 1 && empty($notices['errors'])) {
2799
+				// set plural msg
2800
+				EE_Error::add_success(
2801
+						sprintf(
2802
+								__('The "%s" have been successfully %s.', 'event_espresso'),
2803
+								$what,
2804
+								$action_desc
2805
+						),
2806
+						__FILE__, __FUNCTION__, __LINE__
2807
+				);
2808
+			} else if ($success == 1 && empty($notices['errors'])) {
2809
+				// set singular msg
2810
+				EE_Error::add_success(
2811
+						sprintf(
2812
+								__('The "%s" has been successfully %s.', 'event_espresso'),
2813
+								$what,
2814
+								$action_desc
2815
+						),
2816
+						__FILE__, __FUNCTION__, __LINE__
2817
+				);
2818
+			}
2819
+		}
2820
+		// check that $query_args isn't something crazy
2821
+		if ( ! is_array($query_args)) {
2822
+			$query_args = array();
2823
+		}
2824
+		/**
2825
+		 * Allow injecting actions before the query_args are modified for possible different
2826
+		 * redirections on save and close actions
2827
+		 *
2828
+		 * @since 4.2.0
2829
+		 * @param array $query_args       The original query_args array coming into the
2830
+		 *                                method.
2831
+		 */
2832
+		do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2833
+		//calculate where we're going (if we have a "save and close" button pushed)
2834
+		if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2835
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
2836
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
2837
+			// regenerate query args array from referrer URL
2838
+			parse_str($parsed_url['query'], $query_args);
2839
+			// correct page and action will be in the query args now
2840
+			$redirect_url = admin_url('admin.php');
2841
+		}
2842
+		//merge any default query_args set in _default_route_query_args property
2843
+		if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
2844
+			$args_to_merge = array();
2845
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
2846
+				//is there a wp_referer array in our _default_route_query_args property?
2847
+				if ($query_param == 'wp_referer') {
2848
+					$query_value = (array)$query_value;
2849
+					foreach ($query_value as $reference => $value) {
2850
+						if (strpos($reference, 'nonce') !== false) {
2851
+							continue;
2852
+						}
2853
+						//finally we will override any arguments in the referer with
2854
+						//what might be set on the _default_route_query_args array.
2855
+						if (isset($this->_default_route_query_args[$reference])) {
2856
+							$args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
2857
+						} else {
2858
+							$args_to_merge[$reference] = urlencode($value);
2859
+						}
2860
+					}
2861
+					continue;
2862
+				}
2863
+				$args_to_merge[$query_param] = $query_value;
2864
+			}
2865
+			//now let's merge these arguments but override with what was specifically sent in to the
2866
+			//redirect.
2867
+			$query_args = array_merge($args_to_merge, $query_args);
2868
+		}
2869
+		$this->_process_notices($query_args);
2870
+		// generate redirect url
2871
+		// if redirecting to anything other than the main page, add a nonce
2872
+		if (isset($query_args['action'])) {
2873
+			// manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2874
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2875
+		}
2876
+		//we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
2877
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2878
+		$redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2879
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2880
+		if (defined('DOING_AJAX')) {
2881
+			$default_data = array(
2882
+					'close'        => true,
2883
+					'redirect_url' => $redirect_url,
2884
+					'where'        => 'main',
2885
+					'what'         => 'append',
2886
+			);
2887
+			$this->_template_args['success'] = $success;
2888
+			$this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data;
2889
+			$this->_return_json();
2890
+		}
2891
+		wp_safe_redirect($redirect_url);
2892
+		exit();
2893
+	}
2894
+
2895
+
2896
+
2897
+	/**
2898
+	 * process any notices before redirecting (or returning ajax request)
2899
+	 * This method sets the $this->_template_args['notices'] attribute;
2900
+	 *
2901
+	 * @param  array $query_args        any query args that need to be used for notice transient ('action')
2902
+	 * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet.
2903
+	 * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice.
2904
+	 * @return void
2905
+	 */
2906
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
2907
+	{
2908
+		//first let's set individual error properties if doing_ajax and the properties aren't already set.
2909
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2910
+			$notices = EE_Error::get_notices(false);
2911
+			if (empty($this->_template_args['success'])) {
2912
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
2913
+			}
2914
+			if (empty($this->_template_args['errors'])) {
2915
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
2916
+			}
2917
+			if (empty($this->_template_args['attention'])) {
2918
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
2919
+			}
2920
+		}
2921
+		$this->_template_args['notices'] = EE_Error::get_notices();
2922
+		//IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
2923
+		if ( ! defined('DOING_AJAX') || $sticky_notices) {
2924
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
2925
+			$this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
2926
+		}
2927
+	}
2928
+
2929
+
2930
+
2931
+	/**
2932
+	 * get_action_link_or_button
2933
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
2934
+	 *
2935
+	 * @param string $action        use this to indicate which action the url is generated with.
2936
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key) property.
2937
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
2938
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
2939
+	 * @param string $base_url      If this is not provided
2940
+	 *                              the _admin_base_url will be used as the default for the button base_url.
2941
+	 *                              Otherwise this value will be used.
2942
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
2943
+	 * @return string
2944
+	 * @throws \EE_Error
2945
+	 */
2946
+	public function get_action_link_or_button(
2947
+			$action,
2948
+			$type = 'add',
2949
+			$extra_request = array(),
2950
+			$class = 'button-primary',
2951
+			$base_url = '',
2952
+			$exclude_nonce = false
2953
+	) {
2954
+		//first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
2955
+		if (empty($base_url) && ! isset($this->_page_routes[$action])) {
2956
+			throw new EE_Error(
2957
+					sprintf(
2958
+							__(
2959
+									'There is no page route for given action for the button.  This action was given: %s',
2960
+									'event_espresso'
2961
+							),
2962
+							$action
2963
+					)
2964
+			);
2965
+		}
2966
+		if ( ! isset($this->_labels['buttons'][$type])) {
2967
+			throw new EE_Error(
2968
+					sprintf(
2969
+							__(
2970
+									'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
2971
+									'event_espresso'
2972
+							),
2973
+							$type
2974
+					)
2975
+			);
2976
+		}
2977
+		//finally check user access for this button.
2978
+		$has_access = $this->check_user_access($action, true);
2979
+		if ( ! $has_access) {
2980
+			return '';
2981
+		}
2982
+		$_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
2983
+		$query_args = array(
2984
+				'action' => $action,
2985
+		);
2986
+		//merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
2987
+		if ( ! empty($extra_request)) {
2988
+			$query_args = array_merge($extra_request, $query_args);
2989
+		}
2990
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
2991
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
2992
+	}
2993
+
2994
+
2995
+
2996
+	/**
2997
+	 * _per_page_screen_option
2998
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
2999
+	 *
3000
+	 * @return void
3001
+	 */
3002
+	protected function _per_page_screen_option()
3003
+	{
3004
+		$option = 'per_page';
3005
+		$args = array(
3006
+				'label'   => $this->_admin_page_title,
3007
+				'default' => 10,
3008
+				'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3009
+		);
3010
+		//ONLY add the screen option if the user has access to it.
3011
+		if ($this->check_user_access($this->_current_view, true)) {
3012
+			add_screen_option($option, $args);
3013
+		}
3014
+	}
3015
+
3016
+
3017
+
3018
+	/**
3019
+	 * set_per_page_screen_option
3020
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3021
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu.
3022
+	 *
3023
+	 * @access private
3024
+	 * @return void
3025
+	 */
3026
+	private function _set_per_page_screen_options()
3027
+	{
3028
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3029
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3030
+			if ( ! $user = wp_get_current_user()) {
3031
+				return;
3032
+			}
3033
+			$option = $_POST['wp_screen_options']['option'];
3034
+			$value = $_POST['wp_screen_options']['value'];
3035
+			if ($option != sanitize_key($option)) {
3036
+				return;
3037
+			}
3038
+			$map_option = $option;
3039
+			$option = str_replace('-', '_', $option);
3040
+			switch ($map_option) {
3041
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3042
+					$value = (int)$value;
3043
+					if ($value < 1 || $value > 999) {
3044
+						return;
3045
+					}
3046
+					break;
3047
+				default:
3048
+					$value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value);
3049
+					if (false === $value) {
3050
+						return;
3051
+					}
3052
+					break;
3053
+			}
3054
+			update_user_meta($user->ID, $option, $value);
3055
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3056
+			exit;
3057
+		}
3058
+	}
3059
+
3060
+
3061
+
3062
+	/**
3063
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3064
+	 *
3065
+	 * @param array $data array that will be assigned to template args.
3066
+	 */
3067
+	public function set_template_args($data)
3068
+	{
3069
+		$this->_template_args = array_merge($this->_template_args, (array)$data);
3070
+	}
3071
+
3072
+
3073
+
3074
+	/**
3075
+	 * This makes available the WP transient system for temporarily moving data between routes
3076
+	 *
3077
+	 * @access protected
3078
+	 * @param string $route             the route that should receive the transient
3079
+	 * @param array  $data              the data that gets sent
3080
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a normal route transient.
3081
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used when we are adding a transient before page_routes have been defined.
3082
+	 * @return void
3083
+	 */
3084
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3085
+	{
3086
+		$user_id = get_current_user_id();
3087
+		if ( ! $skip_route_verify) {
3088
+			$this->_verify_route($route);
3089
+		}
3090
+		//now let's set the string for what kind of transient we're setting
3091
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3092
+		$data = $notices ? array('notices' => $data) : $data;
3093
+		//is there already a transient for this route?  If there is then let's ADD to that transient
3094
+		$existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3095
+		if ($existing) {
3096
+			$data = array_merge((array)$data, (array)$existing);
3097
+		}
3098
+		if (is_multisite() && is_network_admin()) {
3099
+			set_site_transient($transient, $data, 8);
3100
+		} else {
3101
+			set_transient($transient, $data, 8);
3102
+		}
3103
+	}
3104
+
3105
+
3106
+
3107
+	/**
3108
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3109
+	 *
3110
+	 * @param bool $notices true we get notices transient. False we just return normal route transient
3111
+	 * @return mixed data
3112
+	 */
3113
+	protected function _get_transient($notices = false, $route = false)
3114
+	{
3115
+		$user_id = get_current_user_id();
3116
+		$route = ! $route ? $this->_req_action : $route;
3117
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3118
+		$data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3119
+		//delete transient after retrieval (just in case it hasn't expired);
3120
+		if (is_multisite() && is_network_admin()) {
3121
+			delete_site_transient($transient);
3122
+		} else {
3123
+			delete_transient($transient);
3124
+		}
3125
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3126
+	}
3127
+
3128
+
3129
+
3130
+	/**
3131
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but would not be called later.
3132
+	 * This will be assigned to run on a specific EE Admin page. (place the method in the default route callback on the EE_Admin page you want it run.)
3133
+	 *
3134
+	 * @return void
3135
+	 */
3136
+	protected function _transient_garbage_collection()
3137
+	{
3138
+		global $wpdb;
3139
+		//retrieve all existing transients
3140
+		$query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3141
+		if ($results = $wpdb->get_results($query)) {
3142
+			foreach ($results as $result) {
3143
+				$transient = str_replace('_transient_', '', $result->option_name);
3144
+				get_transient($transient);
3145
+				if (is_multisite() && is_network_admin()) {
3146
+					get_site_transient($transient);
3147
+				}
3148
+			}
3149
+		}
3150
+	}
3151
+
3152
+
3153
+
3154
+	/**
3155
+	 * get_view
3156
+	 *
3157
+	 * @access public
3158
+	 * @return string content of _view property
3159
+	 */
3160
+	public function get_view()
3161
+	{
3162
+		return $this->_view;
3163
+	}
3164
+
3165
+
3166
+
3167
+	/**
3168
+	 * getter for the protected $_views property
3169
+	 *
3170
+	 * @return array
3171
+	 */
3172
+	public function get_views()
3173
+	{
3174
+		return $this->_views;
3175
+	}
3176
+
3177
+
3178
+
3179
+	/**
3180
+	 * get_current_page
3181
+	 *
3182
+	 * @access public
3183
+	 * @return string _current_page property value
3184
+	 */
3185
+	public function get_current_page()
3186
+	{
3187
+		return $this->_current_page;
3188
+	}
3189
+
3190
+
3191
+
3192
+	/**
3193
+	 * get_current_view
3194
+	 *
3195
+	 * @access public
3196
+	 * @return string _current_view property value
3197
+	 */
3198
+	public function get_current_view()
3199
+	{
3200
+		return $this->_current_view;
3201
+	}
3202
+
3203
+
3204
+
3205
+	/**
3206
+	 * get_current_screen
3207
+	 *
3208
+	 * @access public
3209
+	 * @return object The current WP_Screen object
3210
+	 */
3211
+	public function get_current_screen()
3212
+	{
3213
+		return $this->_current_screen;
3214
+	}
3215
+
3216
+
3217
+
3218
+	/**
3219
+	 * get_current_page_view_url
3220
+	 *
3221
+	 * @access public
3222
+	 * @return string This returns the url for the current_page_view.
3223
+	 */
3224
+	public function get_current_page_view_url()
3225
+	{
3226
+		return $this->_current_page_view_url;
3227
+	}
3228
+
3229
+
3230
+
3231
+	/**
3232
+	 * just returns the _req_data property
3233
+	 *
3234
+	 * @return array
3235
+	 */
3236
+	public function get_request_data()
3237
+	{
3238
+		return $this->_req_data;
3239
+	}
3240
+
3241
+
3242
+
3243
+	/**
3244
+	 * returns the _req_data protected property
3245
+	 *
3246
+	 * @return string
3247
+	 */
3248
+	public function get_req_action()
3249
+	{
3250
+		return $this->_req_action;
3251
+	}
3252
+
3253
+
3254
+
3255
+	/**
3256
+	 * @return bool  value of $_is_caf property
3257
+	 */
3258
+	public function is_caf()
3259
+	{
3260
+		return $this->_is_caf;
3261
+	}
3262
+
3263
+
3264
+
3265
+	/**
3266
+	 * @return mixed
3267
+	 */
3268
+	public function default_espresso_metaboxes()
3269
+	{
3270
+		return $this->_default_espresso_metaboxes;
3271
+	}
3272
+
3273
+
3274
+
3275
+	/**
3276
+	 * @return mixed
3277
+	 */
3278
+	public function admin_base_url()
3279
+	{
3280
+		return $this->_admin_base_url;
3281
+	}
3282
+
3283
+
3284
+
3285
+	/**
3286
+	 * @return mixed
3287
+	 */
3288
+	public function wp_page_slug()
3289
+	{
3290
+		return $this->_wp_page_slug;
3291
+	}
3292
+
3293
+
3294
+
3295
+	/**
3296
+	 * updates  espresso configuration settings
3297
+	 *
3298
+	 * @access    protected
3299
+	 * @param string                   $tab
3300
+	 * @param EE_Config_Base|EE_Config $config
3301
+	 * @param string                   $file file where error occurred
3302
+	 * @param string                   $func function  where error occurred
3303
+	 * @param string                   $line line no where error occurred
3304
+	 * @return boolean
3305
+	 */
3306
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3307
+	{
3308
+		//remove any options that are NOT going to be saved with the config settings.
3309
+		if (isset($config->core->ee_ueip_optin)) {
3310
+			$config->core->ee_ueip_has_notified = true;
3311
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3312
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3313
+			update_option('ee_ueip_has_notified', true);
3314
+		}
3315
+		// and save it (note we're also doing the network save here)
3316
+		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3317
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3318
+		if ($config_saved && $net_saved) {
3319
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3320
+			return true;
3321
+		} else {
3322
+			EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3323
+			return false;
3324
+		}
3325
+	}
3326
+
3327
+
3328
+
3329
+	/**
3330
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3331
+	 *
3332
+	 * @return array
3333
+	 */
3334
+	public function get_yes_no_values()
3335
+	{
3336
+		return $this->_yes_no_values;
3337
+	}
3338
+
3339
+
3340
+
3341
+	protected function _get_dir()
3342
+	{
3343
+		$reflector = new ReflectionClass(get_class($this));
3344
+		return dirname($reflector->getFileName());
3345
+	}
3346
+
3347
+
3348
+
3349
+	/**
3350
+	 * A helper for getting a "next link".
3351
+	 *
3352
+	 * @param string $url   The url to link to
3353
+	 * @param string $class The class to use.
3354
+	 * @return string
3355
+	 */
3356
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3357
+	{
3358
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3359
+	}
3360
+
3361
+
3362
+
3363
+	/**
3364
+	 * A helper for getting a "previous link".
3365
+	 *
3366
+	 * @param string $url   The url to link to
3367
+	 * @param string $class The class to use.
3368
+	 * @return string
3369
+	 */
3370
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3371
+	{
3372
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3373
+	}
3374
+
3375
+
3376
+
3377
+
3378
+
3379
+
3380
+
3381
+	//below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3382
+	/**
3383
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the _req_data
3384
+	 * array.
3385
+	 *
3386
+	 * @return bool success/fail
3387
+	 */
3388
+	protected function _process_resend_registration()
3389
+	{
3390
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3391
+		do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data);
3392
+		return $this->_template_args['success'];
3393
+	}
3394
+
3395
+
3396
+
3397
+	/**
3398
+	 * This automatically processes any payment message notifications when manual payment has been applied.
3399
+	 *
3400
+	 * @access protected
3401
+	 * @param \EE_Payment $payment
3402
+	 * @return bool success/fail
3403
+	 */
3404
+	protected function _process_payment_notification(EE_Payment $payment)
3405
+	{
3406
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3407
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3408
+		$this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment);
3409
+		return $this->_template_args['success'];
3410
+	}
3411 3411
 
3412 3412
 
3413 3413
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Money.helper.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  *
21 21
  * ------------------------------------------------------------------------
22 22
  */
23
-class EEH_Money extends EEH_Base  {
23
+class EEH_Money extends EEH_Base {
24 24
 
25 25
 
26 26
     /**
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
      * @return float
62 62
      * @throws EE_Error
63 63
      */
64
-	public static function convert_to_float_from_localized_money($money_value ) {
64
+	public static function convert_to_float_from_localized_money($money_value) {
65 65
 		//float it! and round to three decimal places
66
-        return round ( (float) EEH_Money::strip_localized_money_formatting($money_value), 3 );
66
+        return round((float) EEH_Money::strip_localized_money_formatting($money_value), 3);
67 67
 	}
68 68
 
69 69
 
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 	 * @throws EE_Error
83 83
 	 */
84 84
 
85
-	public static function compare_floats( $float1, $float2, $operator='=' ) {
85
+	public static function compare_floats($float1, $float2, $operator = '=') {
86 86
 		// Check numbers to 5 digits of precision
87 87
 		$epsilon = 0.00001;
88 88
 
89
-		$float1 = (float)$float1;
90
-		$float2 = (float)$float2;
89
+		$float1 = (float) $float1;
90
+		$float2 = (float) $float2;
91 91
 
92 92
 		switch ($operator) {
93 93
 			// equal
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 				}
144 144
 				break;
145 145
 			default:
146
-				throw new EE_Error(__( "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()", 'event_espresso' ) );
146
+				throw new EE_Error(__("Unknown operator '".$operator."' in EEH_Money::compare_floats()", 'event_espresso'));
147 147
 		}
148 148
 
149 149
 		return false;
@@ -159,14 +159,14 @@  discard block
 block discarded – undo
159 159
      * @return string
160 160
      * @throws EE_Error
161 161
      */
162
-	public static function get_format_for_jqplot( $CNT_ISO = '') {
162
+	public static function get_format_for_jqplot($CNT_ISO = '') {
163 163
 		//default format
164 164
 		$format = 'f';
165 165
 		$currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO);
166 166
         //first get the decimal place and number of places
167
-		$format = "%'." . $currency_config->dec_plc . $format;
167
+		$format = "%'.".$currency_config->dec_plc.$format;
168 168
 		//currency symbol on right side.
169
-		$format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
169
+		$format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign;
170 170
 		return $format;
171 171
 	}
172 172
 
@@ -182,20 +182,20 @@  discard block
 block discarded – undo
182 182
      * @return string
183 183
      * @throws EE_Error
184 184
      */
185
-	public static function get_format_for_google_charts( $CNT_ISO = '' ) {
185
+	public static function get_format_for_google_charts($CNT_ISO = '') {
186 186
 		$currency_config = EEH_Money::get_currency_config($CNT_ISO);
187
-		$decimal_places_placeholder = str_pad( '', $currency_config->dec_plc, '0' );
187
+		$decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0');
188 188
 		//first get the decimal place and number of places
189
-		$format = '#,##0.' . $decimal_places_placeholder;
189
+		$format = '#,##0.'.$decimal_places_placeholder;
190 190
 
191 191
 		//currency symbol on right side.
192
-		$format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
192
+		$format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign;
193 193
 		$formatterObject = array(
194 194
 			'decimalSymbol' => $currency_config->dec_mrk,
195 195
 			'groupingSymbol' => $currency_config->thsnds,
196 196
 			'fractionDigits' => $currency_config->dec_plc,
197 197
 		);
198
-		if ( $currency_config->sign_b4 ) {
198
+		if ($currency_config->sign_b4) {
199 199
 			$formatterObject['prefix'] = $currency_config->sign;
200 200
 		} else {
201 201
 			$formatterObject['suffix'] = $currency_config->sign;
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
             ? new EE_Currency_Config($CNT_ISO)
221 221
             : null;
222 222
         //default currency settings for site if not set
223
-        if (! $currency_config instanceof EE_Currency_Config) {
223
+        if ( ! $currency_config instanceof EE_Currency_Config) {
224 224
             $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
225 225
                 ? EE_Registry::instance()->CFG->currency
226 226
                 : new EE_Currency_Config();
Please login to merge, or discard this patch.
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -8,71 +8,71 @@  discard block
 block discarded – undo
8 8
  */
9 9
 if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
10 10
  /**
11
- *
12
- * Money helper class.
13
- * This class has helper methods that help with money related conversions and calculations.
14
- *
15
- * @since %VER%
16
- *
17
- * @package		Event Espresso
18
- * @subpackage	helpers
19
- * @author		Darren Ethier
20
- *
21
- * ------------------------------------------------------------------------
22
- */
11
+  *
12
+  * Money helper class.
13
+  * This class has helper methods that help with money related conversions and calculations.
14
+  *
15
+  * @since %VER%
16
+  *
17
+  * @package		Event Espresso
18
+  * @subpackage	helpers
19
+  * @author		Darren Ethier
20
+  *
21
+  * ------------------------------------------------------------------------
22
+  */
23 23
 class EEH_Money extends EEH_Base  {
24 24
 
25 25
 
26
-    /**
27
-     * This removes all localized money formatting from the incoming value
28
-     *
29
-     * Note: uses this site's currency settings for deciding what is considered a
30
-     * "thousands separator" (usually the character "," )
31
-     * and what is a "decimal mark" (usually the character ".")
32
-     *
33
-     * @param int|float|string $money_value
34
-     * @param string           $CNT_ISO
35
-     * @return float
36
-     * @throws EE_Error
37
-     */
26
+	/**
27
+	 * This removes all localized money formatting from the incoming value
28
+	 *
29
+	 * Note: uses this site's currency settings for deciding what is considered a
30
+	 * "thousands separator" (usually the character "," )
31
+	 * and what is a "decimal mark" (usually the character ".")
32
+	 *
33
+	 * @param int|float|string $money_value
34
+	 * @param string           $CNT_ISO
35
+	 * @return float
36
+	 * @throws EE_Error
37
+	 */
38 38
 	public static function strip_localized_money_formatting($money_value, $CNT_ISO = '') {
39
-        $currency_config = EEH_Money::get_currency_config($CNT_ISO);
40
-        $money_value = str_replace(
41
-		    array(
42
-                $currency_config->thsnds,
43
-                $currency_config->dec_mrk,
44
-            ),
45
-            array(
46
-                '', // remove thousands separator
47
-                '.', // convert decimal mark to what PHP expects
48
-            ),
49
-            $money_value
50
-        );
51
-        $money_value = filter_var(
52
-            $money_value,
53
-            FILTER_SANITIZE_NUMBER_FLOAT,
54
-            FILTER_FLAG_ALLOW_FRACTION
55
-        );
56
-        return $money_value;
57
-    }
58
-
59
-
60
-
61
-    /**
62
-     * This converts an incoming localized money value into a standard float item (to three decimal places)
63
-     *
64
-     * Only use this if you know the $money_value follows your currency configuration's
65
-     * settings. Note: this uses this site's currency settings for deciding what is considered a
66
-     * "thousands separator" (usually the character "," )
67
-     * and what is a "decimal mark" (usually the character ".")
68
-     *
69
-     * @param int|string $money_value
70
-     * @return float
71
-     * @throws EE_Error
72
-     */
39
+		$currency_config = EEH_Money::get_currency_config($CNT_ISO);
40
+		$money_value = str_replace(
41
+			array(
42
+				$currency_config->thsnds,
43
+				$currency_config->dec_mrk,
44
+			),
45
+			array(
46
+				'', // remove thousands separator
47
+				'.', // convert decimal mark to what PHP expects
48
+			),
49
+			$money_value
50
+		);
51
+		$money_value = filter_var(
52
+			$money_value,
53
+			FILTER_SANITIZE_NUMBER_FLOAT,
54
+			FILTER_FLAG_ALLOW_FRACTION
55
+		);
56
+		return $money_value;
57
+	}
58
+
59
+
60
+
61
+	/**
62
+	 * This converts an incoming localized money value into a standard float item (to three decimal places)
63
+	 *
64
+	 * Only use this if you know the $money_value follows your currency configuration's
65
+	 * settings. Note: this uses this site's currency settings for deciding what is considered a
66
+	 * "thousands separator" (usually the character "," )
67
+	 * and what is a "decimal mark" (usually the character ".")
68
+	 *
69
+	 * @param int|string $money_value
70
+	 * @return float
71
+	 * @throws EE_Error
72
+	 */
73 73
 	public static function convert_to_float_from_localized_money($money_value ) {
74 74
 		//float it! and round to three decimal places
75
-        return round ( (float) EEH_Money::strip_localized_money_formatting($money_value), 3 );
75
+		return round ( (float) EEH_Money::strip_localized_money_formatting($money_value), 3 );
76 76
 	}
77 77
 
78 78
 
@@ -160,19 +160,19 @@  discard block
 block discarded – undo
160 160
 
161 161
 
162 162
 
163
-    /**
164
-     * This returns a localized format string suitable for jQplot.
165
-     *
166
-     * @param string $CNT_ISO  If this is provided, then will attempt to get the currency settings for the country.
167
-     *                         Otherwise will use currency settings for current active country on site.
168
-     * @return string
169
-     * @throws EE_Error
170
-     */
163
+	/**
164
+	 * This returns a localized format string suitable for jQplot.
165
+	 *
166
+	 * @param string $CNT_ISO  If this is provided, then will attempt to get the currency settings for the country.
167
+	 *                         Otherwise will use currency settings for current active country on site.
168
+	 * @return string
169
+	 * @throws EE_Error
170
+	 */
171 171
 	public static function get_format_for_jqplot( $CNT_ISO = '') {
172 172
 		//default format
173 173
 		$format = 'f';
174 174
 		$currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO);
175
-        //first get the decimal place and number of places
175
+		//first get the decimal place and number of places
176 176
 		$format = "%'." . $currency_config->dec_plc . $format;
177 177
 		//currency symbol on right side.
178 178
 		$format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
@@ -181,16 +181,16 @@  discard block
 block discarded – undo
181 181
 
182 182
 
183 183
 
184
-    /**
185
-     * This returns a localized format string suitable for usage with the Google Charts API format param.
186
-     *
187
-     * @param string $CNT_ISO  If this is provided, then will attempt to get the currency settings for the country.
188
-     *                         Otherwise will use currency settings for current active country on site.
189
-     *                         Note: GoogleCharts uses ICU pattern set
190
-     *                         (@see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details)
191
-     * @return string
192
-     * @throws EE_Error
193
-     */
184
+	/**
185
+	 * This returns a localized format string suitable for usage with the Google Charts API format param.
186
+	 *
187
+	 * @param string $CNT_ISO  If this is provided, then will attempt to get the currency settings for the country.
188
+	 *                         Otherwise will use currency settings for current active country on site.
189
+	 *                         Note: GoogleCharts uses ICU pattern set
190
+	 *                         (@see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details)
191
+	 * @return string
192
+	 * @throws EE_Error
193
+	 */
194 194
 	public static function get_format_for_google_charts( $CNT_ISO = '' ) {
195 195
 		$currency_config = EEH_Money::get_currency_config($CNT_ISO);
196 196
 		$decimal_places_placeholder = str_pad( '', $currency_config->dec_plc, '0' );
@@ -217,24 +217,24 @@  discard block
 block discarded – undo
217 217
 
218 218
 
219 219
 
220
-    /**
221
-     * @param string $CNT_ISO
222
-     * @return EE_Currency_Config|null
223
-     * @throws EE_Error
224
-     */
225
-    public static function get_currency_config($CNT_ISO = '')
226
-    {
227
-        //if CNT_ISO passed lets try to get currency settings for it.
228
-        $currency_config = $CNT_ISO !== ''
229
-            ? new EE_Currency_Config($CNT_ISO)
230
-            : null;
231
-        //default currency settings for site if not set
232
-        if (! $currency_config instanceof EE_Currency_Config) {
233
-            $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
234
-                ? EE_Registry::instance()->CFG->currency
235
-                : new EE_Currency_Config();
236
-        }
237
-        return $currency_config;
238
-    }
220
+	/**
221
+	 * @param string $CNT_ISO
222
+	 * @return EE_Currency_Config|null
223
+	 * @throws EE_Error
224
+	 */
225
+	public static function get_currency_config($CNT_ISO = '')
226
+	{
227
+		//if CNT_ISO passed lets try to get currency settings for it.
228
+		$currency_config = $CNT_ISO !== ''
229
+			? new EE_Currency_Config($CNT_ISO)
230
+			: null;
231
+		//default currency settings for site if not set
232
+		if (! $currency_config instanceof EE_Currency_Config) {
233
+			$currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
234
+				? EE_Registry::instance()->CFG->currency
235
+				: new EE_Currency_Config();
236
+		}
237
+		return $currency_config;
238
+	}
239 239
 
240 240
 } //end class EEH_Money
Please login to merge, or discard this patch.
admin_pages/maintenance/Maintenance_Admin_Page.core.php 2 patches
Indentation   +616 added lines, -616 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -28,636 +28,636 @@  discard block
 block discarded – undo
28 28
 {
29 29
 
30 30
 
31
-    public function __construct($routing = true)
32
-    {
33
-        parent::__construct($routing);
34
-    }
35
-
36
-
37
-
38
-    protected function _init_page_props()
39
-    {
40
-        $this->page_slug = EE_MAINTENANCE_PG_SLUG;
41
-        $this->page_label = EE_MAINTENANCE_LABEL;
42
-        $this->_admin_base_url = EE_MAINTENANCE_ADMIN_URL;
43
-        $this->_admin_base_path = EE_MAINTENANCE_ADMIN;
44
-    }
45
-
46
-
47
-
48
-    protected function _ajax_hooks()
49
-    {
50
-        add_action('wp_ajax_migration_step', array($this, 'migration_step'));
51
-        add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran'));
52
-    }
53
-
54
-
55
-
56
-    protected function _define_page_props()
57
-    {
58
-        $this->_admin_page_title = EE_MAINTENANCE_LABEL;
59
-        $this->_labels = array(
60
-            'buttons' => array(
61
-                'reset_reservations' => esc_html__('Reset Ticket and Datetime Reserved Counts', 'event_espresso'),
62
-                'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'),
63
-            ),
64
-        );
65
-    }
66
-
67
-
68
-
69
-    protected function _set_page_routes()
70
-    {
71
-        $this->_page_routes = array(
72
-            'default'                             => array(
73
-                'func'       => '_maintenance',
74
-                'capability' => 'manage_options',
75
-            ),
76
-            'change_maintenance_level'            => array(
77
-                'func'       => '_change_maintenance_level',
78
-                'capability' => 'manage_options',
79
-                'noheader'   => true,
80
-            ),
81
-            'system_status'                       => array(
82
-                'func'       => '_system_status',
83
-                'capability' => 'manage_options',
84
-            ),
85
-            'download_system_status' => array(
86
-                'func'       => '_download_system_status',
87
-                'capability' => 'manage_options',
88
-                'noheader'   => true,
89
-            ),
90
-            'send_migration_crash_report'         => array(
91
-                'func'       => '_send_migration_crash_report',
92
-                'capability' => 'manage_options',
93
-                'noheader'   => true,
94
-            ),
95
-            'confirm_migration_crash_report_sent' => array(
96
-                'func'       => '_confirm_migration_crash_report_sent',
97
-                'capability' => 'manage_options',
98
-            ),
99
-            'data_reset'                          => array(
100
-                'func'       => '_data_reset_and_delete',
101
-                'capability' => 'manage_options',
102
-            ),
103
-            'reset_db'                            => array(
104
-                'func'       => '_reset_db',
105
-                'capability' => 'manage_options',
106
-                'noheader'   => true,
107
-                'args'       => array('nuke_old_ee4_data' => true),
108
-            ),
109
-            'start_with_fresh_ee4_db'             => array(
110
-                'func'       => '_reset_db',
111
-                'capability' => 'manage_options',
112
-                'noheader'   => true,
113
-                'args'       => array('nuke_old_ee4_data' => false),
114
-            ),
115
-            'delete_db'                           => array(
116
-                'func'       => '_delete_db',
117
-                'capability' => 'manage_options',
118
-                'noheader'   => true,
119
-            ),
120
-            'rerun_migration_from_ee3'            => array(
121
-                'func'       => '_rerun_migration_from_ee3',
122
-                'capability' => 'manage_options',
123
-                'noheader'   => true,
124
-            ),
125
-            'reset_reservations'                  => array(
126
-                'func'       => '_reset_reservations',
127
-                'capability' => 'manage_options',
128
-                'noheader'   => true,
129
-            ),
130
-            'reset_capabilities'                  => array(
131
-                'func'       => '_reset_capabilities',
132
-                'capability' => 'manage_options',
133
-                'noheader'   => true,
134
-            ),
135
-            'reattempt_migration'                 => array(
136
-                'func'       => '_reattempt_migration',
137
-                'capability' => 'manage_options',
138
-                'noheader'   => true,
139
-            ),
140
-        );
141
-    }
142
-
143
-
144
-
145
-    protected function _set_page_config()
146
-    {
147
-        $this->_page_config = array(
148
-            'default'       => array(
149
-                'nav'           => array(
150
-                    'label' => esc_html__('Maintenance', 'event_espresso'),
151
-                    'order' => 10,
152
-                ),
153
-                'require_nonce' => false,
154
-            ),
155
-            'data_reset'    => array(
156
-                'nav'           => array(
157
-                    'label' => esc_html__('Reset/Delete Data', 'event_espresso'),
158
-                    'order' => 20,
159
-                ),
160
-                'require_nonce' => false,
161
-            ),
162
-            'system_status' => array(
163
-                'nav'           => array(
164
-                    'label' => esc_html__("System Information", "event_espresso"),
165
-                    'order' => 30,
166
-                ),
167
-                'require_nonce' => false,
168
-            ),
169
-        );
170
-    }
171
-
172
-
173
-
174
-    /**
175
-     * default maintenance page. If we're in maintenance mode level 2, then we need to show
176
-     * the migration scripts and all that UI.
177
-     */
178
-    public function _maintenance()
179
-    {
180
-        //it all depends if we're in maintenance model level 1 (frontend-only) or
181
-        //level 2 (everything except maintenance page)
182
-        try {
183
-            //get the current maintenance level and check if
184
-            //we are removed
185
-            $mm = EE_Maintenance_Mode::instance()->level();
186
-            $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
187
-            if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) {
188
-                //we just took the site out of maintenance mode, so notify the user.
189
-                //unfortunately this message appears to be echoed on the NEXT page load...
190
-                //oh well, we should really be checking for this on addon deactivation anyways
191
-                EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required',
192
-                    'event_espresso'));
193
-                $this->_process_notices(array('page' => 'espresso_maintenance_settings'), false);
194
-            }
195
-            //in case an exception is thrown while trying to handle migrations
196
-            switch (EE_Maintenance_Mode::instance()->level()) {
197
-                case EE_Maintenance_Mode::level_0_not_in_maintenance:
198
-                case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
199
-                    $show_maintenance_switch = true;
200
-                    $show_backup_db_text = false;
201
-                    $show_migration_progress = false;
202
-                    $script_names = array();
203
-                    $addons_should_be_upgraded_first = false;
204
-                    break;
205
-                case EE_Maintenance_Mode::level_2_complete_maintenance:
206
-                    $show_maintenance_switch = false;
207
-                    $show_migration_progress = true;
208
-                    if (isset($this->_req_data['continue_migration'])) {
209
-                        $show_backup_db_text = false;
210
-                    } else {
211
-                        $show_backup_db_text = true;
212
-                    }
213
-                    $scripts_needing_to_run = EE_Data_Migration_Manager::instance()
214
-                                                                       ->check_for_applicable_data_migration_scripts();
215
-                    $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating();
216
-                    $script_names = array();
217
-                    $current_script = null;
218
-                    foreach ($scripts_needing_to_run as $script) {
219
-                        if ($script instanceof EE_Data_Migration_Script_Base) {
220
-                            if ( ! $current_script) {
221
-                                $current_script = $script;
222
-                                $current_script->migration_page_hooks();
223
-                            }
224
-                            $script_names[] = $script->pretty_name();
225
-                        }
226
-                    }
227
-                    break;
228
-            }
229
-            $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);
230
-            $exception_thrown = false;
231
-        } catch (EE_Error $e) {
232
-            EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());
233
-            //now, just so we can display the page correctly, make a error migration script stage object
234
-            //and also put the error on it. It only persists for the duration of this request
235
-            $most_recent_migration = new EE_DMS_Unknown_1_0_0();
236
-            $most_recent_migration->add_error($e->getMessage());
237
-            $exception_thrown = true;
238
-        }
239
-        $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set();
240
-        $current_db_state = str_replace('.decaf', '', $current_db_state);
241
-        if ($exception_thrown
242
-            || ($most_recent_migration
243
-                && $most_recent_migration instanceof EE_Data_Migration_Script_Base
244
-                && $most_recent_migration->is_broken()
245
-            )
246
-        ) {
247
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
248
-            $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/';
249
-            $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action'  => 'confirm_migration_crash_report_sent',
250
-                                                                                        'success' => '0',
251
-            ), EE_MAINTENANCE_ADMIN_URL);
252
-        } elseif ($addons_should_be_upgraded_first) {
253
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
254
-        } else {
255
-            if ($most_recent_migration
256
-                && $most_recent_migration instanceof EE_Data_Migration_Script_Base
257
-                && $most_recent_migration->can_continue()
258
-            ) {
259
-                $show_backup_db_text = false;
260
-                $show_continue_current_migration_script = true;
261
-                $show_most_recent_migration = true;
262
-            } elseif (isset($this->_req_data['continue_migration'])) {
263
-                $show_most_recent_migration = true;
264
-                $show_continue_current_migration_script = false;
265
-            } else {
266
-                $show_most_recent_migration = false;
267
-                $show_continue_current_migration_script = false;
268
-            }
269
-            if (isset($current_script)) {
270
-                $migrates_to = $current_script->migrates_to_version();
271
-                $plugin_slug = $migrates_to['slug'];
272
-                $new_version = $migrates_to['version'];
273
-                $this->_template_args = array_merge($this->_template_args, array(
274
-                    'current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"),
275
-                        isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug),
276
-                    'next_db_state'    => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'),
277
-                        $new_version, $plugin_slug) : null,
278
-                ));
279
-            } else {
280
-                $this->_template_args['current_db_state'] = null;
281
-                $this->_template_args['next_db_state'] = null;
282
-            }
283
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
284
-            $this->_template_args = array_merge(
285
-                $this->_template_args,
286
-                array(
287
-                    'show_most_recent_migration'             => $show_most_recent_migration,
288
-                    //flag for showing the most recent migration's status and/or errors
289
-                    'show_migration_progress'                => $show_migration_progress,
290
-                    //flag for showing the option to run migrations and see their progress
291
-                    'show_backup_db_text'                    => $show_backup_db_text,
292
-                    //flag for showing text telling the user to backup their DB
293
-                    'show_maintenance_switch'                => $show_maintenance_switch,
294
-                    //flag for showing the option to change maintenance mode between levels 0 and 1
295
-                    'script_names'                           => $script_names,
296
-                    //array of names of scripts that have run
297
-                    'show_continue_current_migration_script' => $show_continue_current_migration_script,
298
-                    //flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0
299
-                    'reset_db_page_link'                     => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'),
300
-                        EE_MAINTENANCE_ADMIN_URL),
301
-                    'data_reset_page'                        => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'),
302
-                        EE_MAINTENANCE_ADMIN_URL),
303
-                    'update_migration_script_page_link'      => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'),
304
-                        EE_MAINTENANCE_ADMIN_URL),
305
-                    'ultimate_db_state'                      => sprintf(__("EE%s", 'event_espresso'),
306
-                        espresso_version()),
307
-                )
308
-            );
309
-            //make sure we have the form fields helper available. It usually is, but sometimes it isn't
310
-            //localize script stuff
311
-            wp_localize_script('ee-maintenance', 'ee_maintenance', array(
312
-                'migrating'                        => esc_html__("Updating Database...", "event_espresso"),
313
-                'next'                             => esc_html__("Next", "event_espresso"),
314
-                'fatal_error'                      => esc_html__("A Fatal Error Has Occurred", "event_espresso"),
315
-                'click_next_when_ready'            => esc_html__("The current Database Update has ended. Click 'next' when ready to proceed",
316
-                    "event_espresso"),
317
-                'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts,
318
-                'status_fatal_error'               => EE_Data_Migration_Manager::status_fatal_error,
319
-                'status_completed'                 => EE_Data_Migration_Manager::status_completed,
320
-            ));
321
-        }
322
-        $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration
323
-        //now render the migration options part, and put it in a variable
324
-        $migration_options_template_file = apply_filters(
325
-            'FHEE__ee_migration_page__migration_options_template',
326
-            EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php'
327
-        );
328
-        $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true);
329
-        $this->_template_args['migration_options_html'] = $migration_options_html;
330
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
331
-            $this->_template_args, true);
332
-        $this->display_admin_page_with_sidebar();
333
-    }
334
-
335
-
336
-
337
-    /**
338
-     * returns JSON and executes another step of the currently-executing data migration (called via ajax)
339
-     */
340
-    public function migration_step()
341
-    {
342
-        $this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request();
343
-        $this->_return_json();
344
-    }
345
-
346
-
347
-
348
-    /**
349
-     * Can be used by js when it notices a response with HTML in it in order
350
-     * to log the malformed response
351
-     */
352
-    public function add_error_to_migrations_ran()
353
-    {
354
-        EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']);
355
-        $this->_template_args['data'] = array('ok' => true);
356
-        $this->_return_json();
357
-    }
358
-
359
-
360
-
361
-    /**
362
-     * changes the maintenance level, provided there are still no migration scripts that should run
363
-     */
364
-    public function _change_maintenance_level()
365
-    {
366
-        $new_level = absint($this->_req_data['maintenance_mode_level']);
367
-        if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
368
-            EE_Maintenance_Mode::instance()->set_maintenance_level($new_level);
369
-            $success = true;
370
-        } else {
371
-            EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
372
-            $success = false;
373
-        }
374
-        $this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso"));
375
-    }
376
-
377
-
378
-
379
-    /**
380
-     * a tab with options for resetting and/or deleting EE data
381
-     *
382
-     * @throws \EE_Error
383
-     * @throws \DomainException
384
-     */
385
-    public function _data_reset_and_delete()
386
-    {
387
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
388
-        $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button(
389
-            'reset_reservations',
390
-            'reset_reservations',
391
-            array(),
392
-            'button button-primary',
393
-            '',
394
-            false
395
-        );
396
-        $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button(
397
-            'reset_capabilities',
398
-            'reset_capabilities',
399
-            array(),
400
-            'button button-primary',
401
-            '',
402
-            false
403
-        );
404
-        $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce(
405
-            array('action' => 'delete_db'),
406
-            EE_MAINTENANCE_ADMIN_URL
407
-        );
408
-        $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce(
409
-            array('action' => 'reset_db'),
410
-            EE_MAINTENANCE_ADMIN_URL
411
-        );
412
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
413
-            $this->_template_path,
414
-            $this->_template_args,
415
-            true
416
-        );
417
-        $this->display_admin_page_with_sidebar();
418
-    }
419
-
420
-
421
-
422
-    protected function _reset_reservations()
423
-    {
424
-        if(\EED_Ticket_Sales_Monitor::reset_reservation_counts()) {
425
-            EE_Error::add_success(
426
-                __(
427
-                    'Ticket and datetime reserved counts have been successfully reset.',
428
-                    'event_espresso'
429
-                )
430
-            );
431
-        } else {
432
-            EE_Error::add_success(
433
-                __(
434
-                    'Ticket and datetime reserved counts were correct and did not need resetting.',
435
-                    'event_espresso'
436
-                )
437
-            );
438
-        }
439
-        $this->_redirect_after_action(true, '', '', array('action' => 'data_reset'), true);
440
-    }
441
-
442
-
443
-
444
-    protected function _reset_capabilities()
445
-    {
446
-        EE_Registry::instance()->CAP->init_caps(true);
447
-        EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.',
448
-            'event_espresso'));
449
-        $this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true);
450
-    }
451
-
452
-
453
-
454
-    /**
455
-     * resets the DMSs so we can attempt to continue migrating after a fatal error
456
-     * (only a good idea when someone has somehow tried ot fix whatever caused
457
-     * the fatal error in teh first place)
458
-     */
459
-    protected function _reattempt_migration()
460
-    {
461
-        EE_Data_Migration_Manager::instance()->reattempt();
462
-        $this->_redirect_after_action(false, '', '', array('action' => 'default'), true);
463
-    }
464
-
465
-
466
-
467
-    /**
468
-     * shows the big ol' System Information page
469
-     */
470
-    public function _system_status()
471
-    {
472
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
473
-        $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati();
474
-        $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce(
475
-            array(
476
-                'action' => 'download_system_status',
477
-            ),
478
-            EE_MAINTENANCE_ADMIN_URL
479
-        );
480
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
481
-            $this->_template_args, true);
482
-        $this->display_admin_page_with_sidebar();
483
-    }
484
-
485
-    /**
486
-     * Downloads an HTML file of the system status that can be easily stored or emailed
487
-     */
488
-    public function _download_system_status()
489
-    {
490
-        $status_info = EEM_System_Status::instance()->get_system_stati();
491
-        header( 'Content-Disposition: attachment' );
492
-        header( "Content-Disposition: attachment; filename=system_status_" . sanitize_key( site_url() ) . ".html" );
493
-        echo "<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>";
494
-        echo "<h1>System Information for " . site_url() . "</h1>";
495
-        echo EEH_Template::layout_array_as_table( $status_info );
496
-        die;
497
-    }
498
-
499
-
500
-
501
-    public function _send_migration_crash_report()
502
-    {
503
-        $from = $this->_req_data['from'];
504
-        $from_name = $this->_req_data['from_name'];
505
-        $body = $this->_req_data['body'];
506
-        try {
507
-            $success = wp_mail(EE_SUPPORT_EMAIL,
508
-                'Migration Crash Report',
509
-                $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),
510
-                array(
511
-                    "from:$from_name<$from>",
512
-                    //					'content-type:text/html charset=UTF-8'
513
-                ));
514
-        } catch (Exception $e) {
515
-            $success = false;
516
-        }
517
-        $this->_redirect_after_action($success, esc_html__("Migration Crash Report", "event_espresso"),
518
-            esc_html__("sent", "event_espresso"),
519
-            array('success' => $success, 'action' => 'confirm_migration_crash_report_sent'));
520
-    }
521
-
522
-
523
-
524
-    public function _confirm_migration_crash_report_sent()
525
-    {
526
-        try {
527
-            $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);
528
-        } catch (EE_Error $e) {
529
-            EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());
530
-            //now, just so we can display the page correctly, make a error migration script stage object
531
-            //and also put the error on it. It only persists for the duration of this request
532
-            $most_recent_migration = new EE_DMS_Unknown_1_0_0();
533
-            $most_recent_migration->add_error($e->getMessage());
534
-        }
535
-        $success = $this->_req_data['success'] == '1' ? true : false;
536
-        $this->_template_args['success'] = $success;
537
-        $this->_template_args['most_recent_migration'] = $most_recent_migration;
538
-        $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'),
539
-            EE_MAINTENANCE_ADMIN_URL);
540
-        $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'),
541
-            EE_MAINTENANCE_ADMIN_URL);
542
-        $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'),
543
-            EE_MAINTENANCE_ADMIN_URL);
544
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
545
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
546
-            $this->_template_args, true);
547
-        $this->display_admin_page_with_sidebar();
548
-    }
549
-
550
-
551
-
552
-    /**
553
-     * Resets the entire EE4 database.
554
-     * Currently basically only sets up ee4 database for a fresh install- doesn't
555
-     * actually clean out the old wp options, or cpts (although does erase old ee table data)
556
-     *
557
-     * @param boolean $nuke_old_ee4_data controls whether or not we
558
-     *                                   destroy the old ee4 data, or just try initializing ee4 default data
559
-     */
560
-    public function _reset_db($nuke_old_ee4_data = true)
561
-    {
562
-        EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
563
-        if ($nuke_old_ee4_data) {
564
-            EEH_Activation::delete_all_espresso_cpt_data();
565
-            EEH_Activation::delete_all_espresso_tables_and_data(false);
566
-            EEH_Activation::remove_cron_tasks();
567
-        }
568
-        //make sure when we reset the registry's config that it
569
-        //switches to using the new singleton
570
-        EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true);
571
-        EE_System::instance()->initialize_db_if_no_migrations_required(true);
572
-        EE_System::instance()->redirect_to_about_ee();
573
-    }
574
-
575
-
576
-
577
-    /**
578
-     * Deletes ALL EE tables, Records, and Options from the database.
579
-     */
580
-    public function _delete_db()
581
-    {
582
-        EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
583
-        EEH_Activation::delete_all_espresso_cpt_data();
584
-        EEH_Activation::delete_all_espresso_tables_and_data();
585
-        EEH_Activation::remove_cron_tasks();
586
-        EEH_Activation::deactivate_event_espresso();
587
-        wp_safe_redirect(admin_url('plugins.php'));
588
-        exit;
589
-    }
590
-
591
-
592
-
593
-    /**
594
-     * sets up EE4 to rerun the migrations from ee3 to ee4
595
-     */
596
-    public function _rerun_migration_from_ee3()
597
-    {
598
-        EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
599
-        EEH_Activation::delete_all_espresso_cpt_data();
600
-        EEH_Activation::delete_all_espresso_tables_and_data(false);
601
-        //set the db state to something that will require migrations
602
-        update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0');
603
-        EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance);
604
-        $this->_redirect_after_action(true, esc_html__("Database", 'event_espresso'), esc_html__("reset", 'event_espresso'));
605
-    }
606
-
607
-
608
-
609
-    //none of the below group are currently used for Gateway Settings
610
-    protected function _add_screen_options()
611
-    {
612
-    }
613
-
614
-
615
-
616
-    protected function _add_feature_pointers()
617
-    {
618
-    }
619
-
31
+	public function __construct($routing = true)
32
+	{
33
+		parent::__construct($routing);
34
+	}
35
+
36
+
37
+
38
+	protected function _init_page_props()
39
+	{
40
+		$this->page_slug = EE_MAINTENANCE_PG_SLUG;
41
+		$this->page_label = EE_MAINTENANCE_LABEL;
42
+		$this->_admin_base_url = EE_MAINTENANCE_ADMIN_URL;
43
+		$this->_admin_base_path = EE_MAINTENANCE_ADMIN;
44
+	}
45
+
46
+
47
+
48
+	protected function _ajax_hooks()
49
+	{
50
+		add_action('wp_ajax_migration_step', array($this, 'migration_step'));
51
+		add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran'));
52
+	}
53
+
54
+
55
+
56
+	protected function _define_page_props()
57
+	{
58
+		$this->_admin_page_title = EE_MAINTENANCE_LABEL;
59
+		$this->_labels = array(
60
+			'buttons' => array(
61
+				'reset_reservations' => esc_html__('Reset Ticket and Datetime Reserved Counts', 'event_espresso'),
62
+				'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'),
63
+			),
64
+		);
65
+	}
66
+
67
+
68
+
69
+	protected function _set_page_routes()
70
+	{
71
+		$this->_page_routes = array(
72
+			'default'                             => array(
73
+				'func'       => '_maintenance',
74
+				'capability' => 'manage_options',
75
+			),
76
+			'change_maintenance_level'            => array(
77
+				'func'       => '_change_maintenance_level',
78
+				'capability' => 'manage_options',
79
+				'noheader'   => true,
80
+			),
81
+			'system_status'                       => array(
82
+				'func'       => '_system_status',
83
+				'capability' => 'manage_options',
84
+			),
85
+			'download_system_status' => array(
86
+				'func'       => '_download_system_status',
87
+				'capability' => 'manage_options',
88
+				'noheader'   => true,
89
+			),
90
+			'send_migration_crash_report'         => array(
91
+				'func'       => '_send_migration_crash_report',
92
+				'capability' => 'manage_options',
93
+				'noheader'   => true,
94
+			),
95
+			'confirm_migration_crash_report_sent' => array(
96
+				'func'       => '_confirm_migration_crash_report_sent',
97
+				'capability' => 'manage_options',
98
+			),
99
+			'data_reset'                          => array(
100
+				'func'       => '_data_reset_and_delete',
101
+				'capability' => 'manage_options',
102
+			),
103
+			'reset_db'                            => array(
104
+				'func'       => '_reset_db',
105
+				'capability' => 'manage_options',
106
+				'noheader'   => true,
107
+				'args'       => array('nuke_old_ee4_data' => true),
108
+			),
109
+			'start_with_fresh_ee4_db'             => array(
110
+				'func'       => '_reset_db',
111
+				'capability' => 'manage_options',
112
+				'noheader'   => true,
113
+				'args'       => array('nuke_old_ee4_data' => false),
114
+			),
115
+			'delete_db'                           => array(
116
+				'func'       => '_delete_db',
117
+				'capability' => 'manage_options',
118
+				'noheader'   => true,
119
+			),
120
+			'rerun_migration_from_ee3'            => array(
121
+				'func'       => '_rerun_migration_from_ee3',
122
+				'capability' => 'manage_options',
123
+				'noheader'   => true,
124
+			),
125
+			'reset_reservations'                  => array(
126
+				'func'       => '_reset_reservations',
127
+				'capability' => 'manage_options',
128
+				'noheader'   => true,
129
+			),
130
+			'reset_capabilities'                  => array(
131
+				'func'       => '_reset_capabilities',
132
+				'capability' => 'manage_options',
133
+				'noheader'   => true,
134
+			),
135
+			'reattempt_migration'                 => array(
136
+				'func'       => '_reattempt_migration',
137
+				'capability' => 'manage_options',
138
+				'noheader'   => true,
139
+			),
140
+		);
141
+	}
142
+
143
+
144
+
145
+	protected function _set_page_config()
146
+	{
147
+		$this->_page_config = array(
148
+			'default'       => array(
149
+				'nav'           => array(
150
+					'label' => esc_html__('Maintenance', 'event_espresso'),
151
+					'order' => 10,
152
+				),
153
+				'require_nonce' => false,
154
+			),
155
+			'data_reset'    => array(
156
+				'nav'           => array(
157
+					'label' => esc_html__('Reset/Delete Data', 'event_espresso'),
158
+					'order' => 20,
159
+				),
160
+				'require_nonce' => false,
161
+			),
162
+			'system_status' => array(
163
+				'nav'           => array(
164
+					'label' => esc_html__("System Information", "event_espresso"),
165
+					'order' => 30,
166
+				),
167
+				'require_nonce' => false,
168
+			),
169
+		);
170
+	}
171
+
172
+
173
+
174
+	/**
175
+	 * default maintenance page. If we're in maintenance mode level 2, then we need to show
176
+	 * the migration scripts and all that UI.
177
+	 */
178
+	public function _maintenance()
179
+	{
180
+		//it all depends if we're in maintenance model level 1 (frontend-only) or
181
+		//level 2 (everything except maintenance page)
182
+		try {
183
+			//get the current maintenance level and check if
184
+			//we are removed
185
+			$mm = EE_Maintenance_Mode::instance()->level();
186
+			$placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
187
+			if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) {
188
+				//we just took the site out of maintenance mode, so notify the user.
189
+				//unfortunately this message appears to be echoed on the NEXT page load...
190
+				//oh well, we should really be checking for this on addon deactivation anyways
191
+				EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required',
192
+					'event_espresso'));
193
+				$this->_process_notices(array('page' => 'espresso_maintenance_settings'), false);
194
+			}
195
+			//in case an exception is thrown while trying to handle migrations
196
+			switch (EE_Maintenance_Mode::instance()->level()) {
197
+				case EE_Maintenance_Mode::level_0_not_in_maintenance:
198
+				case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
199
+					$show_maintenance_switch = true;
200
+					$show_backup_db_text = false;
201
+					$show_migration_progress = false;
202
+					$script_names = array();
203
+					$addons_should_be_upgraded_first = false;
204
+					break;
205
+				case EE_Maintenance_Mode::level_2_complete_maintenance:
206
+					$show_maintenance_switch = false;
207
+					$show_migration_progress = true;
208
+					if (isset($this->_req_data['continue_migration'])) {
209
+						$show_backup_db_text = false;
210
+					} else {
211
+						$show_backup_db_text = true;
212
+					}
213
+					$scripts_needing_to_run = EE_Data_Migration_Manager::instance()
214
+																	   ->check_for_applicable_data_migration_scripts();
215
+					$addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating();
216
+					$script_names = array();
217
+					$current_script = null;
218
+					foreach ($scripts_needing_to_run as $script) {
219
+						if ($script instanceof EE_Data_Migration_Script_Base) {
220
+							if ( ! $current_script) {
221
+								$current_script = $script;
222
+								$current_script->migration_page_hooks();
223
+							}
224
+							$script_names[] = $script->pretty_name();
225
+						}
226
+					}
227
+					break;
228
+			}
229
+			$most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);
230
+			$exception_thrown = false;
231
+		} catch (EE_Error $e) {
232
+			EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());
233
+			//now, just so we can display the page correctly, make a error migration script stage object
234
+			//and also put the error on it. It only persists for the duration of this request
235
+			$most_recent_migration = new EE_DMS_Unknown_1_0_0();
236
+			$most_recent_migration->add_error($e->getMessage());
237
+			$exception_thrown = true;
238
+		}
239
+		$current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set();
240
+		$current_db_state = str_replace('.decaf', '', $current_db_state);
241
+		if ($exception_thrown
242
+			|| ($most_recent_migration
243
+				&& $most_recent_migration instanceof EE_Data_Migration_Script_Base
244
+				&& $most_recent_migration->is_broken()
245
+			)
246
+		) {
247
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
248
+			$this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/';
249
+			$this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action'  => 'confirm_migration_crash_report_sent',
250
+																						'success' => '0',
251
+			), EE_MAINTENANCE_ADMIN_URL);
252
+		} elseif ($addons_should_be_upgraded_first) {
253
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
254
+		} else {
255
+			if ($most_recent_migration
256
+				&& $most_recent_migration instanceof EE_Data_Migration_Script_Base
257
+				&& $most_recent_migration->can_continue()
258
+			) {
259
+				$show_backup_db_text = false;
260
+				$show_continue_current_migration_script = true;
261
+				$show_most_recent_migration = true;
262
+			} elseif (isset($this->_req_data['continue_migration'])) {
263
+				$show_most_recent_migration = true;
264
+				$show_continue_current_migration_script = false;
265
+			} else {
266
+				$show_most_recent_migration = false;
267
+				$show_continue_current_migration_script = false;
268
+			}
269
+			if (isset($current_script)) {
270
+				$migrates_to = $current_script->migrates_to_version();
271
+				$plugin_slug = $migrates_to['slug'];
272
+				$new_version = $migrates_to['version'];
273
+				$this->_template_args = array_merge($this->_template_args, array(
274
+					'current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"),
275
+						isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug),
276
+					'next_db_state'    => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'),
277
+						$new_version, $plugin_slug) : null,
278
+				));
279
+			} else {
280
+				$this->_template_args['current_db_state'] = null;
281
+				$this->_template_args['next_db_state'] = null;
282
+			}
283
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
284
+			$this->_template_args = array_merge(
285
+				$this->_template_args,
286
+				array(
287
+					'show_most_recent_migration'             => $show_most_recent_migration,
288
+					//flag for showing the most recent migration's status and/or errors
289
+					'show_migration_progress'                => $show_migration_progress,
290
+					//flag for showing the option to run migrations and see their progress
291
+					'show_backup_db_text'                    => $show_backup_db_text,
292
+					//flag for showing text telling the user to backup their DB
293
+					'show_maintenance_switch'                => $show_maintenance_switch,
294
+					//flag for showing the option to change maintenance mode between levels 0 and 1
295
+					'script_names'                           => $script_names,
296
+					//array of names of scripts that have run
297
+					'show_continue_current_migration_script' => $show_continue_current_migration_script,
298
+					//flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0
299
+					'reset_db_page_link'                     => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'),
300
+						EE_MAINTENANCE_ADMIN_URL),
301
+					'data_reset_page'                        => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'),
302
+						EE_MAINTENANCE_ADMIN_URL),
303
+					'update_migration_script_page_link'      => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'),
304
+						EE_MAINTENANCE_ADMIN_URL),
305
+					'ultimate_db_state'                      => sprintf(__("EE%s", 'event_espresso'),
306
+						espresso_version()),
307
+				)
308
+			);
309
+			//make sure we have the form fields helper available. It usually is, but sometimes it isn't
310
+			//localize script stuff
311
+			wp_localize_script('ee-maintenance', 'ee_maintenance', array(
312
+				'migrating'                        => esc_html__("Updating Database...", "event_espresso"),
313
+				'next'                             => esc_html__("Next", "event_espresso"),
314
+				'fatal_error'                      => esc_html__("A Fatal Error Has Occurred", "event_espresso"),
315
+				'click_next_when_ready'            => esc_html__("The current Database Update has ended. Click 'next' when ready to proceed",
316
+					"event_espresso"),
317
+				'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts,
318
+				'status_fatal_error'               => EE_Data_Migration_Manager::status_fatal_error,
319
+				'status_completed'                 => EE_Data_Migration_Manager::status_completed,
320
+			));
321
+		}
322
+		$this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration
323
+		//now render the migration options part, and put it in a variable
324
+		$migration_options_template_file = apply_filters(
325
+			'FHEE__ee_migration_page__migration_options_template',
326
+			EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php'
327
+		);
328
+		$migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true);
329
+		$this->_template_args['migration_options_html'] = $migration_options_html;
330
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
331
+			$this->_template_args, true);
332
+		$this->display_admin_page_with_sidebar();
333
+	}
334
+
335
+
336
+
337
+	/**
338
+	 * returns JSON and executes another step of the currently-executing data migration (called via ajax)
339
+	 */
340
+	public function migration_step()
341
+	{
342
+		$this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request();
343
+		$this->_return_json();
344
+	}
345
+
346
+
347
+
348
+	/**
349
+	 * Can be used by js when it notices a response with HTML in it in order
350
+	 * to log the malformed response
351
+	 */
352
+	public function add_error_to_migrations_ran()
353
+	{
354
+		EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']);
355
+		$this->_template_args['data'] = array('ok' => true);
356
+		$this->_return_json();
357
+	}
358
+
359
+
360
+
361
+	/**
362
+	 * changes the maintenance level, provided there are still no migration scripts that should run
363
+	 */
364
+	public function _change_maintenance_level()
365
+	{
366
+		$new_level = absint($this->_req_data['maintenance_mode_level']);
367
+		if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
368
+			EE_Maintenance_Mode::instance()->set_maintenance_level($new_level);
369
+			$success = true;
370
+		} else {
371
+			EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
372
+			$success = false;
373
+		}
374
+		$this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso"));
375
+	}
376
+
377
+
378
+
379
+	/**
380
+	 * a tab with options for resetting and/or deleting EE data
381
+	 *
382
+	 * @throws \EE_Error
383
+	 * @throws \DomainException
384
+	 */
385
+	public function _data_reset_and_delete()
386
+	{
387
+		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
388
+		$this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button(
389
+			'reset_reservations',
390
+			'reset_reservations',
391
+			array(),
392
+			'button button-primary',
393
+			'',
394
+			false
395
+		);
396
+		$this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button(
397
+			'reset_capabilities',
398
+			'reset_capabilities',
399
+			array(),
400
+			'button button-primary',
401
+			'',
402
+			false
403
+		);
404
+		$this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce(
405
+			array('action' => 'delete_db'),
406
+			EE_MAINTENANCE_ADMIN_URL
407
+		);
408
+		$this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce(
409
+			array('action' => 'reset_db'),
410
+			EE_MAINTENANCE_ADMIN_URL
411
+		);
412
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
413
+			$this->_template_path,
414
+			$this->_template_args,
415
+			true
416
+		);
417
+		$this->display_admin_page_with_sidebar();
418
+	}
419
+
420
+
421
+
422
+	protected function _reset_reservations()
423
+	{
424
+		if(\EED_Ticket_Sales_Monitor::reset_reservation_counts()) {
425
+			EE_Error::add_success(
426
+				__(
427
+					'Ticket and datetime reserved counts have been successfully reset.',
428
+					'event_espresso'
429
+				)
430
+			);
431
+		} else {
432
+			EE_Error::add_success(
433
+				__(
434
+					'Ticket and datetime reserved counts were correct and did not need resetting.',
435
+					'event_espresso'
436
+				)
437
+			);
438
+		}
439
+		$this->_redirect_after_action(true, '', '', array('action' => 'data_reset'), true);
440
+	}
441
+
442
+
443
+
444
+	protected function _reset_capabilities()
445
+	{
446
+		EE_Registry::instance()->CAP->init_caps(true);
447
+		EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.',
448
+			'event_espresso'));
449
+		$this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true);
450
+	}
451
+
452
+
453
+
454
+	/**
455
+	 * resets the DMSs so we can attempt to continue migrating after a fatal error
456
+	 * (only a good idea when someone has somehow tried ot fix whatever caused
457
+	 * the fatal error in teh first place)
458
+	 */
459
+	protected function _reattempt_migration()
460
+	{
461
+		EE_Data_Migration_Manager::instance()->reattempt();
462
+		$this->_redirect_after_action(false, '', '', array('action' => 'default'), true);
463
+	}
464
+
465
+
466
+
467
+	/**
468
+	 * shows the big ol' System Information page
469
+	 */
470
+	public function _system_status()
471
+	{
472
+		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
473
+		$this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati();
474
+		$this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce(
475
+			array(
476
+				'action' => 'download_system_status',
477
+			),
478
+			EE_MAINTENANCE_ADMIN_URL
479
+		);
480
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
481
+			$this->_template_args, true);
482
+		$this->display_admin_page_with_sidebar();
483
+	}
484
+
485
+	/**
486
+	 * Downloads an HTML file of the system status that can be easily stored or emailed
487
+	 */
488
+	public function _download_system_status()
489
+	{
490
+		$status_info = EEM_System_Status::instance()->get_system_stati();
491
+		header( 'Content-Disposition: attachment' );
492
+		header( "Content-Disposition: attachment; filename=system_status_" . sanitize_key( site_url() ) . ".html" );
493
+		echo "<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>";
494
+		echo "<h1>System Information for " . site_url() . "</h1>";
495
+		echo EEH_Template::layout_array_as_table( $status_info );
496
+		die;
497
+	}
498
+
499
+
500
+
501
+	public function _send_migration_crash_report()
502
+	{
503
+		$from = $this->_req_data['from'];
504
+		$from_name = $this->_req_data['from_name'];
505
+		$body = $this->_req_data['body'];
506
+		try {
507
+			$success = wp_mail(EE_SUPPORT_EMAIL,
508
+				'Migration Crash Report',
509
+				$body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),
510
+				array(
511
+					"from:$from_name<$from>",
512
+					//					'content-type:text/html charset=UTF-8'
513
+				));
514
+		} catch (Exception $e) {
515
+			$success = false;
516
+		}
517
+		$this->_redirect_after_action($success, esc_html__("Migration Crash Report", "event_espresso"),
518
+			esc_html__("sent", "event_espresso"),
519
+			array('success' => $success, 'action' => 'confirm_migration_crash_report_sent'));
520
+	}
521
+
522
+
523
+
524
+	public function _confirm_migration_crash_report_sent()
525
+	{
526
+		try {
527
+			$most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);
528
+		} catch (EE_Error $e) {
529
+			EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());
530
+			//now, just so we can display the page correctly, make a error migration script stage object
531
+			//and also put the error on it. It only persists for the duration of this request
532
+			$most_recent_migration = new EE_DMS_Unknown_1_0_0();
533
+			$most_recent_migration->add_error($e->getMessage());
534
+		}
535
+		$success = $this->_req_data['success'] == '1' ? true : false;
536
+		$this->_template_args['success'] = $success;
537
+		$this->_template_args['most_recent_migration'] = $most_recent_migration;
538
+		$this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'),
539
+			EE_MAINTENANCE_ADMIN_URL);
540
+		$this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'),
541
+			EE_MAINTENANCE_ADMIN_URL);
542
+		$this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'),
543
+			EE_MAINTENANCE_ADMIN_URL);
544
+		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
545
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
546
+			$this->_template_args, true);
547
+		$this->display_admin_page_with_sidebar();
548
+	}
549
+
550
+
551
+
552
+	/**
553
+	 * Resets the entire EE4 database.
554
+	 * Currently basically only sets up ee4 database for a fresh install- doesn't
555
+	 * actually clean out the old wp options, or cpts (although does erase old ee table data)
556
+	 *
557
+	 * @param boolean $nuke_old_ee4_data controls whether or not we
558
+	 *                                   destroy the old ee4 data, or just try initializing ee4 default data
559
+	 */
560
+	public function _reset_db($nuke_old_ee4_data = true)
561
+	{
562
+		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
563
+		if ($nuke_old_ee4_data) {
564
+			EEH_Activation::delete_all_espresso_cpt_data();
565
+			EEH_Activation::delete_all_espresso_tables_and_data(false);
566
+			EEH_Activation::remove_cron_tasks();
567
+		}
568
+		//make sure when we reset the registry's config that it
569
+		//switches to using the new singleton
570
+		EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true);
571
+		EE_System::instance()->initialize_db_if_no_migrations_required(true);
572
+		EE_System::instance()->redirect_to_about_ee();
573
+	}
574
+
575
+
576
+
577
+	/**
578
+	 * Deletes ALL EE tables, Records, and Options from the database.
579
+	 */
580
+	public function _delete_db()
581
+	{
582
+		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
583
+		EEH_Activation::delete_all_espresso_cpt_data();
584
+		EEH_Activation::delete_all_espresso_tables_and_data();
585
+		EEH_Activation::remove_cron_tasks();
586
+		EEH_Activation::deactivate_event_espresso();
587
+		wp_safe_redirect(admin_url('plugins.php'));
588
+		exit;
589
+	}
590
+
591
+
592
+
593
+	/**
594
+	 * sets up EE4 to rerun the migrations from ee3 to ee4
595
+	 */
596
+	public function _rerun_migration_from_ee3()
597
+	{
598
+		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
599
+		EEH_Activation::delete_all_espresso_cpt_data();
600
+		EEH_Activation::delete_all_espresso_tables_and_data(false);
601
+		//set the db state to something that will require migrations
602
+		update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0');
603
+		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance);
604
+		$this->_redirect_after_action(true, esc_html__("Database", 'event_espresso'), esc_html__("reset", 'event_espresso'));
605
+	}
606
+
607
+
608
+
609
+	//none of the below group are currently used for Gateway Settings
610
+	protected function _add_screen_options()
611
+	{
612
+	}
613
+
614
+
615
+
616
+	protected function _add_feature_pointers()
617
+	{
618
+	}
619
+
620 620
 
621 621
 
622
-    public function admin_init()
623
-    {
624
-    }
625
-
626
-
627
-
628
-    public function admin_notices()
629
-    {
630
-    }
631
-
622
+	public function admin_init()
623
+	{
624
+	}
625
+
626
+
627
+
628
+	public function admin_notices()
629
+	{
630
+	}
631
+
632 632
 
633 633
 
634
-    public function admin_footer_scripts()
635
-    {
636
-    }
634
+	public function admin_footer_scripts()
635
+	{
636
+	}
637 637
 
638 638
 
639 639
 
640
-    public function load_scripts_styles()
641
-    {
642
-        wp_enqueue_script('ee_admin_js');
640
+	public function load_scripts_styles()
641
+	{
642
+		wp_enqueue_script('ee_admin_js');
643 643
 //		wp_enqueue_media();
644 644
 //		wp_enqueue_script('media-upload');
645
-        wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'),
646
-            EVENT_ESPRESSO_VERSION, true);
647
-        wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(),
648
-            EVENT_ESPRESSO_VERSION);
649
-        wp_enqueue_style('espresso_maintenance');
650
-    }
645
+		wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'),
646
+			EVENT_ESPRESSO_VERSION, true);
647
+		wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(),
648
+			EVENT_ESPRESSO_VERSION);
649
+		wp_enqueue_style('espresso_maintenance');
650
+	}
651 651
 
652 652
 
653 653
 
654
-    public function load_scripts_styles_default()
655
-    {
656
-        //styles
654
+	public function load_scripts_styles_default()
655
+	{
656
+		//styles
657 657
 //		wp_enqueue_style('ee-text-links');
658 658
 //		//scripts
659 659
 //		wp_enqueue_script('ee-text-links');
660
-    }
660
+	}
661 661
 
662 662
 
663 663
 
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
                 && $most_recent_migration->is_broken()
245 245
             )
246 246
         ) {
247
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
247
+            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_was_borked_page.template.php';
248 248
             $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/';
249 249
             $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action'  => 'confirm_migration_crash_report_sent',
250 250
                                                                                         'success' => '0',
251 251
             ), EE_MAINTENANCE_ADMIN_URL);
252 252
         } elseif ($addons_should_be_upgraded_first) {
253
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
253
+            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_upgrade_addons_before_migrating.template.php';
254 254
         } else {
255 255
             if ($most_recent_migration
256 256
                 && $most_recent_migration instanceof EE_Data_Migration_Script_Base
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
                 $this->_template_args['current_db_state'] = null;
281 281
                 $this->_template_args['next_db_state'] = null;
282 282
             }
283
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
283
+            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_page.template.php';
284 284
             $this->_template_args = array_merge(
285 285
                 $this->_template_args,
286 286
                 array(
@@ -319,13 +319,13 @@  discard block
 block discarded – undo
319 319
                 'status_completed'                 => EE_Data_Migration_Manager::status_completed,
320 320
             ));
321 321
         }
322
-        $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration
322
+        $this->_template_args['most_recent_migration'] = $most_recent_migration; //the actual most recently ran migration
323 323
         //now render the migration options part, and put it in a variable
324 324
         $migration_options_template_file = apply_filters(
325 325
             'FHEE__ee_migration_page__migration_options_template',
326
-            EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php'
326
+            EE_MAINTENANCE_TEMPLATE_PATH.'migration_options_from_ee4.template.php'
327 327
         );
328
-        $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true);
328
+        $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args, true);
329 329
         $this->_template_args['migration_options_html'] = $migration_options_html;
330 330
         $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
331 331
             $this->_template_args, true);
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
      */
385 385
     public function _data_reset_and_delete()
386 386
     {
387
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
387
+        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_data_reset_and_delete.template.php';
388 388
         $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button(
389 389
             'reset_reservations',
390 390
             'reset_reservations',
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 
422 422
     protected function _reset_reservations()
423 423
     {
424
-        if(\EED_Ticket_Sales_Monitor::reset_reservation_counts()) {
424
+        if (\EED_Ticket_Sales_Monitor::reset_reservation_counts()) {
425 425
             EE_Error::add_success(
426 426
                 __(
427 427
                     'Ticket and datetime reserved counts have been successfully reset.',
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
      */
470 470
     public function _system_status()
471 471
     {
472
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
472
+        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_system_stati_page.template.php';
473 473
         $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati();
474 474
         $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce(
475 475
             array(
@@ -488,11 +488,11 @@  discard block
 block discarded – undo
488 488
     public function _download_system_status()
489 489
     {
490 490
         $status_info = EEM_System_Status::instance()->get_system_stati();
491
-        header( 'Content-Disposition: attachment' );
492
-        header( "Content-Disposition: attachment; filename=system_status_" . sanitize_key( site_url() ) . ".html" );
491
+        header('Content-Disposition: attachment');
492
+        header("Content-Disposition: attachment; filename=system_status_".sanitize_key(site_url()).".html");
493 493
         echo "<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>";
494
-        echo "<h1>System Information for " . site_url() . "</h1>";
495
-        echo EEH_Template::layout_array_as_table( $status_info );
494
+        echo "<h1>System Information for ".site_url()."</h1>";
495
+        echo EEH_Template::layout_array_as_table($status_info);
496 496
         die;
497 497
     }
498 498
 
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
         try {
507 507
             $success = wp_mail(EE_SUPPORT_EMAIL,
508 508
                 'Migration Crash Report',
509
-                $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),
509
+                $body."/r/n<br>".print_r(EEM_System_Status::instance()->get_system_stati(), true),
510 510
                 array(
511 511
                     "from:$from_name<$from>",
512 512
                     //					'content-type:text/html charset=UTF-8'
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
             EE_MAINTENANCE_ADMIN_URL);
542 542
         $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'),
543 543
             EE_MAINTENANCE_ADMIN_URL);
544
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
544
+        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_confirm_migration_crash_report_sent.template.php';
545 545
         $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
546 546
             $this->_template_args, true);
547 547
         $this->display_admin_page_with_sidebar();
@@ -642,9 +642,9 @@  discard block
 block discarded – undo
642 642
         wp_enqueue_script('ee_admin_js');
643 643
 //		wp_enqueue_media();
644 644
 //		wp_enqueue_script('media-upload');
645
-        wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'),
645
+        wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL.'/ee-maintenance.js', array('jquery'),
646 646
             EVENT_ESPRESSO_VERSION, true);
647
-        wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(),
647
+        wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL.'ee-maintenance.css', array(),
648 648
             EVENT_ESPRESSO_VERSION);
649 649
         wp_enqueue_style('espresso_maintenance');
650 650
     }
Please login to merge, or discard this patch.
core/services/loaders/CoreLoader.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
      */
39 39
     public function __construct($generator)
40 40
     {
41
-        if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) {
41
+        if ( ! ($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) {
42 42
             throw new InvalidArgumentException(
43 43
                 esc_html__(
44 44
                     'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.',
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
     /**
34 34
      * CoreLoader constructor.
35 35
      *
36
-     * @param EE_Registry|CoffeeShop $generator
36
+     * @param EE_Registry $generator
37 37
      * @throws InvalidArgumentException
38 38
      */
39 39
     public function __construct($generator)
Please login to merge, or discard this patch.
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -23,58 +23,58 @@
 block discarded – undo
23 23
 class CoreLoader implements LoaderDecoratorInterface
24 24
 {
25 25
 
26
-    /**
27
-     * @var EE_Registry|CoffeeShop $generator
28
-     */
29
-    private $generator;
30
-
31
-
32
-
33
-    /**
34
-     * CoreLoader constructor.
35
-     *
36
-     * @param EE_Registry|CoffeeShop $generator
37
-     * @throws InvalidArgumentException
38
-     */
39
-    public function __construct($generator)
40
-    {
41
-        if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) {
42
-            throw new InvalidArgumentException(
43
-                esc_html__(
44
-                    'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.',
45
-                    'event_espresso'
46
-                )
47
-            );
48
-        }
49
-        $this->generator = $generator;
50
-    }
51
-
52
-
53
-
54
-    /**
55
-     * @param string $fqcn
56
-     * @param array  $arguments
57
-     * @return mixed
58
-     * @throws ServiceNotFoundException
59
-     */
60
-    public function load($fqcn, $arguments = array())
61
-    {
62
-        return $this->generator instanceof EE_Registry
63
-            ? $this->generator->create($fqcn, $arguments)
64
-            : $this->generator->brew($fqcn, $arguments);
65
-    }
66
-
67
-
68
-
69
-    /**
70
-     * calls reset() on generator if method exists
71
-     */
72
-    public function reset()
73
-    {
74
-        if (method_exists($this->generator, 'reset')) {
75
-            $this->generator->reset();
76
-        }
77
-    }
26
+	/**
27
+	 * @var EE_Registry|CoffeeShop $generator
28
+	 */
29
+	private $generator;
30
+
31
+
32
+
33
+	/**
34
+	 * CoreLoader constructor.
35
+	 *
36
+	 * @param EE_Registry|CoffeeShop $generator
37
+	 * @throws InvalidArgumentException
38
+	 */
39
+	public function __construct($generator)
40
+	{
41
+		if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) {
42
+			throw new InvalidArgumentException(
43
+				esc_html__(
44
+					'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.',
45
+					'event_espresso'
46
+				)
47
+			);
48
+		}
49
+		$this->generator = $generator;
50
+	}
51
+
52
+
53
+
54
+	/**
55
+	 * @param string $fqcn
56
+	 * @param array  $arguments
57
+	 * @return mixed
58
+	 * @throws ServiceNotFoundException
59
+	 */
60
+	public function load($fqcn, $arguments = array())
61
+	{
62
+		return $this->generator instanceof EE_Registry
63
+			? $this->generator->create($fqcn, $arguments)
64
+			: $this->generator->brew($fqcn, $arguments);
65
+	}
66
+
67
+
68
+
69
+	/**
70
+	 * calls reset() on generator if method exists
71
+	 */
72
+	public function reset()
73
+	{
74
+		if (method_exists($this->generator, 'reset')) {
75
+			$this->generator->reset();
76
+		}
77
+	}
78 78
 
79 79
 }
80 80
 // End of file CoreLoader.php
Please login to merge, or discard this patch.
core/services/collections/CollectionInterface.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\services\collections;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * @param  mixed $identifier
28 28
 	 * @return bool
29 29
 	 */
30
-	public function add( $object, $identifier = null );
30
+	public function add($object, $identifier = null);
31 31
 
32 32
 	/**
33 33
 	 * setIdentifier
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param  mixed $identifier
40 40
 	 * @return bool
41 41
 	 */
42
-	public function setIdentifier( $object, $identifier = null );
42
+	public function setIdentifier($object, $identifier = null);
43 43
 
44 44
 	/**
45 45
 	 * get
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * @param mixed $identifier
51 51
 	 * @return mixed
52 52
 	 */
53
-	public function get( $identifier );
53
+	public function get($identifier);
54 54
 
55 55
 	/**
56 56
 	 * has
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @param  mixed $identifier
63 63
 	 * @return bool
64 64
 	 */
65
-	public function has( $identifier );
65
+	public function has($identifier);
66 66
 
67 67
 	/**
68 68
 	 * hasObject
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param $object
73 73
 	 * @return bool
74 74
 	 */
75
-	public function hasObject( $object );
75
+	public function hasObject($object);
76 76
 
77 77
 	/**
78 78
 	 * remove
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 * @param $object
83 83
 	 * @return bool
84 84
 	 */
85
-	public function remove( $object );
85
+	public function remove($object);
86 86
 
87 87
 	/**
88 88
 	 * setCurrent
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 * @param mixed $identifier
93 93
 	 * @return boolean
94 94
 	 */
95
-	public function setCurrent( $identifier ) ;
95
+	public function setCurrent($identifier);
96 96
 
97 97
 	/**
98 98
 	 * setCurrentUsingObject
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @param $object
103 103
 	 * @return boolean
104 104
 	 */
105
-	public function setCurrentUsingObject( $object );
105
+	public function setCurrentUsingObject($object);
106 106
 
107 107
 	/**
108 108
 	 * Returns the object occupying the index before the current object,
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @param $object
120 120
 	 * @return boolean|int|string
121 121
 	 */
122
-	public function indexOf( $object );
122
+	public function indexOf($object);
123 123
 
124 124
 
125 125
 	/**
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 * @param $index
130 130
 	 * @return mixed
131 131
 	 */
132
-	public function objectAtIndex( $index );
132
+	public function objectAtIndex($index);
133 133
 
134 134
 	/**
135 135
 	 * Returns the sequence of objects as specified by the offset and length
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	 * @param int $length
140 140
 	 * @return array
141 141
 	 */
142
-	public function slice( $offset, $length );
142
+	public function slice($offset, $length);
143 143
 
144 144
 	/**
145 145
 	 * Inserts an object (or an array of objects) at a certain point
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 * @param mixed   $objects A single object or an array of objects
149 149
 	 * @param integer $index
150 150
 	 */
151
-	public function insertAt( $objects, $index );
151
+	public function insertAt($objects, $index);
152 152
 
153 153
 	/**
154 154
 	 * Removes the object at the given index
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @see http://stackoverflow.com/a/8736013
157 157
 	 * @param integer $index
158 158
 	 */
159
-	public function removeAt( $index ) ;
159
+	public function removeAt($index);
160 160
 
161 161
 
162 162
 
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 	public function previous();
114 114
 
115 115
 		/**
116
-	 * Returns the index of a given object, or false if not found
117
-	 *
118
-	 * @see http://stackoverflow.com/a/8736013
119
-	 * @param $object
120
-	 * @return boolean|int|string
121
-	 */
116
+		 * Returns the index of a given object, or false if not found
117
+		 *
118
+		 * @see http://stackoverflow.com/a/8736013
119
+		 * @param $object
120
+		 * @return boolean|int|string
121
+		 */
122 122
 	public function indexOf( $object );
123 123
 
124 124
 
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
 
161 161
 
162 162
 
163
-    /**
164
-     * detaches ALL objects from the Collection
165
-     */
166
-    public function detachAll();
163
+	/**
164
+	 * detaches ALL objects from the Collection
165
+	 */
166
+	public function detachAll();
167 167
 
168 168
 }
169 169
 // End of file CollectionInterface.php
Please login to merge, or discard this patch.
core/services/collections/Collection.php 2 patches
Indentation   +12 added lines, -13 removed lines patch added patch discarded remove patch
@@ -83,7 +83,6 @@  discard block
 block discarded – undo
83 83
 
84 84
 	 /**
85 85
 	  * setIdentifier
86
-
87 86
 	  * Sets the data associated with an object in the Collection
88 87
 	  * if no $identifier is supplied, then the spl_object_hash() is used
89 88
 	  *
@@ -352,18 +351,18 @@  discard block
 block discarded – undo
352 351
 
353 352
 
354 353
 
355
-     /**
356
-      * detaches ALL objects from the Collection
357
-      */
358
-     public function detachAll()
359
-     {
360
-         $this->rewind();
361
-         while ($this->valid()) {
362
-             $object = $this->current();
363
-             $this->next();
364
-             $this->detach($object);
365
-         }
366
-     }
354
+	 /**
355
+	  * detaches ALL objects from the Collection
356
+	  */
357
+	 public function detachAll()
358
+	 {
359
+		 $this->rewind();
360
+		 while ($this->valid()) {
361
+			 $object = $this->current();
362
+			 $this->next();
363
+			 $this->detach($object);
364
+		 }
365
+	 }
367 366
 
368 367
 
369 368
 
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	  * by calling EE_Object_Collection::set_identifier()
66 66
 	  *
67 67
 	  * @access public
68
-	  * @param        $object
68
+	  * @param        \EventEspresso\core\services\progress_steps\ProgressStep $object
69 69
 	  * @param  mixed $identifier
70 70
 	  * @return bool
71 71
 	  * @throws \EventEspresso\core\exceptions\InvalidEntityException
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	  * advances pointer to the provided object
212 212
 	  *
213 213
 	  * @access public
214
-	  * @param $object
214
+	  * @param \EventEspresso\core\libraries\form_sections\form_handlers\SequentialStepForm $object
215 215
 	  * @return boolean
216 216
 	  */
217 217
 	 public function setCurrentUsingObject( $object ) {
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	  *
250 250
 	  * @see http://stackoverflow.com/a/8736013
251 251
 	  * @param $object
252
-	  * @return boolean|int|string
252
+	  * @return integer
253 253
 	  */
254 254
 	 public function indexOf( $object ) {
255 255
 		 if ( ! $this->contains( $object ) ) {
Please login to merge, or discard this patch.
core/services/loaders/CachingLoader.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -102,17 +102,17 @@
 block discarded – undo
102 102
         $fqcn = ltrim($fqcn, '\\');
103 103
         // caching can be turned off via the following code:
104 104
         // add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true');
105
-        if(
105
+        if (
106 106
             apply_filters(
107 107
                 'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache',
108 108
                 false,
109 109
                 $this
110 110
             )
111
-        ){
111
+        ) {
112 112
             return $this->loader->load($fqcn, $arguments);
113 113
         }
114
-        $identifier = md5($fqcn . serialize($arguments));
115
-        if($this->cache->has($identifier)){
114
+        $identifier = md5($fqcn.serialize($arguments));
115
+        if ($this->cache->has($identifier)) {
116 116
             return $this->cache->get($identifier);
117 117
         }
118 118
         $object = $this->loader->load($fqcn, $arguments);
Please login to merge, or discard this patch.
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -22,114 +22,114 @@
 block discarded – undo
22 22
 class CachingLoader extends LoaderDecorator
23 23
 {
24 24
 
25
-    /**
26
-     * @var CollectionInterface $cache
27
-     */
28
-    protected $cache;
29
-
30
-    /**
31
-     * @var string $identifier
32
-     */
33
-    protected $identifier;
34
-
35
-
36
-
37
-    /**
38
-     * CachingLoader constructor.
39
-     *
40
-     * @param LoaderDecoratorInterface $loader
41
-     * @param CollectionInterface      $cache
42
-     * @param string                   $identifier
43
-     * @throws InvalidDataTypeException
44
-     */
45
-    public function __construct(LoaderDecoratorInterface $loader, CollectionInterface $cache, $identifier = '')
46
-    {
47
-        parent::__construct($loader);
48
-        $this->cache = $cache;
49
-        $this->setIdentifier($identifier);
50
-        if ($this->identifier !== '') {
51
-            // to only clear this cache, and assuming an identifier has been set, simply do the following:
52
-            // do_action('AHEE__EventEspresso\core\services\loaders\CachingLoader__resetCache__IDENTIFIER');
53
-            // where "IDENTIFIER" = the string that was set during construction
54
-            add_action(
55
-                "AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__{$identifier}",
56
-                array($this, 'reset')
57
-            );
58
-        }
59
-        // to clear ALL caches, simply do the following:
60
-        // do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache');
61
-        add_action(
62
-            'AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache',
63
-            array($this, 'reset')
64
-        );
65
-    }
66
-
67
-
68
-
69
-    /**
70
-     * @return string
71
-     */
72
-    public function identifier()
73
-    {
74
-        return $this->identifier;
75
-    }
76
-
77
-
78
-
79
-    /**
80
-     * @param string $identifier
81
-     * @throws InvalidDataTypeException
82
-     */
83
-    private function setIdentifier($identifier)
84
-    {
85
-        if ( ! is_string($identifier)) {
86
-            throw new InvalidDataTypeException('$identifier', $identifier, 'string');
87
-        }
88
-        $this->identifier = $identifier;
89
-    }
90
-
91
-
92
-
93
-    /**
94
-     * @param string $fqcn
95
-     * @param array  $arguments
96
-     * @return mixed
97
-     * @throws InvalidEntityException
98
-     * @throws ServiceNotFoundException
99
-     */
100
-    public function load($fqcn, $arguments = array())
101
-    {
102
-        $fqcn = ltrim($fqcn, '\\');
103
-        // caching can be turned off via the following code:
104
-        // add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true');
105
-        if(
106
-            apply_filters(
107
-                'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache',
108
-                false,
109
-                $this
110
-            )
111
-        ){
112
-            return $this->loader->load($fqcn, $arguments);
113
-        }
114
-        $identifier = md5($fqcn . serialize($arguments));
115
-        if($this->cache->has($identifier)){
116
-            return $this->cache->get($identifier);
117
-        }
118
-        $object = $this->loader->load($fqcn, $arguments);
119
-        $this->cache->add($object, $identifier);
120
-        return $object;
121
-    }
122
-
123
-
124
-
125
-    /**
126
-     * empties cache and calls reset() on loader if method exists
127
-     */
128
-    public function reset()
129
-    {
130
-        $this->cache->detachAll();
131
-        $this->loader->reset();
132
-    }
25
+	/**
26
+	 * @var CollectionInterface $cache
27
+	 */
28
+	protected $cache;
29
+
30
+	/**
31
+	 * @var string $identifier
32
+	 */
33
+	protected $identifier;
34
+
35
+
36
+
37
+	/**
38
+	 * CachingLoader constructor.
39
+	 *
40
+	 * @param LoaderDecoratorInterface $loader
41
+	 * @param CollectionInterface      $cache
42
+	 * @param string                   $identifier
43
+	 * @throws InvalidDataTypeException
44
+	 */
45
+	public function __construct(LoaderDecoratorInterface $loader, CollectionInterface $cache, $identifier = '')
46
+	{
47
+		parent::__construct($loader);
48
+		$this->cache = $cache;
49
+		$this->setIdentifier($identifier);
50
+		if ($this->identifier !== '') {
51
+			// to only clear this cache, and assuming an identifier has been set, simply do the following:
52
+			// do_action('AHEE__EventEspresso\core\services\loaders\CachingLoader__resetCache__IDENTIFIER');
53
+			// where "IDENTIFIER" = the string that was set during construction
54
+			add_action(
55
+				"AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__{$identifier}",
56
+				array($this, 'reset')
57
+			);
58
+		}
59
+		// to clear ALL caches, simply do the following:
60
+		// do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache');
61
+		add_action(
62
+			'AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache',
63
+			array($this, 'reset')
64
+		);
65
+	}
66
+
67
+
68
+
69
+	/**
70
+	 * @return string
71
+	 */
72
+	public function identifier()
73
+	{
74
+		return $this->identifier;
75
+	}
76
+
77
+
78
+
79
+	/**
80
+	 * @param string $identifier
81
+	 * @throws InvalidDataTypeException
82
+	 */
83
+	private function setIdentifier($identifier)
84
+	{
85
+		if ( ! is_string($identifier)) {
86
+			throw new InvalidDataTypeException('$identifier', $identifier, 'string');
87
+		}
88
+		$this->identifier = $identifier;
89
+	}
90
+
91
+
92
+
93
+	/**
94
+	 * @param string $fqcn
95
+	 * @param array  $arguments
96
+	 * @return mixed
97
+	 * @throws InvalidEntityException
98
+	 * @throws ServiceNotFoundException
99
+	 */
100
+	public function load($fqcn, $arguments = array())
101
+	{
102
+		$fqcn = ltrim($fqcn, '\\');
103
+		// caching can be turned off via the following code:
104
+		// add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true');
105
+		if(
106
+			apply_filters(
107
+				'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache',
108
+				false,
109
+				$this
110
+			)
111
+		){
112
+			return $this->loader->load($fqcn, $arguments);
113
+		}
114
+		$identifier = md5($fqcn . serialize($arguments));
115
+		if($this->cache->has($identifier)){
116
+			return $this->cache->get($identifier);
117
+		}
118
+		$object = $this->loader->load($fqcn, $arguments);
119
+		$this->cache->add($object, $identifier);
120
+		return $object;
121
+	}
122
+
123
+
124
+
125
+	/**
126
+	 * empties cache and calls reset() on loader if method exists
127
+	 */
128
+	public function reset()
129
+	{
130
+		$this->cache->detachAll();
131
+		$this->loader->reset();
132
+	}
133 133
 
134 134
 
135 135
 }
Please login to merge, or discard this patch.