Completed
Branch FET-10816-display-form-wide-er... (b27d66)
by
unknown
153:47 queued 140:47
created
core/libraries/form_sections/inputs/EE_Email_Input.input.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,22 +6,22 @@
 block discarded – undo
6 6
  * @subpackage
7 7
  * @author				Mike Nelson
8 8
  */
9
-class EE_Email_Input extends EE_Form_Input_Base{
9
+class EE_Email_Input extends EE_Form_Input_Base {
10 10
 
11 11
 	/**
12 12
 	 * @param array $input_settings
13 13
 	 */
14
-	public function __construct( $input_settings = array() ){
15
-		$this->_set_display_strategy( new EE_Text_Input_Display_Strategy('email') );
16
-		$this->_set_normalization_strategy( new EE_Text_Normalization() );
14
+	public function __construct($input_settings = array()) {
15
+		$this->_set_display_strategy(new EE_Text_Input_Display_Strategy('email'));
16
+		$this->_set_normalization_strategy(new EE_Text_Normalization());
17 17
 		$this->_add_validation_strategy(
18 18
 			new EE_Email_Validation_Strategy(
19
-				isset( $input_settings[ 'validation_error_message' ] )
20
-					? $input_settings[ 'validation_error_message' ]
19
+				isset($input_settings['validation_error_message'])
20
+					? $input_settings['validation_error_message']
21 21
 					: NULL
22 22
 			)
23 23
 		);
24
-		parent::__construct( $input_settings );
25
-		$this->set_html_class( $this->html_class() . ' email' );
24
+		parent::__construct($input_settings);
25
+		$this->set_html_class($this->html_class().' email');
26 26
 	}
27 27
 }
Please login to merge, or discard this patch.
modules/venues_archive/EED_Venues_Archive.module.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -39,14 +39,14 @@
 block discarded – undo
39 39
 	 *  @return 	void
40 40
 	 */
41 41
 	public static function set_hooks() {
42
-        $post_type = get_post_type_object('espresso_venues');
43
-        $custom_post_types = EE_Register_CPTs::get_CPTs();
44
-        EE_Config::register_route(
45
-            $custom_post_types['espresso_venues']['plural_slug'],
46
-            'Venues_Archive',
47
-            'run'
48
-        );
49
-    }
42
+		$post_type = get_post_type_object('espresso_venues');
43
+		$custom_post_types = EE_Register_CPTs::get_CPTs();
44
+		EE_Config::register_route(
45
+			$custom_post_types['espresso_venues']['plural_slug'],
46
+			'Venues_Archive',
47
+			'run'
48
+		);
49
+	}
50 50
 
51 51
 	/**
52 52
 	 * 	set_hooks_admin - for hooking into EE Admin Core, other modules, etc
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * @return EED_Venues_Archive
28 28
 	 */
29 29
 	public static function instance() {
30
-		return parent::get_instance( __CLASS__ );
30
+		return parent::get_instance(__CLASS__);
31 31
 	}
32 32
 
33 33
 
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 	 * @access    public
66 66
 	 * @param \WP $WP
67 67
 	 */
68
-	public function run( $WP ) {
68
+	public function run($WP) {
69 69
 		// check what template is loaded
70
-		add_filter( 'template_include',  array( $this, 'template_include' ), 999, 1 );
71
-		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 );
70
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
71
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
72 72
 	}
73 73
 
74 74
 
@@ -80,18 +80,18 @@  discard block
 block discarded – undo
80 80
 	 * @param  string $template
81 81
 	 * @return string
82 82
 	 */
83
-	public function template_include( $template ) {
83
+	public function template_include($template) {
84 84
 		// not a custom template?
85
-		if ( EE_Registry::instance()->load_core( 'Front_Controller', array(), false, true )->get_selected_template() != 'archive-espresso_venues.php' ) {
85
+		if (EE_Registry::instance()->load_core('Front_Controller', array(), false, true)->get_selected_template() != 'archive-espresso_venues.php') {
86 86
 			EEH_Template::load_espresso_theme_functions();
87 87
 			// then add extra event data via hooks
88
-			add_filter( 'the_title', array( $this, 'the_title' ), 100, 1 );
88
+			add_filter('the_title', array($this, 'the_title'), 100, 1);
89 89
 			// don't know if theme uses the_excerpt
90
-			add_filter( 'the_excerpt', array( $this, 'venue_details' ), 100 );
90
+			add_filter('the_excerpt', array($this, 'venue_details'), 100);
91 91
 			// or the_content
92
-			add_filter( 'the_content', array( $this, 'venue_details' ), 100 );
92
+			add_filter('the_content', array($this, 'venue_details'), 100);
93 93
 			// don't display entry meta because the existing theme will take care of that
94
-			add_filter( 'FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false' );
94
+			add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
95 95
 		}
96 96
 		return $template;
97 97
 	}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @param  string $title
106 106
 	 * @return string
107 107
 	 */
108
-	public function the_title( $title = '' ) {
108
+	public function the_title($title = '') {
109 109
 		return $title;
110 110
 	}
111 111
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @param  string $content
118 118
 	 * @return string
119 119
 	 */
120
-	public function venue_details( $content ) {
120
+	public function venue_details($content) {
121 121
 		global $post;
122 122
 		if (
123 123
 			$post->post_type == 'espresso_venues'
@@ -127,22 +127,22 @@  discard block
 block discarded – undo
127 127
 			// it uses the_content() for displaying the $post->post_content
128 128
 			// so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
129 129
 			// we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
130
-			remove_filter( 'the_excerpt', array( $this, 'venue_details' ), 100 );
131
-			remove_filter( 'the_content', array( $this, 'venue_details' ), 100 );
130
+			remove_filter('the_excerpt', array($this, 'venue_details'), 100);
131
+			remove_filter('the_content', array($this, 'venue_details'), 100);
132 132
 			// add filters we want
133
-			add_filter( 'the_content', array( $this, 'venue_location' ), 110 );
134
-			add_filter( 'the_excerpt', array( $this, 'venue_location' ), 110 );
133
+			add_filter('the_content', array($this, 'venue_location'), 110);
134
+			add_filter('the_excerpt', array($this, 'venue_location'), 110);
135 135
 			// now load our template
136
-			$template = EEH_Template::locate_template( 'content-espresso_venues-details.php' );
136
+			$template = EEH_Template::locate_template('content-espresso_venues-details.php');
137 137
 			//now add our filter back in, plus some others
138
-			add_filter( 'the_excerpt', array( $this, 'venue_details' ), 100 );
139
-			add_filter( 'the_content', array( $this, 'venue_details' ), 100 );
138
+			add_filter('the_excerpt', array($this, 'venue_details'), 100);
139
+			add_filter('the_content', array($this, 'venue_details'), 100);
140 140
 			// remove other filters we added so they won't get applied to the next post
141
-			remove_filter( 'the_content', array( $this, 'venue_location' ), 110 );
142
-			remove_filter( 'the_excerpt', array( $this, 'venue_location' ), 110 );
141
+			remove_filter('the_content', array($this, 'venue_location'), 110);
142
+			remove_filter('the_excerpt', array($this, 'venue_location'), 110);
143 143
 			// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
144 144
 		}
145
-		return ! empty( $template ) ? $template : $content;
145
+		return ! empty($template) ? $template : $content;
146 146
 	}
147 147
 
148 148
 
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 	 * @param  string $content
155 155
 	 * @return string
156 156
 	 */
157
-	public function venue_location( $content ) {
158
-		return $content . EEH_Template::locate_template( 'content-espresso_venues-location.php' );
157
+	public function venue_location($content) {
158
+		return $content.EEH_Template::locate_template('content-espresso_venues-location.php');
159 159
 	}
160 160
 
161 161
 
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
 	 */
170 170
 	public function wp_enqueue_scripts() {
171 171
 		// get some style
172
-		if ( apply_filters( 'FHEE_enable_default_espresso_css', TRUE ) && is_archive() ) {
172
+		if (apply_filters('FHEE_enable_default_espresso_css', TRUE) && is_archive()) {
173 173
 			// first check theme folder
174
-			if ( is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) {
175
-				wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' ) );
176
-			} else if ( is_readable( EE_TEMPLATES . $this->theme . DS . 'style.css' )) {
177
-				wp_register_style( $this->theme, EE_TEMPLATES_URL . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' ) );
174
+			if (is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) {
175
+				wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default'));
176
+			} else if (is_readable(EE_TEMPLATES.$this->theme.DS.'style.css')) {
177
+				wp_register_style($this->theme, EE_TEMPLATES_URL.$this->theme.DS.'style.css', array('dashicons', 'espresso_default'));
178 178
 			}
179
-			wp_enqueue_style( $this->theme );
179
+			wp_enqueue_style($this->theme);
180 180
 		}
181 181
 	}
182 182
 
Please login to merge, or discard this patch.
modules/venue_single/EED_Venue_Single.module.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,20 +32,20 @@
 block discarded – undo
32 32
 
33 33
 
34 34
 
35
-    /**
35
+	/**
36 36
 	 * 	set_hooks - for hooking into EE Core, other modules, etc
37 37
 	 *
38 38
 	 *  @access 	public
39 39
 	 *  @return 	void
40 40
 	 */
41 41
 	public static function set_hooks() {
42
-        $custom_post_types = EE_Register_CPTs::get_CPTs();
43
-        EE_Config::register_route(
44
-            $custom_post_types['espresso_venues']['singular_slug'],
45
-            'Venue_Single',
46
-            'run'
47
-        );
48
-    }
42
+		$custom_post_types = EE_Register_CPTs::get_CPTs();
43
+		EE_Config::register_route(
44
+			$custom_post_types['espresso_venues']['singular_slug'],
45
+			'Venue_Single',
46
+			'run'
47
+		);
48
+	}
49 49
 
50 50
 	/**
51 51
 	 * 	set_hooks_admin - for hooking into EE Admin Core, other modules, etc
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * @return EED_Venue_Single
28 28
 	 */
29 29
 	public static function instance() {
30
-		return parent::get_instance( __CLASS__ );
30
+		return parent::get_instance(__CLASS__);
31 31
 	}
32 32
 
33 33
 
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 	 * @access    public
65 65
 	 * @param \WP $WP
66 66
 	 */
67
-	public function run( $WP ) {
67
+	public function run($WP) {
68 68
 		// check what template is loaded
69
-		add_filter( 'template_include',  array( $this, 'template_include' ), 999, 1 );
70
-		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 );
69
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
70
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
71 71
 	}
72 72
 
73 73
 
@@ -79,15 +79,15 @@  discard block
 block discarded – undo
79 79
 	 * @param  string $template
80 80
 	 * @return string
81 81
 	 */
82
-	public function template_include( $template ) {
82
+	public function template_include($template) {
83 83
 		// not a custom template?
84
-		if ( EE_Registry::instance()->load_core( 'Front_Controller', array(), false, true )->get_selected_template() != 'single-espresso_venues.php' ) {
84
+		if (EE_Registry::instance()->load_core('Front_Controller', array(), false, true)->get_selected_template() != 'single-espresso_venues.php') {
85 85
 			EEH_Template::load_espresso_theme_functions();
86 86
 			// then add extra event data via hooks
87
-			add_filter( 'the_title', array( $this, 'the_title' ), 100, 1 );
88
-			add_filter( 'the_content', array( $this, 'venue_details' ), 100 );
87
+			add_filter('the_title', array($this, 'the_title'), 100, 1);
88
+			add_filter('the_content', array($this, 'venue_details'), 100);
89 89
 			// don't display entry meta because the existing theme will take car of that
90
-			add_filter( 'FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false' );
90
+			add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
91 91
 		}
92 92
 		return $template;
93 93
 	}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @param  string $title
102 102
 	 * @return string
103 103
 	 */
104
-	public function the_title( $title = '' ) {
104
+	public function the_title($title = '') {
105 105
 		return $title;
106 106
 	}
107 107
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 * @param  string $content
114 114
 	 * @return string
115 115
 	 */
116
-	public function venue_details( $content ) {
116
+	public function venue_details($content) {
117 117
 		global $post;
118 118
 		if (
119 119
 			$post->post_type == 'espresso_venues'
@@ -123,16 +123,16 @@  discard block
 block discarded – undo
123 123
 			// it uses the_content() for displaying the $post->post_content
124 124
 			// so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
125 125
 			// we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
126
-			remove_filter( 'the_content', array( $this, 'venue_details' ), 100 );
126
+			remove_filter('the_content', array($this, 'venue_details'), 100);
127 127
 			// add filters we want
128
-			add_filter( 'the_content', array( $this, 'venue_location' ), 110 );
128
+			add_filter('the_content', array($this, 'venue_location'), 110);
129 129
 			// now load our template
130
-			$template = EEH_Template::locate_template( 'content-espresso_venues-details.php' );
130
+			$template = EEH_Template::locate_template('content-espresso_venues-details.php');
131 131
 			// remove other filters we added so they won't get applied to the next post
132
-			remove_filter( 'the_content', array( $this, 'venue_location' ), 110 );
132
+			remove_filter('the_content', array($this, 'venue_location'), 110);
133 133
 		}
134 134
 		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
135
-		return ! empty( $template ) ? $template : $content;
135
+		return ! empty($template) ? $template : $content;
136 136
 	}
137 137
 
138 138
 
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 	 * @param  string $content
145 145
 	 * @return string
146 146
 	 */
147
-	public function venue_location( $content ) {
148
-		return $content . EEH_Template::locate_template( 'content-espresso_venues-location.php' );
147
+	public function venue_location($content) {
148
+		return $content.EEH_Template::locate_template('content-espresso_venues-location.php');
149 149
 	}
150 150
 
151 151
 
@@ -158,16 +158,16 @@  discard block
 block discarded – undo
158 158
 	 */
159 159
 	public function wp_enqueue_scripts() {
160 160
 		// get some style
161
-		if ( apply_filters( 'FHEE_enable_default_espresso_css', TRUE ) && is_single() ) {
161
+		if (apply_filters('FHEE_enable_default_espresso_css', TRUE) && is_single()) {
162 162
 			// first check theme folder
163
-			if ( is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) {
164
-				wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' ) );
165
-			} else if ( is_readable( EE_TEMPLATES . $this->theme . DS . 'style.css' )) {
166
-				wp_register_style( $this->theme, EE_TEMPLATES_URL . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' ) );
163
+			if (is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) {
164
+				wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default'));
165
+			} else if (is_readable(EE_TEMPLATES.$this->theme.DS.'style.css')) {
166
+				wp_register_style($this->theme, EE_TEMPLATES_URL.$this->theme.DS.'style.css', array('dashicons', 'espresso_default'));
167 167
 			}
168
-			wp_enqueue_style( $this->theme );
169
-			if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) {
170
-				add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 );
168
+			wp_enqueue_style($this->theme);
169
+			if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
170
+				add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
171 171
 			}
172 172
 		}
173 173
 	}
Please login to merge, or discard this patch.
modules/event_single/EED_Event_Single.module.php 1 patch
Indentation   +462 added lines, -462 removed lines patch added patch discarded remove patch
@@ -13,467 +13,467 @@  discard block
 block discarded – undo
13 13
 class EED_Event_Single extends EED_Module
14 14
 {
15 15
 
16
-    const EVENT_DETAILS_PRIORITY = 100;
17
-    const EVENT_DATETIMES_PRIORITY = 110;
18
-    const EVENT_TICKETS_PRIORITY = 120;
19
-    const EVENT_VENUES_PRIORITY = 130;
20
-
21
-    /**
22
-     * @type bool $using_get_the_excerpt
23
-     */
24
-    protected static $using_get_the_excerpt = false;
25
-
26
-
27
-    /**
28
-     * @type EE_Template_Part_Manager $template_parts
29
-     */
30
-    protected $template_parts;
31
-
32
-
33
-    /**
34
-     * @return EED_Module|EED_Event_Single
35
-     */
36
-    public static function instance()
37
-    {
38
-        return parent::get_instance(__CLASS__);
39
-    }
40
-
41
-
42
-    /**
43
-     * set_hooks - for hooking into EE Core, other modules, etc
44
-     *
45
-     * @return    void
46
-     */
47
-    public static function set_hooks()
48
-    {
49
-        add_filter('FHEE_run_EE_wp', '__return_true');
50
-        add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
51
-        $custom_post_types = EE_Register_CPTs::get_CPTs();
52
-        EE_Config::register_route(
53
-            $custom_post_types['espresso_events']['singular_slug'],
54
-            'Event_Single',
55
-            'run'
56
-        );
57
-    }
58
-
59
-    /**
60
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
61
-     *
62
-     * @return    void
63
-     */
64
-    public static function set_hooks_admin()
65
-    {
66
-        add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
67
-    }
68
-
69
-
70
-    /**
71
-     * set_definitions
72
-     *
73
-     * @static
74
-     * @return void
75
-     */
76
-    public static function set_definitions()
77
-    {
78
-        define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
79
-        define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates' . DS);
80
-    }
81
-
82
-
83
-    /**
84
-     * set_config
85
-     *
86
-     * @void
87
-     */
88
-    protected function set_config()
89
-    {
90
-        $this->set_config_section('template_settings');
91
-        $this->set_config_class('EE_Event_Single_Config');
92
-        $this->set_config_name('EED_Event_Single');
93
-    }
94
-
95
-
96
-    /**
97
-     * initialize_template_parts
98
-     *
99
-     * @param EE_Config_Base|EE_Event_Single_Config $config
100
-     * @return EE_Template_Part_Manager
101
-     */
102
-    public function initialize_template_parts(EE_Event_Single_Config $config = null)
103
-    {
104
-        /** @type EE_Event_Single_Config $config */
105
-        $config = $config instanceof EE_Event_Single_Config ? $config : $this->config();
106
-        EEH_Autoloader::instance()->register_template_part_autoloaders();
107
-        $template_parts = new EE_Template_Part_Manager();
108
-        $template_parts->add_template_part(
109
-            'tickets',
110
-            __('Ticket Selector', 'event_espresso'),
111
-            'content-espresso_events-tickets.php',
112
-            $config->display_order_tickets
113
-        );
114
-        $template_parts->add_template_part(
115
-            'datetimes',
116
-            __('Dates and Times', 'event_espresso'),
117
-            'content-espresso_events-datetimes.php',
118
-            $config->display_order_datetimes
119
-        );
120
-        $template_parts->add_template_part(
121
-            'event',
122
-            __('Event Description', 'event_espresso'),
123
-            'content-espresso_events-details.php',
124
-            $config->display_order_event
125
-        );
126
-        $template_parts->add_template_part(
127
-            'venue',
128
-            __('Venue Information', 'event_espresso'),
129
-            'content-espresso_events-venues.php',
130
-            $config->display_order_venue
131
-        );
132
-        do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts);
133
-        return $template_parts;
134
-    }
135
-
136
-
137
-    /**
138
-     * run - initial module setup
139
-     *
140
-     * @param WP $WP
141
-     * @return    void
142
-     */
143
-    public function run($WP)
144
-    {
145
-        // ensure valid EE_Events_Single_Config() object exists
146
-        $this->set_config();
147
-        // check what template is loaded
148
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
149
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
150
-        // load css
151
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
152
-    }
153
-
154
-
155
-    /**
156
-     * template_include
157
-     *
158
-     * @param    string $template
159
-     * @return    string
160
-     */
161
-    public function template_include($template)
162
-    {
163
-        global $post;
164
-        /** @type EE_Event_Single_Config $config */
165
-        $config = $this->config();
166
-        if ($config->display_status_banner_single) {
167
-            add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2);
168
-        }
169
-        // not a custom template?
170
-        if (
171
-            !post_password_required($post)
172
-            && (
173
-                apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false)
174
-                || EE_Registry::instance()
175
-                    ->load_core('Front_Controller')
176
-                    ->get_selected_template() !== 'single-espresso_events.php'
177
-            )
178
-
179
-        ) {
180
-            EEH_Template::load_espresso_theme_functions();
181
-            // then add extra event data via hooks
182
-            add_action('loop_start', array('EED_Event_Single', 'loop_start'));
183
-            add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1);
184
-            add_filter(
185
-                'the_content',
186
-                array('EED_Event_Single', 'event_details'),
187
-                EED_Event_Single::EVENT_DETAILS_PRIORITY
188
-            );
189
-            add_action('loop_end', array('EED_Event_Single', 'loop_end'));
190
-            // don't display entry meta because the existing theme will take car of that
191
-            add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
192
-        }
193
-        return $template;
194
-    }
195
-
196
-
197
-    /**
198
-     * loop_start
199
-     *
200
-     * @param    array $wp_query_array an array containing the WP_Query object
201
-     * @return    void
202
-     */
203
-    public static function loop_start($wp_query_array)
204
-    {
205
-        global $post;
206
-        do_action('AHEE_event_details_before_post', $post, $wp_query_array);
207
-    }
208
-
209
-
210
-    /**
211
-     * the_title
212
-     *
213
-     * @param    string $title
214
-     * @param    int $id
215
-     * @return    string
216
-     */
217
-    public static function the_title($title = '', $id = 0)
218
-    {
219
-        global $post;
220
-        return in_the_loop() && $post->ID === (int)$id
221
-            ? espresso_event_status_banner($post->ID) . $title
222
-            : $title;
223
-    }
224
-
225
-
226
-    /**
227
-     * get_the_excerpt
228
-     * kinda hacky, but if a theme is using get_the_excerpt(),
229
-     * then we need to remove our filters on the_content()
230
-     *
231
-     * @param        string $excerpt
232
-     * @return        string
233
-     */
234
-    public static function get_the_excerpt($excerpt = '')
235
-    {
236
-        EED_Event_Single::$using_get_the_excerpt = true;
237
-        add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1);
238
-        return $excerpt;
239
-    }
240
-
241
-
242
-    /**
243
-     * end_get_the_excerpt
244
-     *
245
-     * @param  string $text
246
-     * @return string
247
-     */
248
-    public static function end_get_the_excerpt($text = '')
249
-    {
250
-        EED_Event_Single::$using_get_the_excerpt = false;
251
-        return $text;
252
-    }
253
-
254
-
255
-    /**
256
-     * event_details
257
-     *
258
-     * @param    string $content
259
-     * @return    string
260
-     */
261
-    public static function event_details($content)
262
-    {
263
-        global $post;
264
-        static $current_post_ID = 0;
265
-        if (
266
-            $current_post_ID !== $post->ID
267
-            && $post->post_type === 'espresso_events'
268
-            && !EED_Event_Single::$using_get_the_excerpt
269
-            && !post_password_required()
270
-        ) {
271
-            // Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
272
-            // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
273
-            // BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
274
-            // We want to allow those plugins to still do their thing and have access to our content, but depending on
275
-            // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
276
-            // so the following allows this filter to be applied multiple times, but only once for real
277
-            $current_post_ID = did_action('loop_start') ? $post->ID : 0;
278
-            if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) {
279
-                // we need to first remove this callback from being applied to the_content()
280
-                // (otherwise it will recurse and blow up the interweb)
281
-                remove_filter(
282
-                    'the_content',
283
-                    array('EED_Event_Single', 'event_details'),
284
-                    EED_Event_Single::EVENT_DETAILS_PRIORITY
285
-                );
286
-                EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts();
287
-                $content = EEH_Template::locate_template('content-espresso_events-details.php');
288
-                $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content);
289
-                add_filter(
290
-                    'the_content',
291
-                    array('EED_Event_Single', 'event_details'),
292
-                    EED_Event_Single::EVENT_DETAILS_PRIORITY
293
-                );
294
-            } else {
295
-                $content = EED_Event_Single::use_filterable_display_order();
296
-            }
297
-        }
298
-        return $content;
299
-    }
300
-
301
-
302
-    /**
303
-     * use_filterable_display_order
304
-     *
305
-     * @return string
306
-     */
307
-    protected static function use_filterable_display_order()
308
-    {
309
-        // since the 'content-espresso_events-details.php' template might be used directly from within a theme,
310
-        // it uses the_content() for displaying the $post->post_content
311
-        // so in order to load a template that uses the_content()
312
-        // from within a callback being used to filter the_content(),
313
-        // we need to first remove this callback from being applied to the_content()
314
-        // (otherwise it will recurse and blow up the interweb)
315
-        remove_filter(
316
-            'the_content',
317
-            array('EED_Event_Single', 'event_details'),
318
-            EED_Event_Single::EVENT_DETAILS_PRIORITY
319
-        );
320
-        //now add additional content
321
-        add_filter(
322
-            'the_content',
323
-            array('EED_Event_Single', 'event_datetimes'),
324
-            EED_Event_Single::EVENT_DATETIMES_PRIORITY,
325
-            1
326
-        );
327
-        add_filter(
328
-            'the_content',
329
-            array('EED_Event_Single', 'event_tickets'),
330
-            EED_Event_Single::EVENT_TICKETS_PRIORITY,
331
-            1
332
-        );
333
-        add_filter(
334
-            'the_content',
335
-            array('EED_Event_Single', 'event_venues'),
336
-            EED_Event_Single::EVENT_VENUES_PRIORITY,
337
-            1
338
-        );
339
-        do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters');
340
-        // now load our template
341
-        $content = EEH_Template::locate_template('content-espresso_events-details.php');
342
-        //now add our filter back in, plus some others
343
-        add_filter(
344
-            'the_content',
345
-            array('EED_Event_Single', 'event_details'),
346
-            EED_Event_Single::EVENT_DETAILS_PRIORITY
347
-        );
348
-        remove_filter(
349
-            'the_content',
350
-            array('EED_Event_Single', 'event_datetimes'),
351
-            EED_Event_Single::EVENT_DATETIMES_PRIORITY
352
-        );
353
-        remove_filter(
354
-            'the_content',
355
-            array('EED_Event_Single', 'event_tickets'),
356
-            EED_Event_Single::EVENT_TICKETS_PRIORITY
357
-        );
358
-        remove_filter(
359
-            'the_content',
360
-            array('EED_Event_Single', 'event_venues'),
361
-            EED_Event_Single::EVENT_VENUES_PRIORITY
362
-        );
363
-        do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters');
364
-        // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
365
-        return $content;
366
-    }
367
-
368
-
369
-    /**
370
-     * event_datetimes - adds datetimes ABOVE content
371
-     *
372
-     * @param        string $content
373
-     * @return        string
374
-     */
375
-    public static function event_datetimes($content)
376
-    {
377
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
378
-    }
379
-
380
-
381
-    /**
382
-     * event_tickets - adds tickets ABOVE content (which includes datetimes)
383
-     *
384
-     * @param        string $content
385
-     * @return        string
386
-     */
387
-    public static function event_tickets($content)
388
-    {
389
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
390
-    }
391
-
392
-
393
-    /**
394
-     * event_venues
395
-     *
396
-     * @param    string $content
397
-     * @return    string
398
-     */
399
-    public static function event_venue($content)
400
-    {
401
-        return EED_Event_Single::event_venues($content);
402
-    }
403
-
404
-
405
-    /**
406
-     * event_venues - adds venues BELOW content
407
-     *
408
-     * @param        string $content
409
-     * @return        string
410
-     */
411
-    public static function event_venues($content)
412
-    {
413
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
414
-    }
415
-
416
-
417
-    /**
418
-     * loop_end
419
-     *
420
-     * @param        array $wp_query_array an array containing the WP_Query object
421
-     * @return        void
422
-     */
423
-    public static function loop_end($wp_query_array)
424
-    {
425
-        global $post;
426
-        do_action('AHEE_event_details_after_post', $post, $wp_query_array);
427
-    }
428
-
429
-
430
-    /**
431
-     * wp_enqueue_scripts
432
-     *
433
-     * @return    void
434
-     */
435
-    public function wp_enqueue_scripts()
436
-    {
437
-        // get some style
438
-        if (
439
-            apply_filters('FHEE_enable_default_espresso_css', TRUE)
440
-            && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE)
441
-        ) {
442
-            // first check uploads folder
443
-            if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) {
444
-                wp_register_style(
445
-                    $this->theme,
446
-                    get_stylesheet_directory_uri() . $this->theme . DS . 'style.css',
447
-                    array('dashicons', 'espresso_default')
448
-                );
449
-            } else {
450
-                wp_register_style(
451
-                    $this->theme,
452
-                    EE_TEMPLATES_URL . $this->theme . DS . 'style.css',
453
-                    array('dashicons', 'espresso_default')
454
-                );
455
-            }
456
-            wp_enqueue_script($this->theme);
457
-            if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
458
-                add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
459
-            }
460
-        }
461
-    }
462
-
463
-
464
-    /**
465
-     * display_venue
466
-     *
467
-     * @return    bool
468
-     */
469
-    public static function display_venue()
470
-    {
471
-        /** @type EE_Event_Single_Config $config */
472
-        $config = EED_Event_Single::instance()->config();
473
-        $display_venue = $config->display_venue === null ? true : $config->display_venue;
474
-        $venue_name = EEH_Venue_View::venue_name();
475
-        return $display_venue && !empty($venue_name);
476
-    }
16
+	const EVENT_DETAILS_PRIORITY = 100;
17
+	const EVENT_DATETIMES_PRIORITY = 110;
18
+	const EVENT_TICKETS_PRIORITY = 120;
19
+	const EVENT_VENUES_PRIORITY = 130;
20
+
21
+	/**
22
+	 * @type bool $using_get_the_excerpt
23
+	 */
24
+	protected static $using_get_the_excerpt = false;
25
+
26
+
27
+	/**
28
+	 * @type EE_Template_Part_Manager $template_parts
29
+	 */
30
+	protected $template_parts;
31
+
32
+
33
+	/**
34
+	 * @return EED_Module|EED_Event_Single
35
+	 */
36
+	public static function instance()
37
+	{
38
+		return parent::get_instance(__CLASS__);
39
+	}
40
+
41
+
42
+	/**
43
+	 * set_hooks - for hooking into EE Core, other modules, etc
44
+	 *
45
+	 * @return    void
46
+	 */
47
+	public static function set_hooks()
48
+	{
49
+		add_filter('FHEE_run_EE_wp', '__return_true');
50
+		add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
51
+		$custom_post_types = EE_Register_CPTs::get_CPTs();
52
+		EE_Config::register_route(
53
+			$custom_post_types['espresso_events']['singular_slug'],
54
+			'Event_Single',
55
+			'run'
56
+		);
57
+	}
58
+
59
+	/**
60
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
61
+	 *
62
+	 * @return    void
63
+	 */
64
+	public static function set_hooks_admin()
65
+	{
66
+		add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
67
+	}
68
+
69
+
70
+	/**
71
+	 * set_definitions
72
+	 *
73
+	 * @static
74
+	 * @return void
75
+	 */
76
+	public static function set_definitions()
77
+	{
78
+		define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
79
+		define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates' . DS);
80
+	}
81
+
82
+
83
+	/**
84
+	 * set_config
85
+	 *
86
+	 * @void
87
+	 */
88
+	protected function set_config()
89
+	{
90
+		$this->set_config_section('template_settings');
91
+		$this->set_config_class('EE_Event_Single_Config');
92
+		$this->set_config_name('EED_Event_Single');
93
+	}
94
+
95
+
96
+	/**
97
+	 * initialize_template_parts
98
+	 *
99
+	 * @param EE_Config_Base|EE_Event_Single_Config $config
100
+	 * @return EE_Template_Part_Manager
101
+	 */
102
+	public function initialize_template_parts(EE_Event_Single_Config $config = null)
103
+	{
104
+		/** @type EE_Event_Single_Config $config */
105
+		$config = $config instanceof EE_Event_Single_Config ? $config : $this->config();
106
+		EEH_Autoloader::instance()->register_template_part_autoloaders();
107
+		$template_parts = new EE_Template_Part_Manager();
108
+		$template_parts->add_template_part(
109
+			'tickets',
110
+			__('Ticket Selector', 'event_espresso'),
111
+			'content-espresso_events-tickets.php',
112
+			$config->display_order_tickets
113
+		);
114
+		$template_parts->add_template_part(
115
+			'datetimes',
116
+			__('Dates and Times', 'event_espresso'),
117
+			'content-espresso_events-datetimes.php',
118
+			$config->display_order_datetimes
119
+		);
120
+		$template_parts->add_template_part(
121
+			'event',
122
+			__('Event Description', 'event_espresso'),
123
+			'content-espresso_events-details.php',
124
+			$config->display_order_event
125
+		);
126
+		$template_parts->add_template_part(
127
+			'venue',
128
+			__('Venue Information', 'event_espresso'),
129
+			'content-espresso_events-venues.php',
130
+			$config->display_order_venue
131
+		);
132
+		do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts);
133
+		return $template_parts;
134
+	}
135
+
136
+
137
+	/**
138
+	 * run - initial module setup
139
+	 *
140
+	 * @param WP $WP
141
+	 * @return    void
142
+	 */
143
+	public function run($WP)
144
+	{
145
+		// ensure valid EE_Events_Single_Config() object exists
146
+		$this->set_config();
147
+		// check what template is loaded
148
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
149
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
150
+		// load css
151
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
152
+	}
153
+
154
+
155
+	/**
156
+	 * template_include
157
+	 *
158
+	 * @param    string $template
159
+	 * @return    string
160
+	 */
161
+	public function template_include($template)
162
+	{
163
+		global $post;
164
+		/** @type EE_Event_Single_Config $config */
165
+		$config = $this->config();
166
+		if ($config->display_status_banner_single) {
167
+			add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2);
168
+		}
169
+		// not a custom template?
170
+		if (
171
+			!post_password_required($post)
172
+			&& (
173
+				apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false)
174
+				|| EE_Registry::instance()
175
+					->load_core('Front_Controller')
176
+					->get_selected_template() !== 'single-espresso_events.php'
177
+			)
178
+
179
+		) {
180
+			EEH_Template::load_espresso_theme_functions();
181
+			// then add extra event data via hooks
182
+			add_action('loop_start', array('EED_Event_Single', 'loop_start'));
183
+			add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1);
184
+			add_filter(
185
+				'the_content',
186
+				array('EED_Event_Single', 'event_details'),
187
+				EED_Event_Single::EVENT_DETAILS_PRIORITY
188
+			);
189
+			add_action('loop_end', array('EED_Event_Single', 'loop_end'));
190
+			// don't display entry meta because the existing theme will take car of that
191
+			add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
192
+		}
193
+		return $template;
194
+	}
195
+
196
+
197
+	/**
198
+	 * loop_start
199
+	 *
200
+	 * @param    array $wp_query_array an array containing the WP_Query object
201
+	 * @return    void
202
+	 */
203
+	public static function loop_start($wp_query_array)
204
+	{
205
+		global $post;
206
+		do_action('AHEE_event_details_before_post', $post, $wp_query_array);
207
+	}
208
+
209
+
210
+	/**
211
+	 * the_title
212
+	 *
213
+	 * @param    string $title
214
+	 * @param    int $id
215
+	 * @return    string
216
+	 */
217
+	public static function the_title($title = '', $id = 0)
218
+	{
219
+		global $post;
220
+		return in_the_loop() && $post->ID === (int)$id
221
+			? espresso_event_status_banner($post->ID) . $title
222
+			: $title;
223
+	}
224
+
225
+
226
+	/**
227
+	 * get_the_excerpt
228
+	 * kinda hacky, but if a theme is using get_the_excerpt(),
229
+	 * then we need to remove our filters on the_content()
230
+	 *
231
+	 * @param        string $excerpt
232
+	 * @return        string
233
+	 */
234
+	public static function get_the_excerpt($excerpt = '')
235
+	{
236
+		EED_Event_Single::$using_get_the_excerpt = true;
237
+		add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1);
238
+		return $excerpt;
239
+	}
240
+
241
+
242
+	/**
243
+	 * end_get_the_excerpt
244
+	 *
245
+	 * @param  string $text
246
+	 * @return string
247
+	 */
248
+	public static function end_get_the_excerpt($text = '')
249
+	{
250
+		EED_Event_Single::$using_get_the_excerpt = false;
251
+		return $text;
252
+	}
253
+
254
+
255
+	/**
256
+	 * event_details
257
+	 *
258
+	 * @param    string $content
259
+	 * @return    string
260
+	 */
261
+	public static function event_details($content)
262
+	{
263
+		global $post;
264
+		static $current_post_ID = 0;
265
+		if (
266
+			$current_post_ID !== $post->ID
267
+			&& $post->post_type === 'espresso_events'
268
+			&& !EED_Event_Single::$using_get_the_excerpt
269
+			&& !post_password_required()
270
+		) {
271
+			// Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
272
+			// Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
273
+			// BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
274
+			// We want to allow those plugins to still do their thing and have access to our content, but depending on
275
+			// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
276
+			// so the following allows this filter to be applied multiple times, but only once for real
277
+			$current_post_ID = did_action('loop_start') ? $post->ID : 0;
278
+			if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) {
279
+				// we need to first remove this callback from being applied to the_content()
280
+				// (otherwise it will recurse and blow up the interweb)
281
+				remove_filter(
282
+					'the_content',
283
+					array('EED_Event_Single', 'event_details'),
284
+					EED_Event_Single::EVENT_DETAILS_PRIORITY
285
+				);
286
+				EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts();
287
+				$content = EEH_Template::locate_template('content-espresso_events-details.php');
288
+				$content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content);
289
+				add_filter(
290
+					'the_content',
291
+					array('EED_Event_Single', 'event_details'),
292
+					EED_Event_Single::EVENT_DETAILS_PRIORITY
293
+				);
294
+			} else {
295
+				$content = EED_Event_Single::use_filterable_display_order();
296
+			}
297
+		}
298
+		return $content;
299
+	}
300
+
301
+
302
+	/**
303
+	 * use_filterable_display_order
304
+	 *
305
+	 * @return string
306
+	 */
307
+	protected static function use_filterable_display_order()
308
+	{
309
+		// since the 'content-espresso_events-details.php' template might be used directly from within a theme,
310
+		// it uses the_content() for displaying the $post->post_content
311
+		// so in order to load a template that uses the_content()
312
+		// from within a callback being used to filter the_content(),
313
+		// we need to first remove this callback from being applied to the_content()
314
+		// (otherwise it will recurse and blow up the interweb)
315
+		remove_filter(
316
+			'the_content',
317
+			array('EED_Event_Single', 'event_details'),
318
+			EED_Event_Single::EVENT_DETAILS_PRIORITY
319
+		);
320
+		//now add additional content
321
+		add_filter(
322
+			'the_content',
323
+			array('EED_Event_Single', 'event_datetimes'),
324
+			EED_Event_Single::EVENT_DATETIMES_PRIORITY,
325
+			1
326
+		);
327
+		add_filter(
328
+			'the_content',
329
+			array('EED_Event_Single', 'event_tickets'),
330
+			EED_Event_Single::EVENT_TICKETS_PRIORITY,
331
+			1
332
+		);
333
+		add_filter(
334
+			'the_content',
335
+			array('EED_Event_Single', 'event_venues'),
336
+			EED_Event_Single::EVENT_VENUES_PRIORITY,
337
+			1
338
+		);
339
+		do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters');
340
+		// now load our template
341
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
342
+		//now add our filter back in, plus some others
343
+		add_filter(
344
+			'the_content',
345
+			array('EED_Event_Single', 'event_details'),
346
+			EED_Event_Single::EVENT_DETAILS_PRIORITY
347
+		);
348
+		remove_filter(
349
+			'the_content',
350
+			array('EED_Event_Single', 'event_datetimes'),
351
+			EED_Event_Single::EVENT_DATETIMES_PRIORITY
352
+		);
353
+		remove_filter(
354
+			'the_content',
355
+			array('EED_Event_Single', 'event_tickets'),
356
+			EED_Event_Single::EVENT_TICKETS_PRIORITY
357
+		);
358
+		remove_filter(
359
+			'the_content',
360
+			array('EED_Event_Single', 'event_venues'),
361
+			EED_Event_Single::EVENT_VENUES_PRIORITY
362
+		);
363
+		do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters');
364
+		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
365
+		return $content;
366
+	}
367
+
368
+
369
+	/**
370
+	 * event_datetimes - adds datetimes ABOVE content
371
+	 *
372
+	 * @param        string $content
373
+	 * @return        string
374
+	 */
375
+	public static function event_datetimes($content)
376
+	{
377
+		return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
378
+	}
379
+
380
+
381
+	/**
382
+	 * event_tickets - adds tickets ABOVE content (which includes datetimes)
383
+	 *
384
+	 * @param        string $content
385
+	 * @return        string
386
+	 */
387
+	public static function event_tickets($content)
388
+	{
389
+		return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
390
+	}
391
+
392
+
393
+	/**
394
+	 * event_venues
395
+	 *
396
+	 * @param    string $content
397
+	 * @return    string
398
+	 */
399
+	public static function event_venue($content)
400
+	{
401
+		return EED_Event_Single::event_venues($content);
402
+	}
403
+
404
+
405
+	/**
406
+	 * event_venues - adds venues BELOW content
407
+	 *
408
+	 * @param        string $content
409
+	 * @return        string
410
+	 */
411
+	public static function event_venues($content)
412
+	{
413
+		return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
414
+	}
415
+
416
+
417
+	/**
418
+	 * loop_end
419
+	 *
420
+	 * @param        array $wp_query_array an array containing the WP_Query object
421
+	 * @return        void
422
+	 */
423
+	public static function loop_end($wp_query_array)
424
+	{
425
+		global $post;
426
+		do_action('AHEE_event_details_after_post', $post, $wp_query_array);
427
+	}
428
+
429
+
430
+	/**
431
+	 * wp_enqueue_scripts
432
+	 *
433
+	 * @return    void
434
+	 */
435
+	public function wp_enqueue_scripts()
436
+	{
437
+		// get some style
438
+		if (
439
+			apply_filters('FHEE_enable_default_espresso_css', TRUE)
440
+			&& apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE)
441
+		) {
442
+			// first check uploads folder
443
+			if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) {
444
+				wp_register_style(
445
+					$this->theme,
446
+					get_stylesheet_directory_uri() . $this->theme . DS . 'style.css',
447
+					array('dashicons', 'espresso_default')
448
+				);
449
+			} else {
450
+				wp_register_style(
451
+					$this->theme,
452
+					EE_TEMPLATES_URL . $this->theme . DS . 'style.css',
453
+					array('dashicons', 'espresso_default')
454
+				);
455
+			}
456
+			wp_enqueue_script($this->theme);
457
+			if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
458
+				add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
459
+			}
460
+		}
461
+	}
462
+
463
+
464
+	/**
465
+	 * display_venue
466
+	 *
467
+	 * @return    bool
468
+	 */
469
+	public static function display_venue()
470
+	{
471
+		/** @type EE_Event_Single_Config $config */
472
+		$config = EED_Event_Single::instance()->config();
473
+		$display_venue = $config->display_venue === null ? true : $config->display_venue;
474
+		$venue_name = EEH_Venue_View::venue_name();
475
+		return $display_venue && !empty($venue_name);
476
+	}
477 477
 
478 478
 
479 479
 }
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
  */
488 488
 function espresso_display_venue_in_event_details()
489 489
 {
490
-    return EED_Event_Single::display_venue();
490
+	return EED_Event_Single::display_venue();
491 491
 }
492 492
 
493 493
 
Please login to merge, or discard this patch.
modules/events_archive/EED_Events_Archive.module.php 2 patches
Indentation   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class EED_Events_Archive  extends EED_Module {
16 16
 
17
-    const EVENT_DETAILS_PRIORITY = 100;
18
-    const EVENT_DATETIMES_PRIORITY = 110;
19
-    const EVENT_TICKETS_PRIORITY = 120;
20
-    const EVENT_VENUES_PRIORITY = 130;
17
+	const EVENT_DETAILS_PRIORITY = 100;
18
+	const EVENT_DATETIMES_PRIORITY = 110;
19
+	const EVENT_TICKETS_PRIORITY = 120;
20
+	const EVENT_VENUES_PRIORITY = 130;
21 21
 
22 22
 
23
-    public static $espresso_event_list_ID = 0;
23
+	public static $espresso_event_list_ID = 0;
24 24
 	public static $espresso_grid_event_lists = array();
25 25
 
26 26
 	/**
@@ -28,19 +28,19 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	protected static $using_get_the_excerpt = false;
30 30
 
31
-    /**
32
-     * Used to flag when the event list is being called from an external iframe.
33
-     *
34
-     * @var bool $iframe
35
-     */
36
-    protected static $iframe = false;
31
+	/**
32
+	 * Used to flag when the event list is being called from an external iframe.
33
+	 *
34
+	 * @var bool $iframe
35
+	 */
36
+	protected static $iframe = false;
37 37
 
38
-    /**
38
+	/**
39 39
 	 * @var \EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton $_iframe_embed_button
40 40
 	 */
41 41
 	private static $_iframe_embed_button;
42 42
 
43
-    /**
43
+	/**
44 44
 	 * @type EE_Template_Part_Manager $template_parts
45 45
 	 */
46 46
 	protected $template_parts;
@@ -63,24 +63,24 @@  discard block
 block discarded – undo
63 63
 	 *  @return 	void
64 64
 	 */
65 65
 	public static function set_hooks() {
66
-        $custom_post_types = EE_Register_CPTs::get_CPTs();
67
-        EE_Config::register_route(
68
-            $custom_post_types['espresso_events']['plural_slug'],
69
-            'Events_Archive',
70
-            'run'
71
-        );
72
-        EE_Config::register_route(
73
-            'event_list',
74
-            'Events_Archive',
75
-            'event_list'
76
-        );
77
-        EE_Config::register_route(
78
-            'iframe',
79
-            'Events_Archive',
80
-            'event_list_iframe',
81
-            'event_list'
82
-        );
83
-        add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 );
66
+		$custom_post_types = EE_Register_CPTs::get_CPTs();
67
+		EE_Config::register_route(
68
+			$custom_post_types['espresso_events']['plural_slug'],
69
+			'Events_Archive',
70
+			'run'
71
+		);
72
+		EE_Config::register_route(
73
+			'event_list',
74
+			'Events_Archive',
75
+			'event_list'
76
+		);
77
+		EE_Config::register_route(
78
+			'iframe',
79
+			'Events_Archive',
80
+			'event_list_iframe',
81
+			'event_list'
82
+		);
83
+		add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 );
84 84
 	}
85 85
 
86 86
 	/**
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 
225 225
 
226 226
 	/**
227
-     * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting
228
-     *
229
-     * @return    void
227
+	 * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting
228
+	 *
229
+	 * @return    void
230 230
 	 */
231 231
 	public function event_list() {
232 232
 		// ensure valid EE_Events_Archive_Config() object exists
@@ -237,36 +237,36 @@  discard block
 block discarded – undo
237 237
 
238 238
 
239 239
 
240
-    /**
241
-     * @access    public
242
-     * @return    void
243
-     * @throws \EE_Error
244
-     * @throws \DomainException
245
-     */
240
+	/**
241
+	 * @access    public
242
+	 * @return    void
243
+	 * @throws \EE_Error
244
+	 * @throws \DomainException
245
+	 */
246 246
 	public function event_list_iframe() {
247
-        \EED_Events_Archive::$iframe = true;
247
+		\EED_Events_Archive::$iframe = true;
248 248
 		$event_list_iframe = new EventsArchiveIframe( $this );
249 249
 		$event_list_iframe->display();
250 250
 	}
251 251
 
252 252
 
253 253
 
254
-    /**
255
-     * @access public
256
-     * @return string
257
-     */
254
+	/**
255
+	 * @access public
256
+	 * @return string
257
+	 */
258 258
 	public static function is_iframe() {
259
-        return \EED_Events_Archive::$iframe;
259
+		return \EED_Events_Archive::$iframe;
260 260
 	}
261 261
 
262 262
 
263 263
 
264
-    /**
265
-     * @access public
266
-     * @return string
267
-     */
264
+	/**
265
+	 * @access public
266
+	 * @return string
267
+	 */
268 268
 	public static function link_target() {
269
-        return \EED_Events_Archive::$iframe ? ' target="_blank"' : '';
269
+		return \EED_Events_Archive::$iframe ? ' target="_blank"' : '';
270 270
 	}
271 271
 
272 272
 
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 			}
295 295
 			// if NOT a custom template
296 296
 			if (
297
-                apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
297
+				apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
298 298
 				|| EE_Registry::instance()
299
-                    ->load_core( 'Front_Controller' )
300
-                    ->get_selected_template() !== 'archive-espresso_events.php'
299
+					->load_core( 'Front_Controller' )
300
+					->get_selected_template() !== 'archive-espresso_events.php'
301 301
 			) {
302 302
 				// don't display entry meta because the existing theme will take care of that
303 303
 				add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' );
@@ -305,16 +305,16 @@  discard block
 block discarded – undo
305 305
 				EEH_Template::load_espresso_theme_functions();
306 306
 				// because we don't know if the theme is using the_excerpt()
307 307
 				add_filter(
308
-				    'the_excerpt',
309
-                    array( 'EED_Events_Archive', 'event_details' ),
310
-                    EED_Events_Archive::EVENT_DETAILS_PRIORITY
311
-                );
308
+					'the_excerpt',
309
+					array( 'EED_Events_Archive', 'event_details' ),
310
+					EED_Events_Archive::EVENT_DETAILS_PRIORITY
311
+				);
312 312
 				// or the_content
313 313
 				add_filter(
314
-				    'the_content',
315
-                    array( 'EED_Events_Archive', 'event_details' ),
316
-                    EED_Events_Archive::EVENT_DETAILS_PRIORITY
317
-                );
314
+					'the_content',
315
+					array( 'EED_Events_Archive', 'event_details' ),
316
+					EED_Events_Archive::EVENT_DETAILS_PRIORITY
317
+				);
318 318
 				// and just in case they are running get_the_excerpt() which DESTROYS things
319 319
 				add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
320 320
 				// don't display entry meta because the existing theme will take care of that
@@ -339,15 +339,15 @@  discard block
 block discarded – undo
339 339
 		}
340 340
 		if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) {
341 341
 			remove_filter(
342
-			    'the_excerpt',
343
-                array( 'EED_Events_Archive', 'event_details' ),
344
-                EED_Events_Archive::EVENT_DETAILS_PRIORITY
345
-            );
342
+				'the_excerpt',
343
+				array( 'EED_Events_Archive', 'event_details' ),
344
+				EED_Events_Archive::EVENT_DETAILS_PRIORITY
345
+			);
346 346
 			remove_filter(
347
-			    'the_content',
348
-                array( 'EED_Events_Archive', 'event_details' ),
349
-                EED_Events_Archive::EVENT_DETAILS_PRIORITY
350
-            );
347
+				'the_content',
348
+				array( 'EED_Events_Archive', 'event_details' ),
349
+				EED_Events_Archive::EVENT_DETAILS_PRIORITY
350
+			);
351 351
 			$excerpt = EED_Events_Archive::event_details( $excerpt );
352 352
 		} else {
353 353
 			EED_Events_Archive::$using_get_the_excerpt = true;
@@ -438,17 +438,17 @@  discard block
 block discarded – undo
438 438
 		// no further password checks required atm
439 439
 		add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' );
440 440
 		// we need to first remove this callback from being applied to the_content() or the_excerpt()
441
-        // (otherwise it will recurse and blow up the interweb)
441
+		// (otherwise it will recurse and blow up the interweb)
442 442
 		remove_filter(
443
-		    'the_excerpt',
444
-            array( 'EED_Events_Archive', 'event_details' ),
445
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
446
-        );
443
+			'the_excerpt',
444
+			array( 'EED_Events_Archive', 'event_details' ),
445
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
446
+		);
447 447
 		remove_filter(
448
-		    'the_content',
449
-            array( 'EED_Events_Archive', 'event_details' ),
450
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
451
-        );
448
+			'the_content',
449
+			array( 'EED_Events_Archive', 'event_details' ),
450
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
451
+		);
452 452
 		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
453 453
 		// now add additional content depending on whether event is using the_excerpt() or the_content()
454 454
 		EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts();
@@ -456,20 +456,20 @@  discard block
 block discarded – undo
456 456
 		$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content );
457 457
 		// re-add our main filters (or else the next event won't have them)
458 458
 		add_filter(
459
-		    'the_excerpt',
460
-            array( 'EED_Events_Archive', 'event_details' ),
461
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
462
-        );
459
+			'the_excerpt',
460
+			array( 'EED_Events_Archive', 'event_details' ),
461
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
462
+		);
463 463
 		add_filter(
464
-		    'the_content',
465
-            array( 'EED_Events_Archive', 'event_details' ),
466
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
467
-        );
464
+			'the_content',
465
+			array( 'EED_Events_Archive', 'event_details' ),
466
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
467
+		);
468 468
 		add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
469 469
 		remove_filter(
470
-		    'FHEE__EED_Events_Archive__event_details__no_post_password_required',
471
-            '__return_true'
472
-        );
470
+			'FHEE__EED_Events_Archive__event_details__no_post_password_required',
471
+			'__return_true'
472
+		);
473 473
 		return $content;
474 474
 	}
475 475
 
@@ -485,15 +485,15 @@  discard block
 block discarded – undo
485 485
 		// we need to first remove this callback from being applied to the_content()
486 486
 		// (otherwise it will recurse and blow up the interweb)
487 487
 		remove_filter(
488
-		    'the_excerpt',
489
-            array( 'EED_Events_Archive', 'event_details' ),
490
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
491
-        );
488
+			'the_excerpt',
489
+			array( 'EED_Events_Archive', 'event_details' ),
490
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
491
+		);
492 492
 		remove_filter(
493
-		    'the_content',
494
-            array( 'EED_Events_Archive', 'event_details' ),
495
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
496
-        );
493
+			'the_content',
494
+			array( 'EED_Events_Archive', 'event_details' ),
495
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
496
+		);
497 497
 		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
498 498
 		//now add additional content depending on whether event is using the_excerpt() or the_content()
499 499
 		EED_Events_Archive::_add_additional_excerpt_filters();
@@ -503,15 +503,15 @@  discard block
 block discarded – undo
503 503
 		$content = EEH_Template::locate_template( 'content-espresso_events-details.php' );
504 504
 		// re-add our main filters (or else the next event won't have them)
505 505
 		add_filter(
506
-		    'the_excerpt',
507
-            array( 'EED_Events_Archive', 'event_details' ),
508
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
509
-        );
506
+			'the_excerpt',
507
+			array( 'EED_Events_Archive', 'event_details' ),
508
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
509
+		);
510 510
 		add_filter(
511
-		    'the_content',
512
-            array( 'EED_Events_Archive', 'event_details' ),
513
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
514
-        );
511
+			'the_content',
512
+			array( 'EED_Events_Archive', 'event_details' ),
513
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
514
+		);
515 515
 		add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
516 516
 		// but remove the other filters so that they don't get applied to the next post
517 517
 		EED_Events_Archive::_remove_additional_events_archive_filters();
@@ -588,20 +588,20 @@  discard block
 block discarded – undo
588 588
 	 */
589 589
 	private static function _add_additional_excerpt_filters() {
590 590
 		add_filter(
591
-		    'the_excerpt',
592
-            array( 'EED_Events_Archive', 'event_datetimes' ),
593
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
594
-        );
591
+			'the_excerpt',
592
+			array( 'EED_Events_Archive', 'event_datetimes' ),
593
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
594
+		);
595 595
 		add_filter(
596
-		    'the_excerpt',
597
-            array( 'EED_Events_Archive', 'event_tickets' ),
598
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
599
-        );
596
+			'the_excerpt',
597
+			array( 'EED_Events_Archive', 'event_tickets' ),
598
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
599
+		);
600 600
 		add_filter(
601
-		    'the_excerpt',
602
-            array( 'EED_Events_Archive', 'event_venues' ),
603
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
604
-        );
601
+			'the_excerpt',
602
+			array( 'EED_Events_Archive', 'event_venues' ),
603
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
604
+		);
605 605
 	}
606 606
 
607 607
 
@@ -614,20 +614,20 @@  discard block
 block discarded – undo
614 614
 	 */
615 615
 	private static function _add_additional_content_filters() {
616 616
 		add_filter(
617
-		    'the_content',
618
-            array( 'EED_Events_Archive', 'event_datetimes' ),
619
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
620
-        );
617
+			'the_content',
618
+			array( 'EED_Events_Archive', 'event_datetimes' ),
619
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
620
+		);
621 621
 		add_filter(
622
-		    'the_content',
623
-            array( 'EED_Events_Archive', 'event_tickets' ),
624
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
625
-        );
622
+			'the_content',
623
+			array( 'EED_Events_Archive', 'event_tickets' ),
624
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
625
+		);
626 626
 		add_filter(
627
-		    'the_content',
628
-            array( 'EED_Events_Archive', 'event_venues' ),
629
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
630
-        );
627
+			'the_content',
628
+			array( 'EED_Events_Archive', 'event_venues' ),
629
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
630
+		);
631 631
 	}
632 632
 
633 633
 
@@ -640,35 +640,35 @@  discard block
 block discarded – undo
640 640
 	 */
641 641
 	private static function _remove_additional_events_archive_filters() {
642 642
 		remove_filter(
643
-		    'the_excerpt',
644
-            array( 'EED_Events_Archive', 'event_datetimes' ),
645
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
646
-        );
643
+			'the_excerpt',
644
+			array( 'EED_Events_Archive', 'event_datetimes' ),
645
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
646
+		);
647 647
 		remove_filter(
648
-		    'the_excerpt',
649
-            array( 'EED_Events_Archive', 'event_tickets' ),
650
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
651
-        );
648
+			'the_excerpt',
649
+			array( 'EED_Events_Archive', 'event_tickets' ),
650
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
651
+		);
652 652
 		remove_filter(
653
-		    'the_excerpt',
654
-            array( 'EED_Events_Archive', 'event_venues' ),
655
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
656
-        );
653
+			'the_excerpt',
654
+			array( 'EED_Events_Archive', 'event_venues' ),
655
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
656
+		);
657 657
 		remove_filter(
658
-		    'the_content',
659
-            array( 'EED_Events_Archive', 'event_datetimes' ),
660
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
661
-        );
658
+			'the_content',
659
+			array( 'EED_Events_Archive', 'event_datetimes' ),
660
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
661
+		);
662 662
 		remove_filter(
663
-		    'the_content',
664
-            array( 'EED_Events_Archive', 'event_tickets' ),
665
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
666
-        );
663
+			'the_content',
664
+			array( 'EED_Events_Archive', 'event_tickets' ),
665
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
666
+		);
667 667
 		remove_filter(
668
-		    'the_content',
669
-            array( 'EED_Events_Archive', 'event_venues' ),
670
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
671
-        );
668
+			'the_content',
669
+			array( 'EED_Events_Archive', 'event_venues' ),
670
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
671
+		);
672 672
 	}
673 673
 
674 674
 
@@ -683,50 +683,50 @@  discard block
 block discarded – undo
683 683
 		//remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
684 684
 		remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 1 );
685 685
 		remove_filter(
686
-		    'the_excerpt',
687
-            array( 'EED_Events_Archive', 'event_details' ),
688
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
689
-        );
686
+			'the_excerpt',
687
+			array( 'EED_Events_Archive', 'event_details' ),
688
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
689
+		);
690 690
 		remove_filter(
691
-		    'the_excerpt',
692
-            array( 'EED_Events_Archive', 'event_datetimes' ),
693
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
694
-        );
691
+			'the_excerpt',
692
+			array( 'EED_Events_Archive', 'event_datetimes' ),
693
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
694
+		);
695 695
 		remove_filter(
696
-		    'the_excerpt',
697
-            array( 'EED_Events_Archive', 'event_tickets' ),
698
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
699
-        );
696
+			'the_excerpt',
697
+			array( 'EED_Events_Archive', 'event_tickets' ),
698
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
699
+		);
700 700
 		remove_filter(
701
-		    'the_excerpt',
702
-            array( 'EED_Events_Archive', 'event_venues' ),
703
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
704
-        );
701
+			'the_excerpt',
702
+			array( 'EED_Events_Archive', 'event_venues' ),
703
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
704
+		);
705 705
 		remove_filter(
706
-		    'the_content',
707
-            array( 'EED_Events_Archive', 'event_details' ),
708
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
709
-        );
706
+			'the_content',
707
+			array( 'EED_Events_Archive', 'event_details' ),
708
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
709
+		);
710 710
 		remove_filter(
711
-		    'the_content',
712
-            array( 'EED_Events_Archive', 'event_datetimes' ),
713
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
714
-        );
711
+			'the_content',
712
+			array( 'EED_Events_Archive', 'event_datetimes' ),
713
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
714
+		);
715 715
 		remove_filter(
716
-		    'the_content',
717
-            array( 'EED_Events_Archive', 'event_tickets' ),
718
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
719
-        );
716
+			'the_content',
717
+			array( 'EED_Events_Archive', 'event_tickets' ),
718
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
719
+		);
720 720
 		remove_filter(
721
-		    'the_content',
722
-            array( 'EED_Events_Archive', 'event_venues' ),
723
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
724
-        );
721
+			'the_content',
722
+			array( 'EED_Events_Archive', 'event_venues' ),
723
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
724
+		);
725 725
 		// don't display entry meta because the existing theme will take care of that
726 726
 		remove_filter(
727
-		    'FHEE__content_espresso_events_details_template__display_entry_meta',
728
-            '__return_false'
729
-        );
727
+			'FHEE__content_espresso_events_details_template__display_entry_meta',
728
+			'__return_false'
729
+		);
730 730
 	}
731 731
 
732 732
 
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 	 *  @return 	void
742 742
 	 */
743 743
 	public function load_event_list_assets() {
744
-        do_action( 'AHEE__EED_Events_Archive__before_load_assets' );
744
+		do_action( 'AHEE__EED_Events_Archive__before_load_assets' );
745 745
 		add_filter( 'FHEE_load_EE_Session', '__return_true' );
746 746
 		add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' );
747 747
 		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 );
Please login to merge, or discard this patch.
Spacing   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton;
4 4
 use EventEspresso\modules\events_archive\EventsArchiveIframe;
5 5
 
6
-defined( 'EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed');
6
+defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed');
7 7
 
8 8
 /**
9 9
  * Event List
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @return EED_Events_Archive
52 52
 	 */
53 53
 	public static function instance() {
54
-		return parent::get_instance( __CLASS__ );
54
+		return parent::get_instance(__CLASS__);
55 55
 	}
56 56
 
57 57
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
             'event_list_iframe',
81 81
             'event_list'
82 82
         );
83
-        add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 );
83
+        add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
84 84
 	}
85 85
 
86 86
 	/**
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
 	 *  @return 	void
91 91
 	 */
92 92
 	public static function set_hooks_admin() {
93
-		add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 );
93
+		add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
94 94
 		// hook into the end of the \EE_Admin_Page::_load_page_dependencies()
95 95
 		// to load assets for "espresso_events" page on the "default" route (action)
96 96
 		add_action(
97 97
 			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default',
98
-			array( 'EED_Events_Archive', 'event_list_iframe_embed_button' ),
98
+			array('EED_Events_Archive', 'event_list_iframe_embed_button'),
99 99
 			10
100 100
 		);
101 101
 	}
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	 *  @return 	void
111 111
 	 */
112 112
 	public static function set_definitions() {
113
-		define( 'EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
114
-		define( 'EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
113
+		define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
114
+		define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
115 115
 	}
116 116
 
117 117
 
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
 	/**
120 120
 	 * set up EE_Events_Archive_Config
121 121
 	 */
122
-	protected function set_config(){
123
-		$this->set_config_section( 'template_settings' );
124
-		$this->set_config_class( 'EE_Events_Archive_Config' );
125
-		$this->set_config_name( 'EED_Events_Archive' );
122
+	protected function set_config() {
123
+		$this->set_config_section('template_settings');
124
+		$this->set_config_class('EE_Events_Archive_Config');
125
+		$this->set_config_name('EED_Events_Archive');
126 126
 	}
127 127
 
128 128
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @return EventListIframeEmbedButton
132 132
 	 */
133 133
 	public static function get_iframe_embed_button() {
134
-		if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton ) {
134
+		if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
135 135
 			self::$_iframe_embed_button = new EventListIframeEmbedButton();
136 136
 		}
137 137
 		return self::$_iframe_embed_button;
@@ -157,35 +157,35 @@  discard block
 block discarded – undo
157 157
 	 * @param \EE_Events_Archive_Config $config
158 158
 	 * @return \EE_Template_Part_Manager
159 159
 	 */
160
-	public function initialize_template_parts( EE_Events_Archive_Config $config = null ) {
160
+	public function initialize_template_parts(EE_Events_Archive_Config $config = null) {
161 161
 		$config = $config instanceof EE_Events_Archive_Config ? $config : $this->config();
162 162
 		EEH_Autoloader::instance()->register_template_part_autoloaders();
163 163
 		$template_parts = new EE_Template_Part_Manager();
164 164
 		$template_parts->add_template_part(
165 165
 			'tickets',
166
-			__( 'Ticket Selector', 'event_espresso' ),
166
+			__('Ticket Selector', 'event_espresso'),
167 167
 			'content-espresso_events-tickets.php',
168 168
 			$config->display_order_tickets
169 169
 		);
170 170
 		$template_parts->add_template_part(
171 171
 			'datetimes',
172
-			__( 'Dates and Times', 'event_espresso' ),
172
+			__('Dates and Times', 'event_espresso'),
173 173
 			'content-espresso_events-datetimes.php',
174 174
 			$config->display_order_datetimes
175 175
 		);
176 176
 		$template_parts->add_template_part(
177 177
 			'event',
178
-			__( 'Event Description', 'event_espresso' ),
178
+			__('Event Description', 'event_espresso'),
179 179
 			'content-espresso_events-details.php',
180 180
 			$config->display_order_event
181 181
 		);
182 182
 		$template_parts->add_template_part(
183 183
 			'venue',
184
-			__( 'Venue Information', 'event_espresso' ),
184
+			__('Venue Information', 'event_espresso'),
185 185
 			'content-espresso_events-venues.php',
186 186
 			$config->display_order_venue
187 187
 		);
188
-		do_action( 'AHEE__EED_Event_Archive__initialize_template_parts', $template_parts );
188
+		do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts);
189 189
 		return $template_parts;
190 190
 	}
191 191
 
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 	 * @param WP $WP
199 199
 	 * @return    void
200 200
 	 */
201
-	public function run( $WP ) {
202
-		do_action( 'AHEE__EED_Events_Archive__before_run' );
201
+	public function run($WP) {
202
+		do_action('AHEE__EED_Events_Archive__before_run');
203 203
 		// ensure valid EE_Events_Archive_Config() object exists
204 204
 		$this->set_config();
205 205
 		/** @type EE_Events_Archive_Config $config */
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
 		EEH_Event_Query::add_query_filters();
212 212
 		// set params that will get used by the filters
213 213
 		EEH_Event_Query::set_query_params(
214
-			'', 	// month
215
-			'', 	// category
216
-			$config->display_expired_events, 	// show_expired
217
-			'start_date', 	// orderby
214
+			'', // month
215
+			'', // category
216
+			$config->display_expired_events, // show_expired
217
+			'start_date', // orderby
218 218
 			'ASC' 	// sort
219 219
 		);
220 220
 		// check what template is loaded
221
-		add_filter( 'template_include',  array( $this, 'template_include' ), 999, 1 );
221
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
222 222
 	}
223 223
 
224 224
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
      */
246 246
 	public function event_list_iframe() {
247 247
         \EED_Events_Archive::$iframe = true;
248
-		$event_list_iframe = new EventsArchiveIframe( $this );
248
+		$event_list_iframe = new EventsArchiveIframe($this);
249 249
 		$event_list_iframe->display();
250 250
 	}
251 251
 
@@ -283,42 +283,42 @@  discard block
 block discarded – undo
283 283
 	 * @param string $template
284 284
 	 * @return    string
285 285
 	 */
286
-	public function template_include( $template = '' ) {
286
+	public function template_include($template = '') {
287 287
 		// don't add content filter for dedicated EE child themes or private posts
288
-		if ( ! EEH_Template::is_espresso_theme() ) {
288
+		if ( ! EEH_Template::is_espresso_theme()) {
289 289
 			/** @type EE_Events_Archive_Config $config */
290 290
 			$config = $this->config();
291 291
 			// add status banner ?
292
-			if ( $config->display_status_banner ) {
293
-				add_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100, 2 );
292
+			if ($config->display_status_banner) {
293
+				add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2);
294 294
 			}
295 295
 			// if NOT a custom template
296 296
 			if (
297 297
                 apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
298 298
 				|| EE_Registry::instance()
299
-                    ->load_core( 'Front_Controller' )
299
+                    ->load_core('Front_Controller')
300 300
                     ->get_selected_template() !== 'archive-espresso_events.php'
301 301
 			) {
302 302
 				// don't display entry meta because the existing theme will take care of that
303
-				add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' );
303
+				add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true');
304 304
 			// load functions.php file for the theme (loaded by WP if using child theme)
305 305
 				EEH_Template::load_espresso_theme_functions();
306 306
 				// because we don't know if the theme is using the_excerpt()
307 307
 				add_filter(
308 308
 				    'the_excerpt',
309
-                    array( 'EED_Events_Archive', 'event_details' ),
309
+                    array('EED_Events_Archive', 'event_details'),
310 310
                     EED_Events_Archive::EVENT_DETAILS_PRIORITY
311 311
                 );
312 312
 				// or the_content
313 313
 				add_filter(
314 314
 				    'the_content',
315
-                    array( 'EED_Events_Archive', 'event_details' ),
315
+                    array('EED_Events_Archive', 'event_details'),
316 316
                     EED_Events_Archive::EVENT_DETAILS_PRIORITY
317 317
                 );
318 318
 				// and just in case they are running get_the_excerpt() which DESTROYS things
319
-				add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
319
+				add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
320 320
 				// don't display entry meta because the existing theme will take care of that
321
-				add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' );
321
+				add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
322 322
 			}
323 323
 		}
324 324
 		return $template;
@@ -333,25 +333,25 @@  discard block
 block discarded – undo
333 333
 	 * 	@param		string 	$excerpt
334 334
 	 * 	@return 		string
335 335
 	 */
336
-	public static function get_the_excerpt( $excerpt = '' ) {
337
-		if ( post_password_required() ) {
336
+	public static function get_the_excerpt($excerpt = '') {
337
+		if (post_password_required()) {
338 338
 			return $excerpt;
339 339
 		}
340
-		if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) {
340
+		if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) {
341 341
 			remove_filter(
342 342
 			    'the_excerpt',
343
-                array( 'EED_Events_Archive', 'event_details' ),
343
+                array('EED_Events_Archive', 'event_details'),
344 344
                 EED_Events_Archive::EVENT_DETAILS_PRIORITY
345 345
             );
346 346
 			remove_filter(
347 347
 			    'the_content',
348
-                array( 'EED_Events_Archive', 'event_details' ),
348
+                array('EED_Events_Archive', 'event_details'),
349 349
                 EED_Events_Archive::EVENT_DETAILS_PRIORITY
350 350
             );
351
-			$excerpt = EED_Events_Archive::event_details( $excerpt );
351
+			$excerpt = EED_Events_Archive::event_details($excerpt);
352 352
 		} else {
353 353
 			EED_Events_Archive::$using_get_the_excerpt = true;
354
-			add_filter( 'wp_trim_excerpt', array( 'EED_Events_Archive', 'end_get_the_excerpt' ), 999, 1 );
354
+			add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1);
355 355
 		}
356 356
 		return $excerpt;
357 357
 	}
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 * @param  string $text
366 366
 	 * @return string
367 367
 	 */
368
-	public static function end_get_the_excerpt( $text = '' ) {
368
+	public static function end_get_the_excerpt($text = '') {
369 369
 		EED_Events_Archive::$using_get_the_excerpt = false;
370 370
 		return $text;
371 371
 	}
@@ -380,10 +380,10 @@  discard block
 block discarded – undo
380 380
 	 * @param 		string 		$id
381 381
 	 * @return 		string
382 382
 	 */
383
-	public static function the_title( $title = '', $id = '' ) {
383
+	public static function the_title($title = '', $id = '') {
384 384
 	global $post;
385
-	if ( $post instanceof WP_Post ) {
386
-		return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID  ) . $title :  $title;
385
+	if ($post instanceof WP_Post) {
386
+		return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title;
387 387
 	}
388 388
 	return $title;
389 389
 }
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 	 * 	@param		string 	$content
398 398
 	 * 	@return 		string
399 399
 	 */
400
-	public static function event_details( $content ) {
400
+	public static function event_details($content) {
401 401
 		global $post;
402 402
 		static $current_post_ID = 0;
403 403
 		if (
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
 			&& ! EED_Events_Archive::$using_get_the_excerpt
407 407
 			&& ! post_password_required()
408 408
 			&& (
409
-				apply_filters( 'FHEE__EES_Espresso_Events__process_shortcode__true', false )
410
-				|| ! apply_filters( 'FHEE__content_espresso_events__template_loaded', false )
409
+				apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false)
410
+				|| ! apply_filters('FHEE__content_espresso_events__template_loaded', false)
411 411
 			)
412 412
 		) {
413 413
 			// Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 			// We want to allow those plugins to still do their thing and have access to our content, but depending on
417 417
 			// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
418 418
 			// so the following allows this filter to be applied multiple times, but only once for real
419
-			$current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0;
420
-			if ( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order ) {
419
+			$current_post_ID = did_action('loop_start') ? $post->ID : 0;
420
+			if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) {
421 421
 				$content = \EED_Events_Archive::use_sortable_display_order();
422 422
 			} else {
423 423
 				$content = \EED_Events_Archive::use_filterable_display_order();
@@ -436,36 +436,36 @@  discard block
 block discarded – undo
436 436
 	 */
437 437
 	protected static function use_sortable_display_order() {
438 438
 		// no further password checks required atm
439
-		add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' );
439
+		add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true');
440 440
 		// we need to first remove this callback from being applied to the_content() or the_excerpt()
441 441
         // (otherwise it will recurse and blow up the interweb)
442 442
 		remove_filter(
443 443
 		    'the_excerpt',
444
-            array( 'EED_Events_Archive', 'event_details' ),
444
+            array('EED_Events_Archive', 'event_details'),
445 445
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
446 446
         );
447 447
 		remove_filter(
448 448
 		    'the_content',
449
-            array( 'EED_Events_Archive', 'event_details' ),
449
+            array('EED_Events_Archive', 'event_details'),
450 450
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
451 451
         );
452
-		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
452
+		remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
453 453
 		// now add additional content depending on whether event is using the_excerpt() or the_content()
454 454
 		EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts();
455
-		$content = EEH_Template::locate_template( 'content-espresso_events-details.php' );
456
-		$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content );
455
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
456
+		$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content);
457 457
 		// re-add our main filters (or else the next event won't have them)
458 458
 		add_filter(
459 459
 		    'the_excerpt',
460
-            array( 'EED_Events_Archive', 'event_details' ),
460
+            array('EED_Events_Archive', 'event_details'),
461 461
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
462 462
         );
463 463
 		add_filter(
464 464
 		    'the_content',
465
-            array( 'EED_Events_Archive', 'event_details' ),
465
+            array('EED_Events_Archive', 'event_details'),
466 466
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
467 467
         );
468
-		add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
468
+		add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
469 469
 		remove_filter(
470 470
 		    'FHEE__EED_Events_Archive__event_details__no_post_password_required',
471 471
             '__return_true'
@@ -486,36 +486,36 @@  discard block
 block discarded – undo
486 486
 		// (otherwise it will recurse and blow up the interweb)
487 487
 		remove_filter(
488 488
 		    'the_excerpt',
489
-            array( 'EED_Events_Archive', 'event_details' ),
489
+            array('EED_Events_Archive', 'event_details'),
490 490
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
491 491
         );
492 492
 		remove_filter(
493 493
 		    'the_content',
494
-            array( 'EED_Events_Archive', 'event_details' ),
494
+            array('EED_Events_Archive', 'event_details'),
495 495
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
496 496
         );
497
-		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
497
+		remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
498 498
 		//now add additional content depending on whether event is using the_excerpt() or the_content()
499 499
 		EED_Events_Archive::_add_additional_excerpt_filters();
500 500
 		EED_Events_Archive::_add_additional_content_filters();
501
-		do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters' );
501
+		do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters');
502 502
 		// now load our template
503
-		$content = EEH_Template::locate_template( 'content-espresso_events-details.php' );
503
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
504 504
 		// re-add our main filters (or else the next event won't have them)
505 505
 		add_filter(
506 506
 		    'the_excerpt',
507
-            array( 'EED_Events_Archive', 'event_details' ),
507
+            array('EED_Events_Archive', 'event_details'),
508 508
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
509 509
         );
510 510
 		add_filter(
511 511
 		    'the_content',
512
-            array( 'EED_Events_Archive', 'event_details' ),
512
+            array('EED_Events_Archive', 'event_details'),
513 513
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
514 514
         );
515
-		add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
515
+		add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
516 516
 		// but remove the other filters so that they don't get applied to the next post
517 517
 		EED_Events_Archive::_remove_additional_events_archive_filters();
518
-		do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters' );
518
+		do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters');
519 519
 		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
520 520
 		//return ! empty( $template ) ? $template : $content;
521 521
 		return $content;
@@ -530,11 +530,11 @@  discard block
 block discarded – undo
530 530
 	 * 	@param		string 	$content
531 531
 	 *  	@return 		string
532 532
 	 */
533
-	public static function event_datetimes( $content ) {
534
-		if ( post_password_required() ) {
533
+	public static function event_datetimes($content) {
534
+		if (post_password_required()) {
535 535
 			return $content;
536 536
 		}
537
-		return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content;
537
+		return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content;
538 538
 	}
539 539
 
540 540
 	/**
@@ -544,11 +544,11 @@  discard block
 block discarded – undo
544 544
 	 * 	@param		string 	$content
545 545
 	 *  	@return 		string
546 546
 	 */
547
-	public static function event_tickets( $content ) {
548
-		if ( post_password_required() ) {
547
+	public static function event_tickets($content) {
548
+		if (post_password_required()) {
549 549
 			return $content;
550 550
 		}
551
-		return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content;
551
+		return EEH_Template::locate_template('content-espresso_events-tickets.php').$content;
552 552
 	}
553 553
 
554 554
 
@@ -560,8 +560,8 @@  discard block
 block discarded – undo
560 560
 	 * @param    string $content
561 561
 	 * @return    string
562 562
 	 */
563
-	public static function event_venue( $content ) {
564
-		return EED_Events_Archive::event_venues( $content );
563
+	public static function event_venue($content) {
564
+		return EED_Events_Archive::event_venues($content);
565 565
 	}
566 566
 
567 567
 	/**
@@ -571,11 +571,11 @@  discard block
 block discarded – undo
571 571
 	 * 	@param		string 	$content
572 572
 	 *  	@return 		string
573 573
 	 */
574
-	public static function event_venues( $content ) {
575
-		if ( post_password_required() ) {
574
+	public static function event_venues($content) {
575
+		if (post_password_required()) {
576 576
 			return $content;
577 577
 		}
578
-		return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' );
578
+		return $content.EEH_Template::locate_template('content-espresso_events-venues.php');
579 579
 	}
580 580
 
581 581
 
@@ -589,17 +589,17 @@  discard block
 block discarded – undo
589 589
 	private static function _add_additional_excerpt_filters() {
590 590
 		add_filter(
591 591
 		    'the_excerpt',
592
-            array( 'EED_Events_Archive', 'event_datetimes' ),
592
+            array('EED_Events_Archive', 'event_datetimes'),
593 593
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
594 594
         );
595 595
 		add_filter(
596 596
 		    'the_excerpt',
597
-            array( 'EED_Events_Archive', 'event_tickets' ),
597
+            array('EED_Events_Archive', 'event_tickets'),
598 598
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
599 599
         );
600 600
 		add_filter(
601 601
 		    'the_excerpt',
602
-            array( 'EED_Events_Archive', 'event_venues' ),
602
+            array('EED_Events_Archive', 'event_venues'),
603 603
             EED_Events_Archive::EVENT_VENUES_PRIORITY
604 604
         );
605 605
 	}
@@ -615,17 +615,17 @@  discard block
 block discarded – undo
615 615
 	private static function _add_additional_content_filters() {
616 616
 		add_filter(
617 617
 		    'the_content',
618
-            array( 'EED_Events_Archive', 'event_datetimes' ),
618
+            array('EED_Events_Archive', 'event_datetimes'),
619 619
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
620 620
         );
621 621
 		add_filter(
622 622
 		    'the_content',
623
-            array( 'EED_Events_Archive', 'event_tickets' ),
623
+            array('EED_Events_Archive', 'event_tickets'),
624 624
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
625 625
         );
626 626
 		add_filter(
627 627
 		    'the_content',
628
-            array( 'EED_Events_Archive', 'event_venues' ),
628
+            array('EED_Events_Archive', 'event_venues'),
629 629
             EED_Events_Archive::EVENT_VENUES_PRIORITY
630 630
         );
631 631
 	}
@@ -641,32 +641,32 @@  discard block
 block discarded – undo
641 641
 	private static function _remove_additional_events_archive_filters() {
642 642
 		remove_filter(
643 643
 		    'the_excerpt',
644
-            array( 'EED_Events_Archive', 'event_datetimes' ),
644
+            array('EED_Events_Archive', 'event_datetimes'),
645 645
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
646 646
         );
647 647
 		remove_filter(
648 648
 		    'the_excerpt',
649
-            array( 'EED_Events_Archive', 'event_tickets' ),
649
+            array('EED_Events_Archive', 'event_tickets'),
650 650
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
651 651
         );
652 652
 		remove_filter(
653 653
 		    'the_excerpt',
654
-            array( 'EED_Events_Archive', 'event_venues' ),
654
+            array('EED_Events_Archive', 'event_venues'),
655 655
             EED_Events_Archive::EVENT_VENUES_PRIORITY
656 656
         );
657 657
 		remove_filter(
658 658
 		    'the_content',
659
-            array( 'EED_Events_Archive', 'event_datetimes' ),
659
+            array('EED_Events_Archive', 'event_datetimes'),
660 660
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
661 661
         );
662 662
 		remove_filter(
663 663
 		    'the_content',
664
-            array( 'EED_Events_Archive', 'event_tickets' ),
664
+            array('EED_Events_Archive', 'event_tickets'),
665 665
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
666 666
         );
667 667
 		remove_filter(
668 668
 		    'the_content',
669
-            array( 'EED_Events_Archive', 'event_venues' ),
669
+            array('EED_Events_Archive', 'event_venues'),
670 670
             EED_Events_Archive::EVENT_VENUES_PRIORITY
671 671
         );
672 672
 	}
@@ -681,45 +681,45 @@  discard block
 block discarded – undo
681 681
 	 */
682 682
 	public static function remove_all_events_archive_filters() {
683 683
 		//remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
684
-		remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 1 );
684
+		remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1);
685 685
 		remove_filter(
686 686
 		    'the_excerpt',
687
-            array( 'EED_Events_Archive', 'event_details' ),
687
+            array('EED_Events_Archive', 'event_details'),
688 688
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
689 689
         );
690 690
 		remove_filter(
691 691
 		    'the_excerpt',
692
-            array( 'EED_Events_Archive', 'event_datetimes' ),
692
+            array('EED_Events_Archive', 'event_datetimes'),
693 693
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
694 694
         );
695 695
 		remove_filter(
696 696
 		    'the_excerpt',
697
-            array( 'EED_Events_Archive', 'event_tickets' ),
697
+            array('EED_Events_Archive', 'event_tickets'),
698 698
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
699 699
         );
700 700
 		remove_filter(
701 701
 		    'the_excerpt',
702
-            array( 'EED_Events_Archive', 'event_venues' ),
702
+            array('EED_Events_Archive', 'event_venues'),
703 703
             EED_Events_Archive::EVENT_VENUES_PRIORITY
704 704
         );
705 705
 		remove_filter(
706 706
 		    'the_content',
707
-            array( 'EED_Events_Archive', 'event_details' ),
707
+            array('EED_Events_Archive', 'event_details'),
708 708
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
709 709
         );
710 710
 		remove_filter(
711 711
 		    'the_content',
712
-            array( 'EED_Events_Archive', 'event_datetimes' ),
712
+            array('EED_Events_Archive', 'event_datetimes'),
713 713
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
714 714
         );
715 715
 		remove_filter(
716 716
 		    'the_content',
717
-            array( 'EED_Events_Archive', 'event_tickets' ),
717
+            array('EED_Events_Archive', 'event_tickets'),
718 718
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
719 719
         );
720 720
 		remove_filter(
721 721
 		    'the_content',
722
-            array( 'EED_Events_Archive', 'event_venues' ),
722
+            array('EED_Events_Archive', 'event_venues'),
723 723
             EED_Events_Archive::EVENT_VENUES_PRIORITY
724 724
         );
725 725
 		// don't display entry meta because the existing theme will take care of that
@@ -741,12 +741,12 @@  discard block
 block discarded – undo
741 741
 	 *  @return 	void
742 742
 	 */
743 743
 	public function load_event_list_assets() {
744
-        do_action( 'AHEE__EED_Events_Archive__before_load_assets' );
745
-		add_filter( 'FHEE_load_EE_Session', '__return_true' );
746
-		add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' );
747
-		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 );
748
-		if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) {
749
-			add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 );
744
+        do_action('AHEE__EED_Events_Archive__before_load_assets');
745
+		add_filter('FHEE_load_EE_Session', '__return_true');
746
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
747
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
748
+		if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
749
+			add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
750 750
 		}
751 751
 	}
752 752
 
@@ -763,13 +763,13 @@  discard block
 block discarded – undo
763 763
 	 */
764 764
 	public function wp_enqueue_scripts() {
765 765
 		// get some style
766
-		if ( apply_filters( 'FHEE_enable_default_espresso_css', FALSE ) ) {
766
+		if (apply_filters('FHEE_enable_default_espresso_css', FALSE)) {
767 767
 			// first check uploads folder
768
-			if ( EEH_File::is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) {
769
-				wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' ));
768
+			if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) {
769
+				wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default'));
770 770
 			} else {
771 771
 		}
772
-		wp_enqueue_style( $this->theme );
772
+		wp_enqueue_style($this->theme);
773 773
 
774 774
 	}
775 775
 }
@@ -787,8 +787,8 @@  discard block
 block discarded – undo
787 787
 	 */
788 788
 	public static function template_settings_form() {
789 789
 	$template_settings = EE_Registry::instance()->CFG->template_settings;
790
-	$template_settings->EED_Events_Archive = isset( $template_settings->EED_Events_Archive ) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config();
791
-	$template_settings->EED_Events_Archive = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive );
790
+	$template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config();
791
+	$template_settings->EED_Events_Archive = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive);
792 792
 	$events_archive_settings = array(
793 793
 		'display_status_banner' => 0,
794 794
 		'display_description' => 1,
@@ -797,8 +797,8 @@  discard block
 block discarded – undo
797 797
 		'display_venue' => 0,
798 798
 		'display_expired_events' => 0
799 799
 	);
800
-	$events_archive_settings = array_merge( $events_archive_settings, (array)$template_settings->EED_Events_Archive );
801
-	EEH_Template::display_template( EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $events_archive_settings );
800
+	$events_archive_settings = array_merge($events_archive_settings, (array) $template_settings->EED_Events_Archive);
801
+	EEH_Template::display_template(EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', $events_archive_settings);
802 802
 }
803 803
 
804 804
 
@@ -814,16 +814,16 @@  discard block
 block discarded – undo
814 814
 	 *  @param 	EE_Request_Handler $REQ
815 815
 	 *  @return 	EE_Template_Config
816 816
 	 */
817
-	public static function update_template_settings( $CFG, $REQ ) {
817
+	public static function update_template_settings($CFG, $REQ) {
818 818
 		$CFG->EED_Events_Archive = new EE_Events_Archive_Config();
819 819
 		// unless we are resetting the config...
820
-		if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) {
821
-			$CFG->EED_Events_Archive->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0;
822
-			$CFG->EED_Events_Archive->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1;
823
-			$CFG->EED_Events_Archive->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0;
824
-			$CFG->EED_Events_Archive->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1;
825
-			$CFG->EED_Events_Archive->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0;
826
-			$CFG->EED_Events_Archive->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0;			}
820
+		if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) {
821
+			$CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0;
822
+			$CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1;
823
+			$CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0;
824
+			$CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1;
825
+			$CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0;
826
+			$CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; }
827 827
 		return $CFG;
828 828
 	}
829 829
 
@@ -836,10 +836,10 @@  discard block
 block discarded – undo
836 836
 	 * @param string $extra_class
837 837
 	 * @return    string
838 838
 	 */
839
-	public static function event_list_css( $extra_class = '' ) {
840
-		$event_list_css = ! empty( $extra_class ) ? array( $extra_class ) : array();
839
+	public static function event_list_css($extra_class = '') {
840
+		$event_list_css = ! empty($extra_class) ? array($extra_class) : array();
841 841
 		$event_list_css[] = 'espresso-event-list-event';
842
-		return implode( ' ', $event_list_css );
842
+		return implode(' ', $event_list_css);
843 843
 	}
844 844
 
845 845
 
@@ -866,9 +866,9 @@  discard block
 block discarded – undo
866 866
 	 * @param $value
867 867
 	 * @return    bool
868 868
 	 */
869
-	public static function display_description( $value ) {
869
+	public static function display_description($value) {
870 870
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
871
-		$display_description= isset( $config->display_description ) ? $config->display_description : 1;
871
+		$display_description = isset($config->display_description) ? $config->display_description : 1;
872 872
 		return $display_description === $value ? TRUE : FALSE;
873 873
 	}
874 874
 
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 	 */
882 882
 	public static function display_ticket_selector() {
883 883
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
884
-		return isset( $config->display_ticket_selector ) && $config->display_ticket_selector ? TRUE : FALSE;
884
+		return isset($config->display_ticket_selector) && $config->display_ticket_selector ? TRUE : FALSE;
885 885
 	}
886 886
 
887 887
 
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 	 */
895 895
 	public static function display_venue() {
896 896
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
897
-		return isset( $config->display_venue ) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE;
897
+		return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE;
898 898
 	}
899 899
 
900 900
 
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
 	 */
907 907
 	public static function display_datetimes() {
908 908
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
909
-		return isset( $config->display_datetimes ) && $config->display_datetimes ? TRUE : FALSE;
909
+		return isset($config->display_datetimes) && $config->display_datetimes ? TRUE : FALSE;
910 910
 }
911 911
 
912 912
 
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 	 *  @return 	string
922 922
 	 */
923 923
 	public static function event_list_title() {
924
-		return apply_filters( 'FHEE__archive_espresso_events_template__upcoming_events_h1', __( 'Upcoming Events', 'event_espresso' ));
924
+		return apply_filters('FHEE__archive_espresso_events_template__upcoming_events_h1', __('Upcoming Events', 'event_espresso'));
925 925
 	}
926 926
 
927 927
 
@@ -930,11 +930,11 @@  discard block
 block discarded – undo
930 930
 	/**
931 931
 	 * 	@since 4.4.0
932 932
 	 */
933
-	public static function _doing_it_wrong_notice( $function = '' ) {
933
+	public static function _doing_it_wrong_notice($function = '') {
934 934
 		EE_Error::doing_it_wrong(
935 935
 			__FUNCTION__,
936 936
 			sprintf(
937
-				__( 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso' ),
937
+				__('EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso'),
938 938
 				$function,
939 939
 				'<br />',
940 940
 				'4.6.0'
@@ -956,89 +956,89 @@  discard block
 block discarded – undo
956 956
 	 * 	@deprecated
957 957
 	 * 	@since 4.4.0
958 958
 	 */
959
-	public function posts_fields( $SQL, WP_Query $wp_query ) {
960
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
961
-		return EEH_Event_Query::posts_fields( $SQL, $wp_query );
959
+	public function posts_fields($SQL, WP_Query $wp_query) {
960
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
961
+		return EEH_Event_Query::posts_fields($SQL, $wp_query);
962 962
 	}
963 963
 	/**
964 964
 	 * 	@deprecated
965 965
 	 * 	@since 4.4.0
966 966
 	 */
967
-	public static function posts_fields_sql_for_orderby( $orderby_params = array() ) {
968
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
969
-		return EEH_Event_Query::posts_fields_sql_for_orderby( $orderby_params );
967
+	public static function posts_fields_sql_for_orderby($orderby_params = array()) {
968
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
969
+		return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params);
970 970
 	}
971 971
 	/**
972 972
 	 * 	@deprecated
973 973
 	 * 	@since 4.4.0
974 974
 	 */
975
-	public function posts_join( $SQL, WP_Query $wp_query ) {
976
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
977
-		return EEH_Event_Query::posts_join( $SQL, $wp_query );
975
+	public function posts_join($SQL, WP_Query $wp_query) {
976
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
977
+		return EEH_Event_Query::posts_join($SQL, $wp_query);
978 978
 	}
979 979
 	/**
980 980
 	 * 	@deprecated
981 981
 	 * 	@since 4.4.0
982 982
 	 */
983
-	public static function posts_join_sql_for_terms( $join_terms = NULL ) {
984
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
985
-		return EEH_Event_Query::posts_join_sql_for_terms( $join_terms );
983
+	public static function posts_join_sql_for_terms($join_terms = NULL) {
984
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
985
+		return EEH_Event_Query::posts_join_sql_for_terms($join_terms);
986 986
 	}
987 987
 	/**
988 988
 	 * 	@deprecated
989 989
 	 * 	@since 4.4.0
990 990
 	 */
991
-	public static function posts_join_for_orderby( $orderby_params = array() ) {
992
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
993
-		return EEH_Event_Query::posts_join_for_orderby( $orderby_params );
991
+	public static function posts_join_for_orderby($orderby_params = array()) {
992
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
993
+		return EEH_Event_Query::posts_join_for_orderby($orderby_params);
994 994
 	}
995 995
 	/**
996 996
 	 * 	@deprecated
997 997
 	 * 	@since 4.4.0
998 998
 	 */
999
-	public function posts_where( $SQL, WP_Query $wp_query ) {
1000
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
1001
-		return EEH_Event_Query::posts_where( $SQL, $wp_query );
999
+	public function posts_where($SQL, WP_Query $wp_query) {
1000
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1001
+		return EEH_Event_Query::posts_where($SQL, $wp_query);
1002 1002
 	}
1003 1003
 	/**
1004 1004
 	 * 	@deprecated
1005 1005
 	 * 	@since 4.4.0
1006 1006
 	 */
1007
-	public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) {
1008
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
1009
-		return EEH_Event_Query::posts_where_sql_for_show_expired( $show_expired );
1007
+	public static function posts_where_sql_for_show_expired($show_expired = FALSE) {
1008
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1009
+		return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired);
1010 1010
 	}
1011 1011
 	/**
1012 1012
 	 * 	@deprecated
1013 1013
 	 * 	@since 4.4.0
1014 1014
 	 */
1015
-	public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) {
1016
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
1017
-		return EEH_Event_Query::posts_where_sql_for_event_category_slug( $event_category_slug );
1015
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) {
1016
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1017
+		return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug);
1018 1018
 	}
1019 1019
 	/**
1020 1020
 	 * 	@deprecated
1021 1021
 	 * 	@since 4.4.0
1022 1022
 	 */
1023
-	public static function posts_where_sql_for_event_list_month( $month = NULL ) {
1024
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
1025
-		return EEH_Event_Query::posts_where_sql_for_event_list_month( $month );
1023
+	public static function posts_where_sql_for_event_list_month($month = NULL) {
1024
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1025
+		return EEH_Event_Query::posts_where_sql_for_event_list_month($month);
1026 1026
 	}
1027 1027
 	/**
1028 1028
 	 * 	@deprecated
1029 1029
 	 * 	@since 4.4.0
1030 1030
 	 */
1031
-	public function posts_orderby( $SQL, WP_Query $wp_query ) {
1032
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
1033
-		return EEH_Event_Query::posts_orderby( $SQL, $wp_query );
1031
+	public function posts_orderby($SQL, WP_Query $wp_query) {
1032
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1033
+		return EEH_Event_Query::posts_orderby($SQL, $wp_query);
1034 1034
 	}
1035 1035
 	/**
1036 1036
 	 * 	@deprecated
1037 1037
 	 * 	@since 4.4.0
1038 1038
 	 */
1039
-	public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) {
1040
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
1041
-		return EEH_Event_Query::posts_orderby_sql( $orderby_params, $sort );
1039
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') {
1040
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1041
+		return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort);
1042 1042
 	}
1043 1043
 
1044 1044
 
@@ -1069,8 +1069,8 @@  discard block
 block discarded – undo
1069 1069
  * @param string $extra_class
1070 1070
  * @return string
1071 1071
  */
1072
-function espresso_event_list_css( $extra_class = '' ) {
1073
-	return EED_Events_Archive::event_list_css( $extra_class );
1072
+function espresso_event_list_css($extra_class = '') {
1073
+	return EED_Events_Archive::event_list_css($extra_class);
1074 1074
 }
1075 1075
 
1076 1076
 /**
@@ -1084,14 +1084,14 @@  discard block
 block discarded – undo
1084 1084
  * @return bool
1085 1085
  */
1086 1086
 function espresso_display_full_description_in_event_list() {
1087
-	return EED_Events_Archive::display_description( 2 );
1087
+	return EED_Events_Archive::display_description(2);
1088 1088
 }
1089 1089
 
1090 1090
 /**
1091 1091
  * @return bool
1092 1092
  */
1093 1093
 function espresso_display_excerpt_in_event_list() {
1094
-	return EED_Events_Archive::display_description( 1 );
1094
+	return EED_Events_Archive::display_description(1);
1095 1095
 }
1096 1096
 
1097 1097
 /**
Please login to merge, or discard this patch.
core/CPTs/EE_Register_CPTs.core.php 1 patch
Indentation   +616 added lines, -616 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -14,604 +14,604 @@  discard block
 block discarded – undo
14 14
 class EE_Register_CPTs
15 15
 {
16 16
 
17
-    /**
18
-     * This property is used to hold an array of EE_default_term objects assigned to a custom post type when the post
19
-     * for that post type is published with no terms set for the taxonomy.
20
-     *
21
-     * @var array of EE_Default_Term objects
22
-     */
23
-    protected $_default_terms = array();
24
-
25
-
26
-
27
-    /**
28
-     *    constructor
29
-     * instantiated at init priority 5
30
-     */
31
-    public function __construct()
32
-    {
33
-        // register taxonomies
34
-        $taxonomies = self::get_taxonomies();
35
-        foreach ($taxonomies as $taxonomy => $tax) {
36
-            $this->register_taxonomy($taxonomy, $tax['singular_name'], $tax['plural_name'], $tax['args']);
37
-        }
38
-        // register CPTs
39
-        $CPTs = self::get_CPTs();
40
-        foreach ($CPTs as $CPT_name => $CPT) {
41
-            $this->register_CPT($CPT_name, $CPT['singular_name'], $CPT['plural_name'], $CPT['args'],
42
-                $CPT['singular_slug'], $CPT['plural_slug']);
43
-        }
44
-        // setup default terms in any of our taxonomies (but only if we're in admin).
45
-        // Why not added via register_activation_hook?
46
-        // Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies
47
-        // (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin.
48
-        // Keep in mind that this will READ these terms if they are deleted by the user.  Hence MUST use terms.
49
-        // if ( is_admin() ) {
50
-        // 	$this->set_must_use_event_types();
51
-        // }
52
-        //set default terms
53
-        $this->set_default_term('espresso_event_type', 'single-event', array('espresso_events'));
54
-        add_action('AHEE__EE_System__initialize_last', array(__CLASS__, 'maybe_flush_rewrite_rules'), 10);
55
-        // hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts
56
-        // IF they don't have a term for that taxonomy set.
57
-        add_action('save_post', array($this, 'save_default_term'), 100, 2);
58
-        // remove no html restrictions from core wp saving of term descriptions.
59
-        // Note. this will affect only registered EE taxonomies.
60
-        $this->_allow_html_descriptions_for_ee_taxonomies();
61
-        do_action('AHEE__EE_Register_CPTs__construct_end', $this);
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * This will flush rewrite rules on demand.  This actually gets called around wp init priority level 100.
68
-     *
69
-     * @since 4.5.0
70
-     * @return void
71
-     */
72
-    public static function maybe_flush_rewrite_rules()
73
-    {
74
-        if (get_option('ee_flush_rewrite_rules', true)) {
75
-            flush_rewrite_rules();
76
-            update_option('ee_flush_rewrite_rules', false);
77
-        }
78
-    }
79
-
80
-
81
-
82
-    /**
83
-     * By default, WordPress strips all html from term taxonomy description content.  The purpose of this method is to
84
-     * remove that restriction and ensure that we still run ee term taxonomy descriptions through some full html
85
-     * sanitization equivalent to the post content field.
86
-     *
87
-     * @since 4.7.8
88
-     */
89
-    protected function _allow_html_descriptions_for_ee_taxonomies()
90
-    {
91
-        // first remove default filter for term description but we have to do this earlier
92
-        // before wp sets their own filter
93
-        // because they just set a global filter on all term descriptions before the custom term description filter.
94
-        // Really sux.
95
-        add_filter('pre_term_description', array($this, 'ee_filter_ee_term_description_not_wp'), 1, 2);
96
-    }
97
-
98
-
99
-
100
-    /**
101
-     * Callback for pre_term_description hook.
102
-     *
103
-     * @param string $description The description content.
104
-     * @param string $taxonomy    The taxonomy name for the taxonomy being filtered.
105
-     * @return string
106
-     */
107
-    public function ee_filter_ee_term_description_not_wp($description, $taxonomy)
108
-    {
109
-        //get a list of EE taxonomies
110
-        $ee_taxonomies = array_keys(self::get_taxonomies());
111
-        //only do our own thing if the taxonomy listed is an ee taxonomy.
112
-        if (in_array($taxonomy, $ee_taxonomies, true)) {
113
-            //remove default wp filter
114
-            remove_filter('pre_term_description', 'wp_filter_kses');
115
-            //sanitize THIS content.
116
-            $description = wp_kses($description, wp_kses_allowed_html('post'));
117
-        }
118
-        return $description;
119
-    }
120
-
121
-
122
-
123
-    /**
124
-     *    get_taxonomies
125
-     *
126
-     * @access    public
127
-     * @return    array
128
-     */
129
-    public static function get_taxonomies()
130
-    {
131
-        // define taxonomies
132
-        return apply_filters('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array(
133
-            'espresso_event_categories' => array(
134
-                'singular_name' => __("Event Category", "event_espresso"),
135
-                'plural_name'   => __("Event Categories", "event_espresso"),
136
-                'args'          => array(
137
-                    'public'            => true,
138
-                    'show_in_nav_menus' => true,
139
-                    'show_in_rest'      => true,
140
-                    'capabilities'      => array(
141
-                        'manage_terms' => 'ee_manage_event_categories',
142
-                        'edit_terms'   => 'ee_edit_event_category',
143
-                        'delete_terms' => 'ee_delete_event_category',
144
-                        'assign_terms' => 'ee_assign_event_category',
145
-                    ),
146
-                    'rewrite'           => array('slug' => __('event-category', 'event_espresso')),
147
-                ),
148
-            ),
149
-            'espresso_venue_categories' => array(
150
-                'singular_name' => __("Venue Category", "event_espresso"),
151
-                'plural_name'   => __("Venue Categories", "event_espresso"),
152
-                'args'          => array(
153
-                    'public'            => true,
154
-                    'show_in_nav_menus' => false, //by default this doesn't show for decaf
155
-                    'show_in_rest'      => true,
156
-                    'capabilities'      => array(
157
-                        'manage_terms' => 'ee_manage_venue_categories',
158
-                        'edit_terms'   => 'ee_edit_venue_category',
159
-                        'delete_terms' => 'ee_delete_venue_category',
160
-                        'assign_terms' => 'ee_assign_venue_category',
161
-                    ),
162
-                    'rewrite'           => array('slug' => __('venue-category', 'event_espresso')),
163
-                ),
164
-            ),
165
-            'espresso_event_type'       => array(
166
-                'singular_name' => __("Event Type", "event_espresso"),
167
-                'plural_name'   => __("Event Types", "event_espresso"),
168
-                'args'          => array(
169
-                    'public'       => true,
170
-                    'show_ui'      => false,
171
-                    'show_in_rest' => true,
172
-                    'capabilities' => array(
173
-                        'manage_terms' => 'ee_read_event_type',
174
-                        'edit_terms'   => 'ee_edit_event_type',
175
-                        'delete_terms' => 'ee_delete_event_type',
176
-                        'assign_terms' => 'ee_assign_event_type',
177
-                    ),
178
-                    'rewrite'      => array('slug' => __('event-type', 'event_espresso')),
179
-                    'hierarchical' => true,
180
-                ),
181
-            ),
182
-        ));
183
-    }
184
-
185
-
186
-
187
-    /**
188
-     * This returns the corresponding model name for cpts registered by EE.
189
-     *
190
-     * @since 4.6.16.rc.000
191
-     * @param string $post_type_slug              If a slug is included, then attempt to retrieve the model name for
192
-     *                                            the given cpt slug.  Otherwise if empty, then we'll return all cpt
193
-     *                                            model names for cpts registered in EE.
194
-     * @return array           Empty array if no matching model names for the given slug or an array of model
195
-     *                                            names indexed by post type slug.
196
-     */
197
-    public static function get_cpt_model_names($post_type_slug = '')
198
-    {
199
-        $cpts = self::get_CPTs();
200
-        //first if slug passed in...
201
-        if ( ! empty($post_type_slug)) {
202
-            //match?
203
-            if (
204
-                ! isset($cpts[$post_type_slug])
205
-                || (isset($cpts[$post_type_slug]) && empty($cpts[$post_type_slug]['class_name']))
206
-            ) {
207
-                return array();
208
-            }
209
-            //k let's get the model name for this cpt.
210
-            return array($post_type_slug => str_replace('EE', 'EEM', $cpts[$post_type_slug]['class_name']));
211
-        }
212
-        //if we made it here then we're returning an array of cpt model names indexed by post_type_slug.
213
-        $cpt_models = array();
214
-        foreach ($cpts as $slug => $args) {
215
-            if ( ! empty($args['class_name'])) {
216
-                $cpt_models[$slug] = str_replace('EE', 'EEM', $args['class_name']);
217
-            }
218
-        }
219
-        return $cpt_models;
220
-    }
221
-
222
-
223
-
224
-    /**
225
-     * This instantiates cpt models related to the cpts registered via EE.
226
-     *
227
-     * @since 4.6.16.rc.000
228
-     * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for
229
-     *                               the cpt matching the given slug.  Otherwise all cpt models will be
230
-     *                               instantiated (if possible).
231
-     * @return EEM_CPT_Base[]        successful instantiation will return an array of successfully instantiated
232
-     *                               EEM models indexed by post slug.
233
-     */
234
-    public static function instantiate_cpt_models($post_type_slug = '')
235
-    {
236
-        $cpt_model_names = self::get_cpt_model_names($post_type_slug);
237
-        $instantiated = array();
238
-        foreach ($cpt_model_names as $slug => $model_name) {
239
-            $instance = EE_Registry::instance()->load_model(str_replace('EEM_', '', $model_name));
240
-            if ($instance instanceof EEM_CPT_Base) {
241
-                $instantiated[$slug] = $instance;
242
-            }
243
-        }
244
-        return $instantiated;
245
-    }
246
-
247
-
248
-
249
-    /**
250
-     *    get_CPTs
251
-     *
252
-     * @access    public
253
-     * @return    array
254
-     */
255
-    public static function get_CPTs()
256
-    {
257
-        // define CPTs
258
-        // NOTE the ['args']['page_templates'] array index is something specific to our CPTs
259
-        // and not part of the WP custom post type api.
260
-        return apply_filters('FHEE__EE_Register_CPTs__get_CPTs__cpts', array(
261
-            'espresso_events'    => array(
262
-                'singular_name' => __("Event", "event_espresso"),
263
-                'plural_name'   => __("Events", "event_espresso"),
264
-                'singular_slug' => __("event", "event_espresso"),
265
-                'plural_slug'   => EE_Registry::instance()->CFG->core->event_cpt_slug,
266
-                'class_name'    => 'EE_Event',
267
-                'args'          => array(
268
-                    'public'            => true,
269
-                    'show_in_nav_menus' => true,
270
-                    'capability_type'   => 'event',
271
-                    'capabilities'      => array(
272
-                        'edit_post'              => 'ee_edit_event',
273
-                        'read_post'              => 'ee_read_event',
274
-                        'delete_post'            => 'ee_delete_event',
275
-                        'edit_posts'             => 'ee_edit_events',
276
-                        'edit_others_posts'      => 'ee_edit_others_events',
277
-                        'publish_posts'          => 'ee_publish_events',
278
-                        'read_private_posts'     => 'ee_read_private_events',
279
-                        'delete_posts'           => 'ee_delete_events',
280
-                        'delete_private_posts'   => 'ee_delete_private_events',
281
-                        'delete_published_posts' => 'ee_delete_published_events',
282
-                        'delete_others_posts'    => 'ee_delete_others_events',
283
-                        'edit_private_posts'     => 'ee_edit_private_events',
284
-                        'edit_published_posts'   => 'ee_edit_published_events',
285
-                    ),
286
-                    'taxonomies'        => array(
287
-                        'espresso_event_categories',
288
-                        'espresso_event_type',
289
-                        'post_tag',
290
-                    ),
291
-                    'page_templates'    => true,
292
-                ),
293
-            ),
294
-            'espresso_venues'    => array(
295
-                'singular_name' => __("Venue", "event_espresso"),
296
-                'plural_name'   => __("Venues", "event_espresso"),
297
-                'singular_slug' => __("venue", "event_espresso"),
298
-                'plural_slug'   => __("venues", "event_espresso"),
299
-                'class_name'    => 'EE_Venue',
300
-                'args'          => array(
301
-                    'public'            => true,
302
-                    'show_in_nav_menus' => false, //by default this doesn't show for decaf,
303
-                    'capability_type'   => 'venue',
304
-                    'capabilities'      => array(
305
-                        'edit_post'              => 'ee_edit_venue',
306
-                        'read_post'              => 'ee_read_venue',
307
-                        'delete_post'            => 'ee_delete_venue',
308
-                        'edit_posts'             => 'ee_edit_venues',
309
-                        'edit_others_posts'      => 'ee_edit_others_venues',
310
-                        'publish_posts'          => 'ee_publish_venues',
311
-                        'read_private_posts'     => 'ee_read_private_venues',
312
-                        'delete_posts'           => 'ee_delete_venues',
313
-                        'delete_private_posts'   => 'ee_delete_private_venues',
314
-                        'delete_published_posts' => 'ee_delete_published_venues',
315
-                        'delete_others_posts'    => 'ee_edit_others_venues',
316
-                        'edit_private_posts'     => 'ee_edit_private_venues',
317
-                        'edit_published_posts'   => 'ee_edit_published_venues',
318
-                    ),
319
-                    'taxonomies'        => array(
320
-                        'espresso_venue_categories',
321
-                        'post_tag',
322
-                    ),
323
-                    'page_templates'    => true,
324
-                ),
325
-            ),
326
-            'espresso_attendees' => array(
327
-                'singular_name' => __("Contact", "event_espresso"),
328
-                'plural_name'   => __("Contacts", "event_espresso"),
329
-                'singular_slug' => __("contact", "event_espresso"),
330
-                'plural_slug'   => __("contacts", "event_espresso"),
331
-                'class_name'    => 'EE_Attendee',
332
-                'args'          => array(
333
-                    'public'             => false,
334
-                    'publicly_queryable' => false,
335
-                    'hierarchical'       => false,
336
-                    'has_archive'        => false,
337
-                    'taxonomies'         => array('post_tag'),
338
-                    'capability_type'    => 'contact',
339
-                    'capabilities'       => array(
340
-                        'edit_post'              => 'ee_edit_contact',
341
-                        'read_post'              => 'ee_read_contact',
342
-                        'delete_post'            => 'ee_delete_contact',
343
-                        'edit_posts'             => 'ee_edit_contacts',
344
-                        'edit_others_posts'      => 'ee_edit_contacts',
345
-                        'publish_posts'          => 'ee_edit_contacts',
346
-                        'read_private_posts'     => 'ee_edit_contacts',
347
-                        'delete_posts'           => 'ee_delete_contacts',
348
-                        'delete_private_posts'   => 'ee_delete_contacts',
349
-                        'delete_published_posts' => 'ee_delete_contacts',
350
-                        'delete_others_posts'    => 'ee_delete_contacts',
351
-                        'edit_private_posts'     => 'ee_edit_contacts',
352
-                        'edit_published_posts'   => 'ee_edit_contacts',
353
-                    ),
354
-                    'supports'           => array('editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments'),
355
-                ),
356
-            ),
357
-        ));
358
-    }
359
-
360
-
361
-
362
-    /**
363
-     * This basically goes through the CPT array and returns only CPT's
364
-     * that have the ['args']['public'] option set as false
365
-     *
366
-     * @return array
367
-     */
368
-    public static function get_private_CPTs()
369
-    {
370
-        $CPTs = self::get_CPTs();
371
-        $private_CPTs = array();
372
-        foreach ($CPTs as $CPT => $details) {
373
-            if (empty($details['args']['public'])) {
374
-                $private_CPTs[$CPT] = $details;
375
-            }
376
-        }
377
-        return $private_CPTs;
378
-    }
379
-
380
-
381
-
382
-    /**
383
-     * Registers a custom taxonomy. Should be called before registering custom post types,
384
-     * otherwise you should link the taxonomy to the custom post type using 'register_taxonomy_for_object_type'.
385
-     *
386
-     * @param string $taxonomy_name , eg 'books'
387
-     * @param string $singular_name internationalized singular name
388
-     * @param string $plural_name   internationalized plural name
389
-     * @param array  $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy
390
-     */
391
-    public function register_taxonomy($taxonomy_name, $singular_name, $plural_name, $override_args = array())
392
-    {
393
-        $args = array(
394
-            'hierarchical'      => true,
395
-            'labels'            => array(
396
-                'name'          => $plural_name,
397
-                'singular_name' => $singular_name,
398
-            ),
399
-            'show_ui'           => true,
400
-            'show_ee_ui'        => true,
401
-            'show_admin_column' => true,
402
-            'query_var'         => true,
403
-            'show_in_nav_menus' => false,
404
-            'map_meta_cap'      => true
405
-            //'rewrite'           => array( 'slug' => 'genre' ),
406
-        );
407
-        if ($override_args) {
408
-            if (isset($override_args['labels'])) {
409
-                $labels = array_merge($args['labels'], $override_args['labels']);
410
-                $args['labels'] = $labels;
411
-            }
412
-            $args = array_merge($args, $override_args);
413
-        }
414
-        register_taxonomy($taxonomy_name, null, $args);
415
-    }
416
-
417
-
418
-
419
-    /**
420
-     * Registers a new custom post type. Sets default settings given only the following params.
421
-     *
422
-     * @param string $post_type     the actual post type name
423
-     *                              (VERY IMPORTANT: this much match what the slug is for admin pages related to this
424
-     *                              cpt Also any models must use this slug as well)
425
-     * @param string $singular_name a pre-internationalized string for the singular name of the objects
426
-     * @param string $plural_name   a pre-internalized string for the plural name of the objects
427
-     * @param array  $override_args exactly like $args as described in
428
-     *                              http://codex.wordpress.org/Function_Reference/register_post_type The default values
429
-     *                              set in this function will be overridden by whatever you set in $override_args
430
-     * @param string $singular_slug
431
-     * @param string $plural_slug
432
-     * @return void , but registers the custom post type
433
-     */
434
-    public function register_CPT(
435
-        $post_type,
436
-        $singular_name,
437
-        $plural_name,
438
-        $override_args = array(),
439
-        $singular_slug = '',
440
-        $plural_slug = ''
441
-    ) {
442
-        $labels = array(
443
-            'name'               => $plural_name,
444
-            'singular_name'      => $singular_name,
445
-            'singular_slug'      => $singular_slug,
446
-            'plural_slug'        => $plural_slug,
447
-            'add_new'            => sprintf(__("Add %s", "event_espresso"), $singular_name),
448
-            'add_new_item'       => sprintf(__("Add New %s", "event_espresso"), $singular_name),
449
-            'edit_item'          => sprintf(__("Edit %s", "event_espresso"), $singular_name),
450
-            'new_item'           => sprintf(__("New %s", "event_espresso"), $singular_name),
451
-            'all_items'          => sprintf(__("All %s", "event_espresso"), $plural_name),
452
-            'view_item'          => sprintf(__("View %s", "event_espresso"), $singular_name),
453
-            'search_items'       => sprintf(__("Search %s", "event_espresso"), $plural_name),
454
-            'not_found'          => sprintf(__("No %s found", "event_espresso"), $plural_name),
455
-            'not_found_in_trash' => sprintf(__("No %s found in Trash", "event_espresso"), $plural_name),
456
-            'parent_item_colon'  => '',
457
-            'menu_name'          => sprintf(__("%s", "event_espresso"), $plural_name),
458
-        );
459
-        //verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name
460
-        // $singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name;
461
-        $plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name;
462
-        //note the page_templates arg in the supports index is something specific to EE.
463
-        //  WordPress doesn't actually have that in their register_post_type api.
464
-        $args = array(
465
-            'labels'             => $labels,
466
-            'public'             => true,
467
-            'publicly_queryable' => true,
468
-            'show_ui'            => false,
469
-            'show_ee_ui'         => true,
470
-            'show_in_menu'       => false,
471
-            'show_in_nav_menus'  => false,
472
-            'query_var'          => true,
473
-            'rewrite'            => apply_filters(
474
-                'FHEE__EE_Register_CPTs__register_CPT__rewrite',
475
-                array('slug' => $plural_slug),
476
-                $post_type
477
-            ),
478
-            'capability_type'    => 'post',
479
-            'map_meta_cap'       => true,
480
-            'has_archive'        => true,
481
-            'hierarchical'       => false,
482
-            'menu_position'      => null,
483
-            'supports'           => array(
484
-                'title',
485
-                'editor',
486
-                'author',
487
-                'thumbnail',
488
-                'excerpt',
489
-                'custom-fields',
490
-                'comments',
491
-            ),
492
-        );
493
-        if ($override_args) {
494
-            if (isset($override_args['labels'])) {
495
-                $labels = array_merge($args['labels'], $override_args['labels']);
496
-            }
497
-            $args = array_merge($args, $override_args);
498
-            $args['labels'] = $labels;
499
-        }
500
-        register_post_type($post_type, $args);
501
-    }
502
-
503
-
504
-
505
-    public function set_must_use_event_types()
506
-    {
507
-        $term_details = array(
508
-            //Attendee's register for the first date-time only
509
-            'single-event'    => array(
510
-                __('Single Event', 'event_espresso'),
511
-                __('A single event that spans one or more consecutive days.', 'event_espresso'),
512
-            ),
513
-            //example: a party or two-day long workshop
514
-            //Attendee's can register for any of the date-times
515
-            'multi-event'     => array(
516
-                __('Multi Event', 'event_espresso'),
517
-                __('Multiple, separate, but related events that occur on consecutive days.', 'event_espresso'),
518
-            ),
519
-            //example: a three day music festival or week long conference
520
-            //Attendee's register for the first date-time only
521
-            'event-series'    => array(
522
-                __('Event Series', 'event_espresso'),
523
-                __(' Multiple events that occur over multiple non-consecutive days.', 'event_espresso'),
524
-            ),
525
-            //example: an 8 week introduction to basket weaving course
526
-            //Attendee's can register for any of the date-times.
527
-            'recurring-event' => array(
528
-                __('Recurring Event', 'event_espresso'),
529
-                __('Multiple events that occur over multiple non-consecutive days.', 'event_espresso'),
530
-            ),
531
-            //example: a yoga class
532
-            'ongoing' => array(
533
-                __('Ongoing Event', 'event_espresso'),
534
-                __('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event',
535
-                    'event_espresso'),
536
-            )
537
-            //example: access to a museum
538
-            //'walk-in' => array( __('Walk In', 'event_espresso'), __('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ),
539
-            //'reservation' => array( __('Reservation', 'event_espresso'), __('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1
540
-            // 'multiple-session' => array( __('Multiple Session', 'event_espresso'), __('Multiple event, multiple datetime, hierarchically organized, custom entry events. Attendees may be required to register for a parent event before being allowed to register for child events. Attendees can register for any combination of child events as long as the datetimes do not conflict. Parent and child events may have additional fees or registration questions.') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1
541
-            //'appointment' => array( __('Appointments', 'event_espresso'), __('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') )
542
-        );
543
-        $this->set_must_use_terms('espresso_event_type', $term_details);
544
-    }
545
-
546
-
547
-
548
-    /**
549
-     * wrapper method for handling the setting up of initial terms in the db (if they don't already exist).
550
-     * Note this should ONLY be used for terms that always must be present.  Be aware that if an initial term is
551
-     * deleted then it WILL be recreated.
552
-     *
553
-     * @param string $taxonomy     The name of the taxonomy
554
-     * @param array  $term_details An array of term details indexed by slug and containing Name of term, and
555
-     *                             description as the elements in the array
556
-     * @return void
557
-     */
558
-    public function set_must_use_terms($taxonomy, $term_details)
559
-    {
560
-        $term_details = (array)$term_details;
561
-        foreach ($term_details as $slug => $details) {
562
-            if ( ! term_exists($slug, $taxonomy)) {
563
-                $insert_arr = array(
564
-                    'slug'        => $slug,
565
-                    'description' => $details[1],
566
-                );
567
-                wp_insert_term($details[0], $taxonomy, $insert_arr);
568
-            }
569
-        }
570
-    }
571
-
572
-
573
-
574
-    /**
575
-     * Allows us to set what the default will be for terms when a cpt is PUBLISHED.
576
-     *
577
-     * @param string $taxonomy  The taxonomy we're using for the default term
578
-     * @param string $term_slug The slug of the term that will be the default.
579
-     * @param array  $cpt_slugs An array of custom post types we want the default assigned to
580
-     */
581
-    public function set_default_term($taxonomy, $term_slug, $cpt_slugs = array())
582
-    {
583
-        $this->_default_terms[][$term_slug] = new EE_Default_Term($taxonomy, $term_slug, $cpt_slugs);
584
-    }
585
-
586
-
587
-
588
-    /**
589
-     * hooked into the wp 'save_post' action hook for setting our default terms found in the $_default_terms property
590
-     *
591
-     * @param  int    $post_id ID of CPT being saved
592
-     * @param  object $post    Post object
593
-     * @return void
594
-     */
595
-    public function save_default_term($post_id, $post)
596
-    {
597
-        if (empty($this->_default_terms)) {
598
-            return;
599
-        } //no default terms set so lets just exit.
600
-        foreach ($this->_default_terms as $defaults) {
601
-            foreach ($defaults as $default_obj) {
602
-                if ($post->post_status === 'publish' && in_array($post->post_type, $default_obj->cpt_slugs, true)) {
603
-                    //note some error proofing going on here to save unnecessary db queries
604
-                    $taxonomies = get_object_taxonomies($post->post_type);
605
-                    foreach ((array)$taxonomies as $taxonomy) {
606
-                        $terms = wp_get_post_terms($post_id, $taxonomy);
607
-                        if (empty($terms) && $taxonomy === $default_obj->taxonomy) {
608
-                            wp_set_object_terms($post_id, array($default_obj->term_slug), $taxonomy);
609
-                        }
610
-                    }
611
-                }
612
-            }
613
-        }
614
-    }
17
+	/**
18
+	 * This property is used to hold an array of EE_default_term objects assigned to a custom post type when the post
19
+	 * for that post type is published with no terms set for the taxonomy.
20
+	 *
21
+	 * @var array of EE_Default_Term objects
22
+	 */
23
+	protected $_default_terms = array();
24
+
25
+
26
+
27
+	/**
28
+	 *    constructor
29
+	 * instantiated at init priority 5
30
+	 */
31
+	public function __construct()
32
+	{
33
+		// register taxonomies
34
+		$taxonomies = self::get_taxonomies();
35
+		foreach ($taxonomies as $taxonomy => $tax) {
36
+			$this->register_taxonomy($taxonomy, $tax['singular_name'], $tax['plural_name'], $tax['args']);
37
+		}
38
+		// register CPTs
39
+		$CPTs = self::get_CPTs();
40
+		foreach ($CPTs as $CPT_name => $CPT) {
41
+			$this->register_CPT($CPT_name, $CPT['singular_name'], $CPT['plural_name'], $CPT['args'],
42
+				$CPT['singular_slug'], $CPT['plural_slug']);
43
+		}
44
+		// setup default terms in any of our taxonomies (but only if we're in admin).
45
+		// Why not added via register_activation_hook?
46
+		// Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies
47
+		// (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin.
48
+		// Keep in mind that this will READ these terms if they are deleted by the user.  Hence MUST use terms.
49
+		// if ( is_admin() ) {
50
+		// 	$this->set_must_use_event_types();
51
+		// }
52
+		//set default terms
53
+		$this->set_default_term('espresso_event_type', 'single-event', array('espresso_events'));
54
+		add_action('AHEE__EE_System__initialize_last', array(__CLASS__, 'maybe_flush_rewrite_rules'), 10);
55
+		// hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts
56
+		// IF they don't have a term for that taxonomy set.
57
+		add_action('save_post', array($this, 'save_default_term'), 100, 2);
58
+		// remove no html restrictions from core wp saving of term descriptions.
59
+		// Note. this will affect only registered EE taxonomies.
60
+		$this->_allow_html_descriptions_for_ee_taxonomies();
61
+		do_action('AHEE__EE_Register_CPTs__construct_end', $this);
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * This will flush rewrite rules on demand.  This actually gets called around wp init priority level 100.
68
+	 *
69
+	 * @since 4.5.0
70
+	 * @return void
71
+	 */
72
+	public static function maybe_flush_rewrite_rules()
73
+	{
74
+		if (get_option('ee_flush_rewrite_rules', true)) {
75
+			flush_rewrite_rules();
76
+			update_option('ee_flush_rewrite_rules', false);
77
+		}
78
+	}
79
+
80
+
81
+
82
+	/**
83
+	 * By default, WordPress strips all html from term taxonomy description content.  The purpose of this method is to
84
+	 * remove that restriction and ensure that we still run ee term taxonomy descriptions through some full html
85
+	 * sanitization equivalent to the post content field.
86
+	 *
87
+	 * @since 4.7.8
88
+	 */
89
+	protected function _allow_html_descriptions_for_ee_taxonomies()
90
+	{
91
+		// first remove default filter for term description but we have to do this earlier
92
+		// before wp sets their own filter
93
+		// because they just set a global filter on all term descriptions before the custom term description filter.
94
+		// Really sux.
95
+		add_filter('pre_term_description', array($this, 'ee_filter_ee_term_description_not_wp'), 1, 2);
96
+	}
97
+
98
+
99
+
100
+	/**
101
+	 * Callback for pre_term_description hook.
102
+	 *
103
+	 * @param string $description The description content.
104
+	 * @param string $taxonomy    The taxonomy name for the taxonomy being filtered.
105
+	 * @return string
106
+	 */
107
+	public function ee_filter_ee_term_description_not_wp($description, $taxonomy)
108
+	{
109
+		//get a list of EE taxonomies
110
+		$ee_taxonomies = array_keys(self::get_taxonomies());
111
+		//only do our own thing if the taxonomy listed is an ee taxonomy.
112
+		if (in_array($taxonomy, $ee_taxonomies, true)) {
113
+			//remove default wp filter
114
+			remove_filter('pre_term_description', 'wp_filter_kses');
115
+			//sanitize THIS content.
116
+			$description = wp_kses($description, wp_kses_allowed_html('post'));
117
+		}
118
+		return $description;
119
+	}
120
+
121
+
122
+
123
+	/**
124
+	 *    get_taxonomies
125
+	 *
126
+	 * @access    public
127
+	 * @return    array
128
+	 */
129
+	public static function get_taxonomies()
130
+	{
131
+		// define taxonomies
132
+		return apply_filters('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array(
133
+			'espresso_event_categories' => array(
134
+				'singular_name' => __("Event Category", "event_espresso"),
135
+				'plural_name'   => __("Event Categories", "event_espresso"),
136
+				'args'          => array(
137
+					'public'            => true,
138
+					'show_in_nav_menus' => true,
139
+					'show_in_rest'      => true,
140
+					'capabilities'      => array(
141
+						'manage_terms' => 'ee_manage_event_categories',
142
+						'edit_terms'   => 'ee_edit_event_category',
143
+						'delete_terms' => 'ee_delete_event_category',
144
+						'assign_terms' => 'ee_assign_event_category',
145
+					),
146
+					'rewrite'           => array('slug' => __('event-category', 'event_espresso')),
147
+				),
148
+			),
149
+			'espresso_venue_categories' => array(
150
+				'singular_name' => __("Venue Category", "event_espresso"),
151
+				'plural_name'   => __("Venue Categories", "event_espresso"),
152
+				'args'          => array(
153
+					'public'            => true,
154
+					'show_in_nav_menus' => false, //by default this doesn't show for decaf
155
+					'show_in_rest'      => true,
156
+					'capabilities'      => array(
157
+						'manage_terms' => 'ee_manage_venue_categories',
158
+						'edit_terms'   => 'ee_edit_venue_category',
159
+						'delete_terms' => 'ee_delete_venue_category',
160
+						'assign_terms' => 'ee_assign_venue_category',
161
+					),
162
+					'rewrite'           => array('slug' => __('venue-category', 'event_espresso')),
163
+				),
164
+			),
165
+			'espresso_event_type'       => array(
166
+				'singular_name' => __("Event Type", "event_espresso"),
167
+				'plural_name'   => __("Event Types", "event_espresso"),
168
+				'args'          => array(
169
+					'public'       => true,
170
+					'show_ui'      => false,
171
+					'show_in_rest' => true,
172
+					'capabilities' => array(
173
+						'manage_terms' => 'ee_read_event_type',
174
+						'edit_terms'   => 'ee_edit_event_type',
175
+						'delete_terms' => 'ee_delete_event_type',
176
+						'assign_terms' => 'ee_assign_event_type',
177
+					),
178
+					'rewrite'      => array('slug' => __('event-type', 'event_espresso')),
179
+					'hierarchical' => true,
180
+				),
181
+			),
182
+		));
183
+	}
184
+
185
+
186
+
187
+	/**
188
+	 * This returns the corresponding model name for cpts registered by EE.
189
+	 *
190
+	 * @since 4.6.16.rc.000
191
+	 * @param string $post_type_slug              If a slug is included, then attempt to retrieve the model name for
192
+	 *                                            the given cpt slug.  Otherwise if empty, then we'll return all cpt
193
+	 *                                            model names for cpts registered in EE.
194
+	 * @return array           Empty array if no matching model names for the given slug or an array of model
195
+	 *                                            names indexed by post type slug.
196
+	 */
197
+	public static function get_cpt_model_names($post_type_slug = '')
198
+	{
199
+		$cpts = self::get_CPTs();
200
+		//first if slug passed in...
201
+		if ( ! empty($post_type_slug)) {
202
+			//match?
203
+			if (
204
+				! isset($cpts[$post_type_slug])
205
+				|| (isset($cpts[$post_type_slug]) && empty($cpts[$post_type_slug]['class_name']))
206
+			) {
207
+				return array();
208
+			}
209
+			//k let's get the model name for this cpt.
210
+			return array($post_type_slug => str_replace('EE', 'EEM', $cpts[$post_type_slug]['class_name']));
211
+		}
212
+		//if we made it here then we're returning an array of cpt model names indexed by post_type_slug.
213
+		$cpt_models = array();
214
+		foreach ($cpts as $slug => $args) {
215
+			if ( ! empty($args['class_name'])) {
216
+				$cpt_models[$slug] = str_replace('EE', 'EEM', $args['class_name']);
217
+			}
218
+		}
219
+		return $cpt_models;
220
+	}
221
+
222
+
223
+
224
+	/**
225
+	 * This instantiates cpt models related to the cpts registered via EE.
226
+	 *
227
+	 * @since 4.6.16.rc.000
228
+	 * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for
229
+	 *                               the cpt matching the given slug.  Otherwise all cpt models will be
230
+	 *                               instantiated (if possible).
231
+	 * @return EEM_CPT_Base[]        successful instantiation will return an array of successfully instantiated
232
+	 *                               EEM models indexed by post slug.
233
+	 */
234
+	public static function instantiate_cpt_models($post_type_slug = '')
235
+	{
236
+		$cpt_model_names = self::get_cpt_model_names($post_type_slug);
237
+		$instantiated = array();
238
+		foreach ($cpt_model_names as $slug => $model_name) {
239
+			$instance = EE_Registry::instance()->load_model(str_replace('EEM_', '', $model_name));
240
+			if ($instance instanceof EEM_CPT_Base) {
241
+				$instantiated[$slug] = $instance;
242
+			}
243
+		}
244
+		return $instantiated;
245
+	}
246
+
247
+
248
+
249
+	/**
250
+	 *    get_CPTs
251
+	 *
252
+	 * @access    public
253
+	 * @return    array
254
+	 */
255
+	public static function get_CPTs()
256
+	{
257
+		// define CPTs
258
+		// NOTE the ['args']['page_templates'] array index is something specific to our CPTs
259
+		// and not part of the WP custom post type api.
260
+		return apply_filters('FHEE__EE_Register_CPTs__get_CPTs__cpts', array(
261
+			'espresso_events'    => array(
262
+				'singular_name' => __("Event", "event_espresso"),
263
+				'plural_name'   => __("Events", "event_espresso"),
264
+				'singular_slug' => __("event", "event_espresso"),
265
+				'plural_slug'   => EE_Registry::instance()->CFG->core->event_cpt_slug,
266
+				'class_name'    => 'EE_Event',
267
+				'args'          => array(
268
+					'public'            => true,
269
+					'show_in_nav_menus' => true,
270
+					'capability_type'   => 'event',
271
+					'capabilities'      => array(
272
+						'edit_post'              => 'ee_edit_event',
273
+						'read_post'              => 'ee_read_event',
274
+						'delete_post'            => 'ee_delete_event',
275
+						'edit_posts'             => 'ee_edit_events',
276
+						'edit_others_posts'      => 'ee_edit_others_events',
277
+						'publish_posts'          => 'ee_publish_events',
278
+						'read_private_posts'     => 'ee_read_private_events',
279
+						'delete_posts'           => 'ee_delete_events',
280
+						'delete_private_posts'   => 'ee_delete_private_events',
281
+						'delete_published_posts' => 'ee_delete_published_events',
282
+						'delete_others_posts'    => 'ee_delete_others_events',
283
+						'edit_private_posts'     => 'ee_edit_private_events',
284
+						'edit_published_posts'   => 'ee_edit_published_events',
285
+					),
286
+					'taxonomies'        => array(
287
+						'espresso_event_categories',
288
+						'espresso_event_type',
289
+						'post_tag',
290
+					),
291
+					'page_templates'    => true,
292
+				),
293
+			),
294
+			'espresso_venues'    => array(
295
+				'singular_name' => __("Venue", "event_espresso"),
296
+				'plural_name'   => __("Venues", "event_espresso"),
297
+				'singular_slug' => __("venue", "event_espresso"),
298
+				'plural_slug'   => __("venues", "event_espresso"),
299
+				'class_name'    => 'EE_Venue',
300
+				'args'          => array(
301
+					'public'            => true,
302
+					'show_in_nav_menus' => false, //by default this doesn't show for decaf,
303
+					'capability_type'   => 'venue',
304
+					'capabilities'      => array(
305
+						'edit_post'              => 'ee_edit_venue',
306
+						'read_post'              => 'ee_read_venue',
307
+						'delete_post'            => 'ee_delete_venue',
308
+						'edit_posts'             => 'ee_edit_venues',
309
+						'edit_others_posts'      => 'ee_edit_others_venues',
310
+						'publish_posts'          => 'ee_publish_venues',
311
+						'read_private_posts'     => 'ee_read_private_venues',
312
+						'delete_posts'           => 'ee_delete_venues',
313
+						'delete_private_posts'   => 'ee_delete_private_venues',
314
+						'delete_published_posts' => 'ee_delete_published_venues',
315
+						'delete_others_posts'    => 'ee_edit_others_venues',
316
+						'edit_private_posts'     => 'ee_edit_private_venues',
317
+						'edit_published_posts'   => 'ee_edit_published_venues',
318
+					),
319
+					'taxonomies'        => array(
320
+						'espresso_venue_categories',
321
+						'post_tag',
322
+					),
323
+					'page_templates'    => true,
324
+				),
325
+			),
326
+			'espresso_attendees' => array(
327
+				'singular_name' => __("Contact", "event_espresso"),
328
+				'plural_name'   => __("Contacts", "event_espresso"),
329
+				'singular_slug' => __("contact", "event_espresso"),
330
+				'plural_slug'   => __("contacts", "event_espresso"),
331
+				'class_name'    => 'EE_Attendee',
332
+				'args'          => array(
333
+					'public'             => false,
334
+					'publicly_queryable' => false,
335
+					'hierarchical'       => false,
336
+					'has_archive'        => false,
337
+					'taxonomies'         => array('post_tag'),
338
+					'capability_type'    => 'contact',
339
+					'capabilities'       => array(
340
+						'edit_post'              => 'ee_edit_contact',
341
+						'read_post'              => 'ee_read_contact',
342
+						'delete_post'            => 'ee_delete_contact',
343
+						'edit_posts'             => 'ee_edit_contacts',
344
+						'edit_others_posts'      => 'ee_edit_contacts',
345
+						'publish_posts'          => 'ee_edit_contacts',
346
+						'read_private_posts'     => 'ee_edit_contacts',
347
+						'delete_posts'           => 'ee_delete_contacts',
348
+						'delete_private_posts'   => 'ee_delete_contacts',
349
+						'delete_published_posts' => 'ee_delete_contacts',
350
+						'delete_others_posts'    => 'ee_delete_contacts',
351
+						'edit_private_posts'     => 'ee_edit_contacts',
352
+						'edit_published_posts'   => 'ee_edit_contacts',
353
+					),
354
+					'supports'           => array('editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments'),
355
+				),
356
+			),
357
+		));
358
+	}
359
+
360
+
361
+
362
+	/**
363
+	 * This basically goes through the CPT array and returns only CPT's
364
+	 * that have the ['args']['public'] option set as false
365
+	 *
366
+	 * @return array
367
+	 */
368
+	public static function get_private_CPTs()
369
+	{
370
+		$CPTs = self::get_CPTs();
371
+		$private_CPTs = array();
372
+		foreach ($CPTs as $CPT => $details) {
373
+			if (empty($details['args']['public'])) {
374
+				$private_CPTs[$CPT] = $details;
375
+			}
376
+		}
377
+		return $private_CPTs;
378
+	}
379
+
380
+
381
+
382
+	/**
383
+	 * Registers a custom taxonomy. Should be called before registering custom post types,
384
+	 * otherwise you should link the taxonomy to the custom post type using 'register_taxonomy_for_object_type'.
385
+	 *
386
+	 * @param string $taxonomy_name , eg 'books'
387
+	 * @param string $singular_name internationalized singular name
388
+	 * @param string $plural_name   internationalized plural name
389
+	 * @param array  $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy
390
+	 */
391
+	public function register_taxonomy($taxonomy_name, $singular_name, $plural_name, $override_args = array())
392
+	{
393
+		$args = array(
394
+			'hierarchical'      => true,
395
+			'labels'            => array(
396
+				'name'          => $plural_name,
397
+				'singular_name' => $singular_name,
398
+			),
399
+			'show_ui'           => true,
400
+			'show_ee_ui'        => true,
401
+			'show_admin_column' => true,
402
+			'query_var'         => true,
403
+			'show_in_nav_menus' => false,
404
+			'map_meta_cap'      => true
405
+			//'rewrite'           => array( 'slug' => 'genre' ),
406
+		);
407
+		if ($override_args) {
408
+			if (isset($override_args['labels'])) {
409
+				$labels = array_merge($args['labels'], $override_args['labels']);
410
+				$args['labels'] = $labels;
411
+			}
412
+			$args = array_merge($args, $override_args);
413
+		}
414
+		register_taxonomy($taxonomy_name, null, $args);
415
+	}
416
+
417
+
418
+
419
+	/**
420
+	 * Registers a new custom post type. Sets default settings given only the following params.
421
+	 *
422
+	 * @param string $post_type     the actual post type name
423
+	 *                              (VERY IMPORTANT: this much match what the slug is for admin pages related to this
424
+	 *                              cpt Also any models must use this slug as well)
425
+	 * @param string $singular_name a pre-internationalized string for the singular name of the objects
426
+	 * @param string $plural_name   a pre-internalized string for the plural name of the objects
427
+	 * @param array  $override_args exactly like $args as described in
428
+	 *                              http://codex.wordpress.org/Function_Reference/register_post_type The default values
429
+	 *                              set in this function will be overridden by whatever you set in $override_args
430
+	 * @param string $singular_slug
431
+	 * @param string $plural_slug
432
+	 * @return void , but registers the custom post type
433
+	 */
434
+	public function register_CPT(
435
+		$post_type,
436
+		$singular_name,
437
+		$plural_name,
438
+		$override_args = array(),
439
+		$singular_slug = '',
440
+		$plural_slug = ''
441
+	) {
442
+		$labels = array(
443
+			'name'               => $plural_name,
444
+			'singular_name'      => $singular_name,
445
+			'singular_slug'      => $singular_slug,
446
+			'plural_slug'        => $plural_slug,
447
+			'add_new'            => sprintf(__("Add %s", "event_espresso"), $singular_name),
448
+			'add_new_item'       => sprintf(__("Add New %s", "event_espresso"), $singular_name),
449
+			'edit_item'          => sprintf(__("Edit %s", "event_espresso"), $singular_name),
450
+			'new_item'           => sprintf(__("New %s", "event_espresso"), $singular_name),
451
+			'all_items'          => sprintf(__("All %s", "event_espresso"), $plural_name),
452
+			'view_item'          => sprintf(__("View %s", "event_espresso"), $singular_name),
453
+			'search_items'       => sprintf(__("Search %s", "event_espresso"), $plural_name),
454
+			'not_found'          => sprintf(__("No %s found", "event_espresso"), $plural_name),
455
+			'not_found_in_trash' => sprintf(__("No %s found in Trash", "event_espresso"), $plural_name),
456
+			'parent_item_colon'  => '',
457
+			'menu_name'          => sprintf(__("%s", "event_espresso"), $plural_name),
458
+		);
459
+		//verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name
460
+		// $singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name;
461
+		$plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name;
462
+		//note the page_templates arg in the supports index is something specific to EE.
463
+		//  WordPress doesn't actually have that in their register_post_type api.
464
+		$args = array(
465
+			'labels'             => $labels,
466
+			'public'             => true,
467
+			'publicly_queryable' => true,
468
+			'show_ui'            => false,
469
+			'show_ee_ui'         => true,
470
+			'show_in_menu'       => false,
471
+			'show_in_nav_menus'  => false,
472
+			'query_var'          => true,
473
+			'rewrite'            => apply_filters(
474
+				'FHEE__EE_Register_CPTs__register_CPT__rewrite',
475
+				array('slug' => $plural_slug),
476
+				$post_type
477
+			),
478
+			'capability_type'    => 'post',
479
+			'map_meta_cap'       => true,
480
+			'has_archive'        => true,
481
+			'hierarchical'       => false,
482
+			'menu_position'      => null,
483
+			'supports'           => array(
484
+				'title',
485
+				'editor',
486
+				'author',
487
+				'thumbnail',
488
+				'excerpt',
489
+				'custom-fields',
490
+				'comments',
491
+			),
492
+		);
493
+		if ($override_args) {
494
+			if (isset($override_args['labels'])) {
495
+				$labels = array_merge($args['labels'], $override_args['labels']);
496
+			}
497
+			$args = array_merge($args, $override_args);
498
+			$args['labels'] = $labels;
499
+		}
500
+		register_post_type($post_type, $args);
501
+	}
502
+
503
+
504
+
505
+	public function set_must_use_event_types()
506
+	{
507
+		$term_details = array(
508
+			//Attendee's register for the first date-time only
509
+			'single-event'    => array(
510
+				__('Single Event', 'event_espresso'),
511
+				__('A single event that spans one or more consecutive days.', 'event_espresso'),
512
+			),
513
+			//example: a party or two-day long workshop
514
+			//Attendee's can register for any of the date-times
515
+			'multi-event'     => array(
516
+				__('Multi Event', 'event_espresso'),
517
+				__('Multiple, separate, but related events that occur on consecutive days.', 'event_espresso'),
518
+			),
519
+			//example: a three day music festival or week long conference
520
+			//Attendee's register for the first date-time only
521
+			'event-series'    => array(
522
+				__('Event Series', 'event_espresso'),
523
+				__(' Multiple events that occur over multiple non-consecutive days.', 'event_espresso'),
524
+			),
525
+			//example: an 8 week introduction to basket weaving course
526
+			//Attendee's can register for any of the date-times.
527
+			'recurring-event' => array(
528
+				__('Recurring Event', 'event_espresso'),
529
+				__('Multiple events that occur over multiple non-consecutive days.', 'event_espresso'),
530
+			),
531
+			//example: a yoga class
532
+			'ongoing' => array(
533
+				__('Ongoing Event', 'event_espresso'),
534
+				__('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event',
535
+					'event_espresso'),
536
+			)
537
+			//example: access to a museum
538
+			//'walk-in' => array( __('Walk In', 'event_espresso'), __('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ),
539
+			//'reservation' => array( __('Reservation', 'event_espresso'), __('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1
540
+			// 'multiple-session' => array( __('Multiple Session', 'event_espresso'), __('Multiple event, multiple datetime, hierarchically organized, custom entry events. Attendees may be required to register for a parent event before being allowed to register for child events. Attendees can register for any combination of child events as long as the datetimes do not conflict. Parent and child events may have additional fees or registration questions.') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1
541
+			//'appointment' => array( __('Appointments', 'event_espresso'), __('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') )
542
+		);
543
+		$this->set_must_use_terms('espresso_event_type', $term_details);
544
+	}
545
+
546
+
547
+
548
+	/**
549
+	 * wrapper method for handling the setting up of initial terms in the db (if they don't already exist).
550
+	 * Note this should ONLY be used for terms that always must be present.  Be aware that if an initial term is
551
+	 * deleted then it WILL be recreated.
552
+	 *
553
+	 * @param string $taxonomy     The name of the taxonomy
554
+	 * @param array  $term_details An array of term details indexed by slug and containing Name of term, and
555
+	 *                             description as the elements in the array
556
+	 * @return void
557
+	 */
558
+	public function set_must_use_terms($taxonomy, $term_details)
559
+	{
560
+		$term_details = (array)$term_details;
561
+		foreach ($term_details as $slug => $details) {
562
+			if ( ! term_exists($slug, $taxonomy)) {
563
+				$insert_arr = array(
564
+					'slug'        => $slug,
565
+					'description' => $details[1],
566
+				);
567
+				wp_insert_term($details[0], $taxonomy, $insert_arr);
568
+			}
569
+		}
570
+	}
571
+
572
+
573
+
574
+	/**
575
+	 * Allows us to set what the default will be for terms when a cpt is PUBLISHED.
576
+	 *
577
+	 * @param string $taxonomy  The taxonomy we're using for the default term
578
+	 * @param string $term_slug The slug of the term that will be the default.
579
+	 * @param array  $cpt_slugs An array of custom post types we want the default assigned to
580
+	 */
581
+	public function set_default_term($taxonomy, $term_slug, $cpt_slugs = array())
582
+	{
583
+		$this->_default_terms[][$term_slug] = new EE_Default_Term($taxonomy, $term_slug, $cpt_slugs);
584
+	}
585
+
586
+
587
+
588
+	/**
589
+	 * hooked into the wp 'save_post' action hook for setting our default terms found in the $_default_terms property
590
+	 *
591
+	 * @param  int    $post_id ID of CPT being saved
592
+	 * @param  object $post    Post object
593
+	 * @return void
594
+	 */
595
+	public function save_default_term($post_id, $post)
596
+	{
597
+		if (empty($this->_default_terms)) {
598
+			return;
599
+		} //no default terms set so lets just exit.
600
+		foreach ($this->_default_terms as $defaults) {
601
+			foreach ($defaults as $default_obj) {
602
+				if ($post->post_status === 'publish' && in_array($post->post_type, $default_obj->cpt_slugs, true)) {
603
+					//note some error proofing going on here to save unnecessary db queries
604
+					$taxonomies = get_object_taxonomies($post->post_type);
605
+					foreach ((array)$taxonomies as $taxonomy) {
606
+						$terms = wp_get_post_terms($post_id, $taxonomy);
607
+						if (empty($terms) && $taxonomy === $default_obj->taxonomy) {
608
+							wp_set_object_terms($post_id, array($default_obj->term_slug), $taxonomy);
609
+						}
610
+					}
611
+				}
612
+			}
613
+		}
614
+	}
615 615
 
616 616
 }
617 617
 
@@ -625,27 +625,27 @@  discard block
 block discarded – undo
625 625
 {
626 626
 
627 627
 
628
-    //props holding the items
629
-    public $taxonomy  = '';
628
+	//props holding the items
629
+	public $taxonomy  = '';
630 630
 
631
-    public $cpt_slugs = array();
631
+	public $cpt_slugs = array();
632 632
 
633
-    public $term_slug = '';
633
+	public $term_slug = '';
634 634
 
635 635
 
636 636
 
637
-    /**
638
-     * constructor
639
-     *
640
-     * @param string $taxonomy  The taxonomy the default term belongs to
641
-     * @param string $term_slug The slug of the term that will be the default.
642
-     * @param array  $cpt_slugs The custom post type the default term gets saved with
643
-     */
644
-    public function __construct($taxonomy, $term_slug, $cpt_slugs = array())
645
-    {
646
-        $this->taxonomy = $taxonomy;
647
-        $this->cpt_slugs = (array)$cpt_slugs;
648
-        $this->term_slug = $term_slug;
649
-    }
637
+	/**
638
+	 * constructor
639
+	 *
640
+	 * @param string $taxonomy  The taxonomy the default term belongs to
641
+	 * @param string $term_slug The slug of the term that will be the default.
642
+	 * @param array  $cpt_slugs The custom post type the default term gets saved with
643
+	 */
644
+	public function __construct($taxonomy, $term_slug, $cpt_slugs = array())
645
+	{
646
+		$this->taxonomy = $taxonomy;
647
+		$this->cpt_slugs = (array)$cpt_slugs;
648
+		$this->term_slug = $term_slug;
649
+	}
650 650
 
651 651
 }
Please login to merge, or discard this patch.
admin_pages/transactions/EE_Admin_Transactions_List_Table.class.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      *
103 103
      * @abstract
104 104
      * @access protected
105
-     * @return array
105
+     * @return string[]
106 106
      */
107 107
     protected function _get_table_filters()
108 108
     {
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
      *    column_TXN_paid
266 266
      *
267 267
      * @param \EE_Transaction $transaction
268
-     * @return mixed|string
268
+     * @return string
269 269
      * @throws \EE_Error
270 270
      */
271 271
     public function column_TXN_paid(EE_Transaction $transaction)
Please login to merge, or discard this patch.
Indentation   +606 added lines, -606 removed lines patch added patch discarded remove patch
@@ -13,114 +13,114 @@  discard block
 block discarded – undo
13 13
 class EE_Admin_Transactions_List_Table extends EE_Admin_List_Table
14 14
 {
15 15
 
16
-    private $_status;
17
-
18
-
19
-    /**
20
-     * @param \Transactions_Admin_Page $admin_page
21
-     */
22
-    public function __construct(\Transactions_Admin_Page $admin_page)
23
-    {
24
-        parent::__construct($admin_page);
25
-        $this->_status = $this->_admin_page->get_transaction_status_array();
26
-    }
27
-
28
-
29
-    /**
30
-     *_setup_data
31
-     */
32
-    protected function _setup_data()
33
-    {
34
-        $this->_data           = $this->_admin_page->get_transactions($this->_per_page);
35
-        $status                = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all';
36
-        $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status);
37
-    }
38
-
39
-
40
-    /**
41
-     *_set_properties
42
-     */
43
-    protected function _set_properties()
44
-    {
45
-        $this->_wp_list_args = array(
46
-            'singular' => __('transaction', 'event_espresso'),
47
-            'plural'   => __('transactions', 'event_espresso'),
48
-            'ajax'     => true,
49
-            'screen'   => $this->_admin_page->get_current_screen()->id,
50
-        );
51
-        $ID_column_name      = __('ID', 'event_espresso');
52
-        $ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
53
-        $ID_column_name      .= __('Transaction Date', 'event_espresso');
54
-        $ID_column_name      .= '</span> ';
55
-        $this->_columns      = array(
56
-            'TXN_ID'        => $ID_column_name,
57
-            'TXN_timestamp' => __('Transaction Date', 'event_espresso'),
58
-            'TXN_total'     => __('Total', 'event_espresso'),
59
-            'TXN_paid'      => __('Paid', 'event_espresso'),
60
-            'ATT_fname'     => __('Primary Registrant', 'event_espresso'),
61
-            'event_name'    => __('Event', 'event_espresso'),
62
-            'actions'       => __('Actions', 'event_espresso'),
63
-        );
64
-
65
-        $this->_sortable_columns = array(
66
-            'TXN_ID'        => array('TXN_ID' => false),
67
-            'event_name'    => array('event_name' => false),
68
-            'ATT_fname'     => array('ATT_fname' => false),
69
-            'TXN_timestamp' => array('TXN_timestamp' => true) //true means its already sorted
70
-        );
71
-
72
-        $this->_primary_column = 'TXN_ID';
73
-
74
-        $this->_hidden_columns = array();
75
-    }
76
-
77
-
78
-    /**
79
-     * This simply sets up the row class for the table rows.
80
-     * Allows for easier overriding of child methods for setting up sorting.
81
-     *
82
-     * @param  EE_Transaction $transaction the current item
83
-     * @return string
84
-     * @throws \EE_Error
85
-     */
86
-    protected function _get_row_class($transaction)
87
-    {
88
-        $class = parent::_get_row_class($transaction);
89
-        //add status class
90
-        $class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
91
-        if ($this->_has_checkbox_column) {
92
-            $class .= ' has-checkbox-column';
93
-        }
94
-        return $class;
95
-    }
96
-
97
-
98
-    /**
99
-     * _get_table_filters
100
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
101
-     * get's shown in the table.
102
-     *
103
-     * @abstract
104
-     * @access protected
105
-     * @return array
106
-     */
107
-    protected function _get_table_filters()
108
-    {
109
-        $filters    = array();
110
-        $start_date = isset($this->_req_data['txn-filter-start-date'])
111
-            ? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
112
-            : date(
113
-                'm/d/Y',
114
-                strtotime('-10 year')
115
-            );
116
-        $end_date   = isset($this->_req_data['txn-filter-end-date'])
117
-            ? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
118
-            : date(
119
-                'm/d/Y',
120
-                current_time('timestamp')
121
-            );
122
-        ob_start();
123
-        ?>
16
+	private $_status;
17
+
18
+
19
+	/**
20
+	 * @param \Transactions_Admin_Page $admin_page
21
+	 */
22
+	public function __construct(\Transactions_Admin_Page $admin_page)
23
+	{
24
+		parent::__construct($admin_page);
25
+		$this->_status = $this->_admin_page->get_transaction_status_array();
26
+	}
27
+
28
+
29
+	/**
30
+	 *_setup_data
31
+	 */
32
+	protected function _setup_data()
33
+	{
34
+		$this->_data           = $this->_admin_page->get_transactions($this->_per_page);
35
+		$status                = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all';
36
+		$this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status);
37
+	}
38
+
39
+
40
+	/**
41
+	 *_set_properties
42
+	 */
43
+	protected function _set_properties()
44
+	{
45
+		$this->_wp_list_args = array(
46
+			'singular' => __('transaction', 'event_espresso'),
47
+			'plural'   => __('transactions', 'event_espresso'),
48
+			'ajax'     => true,
49
+			'screen'   => $this->_admin_page->get_current_screen()->id,
50
+		);
51
+		$ID_column_name      = __('ID', 'event_espresso');
52
+		$ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
53
+		$ID_column_name      .= __('Transaction Date', 'event_espresso');
54
+		$ID_column_name      .= '</span> ';
55
+		$this->_columns      = array(
56
+			'TXN_ID'        => $ID_column_name,
57
+			'TXN_timestamp' => __('Transaction Date', 'event_espresso'),
58
+			'TXN_total'     => __('Total', 'event_espresso'),
59
+			'TXN_paid'      => __('Paid', 'event_espresso'),
60
+			'ATT_fname'     => __('Primary Registrant', 'event_espresso'),
61
+			'event_name'    => __('Event', 'event_espresso'),
62
+			'actions'       => __('Actions', 'event_espresso'),
63
+		);
64
+
65
+		$this->_sortable_columns = array(
66
+			'TXN_ID'        => array('TXN_ID' => false),
67
+			'event_name'    => array('event_name' => false),
68
+			'ATT_fname'     => array('ATT_fname' => false),
69
+			'TXN_timestamp' => array('TXN_timestamp' => true) //true means its already sorted
70
+		);
71
+
72
+		$this->_primary_column = 'TXN_ID';
73
+
74
+		$this->_hidden_columns = array();
75
+	}
76
+
77
+
78
+	/**
79
+	 * This simply sets up the row class for the table rows.
80
+	 * Allows for easier overriding of child methods for setting up sorting.
81
+	 *
82
+	 * @param  EE_Transaction $transaction the current item
83
+	 * @return string
84
+	 * @throws \EE_Error
85
+	 */
86
+	protected function _get_row_class($transaction)
87
+	{
88
+		$class = parent::_get_row_class($transaction);
89
+		//add status class
90
+		$class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
91
+		if ($this->_has_checkbox_column) {
92
+			$class .= ' has-checkbox-column';
93
+		}
94
+		return $class;
95
+	}
96
+
97
+
98
+	/**
99
+	 * _get_table_filters
100
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
101
+	 * get's shown in the table.
102
+	 *
103
+	 * @abstract
104
+	 * @access protected
105
+	 * @return array
106
+	 */
107
+	protected function _get_table_filters()
108
+	{
109
+		$filters    = array();
110
+		$start_date = isset($this->_req_data['txn-filter-start-date'])
111
+			? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
112
+			: date(
113
+				'm/d/Y',
114
+				strtotime('-10 year')
115
+			);
116
+		$end_date   = isset($this->_req_data['txn-filter-end-date'])
117
+			? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
118
+			: date(
119
+				'm/d/Y',
120
+				current_time('timestamp')
121
+			);
122
+		ob_start();
123
+		?>
124 124
         <label for="txn-filter-start-date">Display Transactions from </label>
125 125
         <input id="txn-filter-start-date" class="datepicker" type="text" value="<?php echo $start_date; ?>"
126 126
                name="txn-filter-start-date" size="15"/>
@@ -128,534 +128,534 @@  discard block
 block discarded – undo
128 128
         <input id="txn-filter-end-date" class="datepicker" type="text" value="<?php echo $end_date; ?>"
129 129
                name="txn-filter-end-date" size="15"/>
130 130
         <?php
131
-        $filters[] = ob_get_contents();
132
-        ob_end_clean();
133
-        return $filters;
134
-    }
135
-
136
-
137
-    /**
138
-     *_add_view_counts
139
-     */
140
-    protected function _add_view_counts()
141
-    {
142
-        $this->_views['all']['count']       = $this->_admin_page->get_transactions($this->_per_page, true, 'all');
143
-        $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'abandoned');
144
-        $this->_views['failed']['count']    = $this->_admin_page->get_transactions($this->_per_page, true, 'failed');
145
-    }
146
-
147
-
148
-    /**
149
-     *    column TXN_ID
150
-     *
151
-     * @param \EE_Transaction $transaction
152
-     * @return string
153
-     * @throws \EE_Error
154
-     */
155
-    public function column_TXN_ID(EE_Transaction $transaction)
156
-    {
157
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
158
-            'action' => 'view_transaction',
159
-            'TXN_ID' => $transaction->ID(),
160
-        ), TXN_ADMIN_URL);
161
-        $content      = '<a href="' . $view_lnk_url . '"'
162
-                        . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
163
-                        . $transaction->ID()
164
-                        . '</a>';
165
-
166
-        //txn timestamp
167
-        $content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
168
-        return $content;
169
-    }
170
-
171
-
172
-    /**
173
-     * @param \EE_Transaction $transaction
174
-     * @return string
175
-     * @throws \EE_Error
176
-     */
177
-    protected function _get_txn_timestamp(EE_Transaction $transaction)
178
-    {
179
-        //txn timestamp
180
-        // is TXN less than 2 hours old ?
181
-        if (($transaction->failed() || $transaction->is_abandoned())
182
-            && (
183
-                (time() - EE_Registry::instance()->SSN->lifespan()) < $transaction->datetime(false, true)
184
-            )
185
-        ) {
186
-            $timestamp = esc_html__('TXN in progress...', 'event_espresso');
187
-        } else {
188
-            $timestamp = $transaction->get_i18n_datetime('TXN_timestamp');
189
-        }
190
-        return $timestamp;
191
-    }
192
-
193
-
194
-    /**
195
-     *    column_cb
196
-     *
197
-     * @param \EE_Transaction $transaction
198
-     * @return string
199
-     * @throws \EE_Error
200
-     */
201
-    public function column_cb($transaction)
202
-    {
203
-        return sprintf(
204
-            '<input type="checkbox" name="%1$s[]" value="%2$s" />',
205
-            $this->_wp_list_args['singular'],
206
-            $transaction->ID()
207
-        );
208
-    }
209
-
210
-
211
-    /**
212
-     *    column_TXN_timestamp
213
-     *
214
-     * @param \EE_Transaction $transaction
215
-     * @return string
216
-     * @throws \EE_Error
217
-     */
218
-    public function column_TXN_timestamp(EE_Transaction $transaction)
219
-    {
220
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
221
-            'action' => 'view_transaction',
222
-            'TXN_ID' => $transaction->ID(),
223
-        ), TXN_ADMIN_URL);
224
-        $txn_date     = '<a href="' . $view_lnk_url . '"'
225
-                        . ' title="'
226
-                        . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
227
-                        . $this->_get_txn_timestamp($transaction)
228
-                        . '</a>';
229
-        //status
230
-        $txn_date .= '<br><span class="ee-status-text-small">'
231
-                     . EEH_Template::pretty_status(
232
-                         $transaction->status_ID(),
233
-                         false,
234
-                         'sentence'
235
-                     )
236
-                     . '</span>';
237
-        return $txn_date;
238
-    }
239
-
240
-
241
-    /**
242
-     *    column_TXN_total
243
-     *
244
-     * @param \EE_Transaction $transaction
245
-     * @return string
246
-     * @throws \EE_Error
247
-     */
248
-    public function column_TXN_total(EE_Transaction $transaction)
249
-    {
250
-        if ($transaction->get('TXN_total') > 0) {
251
-            return '<span class="txn-pad-rght">'
252
-                   . apply_filters(
253
-                       'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total',
254
-                       $transaction->get_pretty('TXN_total'),
255
-                       $transaction
256
-                   )
257
-                   . '</span>';
258
-        } else {
259
-            return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
260
-        }
261
-    }
262
-
263
-
264
-    /**
265
-     *    column_TXN_paid
266
-     *
267
-     * @param \EE_Transaction $transaction
268
-     * @return mixed|string
269
-     * @throws \EE_Error
270
-     */
271
-    public function column_TXN_paid(EE_Transaction $transaction)
272
-    {
273
-        $transaction_total = $transaction->get('TXN_total');
274
-        $transaction_paid  = $transaction->get('TXN_paid');
275
-
276
-        if (\EEH_Money::compare_floats($transaction_total, 0, '>')) {
277
-            // monies owing
278
-            $span_class = 'txn-overview-part-payment-spn';
279
-            if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) {
280
-                // paid in full
281
-                $span_class = 'txn-overview-full-payment-spn';
282
-            } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) {
283
-                // no payments made
284
-                $span_class = 'txn-overview-no-payment-spn';
285
-            }
286
-        } else {
287
-            $span_class       = 'txn-overview-free-event-spn';
288
-            $transaction_paid = 0;
289
-        }
290
-
291
-        $payment_method      = $transaction->payment_method();
292
-        $payment_method_name = $payment_method instanceof EE_Payment_Method
293
-            ? $payment_method->admin_name()
294
-            : esc_html__('Unknown', 'event_espresso');
295
-        $transaction_paid_content = $transaction_paid !== 0 ? $transaction->get_pretty('TXN_paid') : $transaction_paid;
296
-
297
-        $content = '<span class="' . $span_class . ' txn-pad-rght">'
298
-                   . $transaction_paid_content
299
-                   . '</span>';
300
-        if ($transaction_paid > 0) {
301
-            $content .= '<br><span class="ee-status-text-small">'
302
-                        . sprintf(
303
-                            esc_html__('...via %s', 'event_espresso'),
304
-                            $payment_method_name
305
-                        )
306
-                        . '</span>';
307
-        }
308
-        return $content;
309
-    }
310
-
311
-
312
-    /**
313
-     *    column_ATT_fname
314
-     *
315
-     * @param \EE_Transaction $transaction
316
-     * @return string
317
-     * @throws \EE_Error
318
-     */
319
-    public function column_ATT_fname(EE_Transaction $transaction)
320
-    {
321
-        $primary_reg = $transaction->primary_registration();
322
-        $attendee    = $primary_reg->get_first_related('Attendee');
323
-        if ($attendee instanceof EE_Attendee) {
324
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
325
-                'action'  => 'view_registration',
326
-                '_REG_ID' => $primary_reg->ID(),
327
-            ), REG_ADMIN_URL);
328
-            $content      = EE_Registry::instance()->CAP->current_user_can(
329
-                'ee_read_registration',
330
-                'espresso_registrations_view_registration',
331
-                $primary_reg->ID()
332
-            )
333
-                ? '<a href="' . $edit_lnk_url . '"'
334
-                    . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
335
-                    . $attendee->full_name()
336
-                    . '</a>'
337
-                : $attendee->full_name();
338
-            $content      .= '<br>' . $attendee->email();
339
-            return $content;
340
-        }
341
-        return $transaction->failed() || $transaction->is_abandoned()
342
-            ? esc_html__('no contact record.', 'event_espresso')
343
-            : esc_html__(
344
-                'No contact record, because the transaction was abandoned or the registration process failed.',
345
-                'event_espresso'
346
-            );
347
-    }
348
-
349
-
350
-    /**
351
-     *    column_ATT_email
352
-     *
353
-     * @param \EE_Transaction $transaction
354
-     * @return string
355
-     * @throws \EE_Error
356
-     */
357
-    public function column_ATT_email(EE_Transaction $transaction)
358
-    {
359
-        $attendee = $transaction->primary_registration()->get_first_related('Attendee');
360
-        if (! empty($attendee)) {
361
-            return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
362
-                   . $attendee->get('ATT_email')
363
-                   . '</a>';
364
-        } else {
365
-            return $transaction->failed() || $transaction->is_abandoned()
366
-                ? esc_html__('no contact record.', 'event_espresso')
367
-                : esc_html__(
368
-                    'No contact record, because the transaction was abandoned or the registration process failed.',
369
-                    'event_espresso'
370
-                );
371
-        }
372
-    }
373
-
374
-
375
-    /**
376
-     *    column_event_name
377
-     *
378
-     * @param \EE_Transaction $transaction
379
-     * @return string
380
-     * @throws \EE_Error
381
-     */
382
-    public function column_event_name(EE_Transaction $transaction)
383
-    {
384
-        $actions = array();
385
-        $event   = $transaction->primary_registration()->get_first_related('Event');
386
-        if (! empty($event)) {
387
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
388
-                array('action' => 'edit', 'post' => $event->ID()),
389
-                EVENTS_ADMIN_URL
390
-            );
391
-            $event_name     = $event->get('EVT_name');
392
-
393
-            //filter this view by transactions for this event
394
-            $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(array(
395
-                'action' => 'default',
396
-                'EVT_ID' => $event->ID(),
397
-            ));
398
-            if (EE_Registry::instance()->CAP->current_user_can(
399
-                'ee_edit_event',
400
-                'espresso_events_edit',
401
-                $event->ID()
402
-            )) {
403
-                $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
404
-                        . ' title="' . esc_attr__('Filter transactions by this event', 'event_espresso') . '">'
405
-                        . esc_html__('View Transactions for this event', 'event_espresso')
406
-                        . '</a>';
407
-            }
408
-
409
-            return sprintf(
410
-                '%1$s %2$s',
411
-                EE_Registry::instance()->CAP->current_user_can(
412
-                    'ee_edit_event',
413
-                    'espresso_events_edit',
414
-                    $event->ID()
415
-                )
416
-                    ? '<a href="' . $edit_event_url . '"'
417
-                        . ' title="'
418
-                        . sprintf(
419
-                            esc_attr__('Edit Event: %s', 'event_espresso'),
420
-                            $event->get('EVT_name')
421
-                        )
422
-                        . '">'
423
-                        . wp_trim_words(
424
-                            $event_name,
425
-                            30,
426
-                            '...'
427
-                        )
428
-                        . '</a>'
429
-                        : wp_trim_words($event_name, 30, '...'),
430
-                $this->row_actions($actions)
431
-            );
432
-        } else {
433
-            return esc_html__(
434
-                'The event associated with this transaction via the primary registration cannot be retrieved.',
435
-                'event_espresso'
436
-            );
437
-        }
438
-    }
439
-
440
-
441
-    /**
442
-     *    column_actions
443
-     *
444
-     * @param \EE_Transaction $transaction
445
-     * @return string
446
-     * @throws \EE_Error
447
-     */
448
-    public function column_actions(EE_Transaction $transaction)
449
-    {
450
-        return $this->_action_string(
451
-            $this->get_transaction_details_link($transaction)
452
-            . $this->get_invoice_link($transaction)
453
-            . $this->get_receipt_link($transaction)
454
-            . $this->get_primary_registration_details_link($transaction)
455
-            . $this->get_send_payment_reminder_trigger_link($transaction)
456
-            . $this->get_payment_overview_link($transaction)
457
-            . $this->get_related_messages_link($transaction),
458
-            $transaction,
459
-            'ul',
460
-            'txn-overview-actions-ul'
461
-        );
462
-    }
463
-
464
-
465
-    /**
466
-     * Get the transaction details link.
467
-     * @param EE_Transaction $transaction
468
-     * @return string
469
-     * @throws EE_Error
470
-     */
471
-    protected function get_transaction_details_link(EE_Transaction $transaction)
472
-    {
473
-        $url          = EE_Admin_Page::add_query_args_and_nonce(array(
474
-            'action' => 'view_transaction',
475
-            'TXN_ID' => $transaction->ID(),
476
-        ), TXN_ADMIN_URL);
477
-        return '
131
+		$filters[] = ob_get_contents();
132
+		ob_end_clean();
133
+		return $filters;
134
+	}
135
+
136
+
137
+	/**
138
+	 *_add_view_counts
139
+	 */
140
+	protected function _add_view_counts()
141
+	{
142
+		$this->_views['all']['count']       = $this->_admin_page->get_transactions($this->_per_page, true, 'all');
143
+		$this->_views['abandoned']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'abandoned');
144
+		$this->_views['failed']['count']    = $this->_admin_page->get_transactions($this->_per_page, true, 'failed');
145
+	}
146
+
147
+
148
+	/**
149
+	 *    column TXN_ID
150
+	 *
151
+	 * @param \EE_Transaction $transaction
152
+	 * @return string
153
+	 * @throws \EE_Error
154
+	 */
155
+	public function column_TXN_ID(EE_Transaction $transaction)
156
+	{
157
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
158
+			'action' => 'view_transaction',
159
+			'TXN_ID' => $transaction->ID(),
160
+		), TXN_ADMIN_URL);
161
+		$content      = '<a href="' . $view_lnk_url . '"'
162
+						. ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
163
+						. $transaction->ID()
164
+						. '</a>';
165
+
166
+		//txn timestamp
167
+		$content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
168
+		return $content;
169
+	}
170
+
171
+
172
+	/**
173
+	 * @param \EE_Transaction $transaction
174
+	 * @return string
175
+	 * @throws \EE_Error
176
+	 */
177
+	protected function _get_txn_timestamp(EE_Transaction $transaction)
178
+	{
179
+		//txn timestamp
180
+		// is TXN less than 2 hours old ?
181
+		if (($transaction->failed() || $transaction->is_abandoned())
182
+			&& (
183
+				(time() - EE_Registry::instance()->SSN->lifespan()) < $transaction->datetime(false, true)
184
+			)
185
+		) {
186
+			$timestamp = esc_html__('TXN in progress...', 'event_espresso');
187
+		} else {
188
+			$timestamp = $transaction->get_i18n_datetime('TXN_timestamp');
189
+		}
190
+		return $timestamp;
191
+	}
192
+
193
+
194
+	/**
195
+	 *    column_cb
196
+	 *
197
+	 * @param \EE_Transaction $transaction
198
+	 * @return string
199
+	 * @throws \EE_Error
200
+	 */
201
+	public function column_cb($transaction)
202
+	{
203
+		return sprintf(
204
+			'<input type="checkbox" name="%1$s[]" value="%2$s" />',
205
+			$this->_wp_list_args['singular'],
206
+			$transaction->ID()
207
+		);
208
+	}
209
+
210
+
211
+	/**
212
+	 *    column_TXN_timestamp
213
+	 *
214
+	 * @param \EE_Transaction $transaction
215
+	 * @return string
216
+	 * @throws \EE_Error
217
+	 */
218
+	public function column_TXN_timestamp(EE_Transaction $transaction)
219
+	{
220
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
221
+			'action' => 'view_transaction',
222
+			'TXN_ID' => $transaction->ID(),
223
+		), TXN_ADMIN_URL);
224
+		$txn_date     = '<a href="' . $view_lnk_url . '"'
225
+						. ' title="'
226
+						. esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
227
+						. $this->_get_txn_timestamp($transaction)
228
+						. '</a>';
229
+		//status
230
+		$txn_date .= '<br><span class="ee-status-text-small">'
231
+					 . EEH_Template::pretty_status(
232
+						 $transaction->status_ID(),
233
+						 false,
234
+						 'sentence'
235
+					 )
236
+					 . '</span>';
237
+		return $txn_date;
238
+	}
239
+
240
+
241
+	/**
242
+	 *    column_TXN_total
243
+	 *
244
+	 * @param \EE_Transaction $transaction
245
+	 * @return string
246
+	 * @throws \EE_Error
247
+	 */
248
+	public function column_TXN_total(EE_Transaction $transaction)
249
+	{
250
+		if ($transaction->get('TXN_total') > 0) {
251
+			return '<span class="txn-pad-rght">'
252
+				   . apply_filters(
253
+					   'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total',
254
+					   $transaction->get_pretty('TXN_total'),
255
+					   $transaction
256
+				   )
257
+				   . '</span>';
258
+		} else {
259
+			return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
260
+		}
261
+	}
262
+
263
+
264
+	/**
265
+	 *    column_TXN_paid
266
+	 *
267
+	 * @param \EE_Transaction $transaction
268
+	 * @return mixed|string
269
+	 * @throws \EE_Error
270
+	 */
271
+	public function column_TXN_paid(EE_Transaction $transaction)
272
+	{
273
+		$transaction_total = $transaction->get('TXN_total');
274
+		$transaction_paid  = $transaction->get('TXN_paid');
275
+
276
+		if (\EEH_Money::compare_floats($transaction_total, 0, '>')) {
277
+			// monies owing
278
+			$span_class = 'txn-overview-part-payment-spn';
279
+			if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) {
280
+				// paid in full
281
+				$span_class = 'txn-overview-full-payment-spn';
282
+			} elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) {
283
+				// no payments made
284
+				$span_class = 'txn-overview-no-payment-spn';
285
+			}
286
+		} else {
287
+			$span_class       = 'txn-overview-free-event-spn';
288
+			$transaction_paid = 0;
289
+		}
290
+
291
+		$payment_method      = $transaction->payment_method();
292
+		$payment_method_name = $payment_method instanceof EE_Payment_Method
293
+			? $payment_method->admin_name()
294
+			: esc_html__('Unknown', 'event_espresso');
295
+		$transaction_paid_content = $transaction_paid !== 0 ? $transaction->get_pretty('TXN_paid') : $transaction_paid;
296
+
297
+		$content = '<span class="' . $span_class . ' txn-pad-rght">'
298
+				   . $transaction_paid_content
299
+				   . '</span>';
300
+		if ($transaction_paid > 0) {
301
+			$content .= '<br><span class="ee-status-text-small">'
302
+						. sprintf(
303
+							esc_html__('...via %s', 'event_espresso'),
304
+							$payment_method_name
305
+						)
306
+						. '</span>';
307
+		}
308
+		return $content;
309
+	}
310
+
311
+
312
+	/**
313
+	 *    column_ATT_fname
314
+	 *
315
+	 * @param \EE_Transaction $transaction
316
+	 * @return string
317
+	 * @throws \EE_Error
318
+	 */
319
+	public function column_ATT_fname(EE_Transaction $transaction)
320
+	{
321
+		$primary_reg = $transaction->primary_registration();
322
+		$attendee    = $primary_reg->get_first_related('Attendee');
323
+		if ($attendee instanceof EE_Attendee) {
324
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
325
+				'action'  => 'view_registration',
326
+				'_REG_ID' => $primary_reg->ID(),
327
+			), REG_ADMIN_URL);
328
+			$content      = EE_Registry::instance()->CAP->current_user_can(
329
+				'ee_read_registration',
330
+				'espresso_registrations_view_registration',
331
+				$primary_reg->ID()
332
+			)
333
+				? '<a href="' . $edit_lnk_url . '"'
334
+					. ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
335
+					. $attendee->full_name()
336
+					. '</a>'
337
+				: $attendee->full_name();
338
+			$content      .= '<br>' . $attendee->email();
339
+			return $content;
340
+		}
341
+		return $transaction->failed() || $transaction->is_abandoned()
342
+			? esc_html__('no contact record.', 'event_espresso')
343
+			: esc_html__(
344
+				'No contact record, because the transaction was abandoned or the registration process failed.',
345
+				'event_espresso'
346
+			);
347
+	}
348
+
349
+
350
+	/**
351
+	 *    column_ATT_email
352
+	 *
353
+	 * @param \EE_Transaction $transaction
354
+	 * @return string
355
+	 * @throws \EE_Error
356
+	 */
357
+	public function column_ATT_email(EE_Transaction $transaction)
358
+	{
359
+		$attendee = $transaction->primary_registration()->get_first_related('Attendee');
360
+		if (! empty($attendee)) {
361
+			return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
362
+				   . $attendee->get('ATT_email')
363
+				   . '</a>';
364
+		} else {
365
+			return $transaction->failed() || $transaction->is_abandoned()
366
+				? esc_html__('no contact record.', 'event_espresso')
367
+				: esc_html__(
368
+					'No contact record, because the transaction was abandoned or the registration process failed.',
369
+					'event_espresso'
370
+				);
371
+		}
372
+	}
373
+
374
+
375
+	/**
376
+	 *    column_event_name
377
+	 *
378
+	 * @param \EE_Transaction $transaction
379
+	 * @return string
380
+	 * @throws \EE_Error
381
+	 */
382
+	public function column_event_name(EE_Transaction $transaction)
383
+	{
384
+		$actions = array();
385
+		$event   = $transaction->primary_registration()->get_first_related('Event');
386
+		if (! empty($event)) {
387
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
388
+				array('action' => 'edit', 'post' => $event->ID()),
389
+				EVENTS_ADMIN_URL
390
+			);
391
+			$event_name     = $event->get('EVT_name');
392
+
393
+			//filter this view by transactions for this event
394
+			$txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(array(
395
+				'action' => 'default',
396
+				'EVT_ID' => $event->ID(),
397
+			));
398
+			if (EE_Registry::instance()->CAP->current_user_can(
399
+				'ee_edit_event',
400
+				'espresso_events_edit',
401
+				$event->ID()
402
+			)) {
403
+				$actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
404
+						. ' title="' . esc_attr__('Filter transactions by this event', 'event_espresso') . '">'
405
+						. esc_html__('View Transactions for this event', 'event_espresso')
406
+						. '</a>';
407
+			}
408
+
409
+			return sprintf(
410
+				'%1$s %2$s',
411
+				EE_Registry::instance()->CAP->current_user_can(
412
+					'ee_edit_event',
413
+					'espresso_events_edit',
414
+					$event->ID()
415
+				)
416
+					? '<a href="' . $edit_event_url . '"'
417
+						. ' title="'
418
+						. sprintf(
419
+							esc_attr__('Edit Event: %s', 'event_espresso'),
420
+							$event->get('EVT_name')
421
+						)
422
+						. '">'
423
+						. wp_trim_words(
424
+							$event_name,
425
+							30,
426
+							'...'
427
+						)
428
+						. '</a>'
429
+						: wp_trim_words($event_name, 30, '...'),
430
+				$this->row_actions($actions)
431
+			);
432
+		} else {
433
+			return esc_html__(
434
+				'The event associated with this transaction via the primary registration cannot be retrieved.',
435
+				'event_espresso'
436
+			);
437
+		}
438
+	}
439
+
440
+
441
+	/**
442
+	 *    column_actions
443
+	 *
444
+	 * @param \EE_Transaction $transaction
445
+	 * @return string
446
+	 * @throws \EE_Error
447
+	 */
448
+	public function column_actions(EE_Transaction $transaction)
449
+	{
450
+		return $this->_action_string(
451
+			$this->get_transaction_details_link($transaction)
452
+			. $this->get_invoice_link($transaction)
453
+			. $this->get_receipt_link($transaction)
454
+			. $this->get_primary_registration_details_link($transaction)
455
+			. $this->get_send_payment_reminder_trigger_link($transaction)
456
+			. $this->get_payment_overview_link($transaction)
457
+			. $this->get_related_messages_link($transaction),
458
+			$transaction,
459
+			'ul',
460
+			'txn-overview-actions-ul'
461
+		);
462
+	}
463
+
464
+
465
+	/**
466
+	 * Get the transaction details link.
467
+	 * @param EE_Transaction $transaction
468
+	 * @return string
469
+	 * @throws EE_Error
470
+	 */
471
+	protected function get_transaction_details_link(EE_Transaction $transaction)
472
+	{
473
+		$url          = EE_Admin_Page::add_query_args_and_nonce(array(
474
+			'action' => 'view_transaction',
475
+			'TXN_ID' => $transaction->ID(),
476
+		), TXN_ADMIN_URL);
477
+		return '
478 478
 			<li>
479 479
 				<a href="' . $url . '"'
480
-                    . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
480
+					. ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
481 481
 					<span class="dashicons dashicons-cart"></span>
482 482
 				</a>
483 483
 			</li>';
484
-    }
485
-
486
-
487
-    /**
488
-     * Get the invoice link for the given registration.
489
-     * @param EE_Transaction $transaction
490
-     * @return string
491
-     * @throws EE_Error
492
-     */
493
-    protected function get_invoice_link(EE_Transaction $transaction)
494
-    {
495
-        $registration = $transaction->primary_registration();
496
-        if ($registration instanceof EE_Registration) {
497
-            $url = $registration->invoice_url();
498
-            //only show invoice link if message type is active.
499
-            if ($registration->attendee() instanceof EE_Attendee
500
-                && EEH_MSG_Template::is_mt_active('invoice')
501
-            ) {
502
-                return '
484
+	}
485
+
486
+
487
+	/**
488
+	 * Get the invoice link for the given registration.
489
+	 * @param EE_Transaction $transaction
490
+	 * @return string
491
+	 * @throws EE_Error
492
+	 */
493
+	protected function get_invoice_link(EE_Transaction $transaction)
494
+	{
495
+		$registration = $transaction->primary_registration();
496
+		if ($registration instanceof EE_Registration) {
497
+			$url = $registration->invoice_url();
498
+			//only show invoice link if message type is active.
499
+			if ($registration->attendee() instanceof EE_Attendee
500
+				&& EEH_MSG_Template::is_mt_active('invoice')
501
+			) {
502
+				return '
503 503
                 <li>
504 504
                     <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"'
505
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
505
+					   . ' target="_blank" href="' . $url . '" class="tiny-text">
506 506
                         <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
507 507
                     </a>
508 508
                 </li>';
509
-            }
510
-        }
511
-        return '';
512
-    }
513
-
514
-
515
-    /**
516
-     * Get the receipt link for the transaction.
517
-     * @param EE_Transaction $transaction
518
-     * @return string
519
-     * @throws EE_Error
520
-     */
521
-    protected function get_receipt_link(EE_Transaction $transaction)
522
-    {
523
-        $registration = $transaction->primary_registration();
524
-        if ($registration instanceof EE_Registration) {
525
-            $url = $registration->receipt_url();
526
-            //only show receipt link if message type is active.
527
-            if ($registration->attendee() instanceof EE_Attendee
528
-                && EEH_MSG_Template::is_mt_active('receipt')) {
529
-                return '
509
+			}
510
+		}
511
+		return '';
512
+	}
513
+
514
+
515
+	/**
516
+	 * Get the receipt link for the transaction.
517
+	 * @param EE_Transaction $transaction
518
+	 * @return string
519
+	 * @throws EE_Error
520
+	 */
521
+	protected function get_receipt_link(EE_Transaction $transaction)
522
+	{
523
+		$registration = $transaction->primary_registration();
524
+		if ($registration instanceof EE_Registration) {
525
+			$url = $registration->receipt_url();
526
+			//only show receipt link if message type is active.
527
+			if ($registration->attendee() instanceof EE_Attendee
528
+				&& EEH_MSG_Template::is_mt_active('receipt')) {
529
+				return '
530 530
 			<li>
531 531
 				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"'
532
-                                  . ' target="_blank" href="' . $url . '" class="tiny-text">
532
+								  . ' target="_blank" href="' . $url . '" class="tiny-text">
533 533
 					<span class="dashicons dashicons-media-default ee-icon-size-18"></span>
534 534
 				</a>
535 535
 			</li>';
536
-            }
537
-        }
538
-        return '';
539
-    }
540
-
541
-
542
-    /**
543
-     * Get the link to view the details for the primary registration.
544
-     * @param EE_Transaction $transaction
545
-     * @return string
546
-     * @throws EE_Error
547
-     */
548
-    protected function get_primary_registration_details_link(EE_Transaction $transaction)
549
-    {
550
-        $registration = $transaction->primary_registration();
551
-        if ($registration instanceof EE_Registration) {
552
-            $url      = EE_Admin_Page::add_query_args_and_nonce(array(
553
-                'action'  => 'view_registration',
554
-                '_REG_ID' => $registration->ID(),
555
-            ), REG_ADMIN_URL);
556
-            return EE_Registry::instance()->CAP->current_user_can(
557
-                'ee_read_registration',
558
-                'espresso_registrations_view_registration',
559
-                $registration->ID()
560
-            )
561
-                ? '
536
+			}
537
+		}
538
+		return '';
539
+	}
540
+
541
+
542
+	/**
543
+	 * Get the link to view the details for the primary registration.
544
+	 * @param EE_Transaction $transaction
545
+	 * @return string
546
+	 * @throws EE_Error
547
+	 */
548
+	protected function get_primary_registration_details_link(EE_Transaction $transaction)
549
+	{
550
+		$registration = $transaction->primary_registration();
551
+		if ($registration instanceof EE_Registration) {
552
+			$url      = EE_Admin_Page::add_query_args_and_nonce(array(
553
+				'action'  => 'view_registration',
554
+				'_REG_ID' => $registration->ID(),
555
+			), REG_ADMIN_URL);
556
+			return EE_Registry::instance()->CAP->current_user_can(
557
+				'ee_read_registration',
558
+				'espresso_registrations_view_registration',
559
+				$registration->ID()
560
+			)
561
+				? '
562 562
 				<li>
563 563
 					<a href="' . $url . '"'
564
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
564
+				  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
565 565
 						<span class="dashicons dashicons-clipboard"></span>
566 566
 					</a>
567 567
 				</li>'
568
-                : '';
569
-        }
570
-        return '';
571
-    }
572
-
573
-
574
-    /**
575
-     * Get send payment reminder trigger link
576
-     * @param EE_Transaction $transaction
577
-     * @return string
578
-     * @throws EE_Error
579
-     */
580
-    protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction)
581
-    {
582
-        $registration = $transaction->primary_registration();
583
-        if ($registration instanceof EE_Registration
584
-            && $registration->attendee() instanceof EE_Attendee
585
-            && EEH_MSG_Template::is_mt_active('payment_reminder')
586
-            && ! in_array(
587
-                $transaction->status_ID(),
588
-                array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code),
589
-                true
590
-            )
591
-            && EE_Registry::instance()->CAP->current_user_can(
592
-                'ee_send_message',
593
-                'espresso_transactions_send_payment_reminder'
594
-            )
595
-        ) {
596
-            $url = EE_Admin_Page::add_query_args_and_nonce(array(
597
-                'action' => 'send_payment_reminder',
598
-                'TXN_ID' => $transaction->ID(),
599
-            ), TXN_ADMIN_URL);
600
-            return  '
568
+				: '';
569
+		}
570
+		return '';
571
+	}
572
+
573
+
574
+	/**
575
+	 * Get send payment reminder trigger link
576
+	 * @param EE_Transaction $transaction
577
+	 * @return string
578
+	 * @throws EE_Error
579
+	 */
580
+	protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction)
581
+	{
582
+		$registration = $transaction->primary_registration();
583
+		if ($registration instanceof EE_Registration
584
+			&& $registration->attendee() instanceof EE_Attendee
585
+			&& EEH_MSG_Template::is_mt_active('payment_reminder')
586
+			&& ! in_array(
587
+				$transaction->status_ID(),
588
+				array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code),
589
+				true
590
+			)
591
+			&& EE_Registry::instance()->CAP->current_user_can(
592
+				'ee_send_message',
593
+				'espresso_transactions_send_payment_reminder'
594
+			)
595
+		) {
596
+			$url = EE_Admin_Page::add_query_args_and_nonce(array(
597
+				'action' => 'send_payment_reminder',
598
+				'TXN_ID' => $transaction->ID(),
599
+			), TXN_ADMIN_URL);
600
+			return  '
601 601
             <li>
602 602
                 <a href="' . $url . '"'
603
-                  . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
603
+				  . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
604 604
                     <span class="dashicons dashicons-email-alt"></span>
605 605
                 </a>
606 606
             </li>';
607
-        }
608
-        return '';
609
-    }
610
-
611
-
612
-
613
-    /**
614
-     * Get link to filtered view in the message activity list table of messages for this transaction.
615
-     * @param EE_Transaction $transaction
616
-     * @return string
617
-     * @throws EE_Error
618
-     */
619
-    protected function get_related_messages_link(EE_Transaction $transaction)
620
-    {
621
-        $url = EEH_MSG_Template::get_message_action_link(
622
-            'see_notifications_for',
623
-            null,
624
-            array('TXN_ID' => $transaction->ID())
625
-        );
626
-        return EE_Registry::instance()->CAP->current_user_can(
627
-            'ee_read_global_messages',
628
-            'view_filtered_messages'
629
-        )
630
-            ? '<li>' . $url . '</li>'
631
-            : '';
632
-    }
633
-
634
-
635
-    /**
636
-     * Return the link to make a payment on the frontend
637
-     * @param EE_Transaction $transaction
638
-     * @return string
639
-     * @throws EE_Error
640
-     */
641
-    protected function get_payment_overview_link(EE_Transaction $transaction)
642
-    {
643
-        $registration = $transaction->primary_registration();
644
-        if ($registration instanceof EE_Registration
645
-            && $transaction->status_ID() !== EEM_Transaction::complete_status_code
646
-            && $registration->owes_monies_and_can_pay()
647
-        ) {
648
-            return '
607
+		}
608
+		return '';
609
+	}
610
+
611
+
612
+
613
+	/**
614
+	 * Get link to filtered view in the message activity list table of messages for this transaction.
615
+	 * @param EE_Transaction $transaction
616
+	 * @return string
617
+	 * @throws EE_Error
618
+	 */
619
+	protected function get_related_messages_link(EE_Transaction $transaction)
620
+	{
621
+		$url = EEH_MSG_Template::get_message_action_link(
622
+			'see_notifications_for',
623
+			null,
624
+			array('TXN_ID' => $transaction->ID())
625
+		);
626
+		return EE_Registry::instance()->CAP->current_user_can(
627
+			'ee_read_global_messages',
628
+			'view_filtered_messages'
629
+		)
630
+			? '<li>' . $url . '</li>'
631
+			: '';
632
+	}
633
+
634
+
635
+	/**
636
+	 * Return the link to make a payment on the frontend
637
+	 * @param EE_Transaction $transaction
638
+	 * @return string
639
+	 * @throws EE_Error
640
+	 */
641
+	protected function get_payment_overview_link(EE_Transaction $transaction)
642
+	{
643
+		$registration = $transaction->primary_registration();
644
+		if ($registration instanceof EE_Registration
645
+			&& $transaction->status_ID() !== EEM_Transaction::complete_status_code
646
+			&& $registration->owes_monies_and_can_pay()
647
+		) {
648
+			return '
649 649
             <li>
650 650
                 <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"'
651
-                    . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
652
-                    . ' class="tiny-text">
651
+					. ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
652
+					. ' class="tiny-text">
653 653
                     <span class="dashicons dashicons-money ee-icon-size-18"></span>
654 654
                 </a>
655 655
             </li>
656 656
             ';
657 657
 
658
-        }
659
-        return '';
660
-    }
658
+		}
659
+		return '';
660
+	}
661 661
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
             'ajax'     => true,
49 49
             'screen'   => $this->_admin_page->get_current_screen()->id,
50 50
         );
51
-        $ID_column_name      = __('ID', 'event_espresso');
51
+        $ID_column_name = __('ID', 'event_espresso');
52 52
         $ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
53 53
         $ID_column_name      .= __('Transaction Date', 'event_espresso');
54 54
         $ID_column_name      .= '</span> ';
55
-        $this->_columns      = array(
55
+        $this->_columns = array(
56 56
             'TXN_ID'        => $ID_column_name,
57 57
             'TXN_timestamp' => __('Transaction Date', 'event_espresso'),
58 58
             'TXN_total'     => __('Total', 'event_espresso'),
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     {
88 88
         $class = parent::_get_row_class($transaction);
89 89
         //add status class
90
-        $class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
90
+        $class .= ' ee-status-strip txn-status-'.$transaction->status_ID();
91 91
         if ($this->_has_checkbox_column) {
92 92
             $class .= ' has-checkbox-column';
93 93
         }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
                 'm/d/Y',
114 114
                 strtotime('-10 year')
115 115
             );
116
-        $end_date   = isset($this->_req_data['txn-filter-end-date'])
116
+        $end_date = isset($this->_req_data['txn-filter-end-date'])
117 117
             ? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
118 118
             : date(
119 119
                 'm/d/Y',
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
             'action' => 'view_transaction',
159 159
             'TXN_ID' => $transaction->ID(),
160 160
         ), TXN_ADMIN_URL);
161
-        $content      = '<a href="' . $view_lnk_url . '"'
162
-                        . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
161
+        $content = '<a href="'.$view_lnk_url.'"'
162
+                        . ' title="'.esc_attr__('Go to Transaction Details', 'event_espresso').'">'
163 163
                         . $transaction->ID()
164 164
                         . '</a>';
165 165
 
166 166
         //txn timestamp
167
-        $content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
167
+        $content .= '  <span class="show-on-mobile-view-only">'.$this->_get_txn_timestamp($transaction).'</span>';
168 168
         return $content;
169 169
     }
170 170
 
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
             'action' => 'view_transaction',
222 222
             'TXN_ID' => $transaction->ID(),
223 223
         ), TXN_ADMIN_URL);
224
-        $txn_date     = '<a href="' . $view_lnk_url . '"'
224
+        $txn_date = '<a href="'.$view_lnk_url.'"'
225 225
                         . ' title="'
226
-                        . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
226
+                        . esc_attr__('View Transaction Details for TXN #', 'event_espresso').$transaction->ID().'">'
227 227
                         . $this->_get_txn_timestamp($transaction)
228 228
                         . '</a>';
229 229
         //status
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
                    )
257 257
                    . '</span>';
258 258
         } else {
259
-            return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
259
+            return '<span class="txn-overview-free-event-spn">'.esc_html__('free', 'event_espresso').'</span>';
260 260
         }
261 261
     }
262 262
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
             : esc_html__('Unknown', 'event_espresso');
295 295
         $transaction_paid_content = $transaction_paid !== 0 ? $transaction->get_pretty('TXN_paid') : $transaction_paid;
296 296
 
297
-        $content = '<span class="' . $span_class . ' txn-pad-rght">'
297
+        $content = '<span class="'.$span_class.' txn-pad-rght">'
298 298
                    . $transaction_paid_content
299 299
                    . '</span>';
300 300
         if ($transaction_paid > 0) {
@@ -325,17 +325,17 @@  discard block
 block discarded – undo
325 325
                 'action'  => 'view_registration',
326 326
                 '_REG_ID' => $primary_reg->ID(),
327 327
             ), REG_ADMIN_URL);
328
-            $content      = EE_Registry::instance()->CAP->current_user_can(
328
+            $content = EE_Registry::instance()->CAP->current_user_can(
329 329
                 'ee_read_registration',
330 330
                 'espresso_registrations_view_registration',
331 331
                 $primary_reg->ID()
332 332
             )
333
-                ? '<a href="' . $edit_lnk_url . '"'
334
-                    . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
333
+                ? '<a href="'.$edit_lnk_url.'"'
334
+                    . ' title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
335 335
                     . $attendee->full_name()
336 336
                     . '</a>'
337 337
                 : $attendee->full_name();
338
-            $content      .= '<br>' . $attendee->email();
338
+            $content .= '<br>'.$attendee->email();
339 339
             return $content;
340 340
         }
341 341
         return $transaction->failed() || $transaction->is_abandoned()
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
     public function column_ATT_email(EE_Transaction $transaction)
358 358
     {
359 359
         $attendee = $transaction->primary_registration()->get_first_related('Attendee');
360
-        if (! empty($attendee)) {
361
-            return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
360
+        if ( ! empty($attendee)) {
361
+            return '<a href="mailto:'.$attendee->get('ATT_email').'">'
362 362
                    . $attendee->get('ATT_email')
363 363
                    . '</a>';
364 364
         } else {
@@ -383,12 +383,12 @@  discard block
 block discarded – undo
383 383
     {
384 384
         $actions = array();
385 385
         $event   = $transaction->primary_registration()->get_first_related('Event');
386
-        if (! empty($event)) {
386
+        if ( ! empty($event)) {
387 387
             $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
388 388
                 array('action' => 'edit', 'post' => $event->ID()),
389 389
                 EVENTS_ADMIN_URL
390 390
             );
391
-            $event_name     = $event->get('EVT_name');
391
+            $event_name = $event->get('EVT_name');
392 392
 
393 393
             //filter this view by transactions for this event
394 394
             $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(array(
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
                 'espresso_events_edit',
401 401
                 $event->ID()
402 402
             )) {
403
-                $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
404
-                        . ' title="' . esc_attr__('Filter transactions by this event', 'event_espresso') . '">'
403
+                $actions['filter_by_event'] = '<a href="'.$txn_by_event_lnk.'"'
404
+                        . ' title="'.esc_attr__('Filter transactions by this event', 'event_espresso').'">'
405 405
                         . esc_html__('View Transactions for this event', 'event_espresso')
406 406
                         . '</a>';
407 407
             }
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                     'espresso_events_edit',
414 414
                     $event->ID()
415 415
                 )
416
-                    ? '<a href="' . $edit_event_url . '"'
416
+                    ? '<a href="'.$edit_event_url.'"'
417 417
                         . ' title="'
418 418
                         . sprintf(
419 419
                             esc_attr__('Edit Event: %s', 'event_espresso'),
@@ -470,14 +470,14 @@  discard block
 block discarded – undo
470 470
      */
471 471
     protected function get_transaction_details_link(EE_Transaction $transaction)
472 472
     {
473
-        $url          = EE_Admin_Page::add_query_args_and_nonce(array(
473
+        $url = EE_Admin_Page::add_query_args_and_nonce(array(
474 474
             'action' => 'view_transaction',
475 475
             'TXN_ID' => $transaction->ID(),
476 476
         ), TXN_ADMIN_URL);
477 477
         return '
478 478
 			<li>
479
-				<a href="' . $url . '"'
480
-                    . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
479
+				<a href="' . $url.'"'
480
+                    . ' title="'.esc_attr__('View Transaction Details', 'event_espresso').'" class="tiny-text">
481 481
 					<span class="dashicons dashicons-cart"></span>
482 482
 				</a>
483 483
 			</li>';
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
             ) {
502 502
                 return '
503 503
                 <li>
504
-                    <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"'
505
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
504
+                    <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso').'"'
505
+                       . ' target="_blank" href="'.$url.'" class="tiny-text">
506 506
                         <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
507 507
                     </a>
508 508
                 </li>';
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
                 && EEH_MSG_Template::is_mt_active('receipt')) {
529 529
                 return '
530 530
 			<li>
531
-				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"'
532
-                                  . ' target="_blank" href="' . $url . '" class="tiny-text">
531
+				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso').'"'
532
+                                  . ' target="_blank" href="'.$url.'" class="tiny-text">
533 533
 					<span class="dashicons dashicons-media-default ee-icon-size-18"></span>
534 534
 				</a>
535 535
 			</li>';
@@ -560,8 +560,8 @@  discard block
 block discarded – undo
560 560
             )
561 561
                 ? '
562 562
 				<li>
563
-					<a href="' . $url . '"'
564
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
563
+					<a href="' . $url.'"'
564
+                  . ' title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text">
565 565
 						<span class="dashicons dashicons-clipboard"></span>
566 566
 					</a>
567 567
 				</li>'
@@ -599,8 +599,8 @@  discard block
 block discarded – undo
599 599
             ), TXN_ADMIN_URL);
600 600
             return  '
601 601
             <li>
602
-                <a href="' . $url . '"'
603
-                  . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
602
+                <a href="' . $url.'"'
603
+                  . ' title="'.esc_attr__('Send Payment Reminder', 'event_espresso').'" class="tiny-text">
604 604
                     <span class="dashicons dashicons-email-alt"></span>
605 605
                 </a>
606 606
             </li>';
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
             'ee_read_global_messages',
628 628
             'view_filtered_messages'
629 629
         )
630
-            ? '<li>' . $url . '</li>'
630
+            ? '<li>'.$url.'</li>'
631 631
             : '';
632 632
     }
633 633
 
@@ -647,8 +647,8 @@  discard block
 block discarded – undo
647 647
         ) {
648 648
             return '
649 649
             <li>
650
-                <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"'
651
-                    . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
650
+                <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso').'"'
651
+                    . ' target="_blank" href="'.$registration->payment_overview_url(true).'"'
652 652
                     . ' class="tiny-text">
653 653
                     <span class="dashicons dashicons-money ee-icon-size-18"></span>
654 654
                 </a>
Please login to merge, or discard this patch.
core/db_classes/EE_Registration.class.php 3 patches
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
      * Sets deleted
1160 1160
      *
1161 1161
      * @param boolean $deleted
1162
-     * @return bool
1162
+     * @return boolean|null
1163 1163
      * @throws EE_Error
1164 1164
      * @throws RuntimeException
1165 1165
      */
@@ -1217,6 +1217,7 @@  discard block
 block discarded – undo
1217 1217
      * @param int | EE_Datetime $DTT_OR_ID      The datetime the registration is being checked against
1218 1218
      * @param bool              $check_approved This is used to indicate whether the caller wants can_checkin to also
1219 1219
      *                                          consider registration status as well as datetime access.
1220
+     * @param integer $DTT_OR_ID
1220 1221
      * @return bool
1221 1222
      * @throws EE_Error
1222 1223
      */
@@ -1387,7 +1388,7 @@  discard block
 block discarded – undo
1387 1388
      * Returns the latest datetime related to this registration (via the ticket attached to the registration).
1388 1389
      * "Latest" is defined by the `DTT_EVT_start` column.
1389 1390
      *
1390
-     * @return EE_Datetime|null
1391
+     * @return null|EE_Base_Class
1391 1392
      * @throws \EE_Error
1392 1393
      */
1393 1394
     public function get_latest_related_datetime()
@@ -1680,7 +1681,7 @@  discard block
 block discarded – undo
1680 1681
      * This grabs the payment method corresponding to the last payment made for the amount owing on the registration.
1681 1682
      * Note: if there are no payments on the registration there will be no payment method returned.
1682 1683
      *
1683
-     * @return EE_Payment_Method|null
1684
+     * @return null|EE_Base_Class
1684 1685
      */
1685 1686
     public function payment_method()
1686 1687
     {
Please login to merge, or discard this patch.
Indentation   +1934 added lines, -1934 removed lines patch added patch discarded remove patch
@@ -18,1940 +18,1940 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * Used to reference when a registration has never been checked in.
23
-     *
24
-     * @deprecated use \EE_Checkin::status_checked_never instead
25
-     * @type int
26
-     */
27
-    const checkin_status_never = 2;
28
-
29
-    /**
30
-     * Used to reference when a registration has been checked in.
31
-     *
32
-     * @deprecated use \EE_Checkin::status_checked_in instead
33
-     * @type int
34
-     */
35
-    const checkin_status_in = 1;
36
-
37
-
38
-    /**
39
-     * Used to reference when a registration has been checked out.
40
-     *
41
-     * @deprecated use \EE_Checkin::status_checked_out instead
42
-     * @type int
43
-     */
44
-    const checkin_status_out = 0;
45
-
46
-
47
-    /**
48
-     * extra meta key for tracking reg status os trashed registrations
49
-     *
50
-     * @type string
51
-     */
52
-    const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status';
53
-
54
-
55
-    /**
56
-     * extra meta key for tracking if registration has reserved ticket
57
-     *
58
-     * @type string
59
-     */
60
-    const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket';
61
-
62
-
63
-    /**
64
-     * @param array  $props_n_values          incoming values
65
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
66
-     *                                        used.)
67
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
68
-     *                                        date_format and the second value is the time format
69
-     * @return EE_Registration
70
-     * @throws EE_Error
71
-     */
72
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
73
-    {
74
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
75
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
76
-    }
77
-
78
-
79
-    /**
80
-     * @param array  $props_n_values  incoming values from the database
81
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
82
-     *                                the website will be used.
83
-     * @return EE_Registration
84
-     */
85
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
86
-    {
87
-        return new self($props_n_values, true, $timezone);
88
-    }
89
-
90
-
91
-    /**
92
-     *        Set Event ID
93
-     *
94
-     * @param        int $EVT_ID Event ID
95
-     * @throws EE_Error
96
-     * @throws RuntimeException
97
-     */
98
-    public function set_event($EVT_ID = 0)
99
-    {
100
-        $this->set('EVT_ID', $EVT_ID);
101
-    }
102
-
103
-
104
-    /**
105
-     * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can
106
-     * be routed to internal methods
107
-     *
108
-     * @param string $field_name
109
-     * @param mixed  $field_value
110
-     * @param bool   $use_default
111
-     * @throws EE_Error
112
-     * @throws EntityNotFoundException
113
-     * @throws InvalidArgumentException
114
-     * @throws InvalidDataTypeException
115
-     * @throws InvalidInterfaceException
116
-     * @throws ReflectionException
117
-     * @throws RuntimeException
118
-     */
119
-    public function set($field_name, $field_value, $use_default = false)
120
-    {
121
-        switch ($field_name) {
122
-            case 'REG_code':
123
-                if (! empty($field_value) && $this->reg_code() === null) {
124
-                    $this->set_reg_code($field_value, $use_default);
125
-                }
126
-                break;
127
-            case 'STS_ID':
128
-                $this->set_status($field_value, $use_default);
129
-                break;
130
-            default:
131
-                parent::set($field_name, $field_value, $use_default);
132
-        }
133
-    }
134
-
135
-
136
-    /**
137
-     * Set Status ID
138
-     * updates the registration status and ALSO...
139
-     * calls reserve_registration_space() if the reg status changes TO approved from any other reg status
140
-     * calls release_registration_space() if the reg status changes FROM approved to any other reg status
141
-     *
142
-     * @param string       $new_STS_ID
143
-     * @param boolean      $use_default
144
-     * @param Context|null $context
145
-     * @return bool
146
-     * @throws EE_Error
147
-     * @throws EntityNotFoundException
148
-     * @throws InvalidArgumentException
149
-     * @throws ReflectionException
150
-     * @throws RuntimeException
151
-     * @throws InvalidDataTypeException
152
-     * @throws InvalidInterfaceException
153
-     */
154
-    public function set_status($new_STS_ID = null, $use_default = false, Context $context = null)
155
-    {
156
-        // get current REG_Status
157
-        $old_STS_ID = $this->status_ID();
158
-        // if status has changed
159
-        if ($old_STS_ID !== $new_STS_ID // and that status has actually changed
160
-            && ! empty($old_STS_ID) // and that old status is actually set
161
-            && ! empty($new_STS_ID) // as well as the new status
162
-            && $this->ID() // ensure registration is in the db
163
-        ) {
164
-            // TO approved
165
-            if ($new_STS_ID === EEM_Registration::status_id_approved) {
166
-                // reserve a space by incrementing ticket and datetime sold values
167
-                $this->_reserve_registration_space();
168
-                do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID, $context);
169
-                // OR FROM  approved
170
-            } elseif ($old_STS_ID === EEM_Registration::status_id_approved) {
171
-                // release a space by decrementing ticket and datetime sold values
172
-                $this->_release_registration_space();
173
-                do_action(
174
-                    'AHEE__EE_Registration__set_status__from_approved',
175
-                    $this,
176
-                    $old_STS_ID,
177
-                    $new_STS_ID,
178
-                    $context
179
-                );
180
-            }
181
-            // update status
182
-            parent::set('STS_ID', $new_STS_ID, $use_default);
183
-            $this->_update_if_canceled_or_declined($new_STS_ID, $old_STS_ID, $context);
184
-            if($this->statusChangeUpdatesTransaction($context)) {
185
-                $this->updateTransactionAfterStatusChange();
186
-            }
187
-            do_action('AHEE__EE_Registration__set_status__after_update', $this, $old_STS_ID, $new_STS_ID, $context);
188
-            return true;
189
-        }
190
-        //even though the old value matches the new value, it's still good to
191
-        //allow the parent set method to have a say
192
-        parent::set('STS_ID', $new_STS_ID, $use_default);
193
-        return true;
194
-    }
195
-
196
-
197
-    /**
198
-     * update REGs and TXN when cancelled or declined registrations involved
199
-     *
200
-     * @param string       $new_STS_ID
201
-     * @param string       $old_STS_ID
202
-     * @param Context|null $context
203
-     * @throws EE_Error
204
-     * @throws InvalidArgumentException
205
-     * @throws InvalidDataTypeException
206
-     * @throws InvalidInterfaceException
207
-     * @throws ReflectionException
208
-     */
209
-    private function _update_if_canceled_or_declined($new_STS_ID, $old_STS_ID, Context $context = null)
210
-    {
211
-        // these reg statuses should not be considered in any calculations involving monies owing
212
-        $closed_reg_statuses = EEM_Registration::closed_reg_statuses();
213
-        // true if registration has been cancelled or declined
214
-        $this->updateIfCanceled(
215
-            $closed_reg_statuses,
216
-            $new_STS_ID,
217
-            $old_STS_ID,
218
-            $context
219
-        );
220
-        $this->updateIfDeclined(
221
-            $closed_reg_statuses,
222
-            $new_STS_ID,
223
-            $old_STS_ID,
224
-            $context
225
-        );
226
-    }
227
-
228
-
229
-    /**
230
-     * update REGs and TXN when cancelled or declined registrations involved
231
-     *
232
-     * @param array        $closed_reg_statuses
233
-     * @param string       $new_STS_ID
234
-     * @param string       $old_STS_ID
235
-     * @param Context|null $context
236
-     * @throws EE_Error
237
-     * @throws InvalidArgumentException
238
-     * @throws InvalidDataTypeException
239
-     * @throws InvalidInterfaceException
240
-     * @throws ReflectionException
241
-     */
242
-    private function updateIfCanceled(array $closed_reg_statuses, $new_STS_ID, $old_STS_ID, Context $context = null)
243
-    {
244
-        // true if registration has been cancelled or declined
245
-        if (in_array($new_STS_ID, $closed_reg_statuses, true)
246
-            && ! in_array($old_STS_ID, $closed_reg_statuses, true)
247
-        ) {
248
-            /** @type EE_Registration_Processor $registration_processor */
249
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
250
-            /** @type EE_Transaction_Processor $transaction_processor */
251
-            $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
252
-            // cancelled or declined registration
253
-            $registration_processor->update_registration_after_being_canceled_or_declined(
254
-                $this,
255
-                $closed_reg_statuses
256
-            );
257
-            $transaction_processor->update_transaction_after_canceled_or_declined_registration(
258
-                $this,
259
-                $closed_reg_statuses,
260
-                false
261
-            );
262
-            do_action(
263
-                'AHEE__EE_Registration__set_status__canceled_or_declined',
264
-                $this,
265
-                $old_STS_ID,
266
-                $new_STS_ID,
267
-                $context
268
-            );
269
-            return;
270
-        }
271
-    }
272
-
273
-
274
-    /**
275
-     * update REGs and TXN when cancelled or declined registrations involved
276
-     *
277
-     * @param array        $closed_reg_statuses
278
-     * @param string       $new_STS_ID
279
-     * @param string       $old_STS_ID
280
-     * @param Context|null $context
281
-     * @throws EE_Error
282
-     * @throws InvalidArgumentException
283
-     * @throws InvalidDataTypeException
284
-     * @throws InvalidInterfaceException
285
-     * @throws ReflectionException
286
-     */
287
-    private function updateIfDeclined(array $closed_reg_statuses, $new_STS_ID, $old_STS_ID, Context $context = null)
288
-    {
289
-        // true if reinstating cancelled or declined registration
290
-        if (in_array($old_STS_ID, $closed_reg_statuses, true)
291
-            && ! in_array($new_STS_ID, $closed_reg_statuses, true)
292
-        ) {
293
-            /** @type EE_Registration_Processor $registration_processor */
294
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
295
-            /** @type EE_Transaction_Processor $transaction_processor */
296
-            $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
297
-            // reinstating cancelled or declined registration
298
-            $registration_processor->update_canceled_or_declined_registration_after_being_reinstated(
299
-                $this,
300
-                $closed_reg_statuses
301
-            );
302
-            $transaction_processor->update_transaction_after_reinstating_canceled_registration(
303
-                $this,
304
-                $closed_reg_statuses,
305
-                false
306
-            );
307
-            do_action(
308
-                'AHEE__EE_Registration__set_status__after_reinstated',
309
-                $this,
310
-                $old_STS_ID,
311
-                $new_STS_ID,
312
-                $context
313
-            );
314
-        }
315
-    }
316
-
317
-
318
-    /**
319
-     * @param Context|null $context
320
-     * @return bool
321
-     */
322
-    private function statusChangeUpdatesTransaction(Context $context = null)
323
-    {
324
-        $contexts_that_do_not_update_transaction = (array) apply_filters(
325
-            'AHEE__EE_Registration__statusChangeUpdatesTransaction__contexts_that_do_not_update_transaction',
326
-            array('spco_reg_step_attendee_information_process_registrations'),
327
-            $context,
328
-            $this
329
-        );
330
-        return ! (
331
-            $context instanceof Context
332
-            && in_array($context->slug(), $contexts_that_do_not_update_transaction, true)
333
-        );
334
-    }
335
-
336
-
337
-    /**
338
-     * @throws EE_Error
339
-     * @throws EntityNotFoundException
340
-     * @throws InvalidArgumentException
341
-     * @throws InvalidDataTypeException
342
-     * @throws InvalidInterfaceException
343
-     * @throws ReflectionException
344
-     * @throws RuntimeException
345
-     */
346
-    private function updateTransactionAfterStatusChange()
347
-    {
348
-        /** @type EE_Transaction_Payments $transaction_payments */
349
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
350
-        $transaction_payments->recalculate_transaction_total($this->transaction(), false);
351
-        $this->transaction()->update_status_based_on_total_paid(true);
352
-    }
353
-
354
-
355
-    /**
356
-     *        get Status ID
357
-     */
358
-    public function status_ID()
359
-    {
360
-        return $this->get('STS_ID');
361
-    }
362
-
363
-
364
-    /**
365
-     * increments this registration's related ticket sold and corresponding datetime sold values
366
-     *
367
-     * @return void
368
-     * @throws EE_Error
369
-     * @throws EntityNotFoundException
370
-     */
371
-    private function _reserve_registration_space()
372
-    {
373
-        // reserved ticket and datetime counts will be decremented as sold counts are incremented
374
-        // so stop tracking that this reg has a ticket reserved
375
-        $this->release_reserved_ticket();
376
-        $ticket = $this->ticket();
377
-        $ticket->increase_sold();
378
-        $ticket->save();
379
-        // possibly set event status to sold out
380
-        $this->event()->perform_sold_out_status_check();
381
-    }
382
-
383
-
384
-    /**
385
-     * Gets the ticket this registration is for
386
-     *
387
-     * @param boolean $include_archived whether to include archived tickets or not.
388
-     * @return EE_Ticket|EE_Base_Class
389
-     * @throws \EE_Error
390
-     */
391
-    public function ticket($include_archived = true)
392
-    {
393
-        $query_params = array();
394
-        if ($include_archived) {
395
-            $query_params['default_where_conditions'] = 'none';
396
-        }
397
-        return $this->get_first_related('Ticket', $query_params);
398
-    }
399
-
400
-
401
-    /**
402
-     * Gets the event this registration is for
403
-     *
404
-     * @return EE_Event
405
-     * @throws EE_Error
406
-     * @throws EntityNotFoundException
407
-     */
408
-    public function event()
409
-    {
410
-        $event = $this->get_first_related('Event');
411
-        if (! $event instanceof \EE_Event) {
412
-            throw new EntityNotFoundException('Event ID', $this->event_ID());
413
-        }
414
-        return $event;
415
-    }
416
-
417
-
418
-    /**
419
-     * Gets the "author" of the registration.  Note that for the purposes of registrations, the author will correspond
420
-     * with the author of the event this registration is for.
421
-     *
422
-     * @since 4.5.0
423
-     * @return int
424
-     * @throws EE_Error
425
-     * @throws EntityNotFoundException
426
-     */
427
-    public function wp_user()
428
-    {
429
-        $event = $this->event();
430
-        if ($event instanceof EE_Event) {
431
-            return $event->wp_user();
432
-        }
433
-        return 0;
434
-    }
435
-
436
-
437
-    /**
438
-     * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values
439
-     *
440
-     * @return void
441
-     * @throws \EE_Error
442
-     */
443
-    private function _release_registration_space()
444
-    {
445
-        $ticket = $this->ticket();
446
-        $ticket->decrease_sold();
447
-        $ticket->save();
448
-    }
449
-
450
-
451
-    /**
452
-     * tracks this registration's ticket reservation in extra meta
453
-     * and can increment related ticket reserved and corresponding datetime reserved values
454
-     *
455
-     * @param bool $update_ticket if true, will increment ticket and datetime reserved count
456
-     * @return void
457
-     * @throws \EE_Error
458
-     */
459
-    public function reserve_ticket($update_ticket = false)
460
-    {
461
-        if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) === false) {
462
-            // PLZ NOTE: although checking $update_ticket first would be more efficient,
463
-            // we NEED to ALWAYS call update_extra_meta(), which is why that is done first
464
-            if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) && $update_ticket) {
465
-                $ticket = $this->ticket();
466
-                $ticket->increase_reserved();
467
-                $ticket->save();
468
-            }
469
-        }
470
-    }
471
-
472
-
473
-    /**
474
-     * stops tracking this registration's ticket reservation in extra meta
475
-     * decrements (subtracts) related ticket reserved and corresponding datetime reserved values
476
-     *
477
-     * @param bool $update_ticket if true, will decrement ticket and datetime reserved count
478
-     * @return void
479
-     * @throws \EE_Error
480
-     */
481
-    public function release_reserved_ticket($update_ticket = false)
482
-    {
483
-        if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) !== false) {
484
-            // PLZ NOTE: although checking $update_ticket first would be more efficient,
485
-            // we NEED to ALWAYS call delete_extra_meta(), which is why that is done first
486
-            if ($this->delete_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY) && $update_ticket) {
487
-                $ticket = $this->ticket();
488
-                $ticket->decrease_reserved();
489
-                $ticket->save();
490
-            }
491
-        }
492
-    }
493
-
494
-
495
-    /**
496
-     * Set Attendee ID
497
-     *
498
-     * @param        int $ATT_ID Attendee ID
499
-     * @throws EE_Error
500
-     * @throws RuntimeException
501
-     */
502
-    public function set_attendee_id($ATT_ID = 0)
503
-    {
504
-        $this->set('ATT_ID', $ATT_ID);
505
-    }
506
-
507
-
508
-    /**
509
-     *        Set Transaction ID
510
-     *
511
-     * @param        int $TXN_ID Transaction ID
512
-     * @throws EE_Error
513
-     * @throws RuntimeException
514
-     */
515
-    public function set_transaction_id($TXN_ID = 0)
516
-    {
517
-        $this->set('TXN_ID', $TXN_ID);
518
-    }
519
-
520
-
521
-    /**
522
-     *        Set Session
523
-     *
524
-     * @param    string $REG_session PHP Session ID
525
-     * @throws EE_Error
526
-     * @throws RuntimeException
527
-     */
528
-    public function set_session($REG_session = '')
529
-    {
530
-        $this->set('REG_session', $REG_session);
531
-    }
532
-
533
-
534
-    /**
535
-     *        Set Registration URL Link
536
-     *
537
-     * @param    string $REG_url_link Registration URL Link
538
-     * @throws EE_Error
539
-     * @throws RuntimeException
540
-     */
541
-    public function set_reg_url_link($REG_url_link = '')
542
-    {
543
-        $this->set('REG_url_link', $REG_url_link);
544
-    }
545
-
546
-
547
-    /**
548
-     *        Set Attendee Counter
549
-     *
550
-     * @param        int $REG_count Primary Attendee
551
-     * @throws EE_Error
552
-     * @throws RuntimeException
553
-     */
554
-    public function set_count($REG_count = 1)
555
-    {
556
-        $this->set('REG_count', $REG_count);
557
-    }
558
-
559
-
560
-    /**
561
-     *        Set Group Size
562
-     *
563
-     * @param        boolean $REG_group_size Group Registration
564
-     * @throws EE_Error
565
-     * @throws RuntimeException
566
-     */
567
-    public function set_group_size($REG_group_size = false)
568
-    {
569
-        $this->set('REG_group_size', $REG_group_size);
570
-    }
571
-
572
-
573
-    /**
574
-     *    is_not_approved -  convenience method that returns TRUE if REG status ID ==
575
-     *    EEM_Registration::status_id_not_approved
576
-     *
577
-     * @return        boolean
578
-     */
579
-    public function is_not_approved()
580
-    {
581
-        return $this->status_ID() == EEM_Registration::status_id_not_approved ? true : false;
582
-    }
583
-
584
-
585
-    /**
586
-     *    is_pending_payment -  convenience method that returns TRUE if REG status ID ==
587
-     *    EEM_Registration::status_id_pending_payment
588
-     *
589
-     * @return        boolean
590
-     */
591
-    public function is_pending_payment()
592
-    {
593
-        return $this->status_ID() == EEM_Registration::status_id_pending_payment ? true : false;
594
-    }
595
-
596
-
597
-    /**
598
-     *    is_approved -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved
599
-     *
600
-     * @return        boolean
601
-     */
602
-    public function is_approved()
603
-    {
604
-        return $this->status_ID() == EEM_Registration::status_id_approved ? true : false;
605
-    }
606
-
607
-
608
-    /**
609
-     *    is_cancelled -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled
610
-     *
611
-     * @return        boolean
612
-     */
613
-    public function is_cancelled()
614
-    {
615
-        return $this->status_ID() == EEM_Registration::status_id_cancelled ? true : false;
616
-    }
617
-
618
-
619
-    /**
620
-     *    is_declined -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined
621
-     *
622
-     * @return        boolean
623
-     */
624
-    public function is_declined()
625
-    {
626
-        return $this->status_ID() == EEM_Registration::status_id_declined ? true : false;
627
-    }
628
-
629
-
630
-    /**
631
-     *    is_incomplete -  convenience method that returns TRUE if REG status ID ==
632
-     *    EEM_Registration::status_id_incomplete
633
-     *
634
-     * @return        boolean
635
-     */
636
-    public function is_incomplete()
637
-    {
638
-        return $this->status_ID() == EEM_Registration::status_id_incomplete ? true : false;
639
-    }
640
-
641
-
642
-    /**
643
-     *        Set Registration Date
644
-     *
645
-     * @param        mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of
646
-     *                                                 Date
647
-     * @throws EE_Error
648
-     * @throws RuntimeException
649
-     */
650
-    public function set_reg_date($REG_date = false)
651
-    {
652
-        $this->set('REG_date', $REG_date);
653
-    }
654
-
655
-
656
-    /**
657
-     *    Set final price owing for this registration after all ticket/price modifications
658
-     *
659
-     * @access    public
660
-     * @param    float $REG_final_price
661
-     * @throws EE_Error
662
-     * @throws RuntimeException
663
-     */
664
-    public function set_final_price($REG_final_price = 0.00)
665
-    {
666
-        $this->set('REG_final_price', $REG_final_price);
667
-    }
668
-
669
-
670
-    /**
671
-     *    Set amount paid towards this registration's final price
672
-     *
673
-     * @access    public
674
-     * @param    float $REG_paid
675
-     * @throws EE_Error
676
-     * @throws RuntimeException
677
-     */
678
-    public function set_paid($REG_paid = 0.00)
679
-    {
680
-        $this->set('REG_paid', $REG_paid);
681
-    }
682
-
683
-
684
-    /**
685
-     *        Attendee Is Going
686
-     *
687
-     * @param        boolean $REG_att_is_going Attendee Is Going
688
-     * @throws EE_Error
689
-     * @throws RuntimeException
690
-     */
691
-    public function set_att_is_going($REG_att_is_going = false)
692
-    {
693
-        $this->set('REG_att_is_going', $REG_att_is_going);
694
-    }
695
-
696
-
697
-    /**
698
-     * Gets the related attendee
699
-     *
700
-     * @return EE_Attendee
701
-     * @throws EE_Error
702
-     */
703
-    public function attendee()
704
-    {
705
-        return $this->get_first_related('Attendee');
706
-    }
707
-
708
-
709
-    /**
710
-     *        get Event ID
711
-     */
712
-    public function event_ID()
713
-    {
714
-        return $this->get('EVT_ID');
715
-    }
716
-
717
-
718
-    /**
719
-     *        get Event ID
720
-     */
721
-    public function event_name()
722
-    {
723
-        $event = $this->event_obj();
724
-        if ($event) {
725
-            return $event->name();
726
-        } else {
727
-            return null;
728
-        }
729
-    }
730
-
731
-
732
-    /**
733
-     * Fetches the event this registration is for
734
-     *
735
-     * @return EE_Event
736
-     * @throws EE_Error
737
-     */
738
-    public function event_obj()
739
-    {
740
-        return $this->get_first_related('Event');
741
-    }
742
-
743
-
744
-    /**
745
-     *        get Attendee ID
746
-     */
747
-    public function attendee_ID()
748
-    {
749
-        return $this->get('ATT_ID');
750
-    }
751
-
752
-
753
-    /**
754
-     *        get PHP Session ID
755
-     */
756
-    public function session_ID()
757
-    {
758
-        return $this->get('REG_session');
759
-    }
760
-
761
-
762
-    /**
763
-     * Gets the string which represents the URL trigger for the receipt template in the message template system.
764
-     *
765
-     * @param string $messenger 'pdf' or 'html'.  Default 'html'.
766
-     * @return string
767
-     */
768
-    public function receipt_url($messenger = 'html')
769
-    {
770
-
771
-        /**
772
-         * The below will be deprecated one version after this.  We check first if there is a custom receipt template
773
-         * already in use on old system.  If there is then we just return the standard url for it.
774
-         *
775
-         * @since 4.5.0
776
-         */
777
-        $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php';
778
-        $has_custom             = EEH_Template::locate_template(
779
-            $template_relative_path,
780
-            array(),
781
-            true,
782
-            true,
783
-            true
784
-        );
785
-
786
-        if ($has_custom) {
787
-            return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch'));
788
-        }
789
-        return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt');
790
-    }
791
-
792
-
793
-    /**
794
-     * Gets the string which represents the URL trigger for the invoice template in the message template system.
795
-     *
796
-     * @param string $messenger 'pdf' or 'html'.  Default 'html'.
797
-     * @return string
798
-     * @throws EE_Error
799
-     */
800
-    public function invoice_url($messenger = 'html')
801
-    {
802
-        /**
803
-         * The below will be deprecated one version after this.  We check first if there is a custom invoice template
804
-         * already in use on old system.  If there is then we just return the standard url for it.
805
-         *
806
-         * @since 4.5.0
807
-         */
808
-        $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php';
809
-        $has_custom             = EEH_Template::locate_template(
810
-            $template_relative_path,
811
-            array(),
812
-            true,
813
-            true,
814
-            true
815
-        );
816
-
817
-        if ($has_custom) {
818
-            if ($messenger == 'html') {
819
-                return $this->invoice_url('launch');
820
-            }
821
-            $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice';
822
-
823
-            $query_args = array('ee' => $route, 'id' => $this->reg_url_link());
824
-            if ($messenger == 'html') {
825
-                $query_args['html'] = true;
826
-            }
827
-            return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id));
828
-        }
829
-        return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice');
830
-    }
831
-
832
-
833
-    /**
834
-     * get Registration URL Link
835
-     *
836
-     * @access public
837
-     * @return string
838
-     * @throws \EE_Error
839
-     */
840
-    public function reg_url_link()
841
-    {
842
-        return (string) $this->get('REG_url_link');
843
-    }
844
-
845
-
846
-    /**
847
-     * Echoes out invoice_url()
848
-     *
849
-     * @param string $type 'download','launch', or 'html' (default is 'launch')
850
-     * @return void
851
-     * @throws EE_Error
852
-     */
853
-    public function e_invoice_url($type = 'launch')
854
-    {
855
-        echo $this->invoice_url($type);
856
-    }
857
-
858
-
859
-    /**
860
-     * Echoes out payment_overview_url
861
-     */
862
-    public function e_payment_overview_url()
863
-    {
864
-        echo $this->payment_overview_url();
865
-    }
866
-
867
-
868
-    /**
869
-     * Gets the URL of the thank you page with this registration REG_url_link added as
870
-     * a query parameter
871
-     *
872
-     * @param bool $clear_session Set to true when you want to clear the session on revisiting the
873
-     *                            payment overview url.
874
-     * @return string
875
-     * @throws EE_Error
876
-     */
877
-    public function payment_overview_url($clear_session = false)
878
-    {
879
-        return add_query_arg(array(
880
-            'e_reg_url_link' => $this->reg_url_link(),
881
-            'step'           => 'payment_options',
882
-            'revisit'        => true,
883
-            'clear_session' => (bool) $clear_session
884
-        ), EE_Registry::instance()->CFG->core->reg_page_url());
885
-    }
886
-
887
-
888
-    /**
889
-     * Gets the URL of the thank you page with this registration REG_url_link added as
890
-     * a query parameter
891
-     *
892
-     * @return string
893
-     * @throws EE_Error
894
-     */
895
-    public function edit_attendee_information_url()
896
-    {
897
-        return add_query_arg(array(
898
-            'e_reg_url_link' => $this->reg_url_link(),
899
-            'step'           => 'attendee_information',
900
-            'revisit'        => true,
901
-        ), EE_Registry::instance()->CFG->core->reg_page_url());
902
-    }
903
-
904
-
905
-    /**
906
-     * Simply generates and returns the appropriate admin_url link to edit this registration
907
-     *
908
-     * @return string
909
-     * @throws EE_Error
910
-     */
911
-    public function get_admin_edit_url()
912
-    {
913
-        return EEH_URL::add_query_args_and_nonce(array(
914
-            'page'    => 'espresso_registrations',
915
-            'action'  => 'view_registration',
916
-            '_REG_ID' => $this->ID(),
917
-        ), admin_url('admin.php'));
918
-    }
919
-
920
-
921
-    /**
922
-     *    is_primary_registrant?
923
-     */
924
-    public function is_primary_registrant()
925
-    {
926
-        return $this->get('REG_count') == 1 ? true : false;
927
-    }
928
-
929
-
930
-    /**
931
-     * This returns the primary registration object for this registration group (which may be this object).
932
-     *
933
-     * @return EE_Registration
934
-     * @throws EE_Error
935
-     */
936
-    public function get_primary_registration()
937
-    {
938
-        if ($this->is_primary_registrant()) {
939
-            return $this;
940
-        }
941
-
942
-        //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1
943
-        /** @var EE_Registration $primary_registrant */
944
-        $primary_registrant = EEM_Registration::instance()->get_one(array(
945
-            array(
946
-                'TXN_ID'    => $this->transaction_ID(),
947
-                'REG_count' => 1,
948
-            ),
949
-        ));
950
-        return $primary_registrant;
951
-    }
952
-
953
-
954
-    /**
955
-     *        get  Attendee Number
956
-     *
957
-     * @access        public
958
-     */
959
-    public function count()
960
-    {
961
-        return $this->get('REG_count');
962
-    }
963
-
964
-
965
-    /**
966
-     *        get Group Size
967
-     */
968
-    public function group_size()
969
-    {
970
-        return $this->get('REG_group_size');
971
-    }
972
-
973
-
974
-    /**
975
-     *        get Registration Date
976
-     */
977
-    public function date()
978
-    {
979
-        return $this->get('REG_date');
980
-    }
981
-
982
-
983
-    /**
984
-     * gets a pretty date
985
-     *
986
-     * @param string $date_format
987
-     * @param string $time_format
988
-     * @return string
989
-     * @throws EE_Error
990
-     */
991
-    public function pretty_date($date_format = null, $time_format = null)
992
-    {
993
-        return $this->get_datetime('REG_date', $date_format, $time_format);
994
-    }
995
-
996
-
997
-    /**
998
-     * final_price
999
-     * the registration's share of the transaction total, so that the
1000
-     * sum of all the transaction's REG_final_prices equal the transaction's total
1001
-     *
1002
-     * @return float
1003
-     * @throws EE_Error
1004
-     */
1005
-    public function final_price()
1006
-    {
1007
-        return $this->get('REG_final_price');
1008
-    }
1009
-
1010
-
1011
-    /**
1012
-     * pretty_final_price
1013
-     *  final price as formatted string, with correct decimal places and currency symbol
1014
-     *
1015
-     * @return string
1016
-     * @throws EE_Error
1017
-     */
1018
-    public function pretty_final_price()
1019
-    {
1020
-        return $this->get_pretty('REG_final_price');
1021
-    }
1022
-
1023
-
1024
-    /**
1025
-     * get paid (yeah)
1026
-     *
1027
-     * @return float
1028
-     * @throws EE_Error
1029
-     */
1030
-    public function paid()
1031
-    {
1032
-        return $this->get('REG_paid');
1033
-    }
1034
-
1035
-
1036
-    /**
1037
-     * pretty_paid
1038
-     *
1039
-     * @return float
1040
-     * @throws EE_Error
1041
-     */
1042
-    public function pretty_paid()
1043
-    {
1044
-        return $this->get_pretty('REG_paid');
1045
-    }
1046
-
1047
-
1048
-    /**
1049
-     * owes_monies_and_can_pay
1050
-     * whether or not this registration has monies owing and it's' status allows payment
1051
-     *
1052
-     * @param array $requires_payment
1053
-     * @return bool
1054
-     * @throws EE_Error
1055
-     */
1056
-    public function owes_monies_and_can_pay($requires_payment = array())
1057
-    {
1058
-        // these reg statuses require payment (if event is not free)
1059
-        $requires_payment = ! empty($requires_payment)
1060
-            ? $requires_payment
1061
-            : EEM_Registration::reg_statuses_that_allow_payment();
1062
-        if (in_array($this->status_ID(), $requires_payment) &&
1063
-            $this->final_price() != 0 &&
1064
-            $this->final_price() != $this->paid()
1065
-        ) {
1066
-            return true;
1067
-        } else {
1068
-            return false;
1069
-        }
1070
-    }
1071
-
1072
-
1073
-    /**
1074
-     * Prints out the return value of $this->pretty_status()
1075
-     *
1076
-     * @param bool $show_icons
1077
-     * @return void
1078
-     * @throws EE_Error
1079
-     */
1080
-    public function e_pretty_status($show_icons = false)
1081
-    {
1082
-        echo $this->pretty_status($show_icons);
1083
-    }
1084
-
1085
-
1086
-    /**
1087
-     * Returns a nice version of the status for displaying to customers
1088
-     *
1089
-     * @param bool $show_icons
1090
-     * @return string
1091
-     * @throws EE_Error
1092
-     */
1093
-    public function pretty_status($show_icons = false)
1094
-    {
1095
-        $status = EEM_Status::instance()->localized_status(
1096
-            array($this->status_ID() => esc_html__('unknown', 'event_espresso')),
1097
-            false,
1098
-            'sentence'
1099
-        );
1100
-        $icon   = '';
1101
-        switch ($this->status_ID()) {
1102
-            case EEM_Registration::status_id_approved:
1103
-                $icon = $show_icons
1104
-                    ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>'
1105
-                    : '';
1106
-                break;
1107
-            case EEM_Registration::status_id_pending_payment:
1108
-                $icon = $show_icons
1109
-                    ? '<span class="dashicons dashicons-star-half ee-icon-size-16 orange-text"></span>'
1110
-                    : '';
1111
-                break;
1112
-            case EEM_Registration::status_id_not_approved:
1113
-                $icon = $show_icons
1114
-                    ? '<span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>'
1115
-                    : '';
1116
-                break;
1117
-            case EEM_Registration::status_id_cancelled:
1118
-                $icon = $show_icons
1119
-                    ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>'
1120
-                    : '';
1121
-                break;
1122
-            case EEM_Registration::status_id_incomplete:
1123
-                $icon = $show_icons
1124
-                    ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-orange-text"></span>'
1125
-                    : '';
1126
-                break;
1127
-            case EEM_Registration::status_id_declined:
1128
-                $icon = $show_icons
1129
-                    ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>'
1130
-                    : '';
1131
-                break;
1132
-            case EEM_Registration::status_id_wait_list:
1133
-                $icon = $show_icons
1134
-                    ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>'
1135
-                    : '';
1136
-                break;
1137
-        }
1138
-        return $icon . $status[$this->status_ID()];
1139
-    }
1140
-
1141
-
1142
-    /**
1143
-     *        get Attendee Is Going
1144
-     */
1145
-    public function att_is_going()
1146
-    {
1147
-        return $this->get('REG_att_is_going');
1148
-    }
1149
-
1150
-
1151
-    /**
1152
-     * Gets related answers
1153
-     *
1154
-     * @param array $query_params like EEM_Base::get_all
1155
-     * @return EE_Answer[]
1156
-     * @throws EE_Error
1157
-     */
1158
-    public function answers($query_params = null)
1159
-    {
1160
-        return $this->get_many_related('Answer', $query_params);
1161
-    }
1162
-
1163
-
1164
-    /**
1165
-     * Gets the registration's answer value to the specified question
1166
-     * (either the question's ID or a question object)
1167
-     *
1168
-     * @param EE_Question|int $question
1169
-     * @param bool            $pretty_value
1170
-     * @return array|string if pretty_value= true, the result will always be a string
1171
-     * (because the answer might be an array of answer values, so passing pretty_value=true
1172
-     * will convert it into some kind of string)
1173
-     * @throws EE_Error
1174
-     */
1175
-    public function answer_value_to_question($question, $pretty_value = true)
1176
-    {
1177
-        $question_id = EEM_Question::instance()->ensure_is_ID($question);
1178
-        return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value);
1179
-    }
1180
-
1181
-
1182
-    /**
1183
-     * question_groups
1184
-     * returns an array of EE_Question_Group objects for this registration
1185
-     *
1186
-     * @return EE_Question_Group[]
1187
-     * @throws EE_Error
1188
-     * @throws EntityNotFoundException
1189
-     */
1190
-    public function question_groups()
1191
-    {
1192
-        $question_groups = array();
1193
-        if ($this->event() instanceof EE_Event) {
1194
-            $question_groups = $this->event()->question_groups(
1195
-                array(
1196
-                    array(
1197
-                        'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false,
1198
-                    ),
1199
-                    'order_by' => array('QSG_order' => 'ASC'),
1200
-                )
1201
-            );
1202
-        }
1203
-        return $question_groups;
1204
-    }
1205
-
1206
-
1207
-    /**
1208
-     * count_question_groups
1209
-     * returns a count of the number of EE_Question_Group objects for this registration
1210
-     *
1211
-     * @return int
1212
-     * @throws EE_Error
1213
-     * @throws EntityNotFoundException
1214
-     */
1215
-    public function count_question_groups()
1216
-    {
1217
-        $qg_count = 0;
1218
-        if ($this->event() instanceof EE_Event) {
1219
-            $qg_count = $this->event()->count_related(
1220
-                'Question_Group',
1221
-                array(
1222
-                    array(
1223
-                        'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false,
1224
-                    ),
1225
-                )
1226
-            );
1227
-        }
1228
-        return $qg_count;
1229
-    }
1230
-
1231
-
1232
-    /**
1233
-     * Returns the registration date in the 'standard' string format
1234
-     * (function may be improved in the future to allow for different formats and timezones)
1235
-     *
1236
-     * @return string
1237
-     * @throws EE_Error
1238
-     */
1239
-    public function reg_date()
1240
-    {
1241
-        return $this->get_datetime('REG_date');
1242
-    }
1243
-
1244
-
1245
-    /**
1246
-     * Gets the datetime-ticket for this registration (ie, it can be used to isolate
1247
-     * the ticket this registration purchased, or the datetime they have registered
1248
-     * to attend)
1249
-     *
1250
-     * @return EE_Datetime_Ticket
1251
-     * @throws EE_Error
1252
-     */
1253
-    public function datetime_ticket()
1254
-    {
1255
-        return $this->get_first_related('Datetime_Ticket');
1256
-    }
1257
-
1258
-
1259
-    /**
1260
-     * Sets the registration's datetime_ticket.
1261
-     *
1262
-     * @param EE_Datetime_Ticket $datetime_ticket
1263
-     * @return EE_Datetime_Ticket
1264
-     * @throws EE_Error
1265
-     */
1266
-    public function set_datetime_ticket($datetime_ticket)
1267
-    {
1268
-        return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket');
1269
-    }
1270
-
1271
-    /**
1272
-     * Gets deleted
1273
-     *
1274
-     * @return bool
1275
-     * @throws EE_Error
1276
-     */
1277
-    public function deleted()
1278
-    {
1279
-        return $this->get('REG_deleted');
1280
-    }
1281
-
1282
-    /**
1283
-     * Sets deleted
1284
-     *
1285
-     * @param boolean $deleted
1286
-     * @return bool
1287
-     * @throws EE_Error
1288
-     * @throws RuntimeException
1289
-     */
1290
-    public function set_deleted($deleted)
1291
-    {
1292
-        if ($deleted) {
1293
-            $this->delete();
1294
-        } else {
1295
-            $this->restore();
1296
-        }
1297
-    }
1298
-
1299
-
1300
-    /**
1301
-     * Get the status object of this object
1302
-     *
1303
-     * @return EE_Status
1304
-     * @throws EE_Error
1305
-     */
1306
-    public function status_obj()
1307
-    {
1308
-        return $this->get_first_related('Status');
1309
-    }
1310
-
1311
-
1312
-    /**
1313
-     * Returns the number of times this registration has checked into any of the datetimes
1314
-     * its available for
1315
-     *
1316
-     * @return int
1317
-     * @throws EE_Error
1318
-     */
1319
-    public function count_checkins()
1320
-    {
1321
-        return $this->get_model()->count_related($this, 'Checkin');
1322
-    }
1323
-
1324
-
1325
-    /**
1326
-     * Returns the number of current Check-ins this registration is checked into for any of the datetimes the
1327
-     * registration is for.  Note, this is ONLY checked in (does not include checkedout)
1328
-     *
1329
-     * @return int
1330
-     * @throws EE_Error
1331
-     */
1332
-    public function count_checkins_not_checkedout()
1333
-    {
1334
-        return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1)));
1335
-    }
1336
-
1337
-
1338
-    /**
1339
-     * The purpose of this method is simply to check whether this registration can checkin to the given datetime.
1340
-     *
1341
-     * @param int | EE_Datetime $DTT_OR_ID      The datetime the registration is being checked against
1342
-     * @param bool              $check_approved This is used to indicate whether the caller wants can_checkin to also
1343
-     *                                          consider registration status as well as datetime access.
1344
-     * @return bool
1345
-     * @throws EE_Error
1346
-     */
1347
-    public function can_checkin($DTT_OR_ID, $check_approved = true)
1348
-    {
1349
-        $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1350
-
1351
-        //first check registration status
1352
-        if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) {
1353
-            return false;
1354
-        }
1355
-        //is there a datetime ticket that matches this dtt_ID?
1356
-        if (! (EEM_Datetime_Ticket::instance()->exists(array(
1357
-            array(
1358
-                'TKT_ID' => $this->get('TKT_ID'),
1359
-                'DTT_ID' => $DTT_ID,
1360
-            ),
1361
-        )))
1362
-        ) {
1363
-            return false;
1364
-        }
1365
-
1366
-        //final check is against TKT_uses
1367
-        return $this->verify_can_checkin_against_TKT_uses($DTT_ID);
1368
-    }
1369
-
1370
-
1371
-    /**
1372
-     * This method verifies whether the user can checkin for the given datetime considering the max uses value set on
1373
-     * the ticket. To do this,  a query is done to get the count of the datetime records already checked into.  If the
1374
-     * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses,
1375
-     * then return false.  Otherwise return true.
1376
-     *
1377
-     * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against
1378
-     * @return bool true means can checkin.  false means cannot checkin.
1379
-     * @throws EE_Error
1380
-     */
1381
-    public function verify_can_checkin_against_TKT_uses($DTT_OR_ID)
1382
-    {
1383
-        $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1384
-
1385
-        if (! $DTT_ID) {
1386
-            return false;
1387
-        }
1388
-
1389
-        $max_uses = $this->ticket() instanceof EE_Ticket ? $this->ticket()->uses() : EE_INF;
1390
-
1391
-        // if max uses is not set or equals infinity then return true cause its not a factor for whether user can
1392
-        // check-in or not.
1393
-        if (! $max_uses || $max_uses === EE_INF) {
1394
-            return true;
1395
-        }
1396
-
1397
-        //does this datetime have a checkin record?  If so, then the dtt count has already been verified so we can just
1398
-        //go ahead and toggle.
1399
-        if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) {
1400
-            return true;
1401
-        }
1402
-
1403
-        //made it here so the last check is whether the number of checkins per unique datetime on this registration
1404
-        //disallows further check-ins.
1405
-        $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array(
1406
-            array(
1407
-                'REG_ID' => $this->ID(),
1408
-                'CHK_in' => true,
1409
-            ),
1410
-        ), 'DTT_ID', true);
1411
-        // checkins have already reached their max number of uses
1412
-        // so registrant can NOT checkin
1413
-        if ($count_unique_dtt_checkins >= $max_uses) {
1414
-            EE_Error::add_error(
1415
-                esc_html__(
1416
-                    'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.',
1417
-                    'event_espresso'
1418
-                ),
1419
-                __FILE__,
1420
-                __FUNCTION__,
1421
-                __LINE__
1422
-            );
1423
-            return false;
1424
-        }
1425
-        return true;
1426
-    }
1427
-
1428
-
1429
-    /**
1430
-     * toggle Check-in status for this registration
1431
-     * Check-ins are toggled in the following order:
1432
-     * never checked in -> checked in
1433
-     * checked in -> checked out
1434
-     * checked out -> checked in
1435
-     *
1436
-     * @param  int $DTT_ID  include specific datetime to toggle Check-in for.
1437
-     *                      If not included or null, then it is assumed latest datetime is being toggled.
1438
-     * @param bool $verify  If true then can_checkin() is used to verify whether the person
1439
-     *                      can be checked in or not.  Otherwise this forces change in checkin status.
1440
-     * @return bool|int     the chk_in status toggled to OR false if nothing got changed.
1441
-     * @throws EE_Error
1442
-     */
1443
-    public function toggle_checkin_status($DTT_ID = null, $verify = false)
1444
-    {
1445
-        if (empty($DTT_ID)) {
1446
-            $datetime = $this->get_latest_related_datetime();
1447
-            $DTT_ID   = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
1448
-            // verify the registration can checkin for the given DTT_ID
1449
-        } elseif (! $this->can_checkin($DTT_ID, $verify)) {
1450
-            EE_Error::add_error(
1451
-                sprintf(
1452
-                    esc_html__(
1453
-                        'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access',
1454
-                        'event_espresso'
1455
-                    ),
1456
-                    $this->ID(),
1457
-                    $DTT_ID
1458
-                ),
1459
-                __FILE__,
1460
-                __FUNCTION__,
1461
-                __LINE__
1462
-            );
1463
-            return false;
1464
-        }
1465
-        $status_paths = array(
1466
-            EE_Checkin::status_checked_never => EE_Checkin::status_checked_in,
1467
-            EE_Checkin::status_checked_in    => EE_Checkin::status_checked_out,
1468
-            EE_Checkin::status_checked_out   => EE_Checkin::status_checked_in,
1469
-        );
1470
-        //start by getting the current status so we know what status we'll be changing to.
1471
-        $cur_status = $this->check_in_status_for_datetime($DTT_ID, null);
1472
-        $status_to  = $status_paths[$cur_status];
1473
-        // database only records true for checked IN or false for checked OUT
1474
-        // no record ( null ) means checked in NEVER, but we obviously don't save that
1475
-        $new_status = $status_to === EE_Checkin::status_checked_in ? true : false;
1476
-        // add relation - note Check-ins are always creating new rows
1477
-        // because we are keeping track of Check-ins over time.
1478
-        // Eventually we'll probably want to show a list table
1479
-        // for the individual Check-ins so that they can be managed.
1480
-        $checkin = EE_Checkin::new_instance(array(
1481
-            'REG_ID' => $this->ID(),
1482
-            'DTT_ID' => $DTT_ID,
1483
-            'CHK_in' => $new_status,
1484
-        ));
1485
-        // if the record could not be saved then return false
1486
-        if ($checkin->save() === 0) {
1487
-            if (WP_DEBUG) {
1488
-                global $wpdb;
1489
-                $error = sprintf(
1490
-                    esc_html__(
1491
-                        'Registration check in update failed because of the following database error: %1$s%2$s',
1492
-                        'event_espresso'
1493
-                    ),
1494
-                    '<br />',
1495
-                    $wpdb->last_error
1496
-                );
1497
-            } else {
1498
-                $error = esc_html__(
1499
-                    'Registration check in update failed because of an unknown database error',
1500
-                    'event_espresso'
1501
-                );
1502
-            }
1503
-            EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
1504
-            return false;
1505
-        }
1506
-        return $status_to;
1507
-    }
1508
-
1509
-
1510
-    /**
1511
-     * Returns the latest datetime related to this registration (via the ticket attached to the registration).
1512
-     * "Latest" is defined by the `DTT_EVT_start` column.
1513
-     *
1514
-     * @return EE_Datetime|null
1515
-     * @throws \EE_Error
1516
-     */
1517
-    public function get_latest_related_datetime()
1518
-    {
1519
-        return EEM_Datetime::instance()->get_one(
1520
-            array(
1521
-                array(
1522
-                    'Ticket.Registration.REG_ID' => $this->ID(),
1523
-                ),
1524
-                'order_by' => array('DTT_EVT_start' => 'DESC'),
1525
-            )
1526
-        );
1527
-    }
1528
-
1529
-
1530
-    /**
1531
-     * Returns the earliest datetime related to this registration (via the ticket attached to the registration).
1532
-     * "Earliest" is defined by the `DTT_EVT_start` column.
1533
-     *
1534
-     * @throws \EE_Error
1535
-     */
1536
-    public function get_earliest_related_datetime()
1537
-    {
1538
-        return EEM_Datetime::instance()->get_one(
1539
-            array(
1540
-                array(
1541
-                    'Ticket.Registration.REG_ID' => $this->ID(),
1542
-                ),
1543
-                'order_by' => array('DTT_EVT_start' => 'ASC'),
1544
-            )
1545
-        );
1546
-    }
1547
-
1548
-
1549
-    /**
1550
-     * This method simply returns the check-in status for this registration and the given datetime.
1551
-     * If neither the datetime nor the checkin values are provided as arguments,
1552
-     * then this will return the LATEST check-in status for the registration across all datetimes it belongs to.
1553
-     *
1554
-     * @param  int       $DTT_ID  The ID of the datetime we're checking against
1555
-     *                            (if empty we'll get the primary datetime for
1556
-     *                            this registration (via event) and use it's ID);
1557
-     * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id.
1558
-     * @return int                Integer representing Check-in status.
1559
-     * @throws \EE_Error
1560
-     */
1561
-    public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null)
1562
-    {
1563
-        $checkin_query_params = array(
1564
-            'order_by' => array('CHK_timestamp' => 'DESC'),
1565
-        );
1566
-
1567
-        if ($DTT_ID > 0) {
1568
-            $checkin_query_params[0] = array('DTT_ID' => $DTT_ID);
1569
-        }
1570
-
1571
-        //get checkin object (if exists)
1572
-        $checkin = $checkin instanceof EE_Checkin
1573
-            ? $checkin
1574
-            : $this->get_first_related('Checkin', $checkin_query_params);
1575
-        if ($checkin instanceof EE_Checkin) {
1576
-            if ($checkin->get('CHK_in')) {
1577
-                return EE_Checkin::status_checked_in; //checked in
1578
-            }
1579
-            return EE_Checkin::status_checked_out; //had checked in but is now checked out.
1580
-        }
1581
-        return EE_Checkin::status_checked_never; //never been checked in
1582
-    }
1583
-
1584
-
1585
-    /**
1586
-     * This method returns a localized message for the toggled Check-in message.
1587
-     *
1588
-     * @param  int $DTT_ID include specific datetime to get the correct Check-in message.  If not included or null,
1589
-     *                     then it is assumed Check-in for primary datetime was toggled.
1590
-     * @param bool $error  This just flags that you want an error message returned. This is put in so that the error
1591
-     *                     message can be customized with the attendee name.
1592
-     * @return string internationalized message
1593
-     * @throws EE_Error
1594
-     */
1595
-    public function get_checkin_msg($DTT_ID, $error = false)
1596
-    {
1597
-        //let's get the attendee first so we can include the name of the attendee
1598
-        $attendee = $this->get_first_related('Attendee');
1599
-        if ($attendee instanceof EE_Attendee) {
1600
-            if ($error) {
1601
-                return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name());
1602
-            }
1603
-            $cur_status = $this->check_in_status_for_datetime($DTT_ID);
1604
-            //what is the status message going to be?
1605
-            switch ($cur_status) {
1606
-                case EE_Checkin::status_checked_never:
1607
-                    return sprintf(__("%s has been removed from Check-in records", "event_espresso"),
1608
-                        $attendee->full_name());
1609
-                    break;
1610
-                case EE_Checkin::status_checked_in:
1611
-                    return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name());
1612
-                    break;
1613
-                case EE_Checkin::status_checked_out:
1614
-                    return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name());
1615
-                    break;
1616
-            }
1617
-        }
1618
-        return esc_html__("The check-in status could not be determined.", "event_espresso");
1619
-    }
1620
-
1621
-
1622
-    /**
1623
-     * Returns the related EE_Transaction to this registration
1624
-     *
1625
-     * @return EE_Transaction
1626
-     * @throws EE_Error
1627
-     * @throws EntityNotFoundException
1628
-     */
1629
-    public function transaction()
1630
-    {
1631
-        $transaction = $this->get_first_related('Transaction');
1632
-        if (! $transaction instanceof \EE_Transaction) {
1633
-            throw new EntityNotFoundException('Transaction ID', $this->transaction_ID());
1634
-        }
1635
-        return $transaction;
1636
-    }
1637
-
1638
-
1639
-    /**
1640
-     *        get Registration Code
1641
-     */
1642
-    public function reg_code()
1643
-    {
1644
-        return $this->get('REG_code');
1645
-    }
1646
-
1647
-
1648
-    /**
1649
-     *        get Transaction ID
1650
-     */
1651
-    public function transaction_ID()
1652
-    {
1653
-        return $this->get('TXN_ID');
1654
-    }
1655
-
1656
-
1657
-    /**
1658
-     * @return int
1659
-     * @throws EE_Error
1660
-     */
1661
-    public function ticket_ID()
1662
-    {
1663
-        return $this->get('TKT_ID');
1664
-    }
1665
-
1666
-
1667
-    /**
1668
-     *        Set Registration Code
1669
-     *
1670
-     * @access    public
1671
-     * @param    string  $REG_code Registration Code
1672
-     * @param    boolean $use_default
1673
-     * @throws EE_Error
1674
-     */
1675
-    public function set_reg_code($REG_code, $use_default = false)
1676
-    {
1677
-        if (empty($REG_code)) {
1678
-            EE_Error::add_error(
1679
-                esc_html__('REG_code can not be empty.', 'event_espresso'),
1680
-                __FILE__,
1681
-                __FUNCTION__,
1682
-                __LINE__
1683
-            );
1684
-            return;
1685
-        }
1686
-        if (! $this->reg_code()) {
1687
-            parent::set('REG_code', $REG_code, $use_default);
1688
-        } else {
1689
-            EE_Error::doing_it_wrong(
1690
-                __CLASS__ . '::' . __FUNCTION__,
1691
-                esc_html__('Can not change a registration REG_code once it has been set.', 'event_espresso'),
1692
-                '4.6.0'
1693
-            );
1694
-        }
1695
-    }
1696
-
1697
-
1698
-    /**
1699
-     * Returns all other registrations in the same group as this registrant who have the same ticket option.
1700
-     * Note, if you want to just get all registrations in the same transaction (group), use:
1701
-     *    $registration->transaction()->registrations();
1702
-     *
1703
-     * @since 4.5.0
1704
-     * @return EE_Registration[] or empty array if this isn't a group registration.
1705
-     * @throws EE_Error
1706
-     */
1707
-    public function get_all_other_registrations_in_group()
1708
-    {
1709
-        if ($this->group_size() < 2) {
1710
-            return array();
1711
-        }
1712
-
1713
-        $query[0] = array(
1714
-            'TXN_ID' => $this->transaction_ID(),
1715
-            'REG_ID' => array('!=', $this->ID()),
1716
-            'TKT_ID' => $this->ticket_ID(),
1717
-        );
1718
-        /** @var EE_Registration[] $registrations */
1719
-        $registrations = $this->get_model()->get_all($query);
1720
-        return $registrations;
1721
-    }
1722
-
1723
-    /**
1724
-     * Return the link to the admin details for the object.
1725
-     *
1726
-     * @return string
1727
-     * @throws EE_Error
1728
-     */
1729
-    public function get_admin_details_link()
1730
-    {
1731
-        EE_Registry::instance()->load_helper('URL');
1732
-        return EEH_URL::add_query_args_and_nonce(
1733
-            array(
1734
-                'page'    => 'espresso_registrations',
1735
-                'action'  => 'view_registration',
1736
-                '_REG_ID' => $this->ID(),
1737
-            ),
1738
-            admin_url('admin.php')
1739
-        );
1740
-    }
1741
-
1742
-    /**
1743
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
1744
-     *
1745
-     * @return string
1746
-     * @throws EE_Error
1747
-     */
1748
-    public function get_admin_edit_link()
1749
-    {
1750
-        return $this->get_admin_details_link();
1751
-    }
1752
-
1753
-    /**
1754
-     * Returns the link to a settings page for the object.
1755
-     *
1756
-     * @return string
1757
-     * @throws EE_Error
1758
-     */
1759
-    public function get_admin_settings_link()
1760
-    {
1761
-        return $this->get_admin_details_link();
1762
-    }
1763
-
1764
-    /**
1765
-     * Returns the link to the "overview" for the object (typically the "list table" view).
1766
-     *
1767
-     * @return string
1768
-     */
1769
-    public function get_admin_overview_link()
1770
-    {
1771
-        EE_Registry::instance()->load_helper('URL');
1772
-        return EEH_URL::add_query_args_and_nonce(
1773
-            array(
1774
-                'page' => 'espresso_registrations',
1775
-            ),
1776
-            admin_url('admin.php')
1777
-        );
1778
-    }
1779
-
1780
-
1781
-    /**
1782
-     * @param array $query_params
1783
-     * @return \EE_Registration[]
1784
-     * @throws \EE_Error
1785
-     */
1786
-    public function payments($query_params = array())
1787
-    {
1788
-        return $this->get_many_related('Payment', $query_params);
1789
-    }
1790
-
1791
-
1792
-    /**
1793
-     * @param array $query_params
1794
-     * @return \EE_Registration_Payment[]
1795
-     * @throws \EE_Error
1796
-     */
1797
-    public function registration_payments($query_params = array())
1798
-    {
1799
-        return $this->get_many_related('Registration_Payment', $query_params);
1800
-    }
1801
-
1802
-
1803
-    /**
1804
-     * This grabs the payment method corresponding to the last payment made for the amount owing on the registration.
1805
-     * Note: if there are no payments on the registration there will be no payment method returned.
1806
-     *
1807
-     * @return EE_Payment_Method|null
1808
-     */
1809
-    public function payment_method()
1810
-    {
1811
-        return EEM_Payment_Method::instance()->get_last_used_for_registration($this);
1812
-    }
1813
-
1814
-
1815
-    /**
1816
-     * @return \EE_Line_Item
1817
-     * @throws EntityNotFoundException
1818
-     * @throws \EE_Error
1819
-     */
1820
-    public function ticket_line_item()
1821
-    {
1822
-        $ticket            = $this->ticket();
1823
-        $transaction       = $this->transaction();
1824
-        $line_item         = null;
1825
-        $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs(
1826
-            $transaction->total_line_item(),
1827
-            'Ticket',
1828
-            array($ticket->ID())
1829
-        );
1830
-        foreach ($ticket_line_items as $ticket_line_item) {
1831
-            if (
1832
-                $ticket_line_item instanceof \EE_Line_Item
1833
-                && $ticket_line_item->OBJ_type() === 'Ticket'
1834
-                && $ticket_line_item->OBJ_ID() === $ticket->ID()
1835
-            ) {
1836
-                $line_item = $ticket_line_item;
1837
-                break;
1838
-            }
1839
-        }
1840
-        if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) {
1841
-            throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID());
1842
-        }
1843
-        return $line_item;
1844
-    }
1845
-
1846
-
1847
-    /**
1848
-     * Soft Deletes this model object.
1849
-     *
1850
-     * @return boolean | int
1851
-     * @throws \RuntimeException
1852
-     * @throws \EE_Error
1853
-     */
1854
-    public function delete()
1855
-    {
1856
-        if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) {
1857
-            $this->set_status(EEM_Registration::status_id_cancelled);
1858
-        }
1859
-        return parent::delete();
1860
-    }
1861
-
1862
-
1863
-    /**
1864
-     * Restores whatever the previous status was on a registration before it was trashed (if possible)
1865
-     *
1866
-     * @throws \EE_Error
1867
-     * @throws \RuntimeException
1868
-     */
1869
-    public function restore()
1870
-    {
1871
-        $previous_status = $this->get_extra_meta(
1872
-            EE_Registration::PRE_TRASH_REG_STATUS_KEY,
1873
-            true,
1874
-            EEM_Registration::status_id_cancelled
1875
-        );
1876
-        if ($previous_status) {
1877
-            $this->delete_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY);
1878
-            $this->set_status($previous_status);
1879
-        }
1880
-        return parent::restore();
1881
-    }
1882
-
1883
-
1884
-
1885
-    /*************************** DEPRECATED ***************************/
1886
-
1887
-
1888
-    /**
1889
-     * @deprecated
1890
-     * @since     4.7.0
1891
-     * @access    public
1892
-     */
1893
-    public function price_paid()
1894
-    {
1895
-        EE_Error::doing_it_wrong('EE_Registration::price_paid()',
1896
-            esc_html__('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'),
1897
-            '4.7.0');
1898
-        return $this->final_price();
1899
-    }
1900
-
1901
-
1902
-    /**
1903
-     * @deprecated
1904
-     * @since     4.7.0
1905
-     * @access    public
1906
-     * @param    float $REG_final_price
1907
-     * @throws EE_Error
1908
-     * @throws RuntimeException
1909
-     */
1910
-    public function set_price_paid($REG_final_price = 0.00)
1911
-    {
1912
-        EE_Error::doing_it_wrong('EE_Registration::set_price_paid()',
1913
-            esc_html__('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'),
1914
-            '4.7.0');
1915
-        $this->set_final_price($REG_final_price);
1916
-    }
1917
-
1918
-
1919
-    /**
1920
-     * @deprecated
1921
-     * @since 4.7.0
1922
-     * @return string
1923
-     * @throws EE_Error
1924
-     */
1925
-    public function pretty_price_paid()
1926
-    {
1927
-        EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()',
1928
-            esc_html__('This method is deprecated, please use EE_Registration::pretty_final_price() instead.',
1929
-                'event_espresso'), '4.7.0');
1930
-        return $this->pretty_final_price();
1931
-    }
1932
-
1933
-
1934
-    /**
1935
-     * Gets the primary datetime related to this registration via the related Event to this registration
1936
-     *
1937
-     * @deprecated 4.9.17
1938
-     * @return EE_Datetime
1939
-     * @throws EE_Error
1940
-     * @throws EntityNotFoundException
1941
-     */
1942
-    public function get_related_primary_datetime()
1943
-    {
1944
-        EE_Error::doing_it_wrong(
1945
-            __METHOD__,
1946
-            esc_html__(
1947
-                'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()',
1948
-                'event_espresso'
1949
-            ),
1950
-            '4.9.17',
1951
-            '5.0.0'
1952
-        );
1953
-        return $this->event()->primary_datetime();
1954
-    }
21
+	/**
22
+	 * Used to reference when a registration has never been checked in.
23
+	 *
24
+	 * @deprecated use \EE_Checkin::status_checked_never instead
25
+	 * @type int
26
+	 */
27
+	const checkin_status_never = 2;
28
+
29
+	/**
30
+	 * Used to reference when a registration has been checked in.
31
+	 *
32
+	 * @deprecated use \EE_Checkin::status_checked_in instead
33
+	 * @type int
34
+	 */
35
+	const checkin_status_in = 1;
36
+
37
+
38
+	/**
39
+	 * Used to reference when a registration has been checked out.
40
+	 *
41
+	 * @deprecated use \EE_Checkin::status_checked_out instead
42
+	 * @type int
43
+	 */
44
+	const checkin_status_out = 0;
45
+
46
+
47
+	/**
48
+	 * extra meta key for tracking reg status os trashed registrations
49
+	 *
50
+	 * @type string
51
+	 */
52
+	const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status';
53
+
54
+
55
+	/**
56
+	 * extra meta key for tracking if registration has reserved ticket
57
+	 *
58
+	 * @type string
59
+	 */
60
+	const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket';
61
+
62
+
63
+	/**
64
+	 * @param array  $props_n_values          incoming values
65
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
66
+	 *                                        used.)
67
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
68
+	 *                                        date_format and the second value is the time format
69
+	 * @return EE_Registration
70
+	 * @throws EE_Error
71
+	 */
72
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
73
+	{
74
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
75
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
76
+	}
77
+
78
+
79
+	/**
80
+	 * @param array  $props_n_values  incoming values from the database
81
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
82
+	 *                                the website will be used.
83
+	 * @return EE_Registration
84
+	 */
85
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
86
+	{
87
+		return new self($props_n_values, true, $timezone);
88
+	}
89
+
90
+
91
+	/**
92
+	 *        Set Event ID
93
+	 *
94
+	 * @param        int $EVT_ID Event ID
95
+	 * @throws EE_Error
96
+	 * @throws RuntimeException
97
+	 */
98
+	public function set_event($EVT_ID = 0)
99
+	{
100
+		$this->set('EVT_ID', $EVT_ID);
101
+	}
102
+
103
+
104
+	/**
105
+	 * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can
106
+	 * be routed to internal methods
107
+	 *
108
+	 * @param string $field_name
109
+	 * @param mixed  $field_value
110
+	 * @param bool   $use_default
111
+	 * @throws EE_Error
112
+	 * @throws EntityNotFoundException
113
+	 * @throws InvalidArgumentException
114
+	 * @throws InvalidDataTypeException
115
+	 * @throws InvalidInterfaceException
116
+	 * @throws ReflectionException
117
+	 * @throws RuntimeException
118
+	 */
119
+	public function set($field_name, $field_value, $use_default = false)
120
+	{
121
+		switch ($field_name) {
122
+			case 'REG_code':
123
+				if (! empty($field_value) && $this->reg_code() === null) {
124
+					$this->set_reg_code($field_value, $use_default);
125
+				}
126
+				break;
127
+			case 'STS_ID':
128
+				$this->set_status($field_value, $use_default);
129
+				break;
130
+			default:
131
+				parent::set($field_name, $field_value, $use_default);
132
+		}
133
+	}
134
+
135
+
136
+	/**
137
+	 * Set Status ID
138
+	 * updates the registration status and ALSO...
139
+	 * calls reserve_registration_space() if the reg status changes TO approved from any other reg status
140
+	 * calls release_registration_space() if the reg status changes FROM approved to any other reg status
141
+	 *
142
+	 * @param string       $new_STS_ID
143
+	 * @param boolean      $use_default
144
+	 * @param Context|null $context
145
+	 * @return bool
146
+	 * @throws EE_Error
147
+	 * @throws EntityNotFoundException
148
+	 * @throws InvalidArgumentException
149
+	 * @throws ReflectionException
150
+	 * @throws RuntimeException
151
+	 * @throws InvalidDataTypeException
152
+	 * @throws InvalidInterfaceException
153
+	 */
154
+	public function set_status($new_STS_ID = null, $use_default = false, Context $context = null)
155
+	{
156
+		// get current REG_Status
157
+		$old_STS_ID = $this->status_ID();
158
+		// if status has changed
159
+		if ($old_STS_ID !== $new_STS_ID // and that status has actually changed
160
+			&& ! empty($old_STS_ID) // and that old status is actually set
161
+			&& ! empty($new_STS_ID) // as well as the new status
162
+			&& $this->ID() // ensure registration is in the db
163
+		) {
164
+			// TO approved
165
+			if ($new_STS_ID === EEM_Registration::status_id_approved) {
166
+				// reserve a space by incrementing ticket and datetime sold values
167
+				$this->_reserve_registration_space();
168
+				do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID, $context);
169
+				// OR FROM  approved
170
+			} elseif ($old_STS_ID === EEM_Registration::status_id_approved) {
171
+				// release a space by decrementing ticket and datetime sold values
172
+				$this->_release_registration_space();
173
+				do_action(
174
+					'AHEE__EE_Registration__set_status__from_approved',
175
+					$this,
176
+					$old_STS_ID,
177
+					$new_STS_ID,
178
+					$context
179
+				);
180
+			}
181
+			// update status
182
+			parent::set('STS_ID', $new_STS_ID, $use_default);
183
+			$this->_update_if_canceled_or_declined($new_STS_ID, $old_STS_ID, $context);
184
+			if($this->statusChangeUpdatesTransaction($context)) {
185
+				$this->updateTransactionAfterStatusChange();
186
+			}
187
+			do_action('AHEE__EE_Registration__set_status__after_update', $this, $old_STS_ID, $new_STS_ID, $context);
188
+			return true;
189
+		}
190
+		//even though the old value matches the new value, it's still good to
191
+		//allow the parent set method to have a say
192
+		parent::set('STS_ID', $new_STS_ID, $use_default);
193
+		return true;
194
+	}
195
+
196
+
197
+	/**
198
+	 * update REGs and TXN when cancelled or declined registrations involved
199
+	 *
200
+	 * @param string       $new_STS_ID
201
+	 * @param string       $old_STS_ID
202
+	 * @param Context|null $context
203
+	 * @throws EE_Error
204
+	 * @throws InvalidArgumentException
205
+	 * @throws InvalidDataTypeException
206
+	 * @throws InvalidInterfaceException
207
+	 * @throws ReflectionException
208
+	 */
209
+	private function _update_if_canceled_or_declined($new_STS_ID, $old_STS_ID, Context $context = null)
210
+	{
211
+		// these reg statuses should not be considered in any calculations involving monies owing
212
+		$closed_reg_statuses = EEM_Registration::closed_reg_statuses();
213
+		// true if registration has been cancelled or declined
214
+		$this->updateIfCanceled(
215
+			$closed_reg_statuses,
216
+			$new_STS_ID,
217
+			$old_STS_ID,
218
+			$context
219
+		);
220
+		$this->updateIfDeclined(
221
+			$closed_reg_statuses,
222
+			$new_STS_ID,
223
+			$old_STS_ID,
224
+			$context
225
+		);
226
+	}
227
+
228
+
229
+	/**
230
+	 * update REGs and TXN when cancelled or declined registrations involved
231
+	 *
232
+	 * @param array        $closed_reg_statuses
233
+	 * @param string       $new_STS_ID
234
+	 * @param string       $old_STS_ID
235
+	 * @param Context|null $context
236
+	 * @throws EE_Error
237
+	 * @throws InvalidArgumentException
238
+	 * @throws InvalidDataTypeException
239
+	 * @throws InvalidInterfaceException
240
+	 * @throws ReflectionException
241
+	 */
242
+	private function updateIfCanceled(array $closed_reg_statuses, $new_STS_ID, $old_STS_ID, Context $context = null)
243
+	{
244
+		// true if registration has been cancelled or declined
245
+		if (in_array($new_STS_ID, $closed_reg_statuses, true)
246
+			&& ! in_array($old_STS_ID, $closed_reg_statuses, true)
247
+		) {
248
+			/** @type EE_Registration_Processor $registration_processor */
249
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
250
+			/** @type EE_Transaction_Processor $transaction_processor */
251
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
252
+			// cancelled or declined registration
253
+			$registration_processor->update_registration_after_being_canceled_or_declined(
254
+				$this,
255
+				$closed_reg_statuses
256
+			);
257
+			$transaction_processor->update_transaction_after_canceled_or_declined_registration(
258
+				$this,
259
+				$closed_reg_statuses,
260
+				false
261
+			);
262
+			do_action(
263
+				'AHEE__EE_Registration__set_status__canceled_or_declined',
264
+				$this,
265
+				$old_STS_ID,
266
+				$new_STS_ID,
267
+				$context
268
+			);
269
+			return;
270
+		}
271
+	}
272
+
273
+
274
+	/**
275
+	 * update REGs and TXN when cancelled or declined registrations involved
276
+	 *
277
+	 * @param array        $closed_reg_statuses
278
+	 * @param string       $new_STS_ID
279
+	 * @param string       $old_STS_ID
280
+	 * @param Context|null $context
281
+	 * @throws EE_Error
282
+	 * @throws InvalidArgumentException
283
+	 * @throws InvalidDataTypeException
284
+	 * @throws InvalidInterfaceException
285
+	 * @throws ReflectionException
286
+	 */
287
+	private function updateIfDeclined(array $closed_reg_statuses, $new_STS_ID, $old_STS_ID, Context $context = null)
288
+	{
289
+		// true if reinstating cancelled or declined registration
290
+		if (in_array($old_STS_ID, $closed_reg_statuses, true)
291
+			&& ! in_array($new_STS_ID, $closed_reg_statuses, true)
292
+		) {
293
+			/** @type EE_Registration_Processor $registration_processor */
294
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
295
+			/** @type EE_Transaction_Processor $transaction_processor */
296
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
297
+			// reinstating cancelled or declined registration
298
+			$registration_processor->update_canceled_or_declined_registration_after_being_reinstated(
299
+				$this,
300
+				$closed_reg_statuses
301
+			);
302
+			$transaction_processor->update_transaction_after_reinstating_canceled_registration(
303
+				$this,
304
+				$closed_reg_statuses,
305
+				false
306
+			);
307
+			do_action(
308
+				'AHEE__EE_Registration__set_status__after_reinstated',
309
+				$this,
310
+				$old_STS_ID,
311
+				$new_STS_ID,
312
+				$context
313
+			);
314
+		}
315
+	}
316
+
317
+
318
+	/**
319
+	 * @param Context|null $context
320
+	 * @return bool
321
+	 */
322
+	private function statusChangeUpdatesTransaction(Context $context = null)
323
+	{
324
+		$contexts_that_do_not_update_transaction = (array) apply_filters(
325
+			'AHEE__EE_Registration__statusChangeUpdatesTransaction__contexts_that_do_not_update_transaction',
326
+			array('spco_reg_step_attendee_information_process_registrations'),
327
+			$context,
328
+			$this
329
+		);
330
+		return ! (
331
+			$context instanceof Context
332
+			&& in_array($context->slug(), $contexts_that_do_not_update_transaction, true)
333
+		);
334
+	}
335
+
336
+
337
+	/**
338
+	 * @throws EE_Error
339
+	 * @throws EntityNotFoundException
340
+	 * @throws InvalidArgumentException
341
+	 * @throws InvalidDataTypeException
342
+	 * @throws InvalidInterfaceException
343
+	 * @throws ReflectionException
344
+	 * @throws RuntimeException
345
+	 */
346
+	private function updateTransactionAfterStatusChange()
347
+	{
348
+		/** @type EE_Transaction_Payments $transaction_payments */
349
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
350
+		$transaction_payments->recalculate_transaction_total($this->transaction(), false);
351
+		$this->transaction()->update_status_based_on_total_paid(true);
352
+	}
353
+
354
+
355
+	/**
356
+	 *        get Status ID
357
+	 */
358
+	public function status_ID()
359
+	{
360
+		return $this->get('STS_ID');
361
+	}
362
+
363
+
364
+	/**
365
+	 * increments this registration's related ticket sold and corresponding datetime sold values
366
+	 *
367
+	 * @return void
368
+	 * @throws EE_Error
369
+	 * @throws EntityNotFoundException
370
+	 */
371
+	private function _reserve_registration_space()
372
+	{
373
+		// reserved ticket and datetime counts will be decremented as sold counts are incremented
374
+		// so stop tracking that this reg has a ticket reserved
375
+		$this->release_reserved_ticket();
376
+		$ticket = $this->ticket();
377
+		$ticket->increase_sold();
378
+		$ticket->save();
379
+		// possibly set event status to sold out
380
+		$this->event()->perform_sold_out_status_check();
381
+	}
382
+
383
+
384
+	/**
385
+	 * Gets the ticket this registration is for
386
+	 *
387
+	 * @param boolean $include_archived whether to include archived tickets or not.
388
+	 * @return EE_Ticket|EE_Base_Class
389
+	 * @throws \EE_Error
390
+	 */
391
+	public function ticket($include_archived = true)
392
+	{
393
+		$query_params = array();
394
+		if ($include_archived) {
395
+			$query_params['default_where_conditions'] = 'none';
396
+		}
397
+		return $this->get_first_related('Ticket', $query_params);
398
+	}
399
+
400
+
401
+	/**
402
+	 * Gets the event this registration is for
403
+	 *
404
+	 * @return EE_Event
405
+	 * @throws EE_Error
406
+	 * @throws EntityNotFoundException
407
+	 */
408
+	public function event()
409
+	{
410
+		$event = $this->get_first_related('Event');
411
+		if (! $event instanceof \EE_Event) {
412
+			throw new EntityNotFoundException('Event ID', $this->event_ID());
413
+		}
414
+		return $event;
415
+	}
416
+
417
+
418
+	/**
419
+	 * Gets the "author" of the registration.  Note that for the purposes of registrations, the author will correspond
420
+	 * with the author of the event this registration is for.
421
+	 *
422
+	 * @since 4.5.0
423
+	 * @return int
424
+	 * @throws EE_Error
425
+	 * @throws EntityNotFoundException
426
+	 */
427
+	public function wp_user()
428
+	{
429
+		$event = $this->event();
430
+		if ($event instanceof EE_Event) {
431
+			return $event->wp_user();
432
+		}
433
+		return 0;
434
+	}
435
+
436
+
437
+	/**
438
+	 * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values
439
+	 *
440
+	 * @return void
441
+	 * @throws \EE_Error
442
+	 */
443
+	private function _release_registration_space()
444
+	{
445
+		$ticket = $this->ticket();
446
+		$ticket->decrease_sold();
447
+		$ticket->save();
448
+	}
449
+
450
+
451
+	/**
452
+	 * tracks this registration's ticket reservation in extra meta
453
+	 * and can increment related ticket reserved and corresponding datetime reserved values
454
+	 *
455
+	 * @param bool $update_ticket if true, will increment ticket and datetime reserved count
456
+	 * @return void
457
+	 * @throws \EE_Error
458
+	 */
459
+	public function reserve_ticket($update_ticket = false)
460
+	{
461
+		if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) === false) {
462
+			// PLZ NOTE: although checking $update_ticket first would be more efficient,
463
+			// we NEED to ALWAYS call update_extra_meta(), which is why that is done first
464
+			if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) && $update_ticket) {
465
+				$ticket = $this->ticket();
466
+				$ticket->increase_reserved();
467
+				$ticket->save();
468
+			}
469
+		}
470
+	}
471
+
472
+
473
+	/**
474
+	 * stops tracking this registration's ticket reservation in extra meta
475
+	 * decrements (subtracts) related ticket reserved and corresponding datetime reserved values
476
+	 *
477
+	 * @param bool $update_ticket if true, will decrement ticket and datetime reserved count
478
+	 * @return void
479
+	 * @throws \EE_Error
480
+	 */
481
+	public function release_reserved_ticket($update_ticket = false)
482
+	{
483
+		if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) !== false) {
484
+			// PLZ NOTE: although checking $update_ticket first would be more efficient,
485
+			// we NEED to ALWAYS call delete_extra_meta(), which is why that is done first
486
+			if ($this->delete_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY) && $update_ticket) {
487
+				$ticket = $this->ticket();
488
+				$ticket->decrease_reserved();
489
+				$ticket->save();
490
+			}
491
+		}
492
+	}
493
+
494
+
495
+	/**
496
+	 * Set Attendee ID
497
+	 *
498
+	 * @param        int $ATT_ID Attendee ID
499
+	 * @throws EE_Error
500
+	 * @throws RuntimeException
501
+	 */
502
+	public function set_attendee_id($ATT_ID = 0)
503
+	{
504
+		$this->set('ATT_ID', $ATT_ID);
505
+	}
506
+
507
+
508
+	/**
509
+	 *        Set Transaction ID
510
+	 *
511
+	 * @param        int $TXN_ID Transaction ID
512
+	 * @throws EE_Error
513
+	 * @throws RuntimeException
514
+	 */
515
+	public function set_transaction_id($TXN_ID = 0)
516
+	{
517
+		$this->set('TXN_ID', $TXN_ID);
518
+	}
519
+
520
+
521
+	/**
522
+	 *        Set Session
523
+	 *
524
+	 * @param    string $REG_session PHP Session ID
525
+	 * @throws EE_Error
526
+	 * @throws RuntimeException
527
+	 */
528
+	public function set_session($REG_session = '')
529
+	{
530
+		$this->set('REG_session', $REG_session);
531
+	}
532
+
533
+
534
+	/**
535
+	 *        Set Registration URL Link
536
+	 *
537
+	 * @param    string $REG_url_link Registration URL Link
538
+	 * @throws EE_Error
539
+	 * @throws RuntimeException
540
+	 */
541
+	public function set_reg_url_link($REG_url_link = '')
542
+	{
543
+		$this->set('REG_url_link', $REG_url_link);
544
+	}
545
+
546
+
547
+	/**
548
+	 *        Set Attendee Counter
549
+	 *
550
+	 * @param        int $REG_count Primary Attendee
551
+	 * @throws EE_Error
552
+	 * @throws RuntimeException
553
+	 */
554
+	public function set_count($REG_count = 1)
555
+	{
556
+		$this->set('REG_count', $REG_count);
557
+	}
558
+
559
+
560
+	/**
561
+	 *        Set Group Size
562
+	 *
563
+	 * @param        boolean $REG_group_size Group Registration
564
+	 * @throws EE_Error
565
+	 * @throws RuntimeException
566
+	 */
567
+	public function set_group_size($REG_group_size = false)
568
+	{
569
+		$this->set('REG_group_size', $REG_group_size);
570
+	}
571
+
572
+
573
+	/**
574
+	 *    is_not_approved -  convenience method that returns TRUE if REG status ID ==
575
+	 *    EEM_Registration::status_id_not_approved
576
+	 *
577
+	 * @return        boolean
578
+	 */
579
+	public function is_not_approved()
580
+	{
581
+		return $this->status_ID() == EEM_Registration::status_id_not_approved ? true : false;
582
+	}
583
+
584
+
585
+	/**
586
+	 *    is_pending_payment -  convenience method that returns TRUE if REG status ID ==
587
+	 *    EEM_Registration::status_id_pending_payment
588
+	 *
589
+	 * @return        boolean
590
+	 */
591
+	public function is_pending_payment()
592
+	{
593
+		return $this->status_ID() == EEM_Registration::status_id_pending_payment ? true : false;
594
+	}
595
+
596
+
597
+	/**
598
+	 *    is_approved -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved
599
+	 *
600
+	 * @return        boolean
601
+	 */
602
+	public function is_approved()
603
+	{
604
+		return $this->status_ID() == EEM_Registration::status_id_approved ? true : false;
605
+	}
606
+
607
+
608
+	/**
609
+	 *    is_cancelled -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled
610
+	 *
611
+	 * @return        boolean
612
+	 */
613
+	public function is_cancelled()
614
+	{
615
+		return $this->status_ID() == EEM_Registration::status_id_cancelled ? true : false;
616
+	}
617
+
618
+
619
+	/**
620
+	 *    is_declined -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined
621
+	 *
622
+	 * @return        boolean
623
+	 */
624
+	public function is_declined()
625
+	{
626
+		return $this->status_ID() == EEM_Registration::status_id_declined ? true : false;
627
+	}
628
+
629
+
630
+	/**
631
+	 *    is_incomplete -  convenience method that returns TRUE if REG status ID ==
632
+	 *    EEM_Registration::status_id_incomplete
633
+	 *
634
+	 * @return        boolean
635
+	 */
636
+	public function is_incomplete()
637
+	{
638
+		return $this->status_ID() == EEM_Registration::status_id_incomplete ? true : false;
639
+	}
640
+
641
+
642
+	/**
643
+	 *        Set Registration Date
644
+	 *
645
+	 * @param        mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of
646
+	 *                                                 Date
647
+	 * @throws EE_Error
648
+	 * @throws RuntimeException
649
+	 */
650
+	public function set_reg_date($REG_date = false)
651
+	{
652
+		$this->set('REG_date', $REG_date);
653
+	}
654
+
655
+
656
+	/**
657
+	 *    Set final price owing for this registration after all ticket/price modifications
658
+	 *
659
+	 * @access    public
660
+	 * @param    float $REG_final_price
661
+	 * @throws EE_Error
662
+	 * @throws RuntimeException
663
+	 */
664
+	public function set_final_price($REG_final_price = 0.00)
665
+	{
666
+		$this->set('REG_final_price', $REG_final_price);
667
+	}
668
+
669
+
670
+	/**
671
+	 *    Set amount paid towards this registration's final price
672
+	 *
673
+	 * @access    public
674
+	 * @param    float $REG_paid
675
+	 * @throws EE_Error
676
+	 * @throws RuntimeException
677
+	 */
678
+	public function set_paid($REG_paid = 0.00)
679
+	{
680
+		$this->set('REG_paid', $REG_paid);
681
+	}
682
+
683
+
684
+	/**
685
+	 *        Attendee Is Going
686
+	 *
687
+	 * @param        boolean $REG_att_is_going Attendee Is Going
688
+	 * @throws EE_Error
689
+	 * @throws RuntimeException
690
+	 */
691
+	public function set_att_is_going($REG_att_is_going = false)
692
+	{
693
+		$this->set('REG_att_is_going', $REG_att_is_going);
694
+	}
695
+
696
+
697
+	/**
698
+	 * Gets the related attendee
699
+	 *
700
+	 * @return EE_Attendee
701
+	 * @throws EE_Error
702
+	 */
703
+	public function attendee()
704
+	{
705
+		return $this->get_first_related('Attendee');
706
+	}
707
+
708
+
709
+	/**
710
+	 *        get Event ID
711
+	 */
712
+	public function event_ID()
713
+	{
714
+		return $this->get('EVT_ID');
715
+	}
716
+
717
+
718
+	/**
719
+	 *        get Event ID
720
+	 */
721
+	public function event_name()
722
+	{
723
+		$event = $this->event_obj();
724
+		if ($event) {
725
+			return $event->name();
726
+		} else {
727
+			return null;
728
+		}
729
+	}
730
+
731
+
732
+	/**
733
+	 * Fetches the event this registration is for
734
+	 *
735
+	 * @return EE_Event
736
+	 * @throws EE_Error
737
+	 */
738
+	public function event_obj()
739
+	{
740
+		return $this->get_first_related('Event');
741
+	}
742
+
743
+
744
+	/**
745
+	 *        get Attendee ID
746
+	 */
747
+	public function attendee_ID()
748
+	{
749
+		return $this->get('ATT_ID');
750
+	}
751
+
752
+
753
+	/**
754
+	 *        get PHP Session ID
755
+	 */
756
+	public function session_ID()
757
+	{
758
+		return $this->get('REG_session');
759
+	}
760
+
761
+
762
+	/**
763
+	 * Gets the string which represents the URL trigger for the receipt template in the message template system.
764
+	 *
765
+	 * @param string $messenger 'pdf' or 'html'.  Default 'html'.
766
+	 * @return string
767
+	 */
768
+	public function receipt_url($messenger = 'html')
769
+	{
770
+
771
+		/**
772
+		 * The below will be deprecated one version after this.  We check first if there is a custom receipt template
773
+		 * already in use on old system.  If there is then we just return the standard url for it.
774
+		 *
775
+		 * @since 4.5.0
776
+		 */
777
+		$template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php';
778
+		$has_custom             = EEH_Template::locate_template(
779
+			$template_relative_path,
780
+			array(),
781
+			true,
782
+			true,
783
+			true
784
+		);
785
+
786
+		if ($has_custom) {
787
+			return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch'));
788
+		}
789
+		return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt');
790
+	}
791
+
792
+
793
+	/**
794
+	 * Gets the string which represents the URL trigger for the invoice template in the message template system.
795
+	 *
796
+	 * @param string $messenger 'pdf' or 'html'.  Default 'html'.
797
+	 * @return string
798
+	 * @throws EE_Error
799
+	 */
800
+	public function invoice_url($messenger = 'html')
801
+	{
802
+		/**
803
+		 * The below will be deprecated one version after this.  We check first if there is a custom invoice template
804
+		 * already in use on old system.  If there is then we just return the standard url for it.
805
+		 *
806
+		 * @since 4.5.0
807
+		 */
808
+		$template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php';
809
+		$has_custom             = EEH_Template::locate_template(
810
+			$template_relative_path,
811
+			array(),
812
+			true,
813
+			true,
814
+			true
815
+		);
816
+
817
+		if ($has_custom) {
818
+			if ($messenger == 'html') {
819
+				return $this->invoice_url('launch');
820
+			}
821
+			$route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice';
822
+
823
+			$query_args = array('ee' => $route, 'id' => $this->reg_url_link());
824
+			if ($messenger == 'html') {
825
+				$query_args['html'] = true;
826
+			}
827
+			return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id));
828
+		}
829
+		return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice');
830
+	}
831
+
832
+
833
+	/**
834
+	 * get Registration URL Link
835
+	 *
836
+	 * @access public
837
+	 * @return string
838
+	 * @throws \EE_Error
839
+	 */
840
+	public function reg_url_link()
841
+	{
842
+		return (string) $this->get('REG_url_link');
843
+	}
844
+
845
+
846
+	/**
847
+	 * Echoes out invoice_url()
848
+	 *
849
+	 * @param string $type 'download','launch', or 'html' (default is 'launch')
850
+	 * @return void
851
+	 * @throws EE_Error
852
+	 */
853
+	public function e_invoice_url($type = 'launch')
854
+	{
855
+		echo $this->invoice_url($type);
856
+	}
857
+
858
+
859
+	/**
860
+	 * Echoes out payment_overview_url
861
+	 */
862
+	public function e_payment_overview_url()
863
+	{
864
+		echo $this->payment_overview_url();
865
+	}
866
+
867
+
868
+	/**
869
+	 * Gets the URL of the thank you page with this registration REG_url_link added as
870
+	 * a query parameter
871
+	 *
872
+	 * @param bool $clear_session Set to true when you want to clear the session on revisiting the
873
+	 *                            payment overview url.
874
+	 * @return string
875
+	 * @throws EE_Error
876
+	 */
877
+	public function payment_overview_url($clear_session = false)
878
+	{
879
+		return add_query_arg(array(
880
+			'e_reg_url_link' => $this->reg_url_link(),
881
+			'step'           => 'payment_options',
882
+			'revisit'        => true,
883
+			'clear_session' => (bool) $clear_session
884
+		), EE_Registry::instance()->CFG->core->reg_page_url());
885
+	}
886
+
887
+
888
+	/**
889
+	 * Gets the URL of the thank you page with this registration REG_url_link added as
890
+	 * a query parameter
891
+	 *
892
+	 * @return string
893
+	 * @throws EE_Error
894
+	 */
895
+	public function edit_attendee_information_url()
896
+	{
897
+		return add_query_arg(array(
898
+			'e_reg_url_link' => $this->reg_url_link(),
899
+			'step'           => 'attendee_information',
900
+			'revisit'        => true,
901
+		), EE_Registry::instance()->CFG->core->reg_page_url());
902
+	}
903
+
904
+
905
+	/**
906
+	 * Simply generates and returns the appropriate admin_url link to edit this registration
907
+	 *
908
+	 * @return string
909
+	 * @throws EE_Error
910
+	 */
911
+	public function get_admin_edit_url()
912
+	{
913
+		return EEH_URL::add_query_args_and_nonce(array(
914
+			'page'    => 'espresso_registrations',
915
+			'action'  => 'view_registration',
916
+			'_REG_ID' => $this->ID(),
917
+		), admin_url('admin.php'));
918
+	}
919
+
920
+
921
+	/**
922
+	 *    is_primary_registrant?
923
+	 */
924
+	public function is_primary_registrant()
925
+	{
926
+		return $this->get('REG_count') == 1 ? true : false;
927
+	}
928
+
929
+
930
+	/**
931
+	 * This returns the primary registration object for this registration group (which may be this object).
932
+	 *
933
+	 * @return EE_Registration
934
+	 * @throws EE_Error
935
+	 */
936
+	public function get_primary_registration()
937
+	{
938
+		if ($this->is_primary_registrant()) {
939
+			return $this;
940
+		}
941
+
942
+		//k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1
943
+		/** @var EE_Registration $primary_registrant */
944
+		$primary_registrant = EEM_Registration::instance()->get_one(array(
945
+			array(
946
+				'TXN_ID'    => $this->transaction_ID(),
947
+				'REG_count' => 1,
948
+			),
949
+		));
950
+		return $primary_registrant;
951
+	}
952
+
953
+
954
+	/**
955
+	 *        get  Attendee Number
956
+	 *
957
+	 * @access        public
958
+	 */
959
+	public function count()
960
+	{
961
+		return $this->get('REG_count');
962
+	}
963
+
964
+
965
+	/**
966
+	 *        get Group Size
967
+	 */
968
+	public function group_size()
969
+	{
970
+		return $this->get('REG_group_size');
971
+	}
972
+
973
+
974
+	/**
975
+	 *        get Registration Date
976
+	 */
977
+	public function date()
978
+	{
979
+		return $this->get('REG_date');
980
+	}
981
+
982
+
983
+	/**
984
+	 * gets a pretty date
985
+	 *
986
+	 * @param string $date_format
987
+	 * @param string $time_format
988
+	 * @return string
989
+	 * @throws EE_Error
990
+	 */
991
+	public function pretty_date($date_format = null, $time_format = null)
992
+	{
993
+		return $this->get_datetime('REG_date', $date_format, $time_format);
994
+	}
995
+
996
+
997
+	/**
998
+	 * final_price
999
+	 * the registration's share of the transaction total, so that the
1000
+	 * sum of all the transaction's REG_final_prices equal the transaction's total
1001
+	 *
1002
+	 * @return float
1003
+	 * @throws EE_Error
1004
+	 */
1005
+	public function final_price()
1006
+	{
1007
+		return $this->get('REG_final_price');
1008
+	}
1009
+
1010
+
1011
+	/**
1012
+	 * pretty_final_price
1013
+	 *  final price as formatted string, with correct decimal places and currency symbol
1014
+	 *
1015
+	 * @return string
1016
+	 * @throws EE_Error
1017
+	 */
1018
+	public function pretty_final_price()
1019
+	{
1020
+		return $this->get_pretty('REG_final_price');
1021
+	}
1022
+
1023
+
1024
+	/**
1025
+	 * get paid (yeah)
1026
+	 *
1027
+	 * @return float
1028
+	 * @throws EE_Error
1029
+	 */
1030
+	public function paid()
1031
+	{
1032
+		return $this->get('REG_paid');
1033
+	}
1034
+
1035
+
1036
+	/**
1037
+	 * pretty_paid
1038
+	 *
1039
+	 * @return float
1040
+	 * @throws EE_Error
1041
+	 */
1042
+	public function pretty_paid()
1043
+	{
1044
+		return $this->get_pretty('REG_paid');
1045
+	}
1046
+
1047
+
1048
+	/**
1049
+	 * owes_monies_and_can_pay
1050
+	 * whether or not this registration has monies owing and it's' status allows payment
1051
+	 *
1052
+	 * @param array $requires_payment
1053
+	 * @return bool
1054
+	 * @throws EE_Error
1055
+	 */
1056
+	public function owes_monies_and_can_pay($requires_payment = array())
1057
+	{
1058
+		// these reg statuses require payment (if event is not free)
1059
+		$requires_payment = ! empty($requires_payment)
1060
+			? $requires_payment
1061
+			: EEM_Registration::reg_statuses_that_allow_payment();
1062
+		if (in_array($this->status_ID(), $requires_payment) &&
1063
+			$this->final_price() != 0 &&
1064
+			$this->final_price() != $this->paid()
1065
+		) {
1066
+			return true;
1067
+		} else {
1068
+			return false;
1069
+		}
1070
+	}
1071
+
1072
+
1073
+	/**
1074
+	 * Prints out the return value of $this->pretty_status()
1075
+	 *
1076
+	 * @param bool $show_icons
1077
+	 * @return void
1078
+	 * @throws EE_Error
1079
+	 */
1080
+	public function e_pretty_status($show_icons = false)
1081
+	{
1082
+		echo $this->pretty_status($show_icons);
1083
+	}
1084
+
1085
+
1086
+	/**
1087
+	 * Returns a nice version of the status for displaying to customers
1088
+	 *
1089
+	 * @param bool $show_icons
1090
+	 * @return string
1091
+	 * @throws EE_Error
1092
+	 */
1093
+	public function pretty_status($show_icons = false)
1094
+	{
1095
+		$status = EEM_Status::instance()->localized_status(
1096
+			array($this->status_ID() => esc_html__('unknown', 'event_espresso')),
1097
+			false,
1098
+			'sentence'
1099
+		);
1100
+		$icon   = '';
1101
+		switch ($this->status_ID()) {
1102
+			case EEM_Registration::status_id_approved:
1103
+				$icon = $show_icons
1104
+					? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>'
1105
+					: '';
1106
+				break;
1107
+			case EEM_Registration::status_id_pending_payment:
1108
+				$icon = $show_icons
1109
+					? '<span class="dashicons dashicons-star-half ee-icon-size-16 orange-text"></span>'
1110
+					: '';
1111
+				break;
1112
+			case EEM_Registration::status_id_not_approved:
1113
+				$icon = $show_icons
1114
+					? '<span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>'
1115
+					: '';
1116
+				break;
1117
+			case EEM_Registration::status_id_cancelled:
1118
+				$icon = $show_icons
1119
+					? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>'
1120
+					: '';
1121
+				break;
1122
+			case EEM_Registration::status_id_incomplete:
1123
+				$icon = $show_icons
1124
+					? '<span class="dashicons dashicons-no ee-icon-size-16 lt-orange-text"></span>'
1125
+					: '';
1126
+				break;
1127
+			case EEM_Registration::status_id_declined:
1128
+				$icon = $show_icons
1129
+					? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>'
1130
+					: '';
1131
+				break;
1132
+			case EEM_Registration::status_id_wait_list:
1133
+				$icon = $show_icons
1134
+					? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>'
1135
+					: '';
1136
+				break;
1137
+		}
1138
+		return $icon . $status[$this->status_ID()];
1139
+	}
1140
+
1141
+
1142
+	/**
1143
+	 *        get Attendee Is Going
1144
+	 */
1145
+	public function att_is_going()
1146
+	{
1147
+		return $this->get('REG_att_is_going');
1148
+	}
1149
+
1150
+
1151
+	/**
1152
+	 * Gets related answers
1153
+	 *
1154
+	 * @param array $query_params like EEM_Base::get_all
1155
+	 * @return EE_Answer[]
1156
+	 * @throws EE_Error
1157
+	 */
1158
+	public function answers($query_params = null)
1159
+	{
1160
+		return $this->get_many_related('Answer', $query_params);
1161
+	}
1162
+
1163
+
1164
+	/**
1165
+	 * Gets the registration's answer value to the specified question
1166
+	 * (either the question's ID or a question object)
1167
+	 *
1168
+	 * @param EE_Question|int $question
1169
+	 * @param bool            $pretty_value
1170
+	 * @return array|string if pretty_value= true, the result will always be a string
1171
+	 * (because the answer might be an array of answer values, so passing pretty_value=true
1172
+	 * will convert it into some kind of string)
1173
+	 * @throws EE_Error
1174
+	 */
1175
+	public function answer_value_to_question($question, $pretty_value = true)
1176
+	{
1177
+		$question_id = EEM_Question::instance()->ensure_is_ID($question);
1178
+		return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value);
1179
+	}
1180
+
1181
+
1182
+	/**
1183
+	 * question_groups
1184
+	 * returns an array of EE_Question_Group objects for this registration
1185
+	 *
1186
+	 * @return EE_Question_Group[]
1187
+	 * @throws EE_Error
1188
+	 * @throws EntityNotFoundException
1189
+	 */
1190
+	public function question_groups()
1191
+	{
1192
+		$question_groups = array();
1193
+		if ($this->event() instanceof EE_Event) {
1194
+			$question_groups = $this->event()->question_groups(
1195
+				array(
1196
+					array(
1197
+						'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false,
1198
+					),
1199
+					'order_by' => array('QSG_order' => 'ASC'),
1200
+				)
1201
+			);
1202
+		}
1203
+		return $question_groups;
1204
+	}
1205
+
1206
+
1207
+	/**
1208
+	 * count_question_groups
1209
+	 * returns a count of the number of EE_Question_Group objects for this registration
1210
+	 *
1211
+	 * @return int
1212
+	 * @throws EE_Error
1213
+	 * @throws EntityNotFoundException
1214
+	 */
1215
+	public function count_question_groups()
1216
+	{
1217
+		$qg_count = 0;
1218
+		if ($this->event() instanceof EE_Event) {
1219
+			$qg_count = $this->event()->count_related(
1220
+				'Question_Group',
1221
+				array(
1222
+					array(
1223
+						'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false,
1224
+					),
1225
+				)
1226
+			);
1227
+		}
1228
+		return $qg_count;
1229
+	}
1230
+
1231
+
1232
+	/**
1233
+	 * Returns the registration date in the 'standard' string format
1234
+	 * (function may be improved in the future to allow for different formats and timezones)
1235
+	 *
1236
+	 * @return string
1237
+	 * @throws EE_Error
1238
+	 */
1239
+	public function reg_date()
1240
+	{
1241
+		return $this->get_datetime('REG_date');
1242
+	}
1243
+
1244
+
1245
+	/**
1246
+	 * Gets the datetime-ticket for this registration (ie, it can be used to isolate
1247
+	 * the ticket this registration purchased, or the datetime they have registered
1248
+	 * to attend)
1249
+	 *
1250
+	 * @return EE_Datetime_Ticket
1251
+	 * @throws EE_Error
1252
+	 */
1253
+	public function datetime_ticket()
1254
+	{
1255
+		return $this->get_first_related('Datetime_Ticket');
1256
+	}
1257
+
1258
+
1259
+	/**
1260
+	 * Sets the registration's datetime_ticket.
1261
+	 *
1262
+	 * @param EE_Datetime_Ticket $datetime_ticket
1263
+	 * @return EE_Datetime_Ticket
1264
+	 * @throws EE_Error
1265
+	 */
1266
+	public function set_datetime_ticket($datetime_ticket)
1267
+	{
1268
+		return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket');
1269
+	}
1270
+
1271
+	/**
1272
+	 * Gets deleted
1273
+	 *
1274
+	 * @return bool
1275
+	 * @throws EE_Error
1276
+	 */
1277
+	public function deleted()
1278
+	{
1279
+		return $this->get('REG_deleted');
1280
+	}
1281
+
1282
+	/**
1283
+	 * Sets deleted
1284
+	 *
1285
+	 * @param boolean $deleted
1286
+	 * @return bool
1287
+	 * @throws EE_Error
1288
+	 * @throws RuntimeException
1289
+	 */
1290
+	public function set_deleted($deleted)
1291
+	{
1292
+		if ($deleted) {
1293
+			$this->delete();
1294
+		} else {
1295
+			$this->restore();
1296
+		}
1297
+	}
1298
+
1299
+
1300
+	/**
1301
+	 * Get the status object of this object
1302
+	 *
1303
+	 * @return EE_Status
1304
+	 * @throws EE_Error
1305
+	 */
1306
+	public function status_obj()
1307
+	{
1308
+		return $this->get_first_related('Status');
1309
+	}
1310
+
1311
+
1312
+	/**
1313
+	 * Returns the number of times this registration has checked into any of the datetimes
1314
+	 * its available for
1315
+	 *
1316
+	 * @return int
1317
+	 * @throws EE_Error
1318
+	 */
1319
+	public function count_checkins()
1320
+	{
1321
+		return $this->get_model()->count_related($this, 'Checkin');
1322
+	}
1323
+
1324
+
1325
+	/**
1326
+	 * Returns the number of current Check-ins this registration is checked into for any of the datetimes the
1327
+	 * registration is for.  Note, this is ONLY checked in (does not include checkedout)
1328
+	 *
1329
+	 * @return int
1330
+	 * @throws EE_Error
1331
+	 */
1332
+	public function count_checkins_not_checkedout()
1333
+	{
1334
+		return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1)));
1335
+	}
1336
+
1337
+
1338
+	/**
1339
+	 * The purpose of this method is simply to check whether this registration can checkin to the given datetime.
1340
+	 *
1341
+	 * @param int | EE_Datetime $DTT_OR_ID      The datetime the registration is being checked against
1342
+	 * @param bool              $check_approved This is used to indicate whether the caller wants can_checkin to also
1343
+	 *                                          consider registration status as well as datetime access.
1344
+	 * @return bool
1345
+	 * @throws EE_Error
1346
+	 */
1347
+	public function can_checkin($DTT_OR_ID, $check_approved = true)
1348
+	{
1349
+		$DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1350
+
1351
+		//first check registration status
1352
+		if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) {
1353
+			return false;
1354
+		}
1355
+		//is there a datetime ticket that matches this dtt_ID?
1356
+		if (! (EEM_Datetime_Ticket::instance()->exists(array(
1357
+			array(
1358
+				'TKT_ID' => $this->get('TKT_ID'),
1359
+				'DTT_ID' => $DTT_ID,
1360
+			),
1361
+		)))
1362
+		) {
1363
+			return false;
1364
+		}
1365
+
1366
+		//final check is against TKT_uses
1367
+		return $this->verify_can_checkin_against_TKT_uses($DTT_ID);
1368
+	}
1369
+
1370
+
1371
+	/**
1372
+	 * This method verifies whether the user can checkin for the given datetime considering the max uses value set on
1373
+	 * the ticket. To do this,  a query is done to get the count of the datetime records already checked into.  If the
1374
+	 * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses,
1375
+	 * then return false.  Otherwise return true.
1376
+	 *
1377
+	 * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against
1378
+	 * @return bool true means can checkin.  false means cannot checkin.
1379
+	 * @throws EE_Error
1380
+	 */
1381
+	public function verify_can_checkin_against_TKT_uses($DTT_OR_ID)
1382
+	{
1383
+		$DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1384
+
1385
+		if (! $DTT_ID) {
1386
+			return false;
1387
+		}
1388
+
1389
+		$max_uses = $this->ticket() instanceof EE_Ticket ? $this->ticket()->uses() : EE_INF;
1390
+
1391
+		// if max uses is not set or equals infinity then return true cause its not a factor for whether user can
1392
+		// check-in or not.
1393
+		if (! $max_uses || $max_uses === EE_INF) {
1394
+			return true;
1395
+		}
1396
+
1397
+		//does this datetime have a checkin record?  If so, then the dtt count has already been verified so we can just
1398
+		//go ahead and toggle.
1399
+		if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) {
1400
+			return true;
1401
+		}
1402
+
1403
+		//made it here so the last check is whether the number of checkins per unique datetime on this registration
1404
+		//disallows further check-ins.
1405
+		$count_unique_dtt_checkins = EEM_Checkin::instance()->count(array(
1406
+			array(
1407
+				'REG_ID' => $this->ID(),
1408
+				'CHK_in' => true,
1409
+			),
1410
+		), 'DTT_ID', true);
1411
+		// checkins have already reached their max number of uses
1412
+		// so registrant can NOT checkin
1413
+		if ($count_unique_dtt_checkins >= $max_uses) {
1414
+			EE_Error::add_error(
1415
+				esc_html__(
1416
+					'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.',
1417
+					'event_espresso'
1418
+				),
1419
+				__FILE__,
1420
+				__FUNCTION__,
1421
+				__LINE__
1422
+			);
1423
+			return false;
1424
+		}
1425
+		return true;
1426
+	}
1427
+
1428
+
1429
+	/**
1430
+	 * toggle Check-in status for this registration
1431
+	 * Check-ins are toggled in the following order:
1432
+	 * never checked in -> checked in
1433
+	 * checked in -> checked out
1434
+	 * checked out -> checked in
1435
+	 *
1436
+	 * @param  int $DTT_ID  include specific datetime to toggle Check-in for.
1437
+	 *                      If not included or null, then it is assumed latest datetime is being toggled.
1438
+	 * @param bool $verify  If true then can_checkin() is used to verify whether the person
1439
+	 *                      can be checked in or not.  Otherwise this forces change in checkin status.
1440
+	 * @return bool|int     the chk_in status toggled to OR false if nothing got changed.
1441
+	 * @throws EE_Error
1442
+	 */
1443
+	public function toggle_checkin_status($DTT_ID = null, $verify = false)
1444
+	{
1445
+		if (empty($DTT_ID)) {
1446
+			$datetime = $this->get_latest_related_datetime();
1447
+			$DTT_ID   = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
1448
+			// verify the registration can checkin for the given DTT_ID
1449
+		} elseif (! $this->can_checkin($DTT_ID, $verify)) {
1450
+			EE_Error::add_error(
1451
+				sprintf(
1452
+					esc_html__(
1453
+						'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access',
1454
+						'event_espresso'
1455
+					),
1456
+					$this->ID(),
1457
+					$DTT_ID
1458
+				),
1459
+				__FILE__,
1460
+				__FUNCTION__,
1461
+				__LINE__
1462
+			);
1463
+			return false;
1464
+		}
1465
+		$status_paths = array(
1466
+			EE_Checkin::status_checked_never => EE_Checkin::status_checked_in,
1467
+			EE_Checkin::status_checked_in    => EE_Checkin::status_checked_out,
1468
+			EE_Checkin::status_checked_out   => EE_Checkin::status_checked_in,
1469
+		);
1470
+		//start by getting the current status so we know what status we'll be changing to.
1471
+		$cur_status = $this->check_in_status_for_datetime($DTT_ID, null);
1472
+		$status_to  = $status_paths[$cur_status];
1473
+		// database only records true for checked IN or false for checked OUT
1474
+		// no record ( null ) means checked in NEVER, but we obviously don't save that
1475
+		$new_status = $status_to === EE_Checkin::status_checked_in ? true : false;
1476
+		// add relation - note Check-ins are always creating new rows
1477
+		// because we are keeping track of Check-ins over time.
1478
+		// Eventually we'll probably want to show a list table
1479
+		// for the individual Check-ins so that they can be managed.
1480
+		$checkin = EE_Checkin::new_instance(array(
1481
+			'REG_ID' => $this->ID(),
1482
+			'DTT_ID' => $DTT_ID,
1483
+			'CHK_in' => $new_status,
1484
+		));
1485
+		// if the record could not be saved then return false
1486
+		if ($checkin->save() === 0) {
1487
+			if (WP_DEBUG) {
1488
+				global $wpdb;
1489
+				$error = sprintf(
1490
+					esc_html__(
1491
+						'Registration check in update failed because of the following database error: %1$s%2$s',
1492
+						'event_espresso'
1493
+					),
1494
+					'<br />',
1495
+					$wpdb->last_error
1496
+				);
1497
+			} else {
1498
+				$error = esc_html__(
1499
+					'Registration check in update failed because of an unknown database error',
1500
+					'event_espresso'
1501
+				);
1502
+			}
1503
+			EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
1504
+			return false;
1505
+		}
1506
+		return $status_to;
1507
+	}
1508
+
1509
+
1510
+	/**
1511
+	 * Returns the latest datetime related to this registration (via the ticket attached to the registration).
1512
+	 * "Latest" is defined by the `DTT_EVT_start` column.
1513
+	 *
1514
+	 * @return EE_Datetime|null
1515
+	 * @throws \EE_Error
1516
+	 */
1517
+	public function get_latest_related_datetime()
1518
+	{
1519
+		return EEM_Datetime::instance()->get_one(
1520
+			array(
1521
+				array(
1522
+					'Ticket.Registration.REG_ID' => $this->ID(),
1523
+				),
1524
+				'order_by' => array('DTT_EVT_start' => 'DESC'),
1525
+			)
1526
+		);
1527
+	}
1528
+
1529
+
1530
+	/**
1531
+	 * Returns the earliest datetime related to this registration (via the ticket attached to the registration).
1532
+	 * "Earliest" is defined by the `DTT_EVT_start` column.
1533
+	 *
1534
+	 * @throws \EE_Error
1535
+	 */
1536
+	public function get_earliest_related_datetime()
1537
+	{
1538
+		return EEM_Datetime::instance()->get_one(
1539
+			array(
1540
+				array(
1541
+					'Ticket.Registration.REG_ID' => $this->ID(),
1542
+				),
1543
+				'order_by' => array('DTT_EVT_start' => 'ASC'),
1544
+			)
1545
+		);
1546
+	}
1547
+
1548
+
1549
+	/**
1550
+	 * This method simply returns the check-in status for this registration and the given datetime.
1551
+	 * If neither the datetime nor the checkin values are provided as arguments,
1552
+	 * then this will return the LATEST check-in status for the registration across all datetimes it belongs to.
1553
+	 *
1554
+	 * @param  int       $DTT_ID  The ID of the datetime we're checking against
1555
+	 *                            (if empty we'll get the primary datetime for
1556
+	 *                            this registration (via event) and use it's ID);
1557
+	 * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id.
1558
+	 * @return int                Integer representing Check-in status.
1559
+	 * @throws \EE_Error
1560
+	 */
1561
+	public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null)
1562
+	{
1563
+		$checkin_query_params = array(
1564
+			'order_by' => array('CHK_timestamp' => 'DESC'),
1565
+		);
1566
+
1567
+		if ($DTT_ID > 0) {
1568
+			$checkin_query_params[0] = array('DTT_ID' => $DTT_ID);
1569
+		}
1570
+
1571
+		//get checkin object (if exists)
1572
+		$checkin = $checkin instanceof EE_Checkin
1573
+			? $checkin
1574
+			: $this->get_first_related('Checkin', $checkin_query_params);
1575
+		if ($checkin instanceof EE_Checkin) {
1576
+			if ($checkin->get('CHK_in')) {
1577
+				return EE_Checkin::status_checked_in; //checked in
1578
+			}
1579
+			return EE_Checkin::status_checked_out; //had checked in but is now checked out.
1580
+		}
1581
+		return EE_Checkin::status_checked_never; //never been checked in
1582
+	}
1583
+
1584
+
1585
+	/**
1586
+	 * This method returns a localized message for the toggled Check-in message.
1587
+	 *
1588
+	 * @param  int $DTT_ID include specific datetime to get the correct Check-in message.  If not included or null,
1589
+	 *                     then it is assumed Check-in for primary datetime was toggled.
1590
+	 * @param bool $error  This just flags that you want an error message returned. This is put in so that the error
1591
+	 *                     message can be customized with the attendee name.
1592
+	 * @return string internationalized message
1593
+	 * @throws EE_Error
1594
+	 */
1595
+	public function get_checkin_msg($DTT_ID, $error = false)
1596
+	{
1597
+		//let's get the attendee first so we can include the name of the attendee
1598
+		$attendee = $this->get_first_related('Attendee');
1599
+		if ($attendee instanceof EE_Attendee) {
1600
+			if ($error) {
1601
+				return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name());
1602
+			}
1603
+			$cur_status = $this->check_in_status_for_datetime($DTT_ID);
1604
+			//what is the status message going to be?
1605
+			switch ($cur_status) {
1606
+				case EE_Checkin::status_checked_never:
1607
+					return sprintf(__("%s has been removed from Check-in records", "event_espresso"),
1608
+						$attendee->full_name());
1609
+					break;
1610
+				case EE_Checkin::status_checked_in:
1611
+					return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name());
1612
+					break;
1613
+				case EE_Checkin::status_checked_out:
1614
+					return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name());
1615
+					break;
1616
+			}
1617
+		}
1618
+		return esc_html__("The check-in status could not be determined.", "event_espresso");
1619
+	}
1620
+
1621
+
1622
+	/**
1623
+	 * Returns the related EE_Transaction to this registration
1624
+	 *
1625
+	 * @return EE_Transaction
1626
+	 * @throws EE_Error
1627
+	 * @throws EntityNotFoundException
1628
+	 */
1629
+	public function transaction()
1630
+	{
1631
+		$transaction = $this->get_first_related('Transaction');
1632
+		if (! $transaction instanceof \EE_Transaction) {
1633
+			throw new EntityNotFoundException('Transaction ID', $this->transaction_ID());
1634
+		}
1635
+		return $transaction;
1636
+	}
1637
+
1638
+
1639
+	/**
1640
+	 *        get Registration Code
1641
+	 */
1642
+	public function reg_code()
1643
+	{
1644
+		return $this->get('REG_code');
1645
+	}
1646
+
1647
+
1648
+	/**
1649
+	 *        get Transaction ID
1650
+	 */
1651
+	public function transaction_ID()
1652
+	{
1653
+		return $this->get('TXN_ID');
1654
+	}
1655
+
1656
+
1657
+	/**
1658
+	 * @return int
1659
+	 * @throws EE_Error
1660
+	 */
1661
+	public function ticket_ID()
1662
+	{
1663
+		return $this->get('TKT_ID');
1664
+	}
1665
+
1666
+
1667
+	/**
1668
+	 *        Set Registration Code
1669
+	 *
1670
+	 * @access    public
1671
+	 * @param    string  $REG_code Registration Code
1672
+	 * @param    boolean $use_default
1673
+	 * @throws EE_Error
1674
+	 */
1675
+	public function set_reg_code($REG_code, $use_default = false)
1676
+	{
1677
+		if (empty($REG_code)) {
1678
+			EE_Error::add_error(
1679
+				esc_html__('REG_code can not be empty.', 'event_espresso'),
1680
+				__FILE__,
1681
+				__FUNCTION__,
1682
+				__LINE__
1683
+			);
1684
+			return;
1685
+		}
1686
+		if (! $this->reg_code()) {
1687
+			parent::set('REG_code', $REG_code, $use_default);
1688
+		} else {
1689
+			EE_Error::doing_it_wrong(
1690
+				__CLASS__ . '::' . __FUNCTION__,
1691
+				esc_html__('Can not change a registration REG_code once it has been set.', 'event_espresso'),
1692
+				'4.6.0'
1693
+			);
1694
+		}
1695
+	}
1696
+
1697
+
1698
+	/**
1699
+	 * Returns all other registrations in the same group as this registrant who have the same ticket option.
1700
+	 * Note, if you want to just get all registrations in the same transaction (group), use:
1701
+	 *    $registration->transaction()->registrations();
1702
+	 *
1703
+	 * @since 4.5.0
1704
+	 * @return EE_Registration[] or empty array if this isn't a group registration.
1705
+	 * @throws EE_Error
1706
+	 */
1707
+	public function get_all_other_registrations_in_group()
1708
+	{
1709
+		if ($this->group_size() < 2) {
1710
+			return array();
1711
+		}
1712
+
1713
+		$query[0] = array(
1714
+			'TXN_ID' => $this->transaction_ID(),
1715
+			'REG_ID' => array('!=', $this->ID()),
1716
+			'TKT_ID' => $this->ticket_ID(),
1717
+		);
1718
+		/** @var EE_Registration[] $registrations */
1719
+		$registrations = $this->get_model()->get_all($query);
1720
+		return $registrations;
1721
+	}
1722
+
1723
+	/**
1724
+	 * Return the link to the admin details for the object.
1725
+	 *
1726
+	 * @return string
1727
+	 * @throws EE_Error
1728
+	 */
1729
+	public function get_admin_details_link()
1730
+	{
1731
+		EE_Registry::instance()->load_helper('URL');
1732
+		return EEH_URL::add_query_args_and_nonce(
1733
+			array(
1734
+				'page'    => 'espresso_registrations',
1735
+				'action'  => 'view_registration',
1736
+				'_REG_ID' => $this->ID(),
1737
+			),
1738
+			admin_url('admin.php')
1739
+		);
1740
+	}
1741
+
1742
+	/**
1743
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
1744
+	 *
1745
+	 * @return string
1746
+	 * @throws EE_Error
1747
+	 */
1748
+	public function get_admin_edit_link()
1749
+	{
1750
+		return $this->get_admin_details_link();
1751
+	}
1752
+
1753
+	/**
1754
+	 * Returns the link to a settings page for the object.
1755
+	 *
1756
+	 * @return string
1757
+	 * @throws EE_Error
1758
+	 */
1759
+	public function get_admin_settings_link()
1760
+	{
1761
+		return $this->get_admin_details_link();
1762
+	}
1763
+
1764
+	/**
1765
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
1766
+	 *
1767
+	 * @return string
1768
+	 */
1769
+	public function get_admin_overview_link()
1770
+	{
1771
+		EE_Registry::instance()->load_helper('URL');
1772
+		return EEH_URL::add_query_args_and_nonce(
1773
+			array(
1774
+				'page' => 'espresso_registrations',
1775
+			),
1776
+			admin_url('admin.php')
1777
+		);
1778
+	}
1779
+
1780
+
1781
+	/**
1782
+	 * @param array $query_params
1783
+	 * @return \EE_Registration[]
1784
+	 * @throws \EE_Error
1785
+	 */
1786
+	public function payments($query_params = array())
1787
+	{
1788
+		return $this->get_many_related('Payment', $query_params);
1789
+	}
1790
+
1791
+
1792
+	/**
1793
+	 * @param array $query_params
1794
+	 * @return \EE_Registration_Payment[]
1795
+	 * @throws \EE_Error
1796
+	 */
1797
+	public function registration_payments($query_params = array())
1798
+	{
1799
+		return $this->get_many_related('Registration_Payment', $query_params);
1800
+	}
1801
+
1802
+
1803
+	/**
1804
+	 * This grabs the payment method corresponding to the last payment made for the amount owing on the registration.
1805
+	 * Note: if there are no payments on the registration there will be no payment method returned.
1806
+	 *
1807
+	 * @return EE_Payment_Method|null
1808
+	 */
1809
+	public function payment_method()
1810
+	{
1811
+		return EEM_Payment_Method::instance()->get_last_used_for_registration($this);
1812
+	}
1813
+
1814
+
1815
+	/**
1816
+	 * @return \EE_Line_Item
1817
+	 * @throws EntityNotFoundException
1818
+	 * @throws \EE_Error
1819
+	 */
1820
+	public function ticket_line_item()
1821
+	{
1822
+		$ticket            = $this->ticket();
1823
+		$transaction       = $this->transaction();
1824
+		$line_item         = null;
1825
+		$ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs(
1826
+			$transaction->total_line_item(),
1827
+			'Ticket',
1828
+			array($ticket->ID())
1829
+		);
1830
+		foreach ($ticket_line_items as $ticket_line_item) {
1831
+			if (
1832
+				$ticket_line_item instanceof \EE_Line_Item
1833
+				&& $ticket_line_item->OBJ_type() === 'Ticket'
1834
+				&& $ticket_line_item->OBJ_ID() === $ticket->ID()
1835
+			) {
1836
+				$line_item = $ticket_line_item;
1837
+				break;
1838
+			}
1839
+		}
1840
+		if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) {
1841
+			throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID());
1842
+		}
1843
+		return $line_item;
1844
+	}
1845
+
1846
+
1847
+	/**
1848
+	 * Soft Deletes this model object.
1849
+	 *
1850
+	 * @return boolean | int
1851
+	 * @throws \RuntimeException
1852
+	 * @throws \EE_Error
1853
+	 */
1854
+	public function delete()
1855
+	{
1856
+		if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) {
1857
+			$this->set_status(EEM_Registration::status_id_cancelled);
1858
+		}
1859
+		return parent::delete();
1860
+	}
1861
+
1862
+
1863
+	/**
1864
+	 * Restores whatever the previous status was on a registration before it was trashed (if possible)
1865
+	 *
1866
+	 * @throws \EE_Error
1867
+	 * @throws \RuntimeException
1868
+	 */
1869
+	public function restore()
1870
+	{
1871
+		$previous_status = $this->get_extra_meta(
1872
+			EE_Registration::PRE_TRASH_REG_STATUS_KEY,
1873
+			true,
1874
+			EEM_Registration::status_id_cancelled
1875
+		);
1876
+		if ($previous_status) {
1877
+			$this->delete_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY);
1878
+			$this->set_status($previous_status);
1879
+		}
1880
+		return parent::restore();
1881
+	}
1882
+
1883
+
1884
+
1885
+	/*************************** DEPRECATED ***************************/
1886
+
1887
+
1888
+	/**
1889
+	 * @deprecated
1890
+	 * @since     4.7.0
1891
+	 * @access    public
1892
+	 */
1893
+	public function price_paid()
1894
+	{
1895
+		EE_Error::doing_it_wrong('EE_Registration::price_paid()',
1896
+			esc_html__('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'),
1897
+			'4.7.0');
1898
+		return $this->final_price();
1899
+	}
1900
+
1901
+
1902
+	/**
1903
+	 * @deprecated
1904
+	 * @since     4.7.0
1905
+	 * @access    public
1906
+	 * @param    float $REG_final_price
1907
+	 * @throws EE_Error
1908
+	 * @throws RuntimeException
1909
+	 */
1910
+	public function set_price_paid($REG_final_price = 0.00)
1911
+	{
1912
+		EE_Error::doing_it_wrong('EE_Registration::set_price_paid()',
1913
+			esc_html__('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'),
1914
+			'4.7.0');
1915
+		$this->set_final_price($REG_final_price);
1916
+	}
1917
+
1918
+
1919
+	/**
1920
+	 * @deprecated
1921
+	 * @since 4.7.0
1922
+	 * @return string
1923
+	 * @throws EE_Error
1924
+	 */
1925
+	public function pretty_price_paid()
1926
+	{
1927
+		EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()',
1928
+			esc_html__('This method is deprecated, please use EE_Registration::pretty_final_price() instead.',
1929
+				'event_espresso'), '4.7.0');
1930
+		return $this->pretty_final_price();
1931
+	}
1932
+
1933
+
1934
+	/**
1935
+	 * Gets the primary datetime related to this registration via the related Event to this registration
1936
+	 *
1937
+	 * @deprecated 4.9.17
1938
+	 * @return EE_Datetime
1939
+	 * @throws EE_Error
1940
+	 * @throws EntityNotFoundException
1941
+	 */
1942
+	public function get_related_primary_datetime()
1943
+	{
1944
+		EE_Error::doing_it_wrong(
1945
+			__METHOD__,
1946
+			esc_html__(
1947
+				'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()',
1948
+				'event_espresso'
1949
+			),
1950
+			'4.9.17',
1951
+			'5.0.0'
1952
+		);
1953
+		return $this->event()->primary_datetime();
1954
+	}
1955 1955
 
1956 1956
 
1957 1957
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     {
121 121
         switch ($field_name) {
122 122
             case 'REG_code':
123
-                if (! empty($field_value) && $this->reg_code() === null) {
123
+                if ( ! empty($field_value) && $this->reg_code() === null) {
124 124
                     $this->set_reg_code($field_value, $use_default);
125 125
                 }
126 126
                 break;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             // update status
182 182
             parent::set('STS_ID', $new_STS_ID, $use_default);
183 183
             $this->_update_if_canceled_or_declined($new_STS_ID, $old_STS_ID, $context);
184
-            if($this->statusChangeUpdatesTransaction($context)) {
184
+            if ($this->statusChangeUpdatesTransaction($context)) {
185 185
                 $this->updateTransactionAfterStatusChange();
186 186
             }
187 187
             do_action('AHEE__EE_Registration__set_status__after_update', $this, $old_STS_ID, $new_STS_ID, $context);
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
     public function event()
409 409
     {
410 410
         $event = $this->get_first_related('Event');
411
-        if (! $event instanceof \EE_Event) {
411
+        if ( ! $event instanceof \EE_Event) {
412 412
             throw new EntityNotFoundException('Event ID', $this->event_ID());
413 413
         }
414 414
         return $event;
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
             false,
1098 1098
             'sentence'
1099 1099
         );
1100
-        $icon   = '';
1100
+        $icon = '';
1101 1101
         switch ($this->status_ID()) {
1102 1102
             case EEM_Registration::status_id_approved:
1103 1103
                 $icon = $show_icons
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
                     : '';
1136 1136
                 break;
1137 1137
         }
1138
-        return $icon . $status[$this->status_ID()];
1138
+        return $icon.$status[$this->status_ID()];
1139 1139
     }
1140 1140
 
1141 1141
 
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
             return false;
1354 1354
         }
1355 1355
         //is there a datetime ticket that matches this dtt_ID?
1356
-        if (! (EEM_Datetime_Ticket::instance()->exists(array(
1356
+        if ( ! (EEM_Datetime_Ticket::instance()->exists(array(
1357 1357
             array(
1358 1358
                 'TKT_ID' => $this->get('TKT_ID'),
1359 1359
                 'DTT_ID' => $DTT_ID,
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
     {
1383 1383
         $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1384 1384
 
1385
-        if (! $DTT_ID) {
1385
+        if ( ! $DTT_ID) {
1386 1386
             return false;
1387 1387
         }
1388 1388
 
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
 
1391 1391
         // if max uses is not set or equals infinity then return true cause its not a factor for whether user can
1392 1392
         // check-in or not.
1393
-        if (! $max_uses || $max_uses === EE_INF) {
1393
+        if ( ! $max_uses || $max_uses === EE_INF) {
1394 1394
             return true;
1395 1395
         }
1396 1396
 
@@ -1446,7 +1446,7 @@  discard block
 block discarded – undo
1446 1446
             $datetime = $this->get_latest_related_datetime();
1447 1447
             $DTT_ID   = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
1448 1448
             // verify the registration can checkin for the given DTT_ID
1449
-        } elseif (! $this->can_checkin($DTT_ID, $verify)) {
1449
+        } elseif ( ! $this->can_checkin($DTT_ID, $verify)) {
1450 1450
             EE_Error::add_error(
1451 1451
                 sprintf(
1452 1452
                     esc_html__(
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
     public function transaction()
1630 1630
     {
1631 1631
         $transaction = $this->get_first_related('Transaction');
1632
-        if (! $transaction instanceof \EE_Transaction) {
1632
+        if ( ! $transaction instanceof \EE_Transaction) {
1633 1633
             throw new EntityNotFoundException('Transaction ID', $this->transaction_ID());
1634 1634
         }
1635 1635
         return $transaction;
@@ -1683,11 +1683,11 @@  discard block
 block discarded – undo
1683 1683
             );
1684 1684
             return;
1685 1685
         }
1686
-        if (! $this->reg_code()) {
1686
+        if ( ! $this->reg_code()) {
1687 1687
             parent::set('REG_code', $REG_code, $use_default);
1688 1688
         } else {
1689 1689
             EE_Error::doing_it_wrong(
1690
-                __CLASS__ . '::' . __FUNCTION__,
1690
+                __CLASS__.'::'.__FUNCTION__,
1691 1691
                 esc_html__('Can not change a registration REG_code once it has been set.', 'event_espresso'),
1692 1692
                 '4.6.0'
1693 1693
             );
@@ -1837,7 +1837,7 @@  discard block
 block discarded – undo
1837 1837
                 break;
1838 1838
             }
1839 1839
         }
1840
-        if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) {
1840
+        if ( ! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) {
1841 1841
             throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID());
1842 1842
         }
1843 1843
         return $line_item;
Please login to merge, or discard this patch.
modules/single_page_checkout/EED_Single_Page_Checkout.module.php 2 patches
Indentation   +1856 added lines, -1856 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use EventEspresso\core\exceptions\InvalidEntityException;
6 6
 
7 7
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
8
-    exit('No direct script access allowed');
8
+	exit('No direct script access allowed');
9 9
 }
10 10
 
11 11
 
@@ -20,1861 +20,1861 @@  discard block
 block discarded – undo
20 20
 class EED_Single_Page_Checkout extends EED_Module
21 21
 {
22 22
 
23
-    /**
24
-     * $_initialized - has the SPCO controller already been initialized ?
25
-     *
26
-     * @access private
27
-     * @var bool $_initialized
28
-     */
29
-    private static $_initialized = false;
30
-
31
-
32
-    /**
33
-     * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
34
-     *
35
-     * @access private
36
-     * @var bool $_valid_checkout
37
-     */
38
-    private static $_checkout_verified = true;
39
-
40
-    /**
41
-     *    $_reg_steps_array - holds initial array of reg steps
42
-     *
43
-     * @access private
44
-     * @var array $_reg_steps_array
45
-     */
46
-    private static $_reg_steps_array = array();
47
-
48
-    /**
49
-     *    $checkout - EE_Checkout object for handling the properties of the current checkout process
50
-     *
51
-     * @access public
52
-     * @var EE_Checkout $checkout
53
-     */
54
-    public $checkout;
55
-
56
-
57
-
58
-    /**
59
-     * @return EED_Module|EED_Single_Page_Checkout
60
-     */
61
-    public static function instance()
62
-    {
63
-        add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
64
-        return parent::get_instance(__CLASS__);
65
-    }
66
-
67
-
68
-
69
-    /**
70
-     * @return EE_CART
71
-     */
72
-    public function cart()
73
-    {
74
-        return $this->checkout->cart;
75
-    }
76
-
77
-
78
-
79
-    /**
80
-     * @return EE_Transaction
81
-     */
82
-    public function transaction()
83
-    {
84
-        return $this->checkout->transaction;
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     *    set_hooks - for hooking into EE Core, other modules, etc
91
-     *
92
-     * @access    public
93
-     * @return    void
94
-     * @throws EE_Error
95
-     */
96
-    public static function set_hooks()
97
-    {
98
-        EED_Single_Page_Checkout::set_definitions();
99
-    }
100
-
101
-
102
-
103
-    /**
104
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
105
-     *
106
-     * @access    public
107
-     * @return    void
108
-     * @throws EE_Error
109
-     */
110
-    public static function set_hooks_admin()
111
-    {
112
-        EED_Single_Page_Checkout::set_definitions();
113
-        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
114
-            return;
115
-        }
116
-        // going to start an output buffer in case anything gets accidentally output
117
-        // that might disrupt our JSON response
118
-        ob_start();
119
-        EED_Single_Page_Checkout::load_request_handler();
120
-        EED_Single_Page_Checkout::load_reg_steps();
121
-        // set ajax hooks
122
-        add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
123
-        add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
124
-        add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
125
-        add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
126
-        add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
127
-        add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     *    process ajax request
134
-     *
135
-     * @param string $ajax_action
136
-     * @throws EE_Error
137
-     */
138
-    public static function process_ajax_request($ajax_action)
139
-    {
140
-        EE_Registry::instance()->REQ->set('action', $ajax_action);
141
-        EED_Single_Page_Checkout::instance()->_initialize();
142
-    }
143
-
144
-
145
-
146
-    /**
147
-     *    ajax display registration step
148
-     *
149
-     * @throws EE_Error
150
-     */
151
-    public static function display_reg_step()
152
-    {
153
-        EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
154
-    }
155
-
156
-
157
-
158
-    /**
159
-     *    ajax process registration step
160
-     *
161
-     * @throws EE_Error
162
-     */
163
-    public static function process_reg_step()
164
-    {
165
-        EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
166
-    }
167
-
168
-
169
-
170
-    /**
171
-     *    ajax process registration step
172
-     *
173
-     * @throws EE_Error
174
-     */
175
-    public static function update_reg_step()
176
-    {
177
-        EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
178
-    }
179
-
180
-
181
-
182
-    /**
183
-     *   update_checkout
184
-     *
185
-     * @access public
186
-     * @return void
187
-     * @throws EE_Error
188
-     */
189
-    public static function update_checkout()
190
-    {
191
-        EED_Single_Page_Checkout::process_ajax_request('update_checkout');
192
-    }
193
-
194
-
195
-
196
-    /**
197
-     *    load_request_handler
198
-     *
199
-     * @access    public
200
-     * @return    void
201
-     */
202
-    public static function load_request_handler()
203
-    {
204
-        // load core Request_Handler class
205
-        if (EE_Registry::instance()->REQ !== null) {
206
-            EE_Registry::instance()->load_core('Request_Handler');
207
-        }
208
-    }
209
-
210
-
211
-
212
-    /**
213
-     *    set_definitions
214
-     *
215
-     * @access    public
216
-     * @return    void
217
-     * @throws EE_Error
218
-     */
219
-    public static function set_definitions()
220
-    {
221
-        if(defined('SPCO_BASE_PATH')) {
222
-            return;
223
-        }
224
-        define(
225
-            'SPCO_BASE_PATH',
226
-            rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
227
-        );
228
-        define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
229
-        define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
230
-        define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
231
-        define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
232
-        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
233
-        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
234
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
235
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
236
-            __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s',
237
-                'event_espresso'),
238
-            '<h4 class="important-notice">',
239
-            '</h4>',
240
-            '<br />',
241
-            '<p>',
242
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
243
-            '">',
244
-            '</a>',
245
-            '</p>'
246
-        );
247
-    }
248
-
249
-
250
-
251
-    /**
252
-     * load_reg_steps
253
-     * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
254
-     *
255
-     * @access    private
256
-     * @throws EE_Error
257
-     */
258
-    public static function load_reg_steps()
259
-    {
260
-        static $reg_steps_loaded = false;
261
-        if ($reg_steps_loaded) {
262
-            return;
263
-        }
264
-        // filter list of reg_steps
265
-        $reg_steps_to_load = (array)apply_filters(
266
-            'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
267
-            EED_Single_Page_Checkout::get_reg_steps()
268
-        );
269
-        // sort by key (order)
270
-        ksort($reg_steps_to_load);
271
-        // loop through folders
272
-        foreach ($reg_steps_to_load as $order => $reg_step) {
273
-            // we need a
274
-            if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
275
-                // copy over to the reg_steps_array
276
-                EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
277
-                // register custom key route for each reg step
278
-                // ie: step=>"slug" - this is the entire reason we load the reg steps array now
279
-                EE_Config::register_route(
280
-                    $reg_step['slug'],
281
-                    'EED_Single_Page_Checkout',
282
-                    'run',
283
-                    'step'
284
-                );
285
-                // add AJAX or other hooks
286
-                if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
287
-                    // setup autoloaders if necessary
288
-                    if ( ! class_exists($reg_step['class_name'])) {
289
-                        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
290
-                            $reg_step['file_path'],
291
-                            true
292
-                        );
293
-                    }
294
-                    if (is_callable($reg_step['class_name'], 'set_hooks')) {
295
-                        call_user_func(array($reg_step['class_name'], 'set_hooks'));
296
-                    }
297
-                }
298
-            }
299
-        }
300
-        $reg_steps_loaded = true;
301
-    }
302
-
303
-
304
-
305
-    /**
306
-     *    get_reg_steps
307
-     *
308
-     * @access    public
309
-     * @return    array
310
-     */
311
-    public static function get_reg_steps()
312
-    {
313
-        $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
314
-        if (empty($reg_steps)) {
315
-            $reg_steps = array(
316
-                10  => array(
317
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
318
-                    'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
319
-                    'slug'       => 'attendee_information',
320
-                    'has_hooks'  => false,
321
-                ),
322
-                20  => array(
323
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'registration_confirmation',
324
-                    'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
325
-                    'slug'       => 'registration_confirmation',
326
-                    'has_hooks'  => false,
327
-                ),
328
-                30  => array(
329
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
330
-                    'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
331
-                    'slug'       => 'payment_options',
332
-                    'has_hooks'  => true,
333
-                ),
334
-                999 => array(
335
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
336
-                    'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
337
-                    'slug'       => 'finalize_registration',
338
-                    'has_hooks'  => false,
339
-                ),
340
-            );
341
-        }
342
-        return $reg_steps;
343
-    }
344
-
345
-
346
-
347
-    /**
348
-     *    registration_checkout_for_admin
349
-     *
350
-     * @access    public
351
-     * @return    string
352
-     * @throws EE_Error
353
-     */
354
-    public static function registration_checkout_for_admin()
355
-    {
356
-        EED_Single_Page_Checkout::load_request_handler();
357
-        EE_Registry::instance()->REQ->set('step', 'attendee_information');
358
-        EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
359
-        EE_Registry::instance()->REQ->set('process_form_submission', false);
360
-        EED_Single_Page_Checkout::instance()->_initialize();
361
-        EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
362
-        return EE_Registry::instance()->REQ->get_output();
363
-    }
364
-
365
-
366
-
367
-    /**
368
-     * process_registration_from_admin
369
-     *
370
-     * @access public
371
-     * @return \EE_Transaction
372
-     * @throws EE_Error
373
-     */
374
-    public static function process_registration_from_admin()
375
-    {
376
-        EED_Single_Page_Checkout::load_request_handler();
377
-        EE_Registry::instance()->REQ->set('step', 'attendee_information');
378
-        EE_Registry::instance()->REQ->set('action', 'process_reg_step');
379
-        EE_Registry::instance()->REQ->set('process_form_submission', true);
380
-        EED_Single_Page_Checkout::instance()->_initialize();
381
-        if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
382
-            $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
383
-            if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
384
-                EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
385
-                if ($final_reg_step->process_reg_step()) {
386
-                    $final_reg_step->set_completed();
387
-                    EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
388
-                    return EED_Single_Page_Checkout::instance()->checkout->transaction;
389
-                }
390
-            }
391
-        }
392
-        return null;
393
-    }
394
-
395
-
396
-
397
-    /**
398
-     *    run
399
-     *
400
-     * @access    public
401
-     * @param WP_Query $WP_Query
402
-     * @return    void
403
-     * @throws EE_Error
404
-     */
405
-    public function run($WP_Query)
406
-    {
407
-        if (
408
-            $WP_Query instanceof WP_Query
409
-            && $WP_Query->is_main_query()
410
-            && apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
411
-            && $this->_is_reg_checkout()
412
-        ) {
413
-            $this->_initialize();
414
-        }
415
-    }
416
-
417
-
418
-
419
-    /**
420
-     * determines whether current url matches reg page url
421
-     *
422
-     * @return bool
423
-     */
424
-    protected function _is_reg_checkout()
425
-    {
426
-        // get current permalink for reg page without any extra query args
427
-        $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id);
428
-        // get request URI for current request, but without the scheme or host
429
-        $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI');
430
-        $current_request_uri = html_entity_decode($current_request_uri);
431
-        // get array of query args from the current request URI
432
-        $query_args = \EEH_URL::get_query_string($current_request_uri);
433
-        // grab page id if it is set
434
-        $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
435
-        // and remove the page id from the query args (we will re-add it later)
436
-        unset($query_args['page_id']);
437
-        // now strip all query args from current request URI
438
-        $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri);
439
-        // and re-add the page id if it was set
440
-        if ($page_id) {
441
-            $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
442
-        }
443
-        // remove slashes and ?
444
-        $current_request_uri = trim($current_request_uri, '?/');
445
-        // is current request URI part of the known full reg page URL ?
446
-        return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
447
-    }
448
-
449
-
450
-
451
-    /**
452
-     * @param WP_Query $wp_query
453
-     * @return    void
454
-     * @throws EE_Error
455
-     */
456
-    public static function init($wp_query)
457
-    {
458
-        EED_Single_Page_Checkout::instance()->run($wp_query);
459
-    }
460
-
461
-
462
-
463
-    /**
464
-     *    _initialize - initial module setup
465
-     *
466
-     * @access    private
467
-     * @throws EE_Error
468
-     * @return    void
469
-     */
470
-    private function _initialize()
471
-    {
472
-        // ensure SPCO doesn't run twice
473
-        if (EED_Single_Page_Checkout::$_initialized) {
474
-            return;
475
-        }
476
-        try {
477
-            EED_Single_Page_Checkout::load_reg_steps();
478
-            $this->_verify_session();
479
-            // setup the EE_Checkout object
480
-            $this->checkout = $this->_initialize_checkout();
481
-            // filter checkout
482
-            $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
483
-            // get the $_GET
484
-            $this->_get_request_vars();
485
-            if ($this->_block_bots()) {
486
-                return;
487
-            }
488
-            // filter continue_reg
489
-            $this->checkout->continue_reg = apply_filters(
490
-                'FHEE__EED_Single_Page_Checkout__init___continue_reg',
491
-                true,
492
-                $this->checkout
493
-            );
494
-            // load the reg steps array
495
-            if ( ! $this->_load_and_instantiate_reg_steps()) {
496
-                EED_Single_Page_Checkout::$_initialized = true;
497
-                return;
498
-            }
499
-            // set the current step
500
-            $this->checkout->set_current_step($this->checkout->step);
501
-            // and the next step
502
-            $this->checkout->set_next_step();
503
-            // verify that everything has been setup correctly
504
-            if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
505
-                EED_Single_Page_Checkout::$_initialized = true;
506
-                return;
507
-            }
508
-            // lock the transaction
509
-            $this->checkout->transaction->lock();
510
-            // make sure all of our cached objects are added to their respective model entity mappers
511
-            $this->checkout->refresh_all_entities();
512
-            // set amount owing
513
-            $this->checkout->amount_owing = $this->checkout->transaction->remaining();
514
-            // initialize each reg step, which gives them the chance to potentially alter the process
515
-            $this->_initialize_reg_steps();
516
-            // DEBUG LOG
517
-            //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
518
-            // get reg form
519
-            if( ! $this->_check_form_submission()) {
520
-                EED_Single_Page_Checkout::$_initialized = true;
521
-                return;
522
-            }
523
-            // checkout the action!!!
524
-            $this->_process_form_action();
525
-            // add some style and make it dance
526
-            $this->add_styles_and_scripts();
527
-            // kk... SPCO has successfully run
528
-            EED_Single_Page_Checkout::$_initialized = true;
529
-            // set no cache headers and constants
530
-            EE_System::do_not_cache();
531
-            // add anchor
532
-            add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
533
-            // remove transaction lock
534
-            add_action('shutdown', array($this, 'unlock_transaction'), 1);
535
-        } catch (Exception $e) {
536
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
537
-        }
538
-    }
539
-
540
-
541
-
542
-    /**
543
-     *    _verify_session
544
-     * checks that the session is valid and not expired
545
-     *
546
-     * @access    private
547
-     * @throws EE_Error
548
-     */
549
-    private function _verify_session()
550
-    {
551
-        if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
552
-            throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso'));
553
-        }
554
-        $clear_session_requested = filter_var(
555
-            EE_Registry::instance()->REQ->get('clear_session', false),
556
-            FILTER_VALIDATE_BOOLEAN
557
-        );
558
-        // is session still valid ?
559
-        if ($clear_session_requested
560
-            || ( EE_Registry::instance()->SSN->expired()
561
-              && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === ''
562
-            )
563
-        ) {
564
-            $this->checkout = new EE_Checkout();
565
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
566
-            // EE_Registry::instance()->SSN->reset_cart();
567
-            // EE_Registry::instance()->SSN->reset_checkout();
568
-            // EE_Registry::instance()->SSN->reset_transaction();
569
-            if (! $clear_session_requested) {
570
-                EE_Error::add_attention(
571
-                    EE_Registry::$i18n_js_strings['registration_expiration_notice'],
572
-                    __FILE__, __FUNCTION__, __LINE__
573
-                );
574
-            }
575
-            // EE_Registry::instance()->SSN->reset_expired();
576
-        }
577
-    }
578
-
579
-
580
-
581
-    /**
582
-     *    _initialize_checkout
583
-     * loads and instantiates EE_Checkout
584
-     *
585
-     * @access    private
586
-     * @throws EE_Error
587
-     * @return EE_Checkout
588
-     */
589
-    private function _initialize_checkout()
590
-    {
591
-        // look in session for existing checkout
592
-        /** @type EE_Checkout $checkout */
593
-        $checkout = EE_Registry::instance()->SSN->checkout();
594
-        // verify
595
-        if ( ! $checkout instanceof EE_Checkout) {
596
-            // instantiate EE_Checkout object for handling the properties of the current checkout process
597
-            $checkout = EE_Registry::instance()->load_file(
598
-                SPCO_INC_PATH,
599
-                'EE_Checkout',
600
-                'class', array(),
601
-                false
602
-            );
603
-        } else {
604
-            if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
605
-                $this->unlock_transaction();
606
-                wp_safe_redirect($checkout->redirect_url);
607
-                exit();
608
-            }
609
-        }
610
-        $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
611
-        // verify again
612
-        if ( ! $checkout instanceof EE_Checkout) {
613
-            throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
614
-        }
615
-        // reset anything that needs a clean slate for each request
616
-        $checkout->reset_for_current_request();
617
-        return $checkout;
618
-    }
619
-
620
-
621
-
622
-    /**
623
-     *    _get_request_vars
624
-     *
625
-     * @access    private
626
-     * @return    void
627
-     * @throws EE_Error
628
-     */
629
-    private function _get_request_vars()
630
-    {
631
-        // load classes
632
-        EED_Single_Page_Checkout::load_request_handler();
633
-        //make sure this request is marked as belonging to EE
634
-        EE_Registry::instance()->REQ->set_espresso_page(true);
635
-        // which step is being requested ?
636
-        $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
637
-        // which step is being edited ?
638
-        $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
639
-        // and what we're doing on the current step
640
-        $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
641
-        // timestamp
642
-        $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0);
643
-        // returning to edit ?
644
-        $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
645
-        // or some other kind of revisit ?
646
-        $this->checkout->revisit = filter_var(
647
-            EE_Registry::instance()->REQ->get('revisit', false),
648
-            FILTER_VALIDATE_BOOLEAN
649
-        );
650
-        // and whether or not to generate a reg form for this request
651
-        $this->checkout->generate_reg_form = filter_var(
652
-            EE_Registry::instance()->REQ->get('generate_reg_form', true),
653
-            FILTER_VALIDATE_BOOLEAN
654
-        );
655
-        // and whether or not to process a reg form submission for this request
656
-        $this->checkout->process_form_submission = filter_var(
657
-            EE_Registry::instance()->REQ->get(
658
-                'process_form_submission',
659
-                $this->checkout->action === 'process_reg_step'
660
-            ),
661
-            FILTER_VALIDATE_BOOLEAN
662
-        );
663
-        $this->checkout->process_form_submission = filter_var(
664
-            $this->checkout->action !== 'display_spco_reg_step'
665
-                ? $this->checkout->process_form_submission
666
-                : false,
667
-            FILTER_VALIDATE_BOOLEAN
668
-        );
669
-        // $this->_display_request_vars();
670
-    }
671
-
672
-
673
-
674
-    /**
675
-     *  _display_request_vars
676
-     *
677
-     * @access    protected
678
-     * @return    void
679
-     */
680
-    protected function _display_request_vars()
681
-    {
682
-        if ( ! WP_DEBUG) {
683
-            return;
684
-        }
685
-        EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
686
-        EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
687
-        EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
688
-        EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
689
-        EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
690
-        EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
691
-        EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
692
-        EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
693
-    }
694
-
695
-
696
-
697
-    /**
698
-     * _block_bots
699
-     * checks that the incoming request has either of the following set:
700
-     *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
701
-     *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
702
-     * so if you're not coming from the Ticket Selector nor returning for a valid IP...
703
-     * then where you coming from man?
704
-     *
705
-     * @return boolean
706
-     */
707
-    private function _block_bots()
708
-    {
709
-        $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
710
-        if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
711
-            return true;
712
-        }
713
-        return false;
714
-    }
715
-
716
-
717
-
718
-    /**
719
-     *    _get_first_step
720
-     *  gets slug for first step in $_reg_steps_array
721
-     *
722
-     * @access    private
723
-     * @throws EE_Error
724
-     * @return    string
725
-     */
726
-    private function _get_first_step()
727
-    {
728
-        $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
729
-        return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
730
-    }
731
-
732
-
733
-
734
-    /**
735
-     *    _load_and_instantiate_reg_steps
736
-     *  instantiates each reg step based on the loaded reg_steps array
737
-     *
738
-     * @access    private
739
-     * @throws EE_Error
740
-     * @return    bool
741
-     */
742
-    private function _load_and_instantiate_reg_steps()
743
-    {
744
-        do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout);
745
-        // have reg_steps already been instantiated ?
746
-        if (
747
-            empty($this->checkout->reg_steps)
748
-            || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
749
-        ) {
750
-            // if not, then loop through raw reg steps array
751
-            foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
752
-                if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
753
-                    return false;
754
-                }
755
-            }
756
-            EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true;
757
-            EE_Registry::instance()->CFG->registration->reg_confirmation_last = true;
758
-            // skip the registration_confirmation page ?
759
-            if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
760
-                // just remove it from the reg steps array
761
-                $this->checkout->remove_reg_step('registration_confirmation', false);
762
-            } else if (
763
-                isset($this->checkout->reg_steps['registration_confirmation'])
764
-                && EE_Registry::instance()->CFG->registration->reg_confirmation_last
765
-            ) {
766
-                // set the order to something big like 100
767
-                $this->checkout->set_reg_step_order('registration_confirmation', 100);
768
-            }
769
-            // filter the array for good luck
770
-            $this->checkout->reg_steps = apply_filters(
771
-                'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps',
772
-                $this->checkout->reg_steps
773
-            );
774
-            // finally re-sort based on the reg step class order properties
775
-            $this->checkout->sort_reg_steps();
776
-        } else {
777
-            foreach ($this->checkout->reg_steps as $reg_step) {
778
-                // set all current step stati to FALSE
779
-                $reg_step->set_is_current_step(false);
780
-            }
781
-        }
782
-        if (empty($this->checkout->reg_steps)) {
783
-            EE_Error::add_error(
784
-                __('No Reg Steps were loaded..', 'event_espresso'),
785
-                __FILE__, __FUNCTION__, __LINE__
786
-            );
787
-            return false;
788
-        }
789
-        // make reg step details available to JS
790
-        $this->checkout->set_reg_step_JSON_info();
791
-        return true;
792
-    }
793
-
794
-
795
-
796
-    /**
797
-     *     _load_and_instantiate_reg_step
798
-     *
799
-     * @access    private
800
-     * @param array $reg_step
801
-     * @param int   $order
802
-     * @return bool
803
-     */
804
-    private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
805
-    {
806
-        // we need a file_path, class_name, and slug to add a reg step
807
-        if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
808
-            // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
809
-            if (
810
-                $this->checkout->reg_url_link
811
-                && $this->checkout->step !== $reg_step['slug']
812
-                && $reg_step['slug'] !== 'finalize_registration'
813
-                // normally at this point we would NOT load the reg step, but this filter can change that
814
-                && apply_filters(
815
-                    'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step',
816
-                    true,
817
-                    $reg_step,
818
-                    $this->checkout
819
-                )
820
-            ) {
821
-                return true;
822
-            }
823
-            // instantiate step class using file path and class name
824
-            $reg_step_obj = EE_Registry::instance()->load_file(
825
-                $reg_step['file_path'],
826
-                $reg_step['class_name'],
827
-                'class',
828
-                $this->checkout,
829
-                false
830
-            );
831
-            // did we gets the goods ?
832
-            if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
833
-                // set reg step order based on config
834
-                $reg_step_obj->set_order($order);
835
-                // add instantiated reg step object to the master reg steps array
836
-                $this->checkout->add_reg_step($reg_step_obj);
837
-            } else {
838
-                EE_Error::add_error(
839
-                    __('The current step could not be set.', 'event_espresso'),
840
-                    __FILE__, __FUNCTION__, __LINE__
841
-                );
842
-                return false;
843
-            }
844
-        } else {
845
-            if (WP_DEBUG) {
846
-                EE_Error::add_error(
847
-                    sprintf(
848
-                        __(
849
-                            'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s',
850
-                            'event_espresso'
851
-                        ),
852
-                        isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
853
-                        isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
854
-                        isset($reg_step['slug']) ? $reg_step['slug'] : '',
855
-                        '<ul>',
856
-                        '<li>',
857
-                        '</li>',
858
-                        '</ul>'
859
-                    ),
860
-                    __FILE__, __FUNCTION__, __LINE__
861
-                );
862
-            }
863
-            return false;
864
-        }
865
-        return true;
866
-    }
867
-
868
-
869
-    /**
870
-     * _verify_transaction_and_get_registrations
871
-     *
872
-     * @access private
873
-     * @return bool
874
-     * @throws InvalidDataTypeException
875
-     * @throws InvalidEntityException
876
-     * @throws EE_Error
877
-     */
878
-    private function _verify_transaction_and_get_registrations()
879
-    {
880
-        // was there already a valid transaction in the checkout from the session ?
881
-        if ( ! $this->checkout->transaction instanceof EE_Transaction) {
882
-            // get transaction from db or session
883
-            $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
884
-                ? $this->_get_transaction_and_cart_for_previous_visit()
885
-                : $this->_get_cart_for_current_session_and_setup_new_transaction();
886
-            if ( ! $this->checkout->transaction instanceof EE_Transaction) {
887
-                EE_Error::add_error(
888
-                    __('Your Registration and Transaction information could not be retrieved from the db.',
889
-                        'event_espresso'),
890
-                    __FILE__, __FUNCTION__, __LINE__
891
-                );
892
-                $this->checkout->transaction = EE_Transaction::new_instance();
893
-                // add some style and make it dance
894
-                $this->add_styles_and_scripts();
895
-                EED_Single_Page_Checkout::$_initialized = true;
896
-                return false;
897
-            }
898
-            // and the registrations for the transaction
899
-            $this->_get_registrations($this->checkout->transaction);
900
-        }
901
-        return true;
902
-    }
903
-
904
-
905
-
906
-    /**
907
-     * _get_transaction_and_cart_for_previous_visit
908
-     *
909
-     * @access private
910
-     * @return mixed EE_Transaction|NULL
911
-     */
912
-    private function _get_transaction_and_cart_for_previous_visit()
913
-    {
914
-        /** @var $TXN_model EEM_Transaction */
915
-        $TXN_model = EE_Registry::instance()->load_model('Transaction');
916
-        // because the reg_url_link is present in the request,
917
-        // this is a return visit to SPCO, so we'll get the transaction data from the db
918
-        $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
919
-        // verify transaction
920
-        if ($transaction instanceof EE_Transaction) {
921
-            // and get the cart that was used for that transaction
922
-            $this->checkout->cart = $this->_get_cart_for_transaction($transaction);
923
-            return $transaction;
924
-        }
925
-        EE_Error::add_error(
926
-            __('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
927
-            __FILE__, __FUNCTION__, __LINE__
928
-        );
929
-        return null;
930
-
931
-    }
932
-
933
-
934
-
935
-    /**
936
-     * _get_cart_for_transaction
937
-     *
938
-     * @access private
939
-     * @param EE_Transaction $transaction
940
-     * @return EE_Cart
941
-     */
942
-    private function _get_cart_for_transaction($transaction)
943
-    {
944
-        return $this->checkout->get_cart_for_transaction($transaction);
945
-    }
946
-
947
-
948
-
949
-    /**
950
-     * get_cart_for_transaction
951
-     *
952
-     * @access public
953
-     * @param EE_Transaction $transaction
954
-     * @return EE_Cart
955
-     */
956
-    public function get_cart_for_transaction(EE_Transaction $transaction)
957
-    {
958
-        return $this->checkout->get_cart_for_transaction($transaction);
959
-    }
960
-
961
-
962
-
963
-    /**
964
-     * _get_transaction_and_cart_for_current_session
965
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
966
-     *
967
-     * @access private
968
-     * @return EE_Transaction
969
-     * @throws EE_Error
970
-     */
971
-    private function _get_cart_for_current_session_and_setup_new_transaction()
972
-    {
973
-        //  if there's no transaction, then this is the FIRST visit to SPCO
974
-        // so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
975
-        $this->checkout->cart = $this->_get_cart_for_transaction(null);
976
-        // and then create a new transaction
977
-        $transaction = $this->_initialize_transaction();
978
-        // verify transaction
979
-        if ($transaction instanceof EE_Transaction) {
980
-            // save it so that we have an ID for other objects to use
981
-            $transaction->save();
982
-            // and save TXN data to the cart
983
-            $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
984
-        } else {
985
-            EE_Error::add_error(
986
-                __('A Valid Transaction could not be initialized.', 'event_espresso'),
987
-                __FILE__, __FUNCTION__, __LINE__
988
-            );
989
-        }
990
-        return $transaction;
991
-    }
992
-
993
-
994
-
995
-    /**
996
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
997
-     *
998
-     * @access private
999
-     * @return mixed EE_Transaction|NULL
1000
-     */
1001
-    private function _initialize_transaction()
1002
-    {
1003
-        try {
1004
-            // ensure cart totals have been calculated
1005
-            $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
1006
-            // grab the cart grand total
1007
-            $cart_total = $this->checkout->cart->get_cart_grand_total();
1008
-            // create new TXN
1009
-            $transaction = EE_Transaction::new_instance(
1010
-                array(
1011
-                    'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
1012
-                    'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
1013
-                    'TXN_paid'      => 0,
1014
-                    'STS_ID'        => EEM_Transaction::failed_status_code,
1015
-                )
1016
-            );
1017
-            // save it so that we have an ID for other objects to use
1018
-            $transaction->save();
1019
-            // set cron job for following up on TXNs after their session has expired
1020
-            EE_Cron_Tasks::schedule_expired_transaction_check(
1021
-                EE_Registry::instance()->SSN->expiration() + 1,
1022
-                $transaction->ID()
1023
-            );
1024
-            return $transaction;
1025
-        } catch (Exception $e) {
1026
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1027
-        }
1028
-        return null;
1029
-    }
1030
-
1031
-
1032
-    /**
1033
-     * _get_registrations
1034
-     *
1035
-     * @access private
1036
-     * @param EE_Transaction $transaction
1037
-     * @return void
1038
-     * @throws InvalidDataTypeException
1039
-     * @throws InvalidEntityException
1040
-     * @throws EE_Error
1041
-     */
1042
-    private function _get_registrations(EE_Transaction $transaction)
1043
-    {
1044
-        // first step: grab the registrants  { : o
1045
-        $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true);
1046
-        // verify registrations have been set
1047
-        if (empty($registrations)) {
1048
-            // if no cached registrations, then check the db
1049
-            $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1050
-            // still nothing ? well as long as this isn't a revisit
1051
-            if (empty($registrations) && ! $this->checkout->revisit) {
1052
-                // generate new registrations from scratch
1053
-                $registrations = $this->_initialize_registrations($transaction);
1054
-            }
1055
-        }
1056
-        // sort by their original registration order
1057
-        usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1058
-        // then loop thru the array
1059
-        foreach ($registrations as $registration) {
1060
-            // verify each registration
1061
-            if ($registration instanceof EE_Registration) {
1062
-                // we display all attendee info for the primary registrant
1063
-                if ($this->checkout->reg_url_link === $registration->reg_url_link()
1064
-                    && $registration->is_primary_registrant()
1065
-                ) {
1066
-                    $this->checkout->primary_revisit = true;
1067
-                    break;
1068
-                }
1069
-                if ($this->checkout->revisit
1070
-                           && $this->checkout->reg_url_link !== $registration->reg_url_link()
1071
-                ) {
1072
-                    // but hide info if it doesn't belong to you
1073
-                    $transaction->clear_cache('Registration', $registration->ID());
1074
-                }
1075
-                $this->checkout->set_reg_status_updated($registration->ID(), false);
1076
-            }
1077
-        }
1078
-    }
1079
-
1080
-
1081
-    /**
1082
-     *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1083
-     *
1084
-     * @access private
1085
-     * @param EE_Transaction $transaction
1086
-     * @return    array
1087
-     * @throws InvalidDataTypeException
1088
-     * @throws InvalidEntityException
1089
-     * @throws EE_Error
1090
-     */
1091
-    private function _initialize_registrations(EE_Transaction $transaction)
1092
-    {
1093
-        $att_nmbr = 0;
1094
-        $registrations = array();
1095
-        if ($transaction instanceof EE_Transaction) {
1096
-            /** @type EE_Registration_Processor $registration_processor */
1097
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1098
-            $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1099
-            // now let's add the cart items to the $transaction
1100
-            foreach ($this->checkout->cart->get_tickets() as $line_item) {
1101
-                //do the following for each ticket of this type they selected
1102
-                for ($x = 1; $x <= $line_item->quantity(); $x++) {
1103
-                    $att_nmbr++;
1104
-                    /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
1105
-                    $CreateRegistrationCommand = EE_Registry::instance()->create(
1106
-                        'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1107
-                        array(
1108
-                            $transaction,
1109
-                            $line_item,
1110
-                            $att_nmbr,
1111
-                            $this->checkout->total_ticket_count,
1112
-                        )
1113
-                    );
1114
-                    // override capabilities for frontend registrations
1115
-                    if ( ! is_admin()) {
1116
-                        $CreateRegistrationCommand->setCapCheck(
1117
-                            new PublicCapabilities('', 'create_new_registration')
1118
-                        );
1119
-                    }
1120
-                    $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1121
-                    if ( ! $registration instanceof EE_Registration) {
1122
-                        throw new InvalidEntityException($registration, 'EE_Registration');
1123
-                    }
1124
-                    $registrations[ $registration->ID() ] = $registration;
1125
-                }
1126
-            }
1127
-            $registration_processor->fix_reg_final_price_rounding_issue($transaction);
1128
-        }
1129
-        return $registrations;
1130
-    }
1131
-
1132
-
1133
-
1134
-    /**
1135
-     * sorts registrations by REG_count
1136
-     *
1137
-     * @access public
1138
-     * @param EE_Registration $reg_A
1139
-     * @param EE_Registration $reg_B
1140
-     * @return int
1141
-     */
1142
-    public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1143
-    {
1144
-        // this shouldn't ever happen within the same TXN, but oh well
1145
-        if ($reg_A->count() === $reg_B->count()) {
1146
-            return 0;
1147
-        }
1148
-        return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1149
-    }
1150
-
1151
-
1152
-
1153
-    /**
1154
-     *    _final_verifications
1155
-     * just makes sure that everything is set up correctly before proceeding
1156
-     *
1157
-     * @access    private
1158
-     * @return    bool
1159
-     * @throws EE_Error
1160
-     */
1161
-    private function _final_verifications()
1162
-    {
1163
-        // filter checkout
1164
-        $this->checkout = apply_filters(
1165
-            'FHEE__EED_Single_Page_Checkout___final_verifications__checkout',
1166
-            $this->checkout
1167
-        );
1168
-        //verify that current step is still set correctly
1169
-        if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1170
-            EE_Error::add_error(
1171
-                __('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'),
1172
-                __FILE__,
1173
-                __FUNCTION__,
1174
-                __LINE__
1175
-            );
1176
-            return false;
1177
-        }
1178
-        // if returning to SPCO, then verify that primary registrant is set
1179
-        if ( ! empty($this->checkout->reg_url_link)) {
1180
-            $valid_registrant = $this->checkout->transaction->primary_registration();
1181
-            if ( ! $valid_registrant instanceof EE_Registration) {
1182
-                EE_Error::add_error(
1183
-                    __('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'),
1184
-                    __FILE__,
1185
-                    __FUNCTION__,
1186
-                    __LINE__
1187
-                );
1188
-                return false;
1189
-            }
1190
-            $valid_registrant = null;
1191
-            foreach (
1192
-                $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration
1193
-            ) {
1194
-                if (
1195
-                    $registration instanceof EE_Registration
1196
-                    && $registration->reg_url_link() === $this->checkout->reg_url_link
1197
-                ) {
1198
-                    $valid_registrant = $registration;
1199
-                }
1200
-            }
1201
-            if ( ! $valid_registrant instanceof EE_Registration) {
1202
-                // hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1203
-                if (EED_Single_Page_Checkout::$_checkout_verified) {
1204
-                    // clear the session, mark the checkout as unverified, and try again
1205
-                    EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1206
-                    EED_Single_Page_Checkout::$_initialized = false;
1207
-                    EED_Single_Page_Checkout::$_checkout_verified = false;
1208
-                    $this->_initialize();
1209
-                    EE_Error::reset_notices();
1210
-                    return false;
1211
-                }
1212
-                EE_Error::add_error(
1213
-                    __(
1214
-                        'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.',
1215
-                        'event_espresso'
1216
-                    ),
1217
-                    __FILE__,
1218
-                    __FUNCTION__,
1219
-                    __LINE__
1220
-                );
1221
-                return false;
1222
-            }
1223
-        }
1224
-        // now that things have been kinda sufficiently verified,
1225
-        // let's add the checkout to the session so that it's available to other systems
1226
-        EE_Registry::instance()->SSN->set_checkout($this->checkout);
1227
-        return true;
1228
-    }
1229
-
1230
-
1231
-
1232
-    /**
1233
-     *    _initialize_reg_steps
1234
-     * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1235
-     * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1236
-     *
1237
-     * @access    private
1238
-     * @param bool $reinitializing
1239
-     * @throws EE_Error
1240
-     */
1241
-    private function _initialize_reg_steps($reinitializing = false)
1242
-    {
1243
-        $this->checkout->set_reg_step_initiated($this->checkout->current_step);
1244
-        // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1245
-        foreach ($this->checkout->reg_steps as $reg_step) {
1246
-            if ( ! $reg_step->initialize_reg_step()) {
1247
-                // if not initialized then maybe this step is being removed...
1248
-                if ( ! $reinitializing && $reg_step->is_current_step()) {
1249
-                    // if it was the current step, then we need to start over here
1250
-                    $this->_initialize_reg_steps(true);
1251
-                    return;
1252
-                }
1253
-                continue;
1254
-            }
1255
-            // add css and JS for current step
1256
-            $reg_step->enqueue_styles_and_scripts();
1257
-            // i18n
1258
-            $reg_step->translate_js_strings();
1259
-            if ($reg_step->is_current_step()) {
1260
-                // the text that appears on the reg step form submit button
1261
-                $reg_step->set_submit_button_text();
1262
-            }
1263
-        }
1264
-        // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1265
-        do_action(
1266
-            "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}",
1267
-            $this->checkout->current_step
1268
-        );
1269
-    }
1270
-
1271
-
1272
-
1273
-    /**
1274
-     * _check_form_submission
1275
-     *
1276
-     * @access private
1277
-     * @return boolean
1278
-     */
1279
-    private function _check_form_submission()
1280
-    {
1281
-        //does this request require the reg form to be generated ?
1282
-        if ($this->checkout->generate_reg_form) {
1283
-            // ever heard that song by Blue Rodeo ?
1284
-            try {
1285
-                $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1286
-                // if not displaying a form, then check for form submission
1287
-                if (
1288
-                    $this->checkout->process_form_submission
1289
-                    && $this->checkout->current_step->reg_form->was_submitted()
1290
-                ) {
1291
-                    // clear out any old data in case this step is being run again
1292
-                    $this->checkout->current_step->set_valid_data(array());
1293
-                    // capture submitted form data
1294
-                    $this->checkout->current_step->reg_form->receive_form_submission(
1295
-                        apply_filters(
1296
-                            'FHEE__Single_Page_Checkout___check_form_submission__request_params',
1297
-                            EE_Registry::instance()->REQ->params(),
1298
-                            $this->checkout
1299
-                        )
1300
-                    );
1301
-                    // validate submitted form data
1302
-                    if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1303
-                        // thou shall not pass !!!
1304
-                        $this->checkout->continue_reg = false;
1305
-                        // any form validation errors?
1306
-                        if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1307
-                            $submission_error_messages = array();
1308
-                            // bad, bad, bad registrant
1309
-                            foreach (
1310
-                                $this->checkout->current_step->reg_form->get_validation_errors_accumulated()
1311
-                                as $validation_error
1312
-                            ) {
1313
-                                if ($validation_error instanceof EE_Validation_Error) {
1314
-                                    $submission_error_messages[] = sprintf(
1315
-                                        __('%s : %s', 'event_espresso'),
1316
-                                        $validation_error->get_form_section()->html_label_text(),
1317
-                                        $validation_error->getMessage()
1318
-                                    );
1319
-                                }
1320
-                            }
1321
-                            EE_Error::add_error(
1322
-                                implode('<br />', $submission_error_messages),
1323
-                                __FILE__, __FUNCTION__, __LINE__
1324
-                            );
1325
-                        }
1326
-                        // well not really... what will happen is
1327
-                        // we'll just get redirected back to redo the current step
1328
-                        $this->go_to_next_step();
1329
-                        return false;
1330
-                    }
1331
-                }
1332
-            } catch (EE_Error $e) {
1333
-                $e->get_error();
1334
-            }
1335
-        }
1336
-        return true;
1337
-    }
1338
-
1339
-
1340
-
1341
-    /**
1342
-     * _process_action
1343
-     *
1344
-     * @access private
1345
-     * @return void
1346
-     * @throws EE_Error
1347
-     */
1348
-    private function _process_form_action()
1349
-    {
1350
-        // what cha wanna do?
1351
-        switch ($this->checkout->action) {
1352
-            // AJAX next step reg form
1353
-            case 'display_spco_reg_step' :
1354
-                $this->checkout->redirect = false;
1355
-                if (EE_Registry::instance()->REQ->ajax) {
1356
-                    $this->checkout->json_response->set_reg_step_html(
1357
-                        $this->checkout->current_step->display_reg_form()
1358
-                    );
1359
-                }
1360
-                break;
1361
-            default :
1362
-                // meh... do one of those other steps first
1363
-                if (
1364
-                    ! empty($this->checkout->action)
1365
-                    && is_callable(array($this->checkout->current_step, $this->checkout->action))
1366
-                ) {
1367
-                    // dynamically creates hook point like:
1368
-                    //   AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1369
-                    do_action(
1370
-                        "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1371
-                        $this->checkout->current_step
1372
-                    );
1373
-                    // call action on current step
1374
-                    if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1375
-                        // good registrant, you get to proceed
1376
-                        if (
1377
-                            $this->checkout->current_step->success_message() !== ''
1378
-                            && apply_filters(
1379
-                                'FHEE__Single_Page_Checkout___process_form_action__display_success',
1380
-                                false
1381
-                            )
1382
-                        ) {
1383
-                            EE_Error::add_success(
1384
-                                $this->checkout->current_step->success_message()
1385
-                                . '<br />' . $this->checkout->next_step->_instructions()
1386
-                            );
1387
-                        }
1388
-                        // pack it up, pack it in...
1389
-                        $this->_setup_redirect();
1390
-                    }
1391
-                    // dynamically creates hook point like:
1392
-                    //  AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1393
-                    do_action(
1394
-                        "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1395
-                        $this->checkout->current_step
1396
-                    );
1397
-                } else {
1398
-                    EE_Error::add_error(
1399
-                        sprintf(
1400
-                            __(
1401
-                                'The requested form action "%s" does not exist for the current "%s" registration step.',
1402
-                                'event_espresso'
1403
-                            ),
1404
-                            $this->checkout->action,
1405
-                            $this->checkout->current_step->name()
1406
-                        ),
1407
-                        __FILE__,
1408
-                        __FUNCTION__,
1409
-                        __LINE__
1410
-                    );
1411
-                }
1412
-            // end default
1413
-        }
1414
-        // store our progress so far
1415
-        $this->checkout->stash_transaction_and_checkout();
1416
-        // advance to the next step! If you pass GO, collect $200
1417
-        $this->go_to_next_step();
1418
-    }
1419
-
1420
-
1421
-
1422
-    /**
1423
-     *        add_styles_and_scripts
1424
-     *
1425
-     * @access        public
1426
-     * @return        void
1427
-     */
1428
-    public function add_styles_and_scripts()
1429
-    {
1430
-        // i18n
1431
-        $this->translate_js_strings();
1432
-        if ($this->checkout->admin_request) {
1433
-            add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1434
-        } else {
1435
-            add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1436
-        }
1437
-    }
1438
-
1439
-
1440
-
1441
-    /**
1442
-     *        translate_js_strings
1443
-     *
1444
-     * @access        public
1445
-     * @return        void
1446
-     */
1447
-    public function translate_js_strings()
1448
-    {
1449
-        EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1450
-        EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1451
-        EE_Registry::$i18n_js_strings['server_error'] = __(
1452
-            'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
1453
-            'event_espresso'
1454
-        );
1455
-        EE_Registry::$i18n_js_strings['invalid_json_response'] = __(
1456
-            'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.',
1457
-            'event_espresso'
1458
-        );
1459
-        EE_Registry::$i18n_js_strings['validation_error'] = __(
1460
-            'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.',
1461
-            'event_espresso'
1462
-        );
1463
-        EE_Registry::$i18n_js_strings['invalid_payment_method'] = __(
1464
-            'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.',
1465
-            'event_espresso'
1466
-        );
1467
-        EE_Registry::$i18n_js_strings['reg_step_error'] = __(
1468
-            'This registration step could not be completed. Please refresh the page and try again.',
1469
-            'event_espresso'
1470
-        );
1471
-        EE_Registry::$i18n_js_strings['invalid_coupon'] = __(
1472
-            'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.',
1473
-            'event_espresso'
1474
-        );
1475
-        EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1476
-            __(
1477
-                'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.',
1478
-                'event_espresso'
1479
-            ),
1480
-            '<br/>',
1481
-            '<br/>'
1482
-        );
1483
-        EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1484
-        EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1485
-        EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1486
-        EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1487
-        EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1488
-        EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1489
-        EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1490
-        EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1491
-        EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1492
-        EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1493
-        EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1494
-        EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1495
-        EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1496
-        EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1497
-        EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1498
-        EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1499
-        EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1500
-        EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1501
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
1502
-            __(
1503
-                '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s',
1504
-                'event_espresso'
1505
-            ),
1506
-            '<h4 class="important-notice">',
1507
-            '</h4>',
1508
-            '<br />',
1509
-            '<p>',
1510
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1511
-            '">',
1512
-            '</a>',
1513
-            '</p>'
1514
-        );
1515
-        EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters(
1516
-            'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
1517
-            true
1518
-        );
1519
-        EE_Registry::$i18n_js_strings['session_extension'] = absint(
1520
-            apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1521
-        );
1522
-        EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1523
-            'M d, Y H:i:s',
1524
-            EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1525
-        );
1526
-    }
1527
-
1528
-
1529
-
1530
-    /**
1531
-     *    enqueue_styles_and_scripts
1532
-     *
1533
-     * @access        public
1534
-     * @return        void
1535
-     * @throws EE_Error
1536
-     */
1537
-    public function enqueue_styles_and_scripts()
1538
-    {
1539
-        // load css
1540
-        wp_register_style(
1541
-            'single_page_checkout',
1542
-            SPCO_CSS_URL . 'single_page_checkout.css',
1543
-            array('espresso_default'),
1544
-            EVENT_ESPRESSO_VERSION
1545
-        );
1546
-        wp_enqueue_style('single_page_checkout');
1547
-        // load JS
1548
-        wp_register_script(
1549
-            'jquery_plugin',
1550
-            EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1551
-            array('jquery'),
1552
-            '1.0.1',
1553
-            true
1554
-        );
1555
-        wp_register_script(
1556
-            'jquery_countdown',
1557
-            EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1558
-            array('jquery_plugin'),
1559
-            '2.0.2',
1560
-            true
1561
-        );
1562
-        wp_register_script(
1563
-            'single_page_checkout',
1564
-            SPCO_JS_URL . 'single_page_checkout.js',
1565
-            array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'),
1566
-            EVENT_ESPRESSO_VERSION,
1567
-            true
1568
-        );
1569
-        if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1570
-            $this->checkout->registration_form->enqueue_js();
1571
-        }
1572
-        if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1573
-            $this->checkout->current_step->reg_form->enqueue_js();
1574
-        }
1575
-        wp_enqueue_script('single_page_checkout');
1576
-        /**
1577
-         * global action hook for enqueueing styles and scripts with
1578
-         * spco calls.
1579
-         */
1580
-        do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1581
-        /**
1582
-         * dynamic action hook for enqueueing styles and scripts with spco calls.
1583
-         * The hook will end up being something like:
1584
-         *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1585
-         */
1586
-        do_action(
1587
-            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1588
-            $this
1589
-        );
1590
-    }
1591
-
1592
-
1593
-
1594
-    /**
1595
-     *    display the Registration Single Page Checkout Form
1596
-     *
1597
-     * @access    private
1598
-     * @return    void
1599
-     * @throws EE_Error
1600
-     */
1601
-    private function _display_spco_reg_form()
1602
-    {
1603
-        // if registering via the admin, just display the reg form for the current step
1604
-        if ($this->checkout->admin_request) {
1605
-            EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1606
-        } else {
1607
-            // add powered by EE msg
1608
-            add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1609
-            $empty_cart = count(
1610
-                $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)
1611
-            ) < 1;
1612
-            EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1613
-            $cookies_not_set_msg = '';
1614
-            if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) {
1615
-                $cookies_not_set_msg = apply_filters(
1616
-                    'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1617
-                    sprintf(
1618
-                        __(
1619
-                            '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s',
1620
-                            'event_espresso'
1621
-                        ),
1622
-                        '<div class="ee-attention">',
1623
-                        '</div>',
1624
-                        '<h6 class="important-notice">',
1625
-                        '</h6>',
1626
-                        '<p>',
1627
-                        '</p>',
1628
-                        '<br />',
1629
-                        '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">',
1630
-                        '</a>'
1631
-                    )
1632
-                );
1633
-            }
1634
-            $this->checkout->registration_form = new EE_Form_Section_Proper(
1635
-                array(
1636
-                    'name'            => 'single-page-checkout',
1637
-                    'html_id'         => 'ee-single-page-checkout-dv',
1638
-                    'layout_strategy' =>
1639
-                        new EE_Template_Layout(
1640
-                            array(
1641
-                                'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1642
-                                'template_args'        => array(
1643
-                                    'empty_cart'              => $empty_cart,
1644
-                                    'revisit'                 => $this->checkout->revisit,
1645
-                                    'reg_steps'               => $this->checkout->reg_steps,
1646
-                                    'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1647
-                                        ? $this->checkout->next_step->slug()
1648
-                                        : '',
1649
-                                    'cancel_page_url'         => $this->checkout->cancel_page_url,
1650
-                                    'empty_msg'               => apply_filters(
1651
-                                        'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1652
-                                        sprintf(
1653
-                                            __(
1654
-                                                'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1655
-                                                'event_espresso'
1656
-                                            ),
1657
-                                            '<a href="'
1658
-                                            . get_post_type_archive_link('espresso_events')
1659
-                                            . '" title="',
1660
-                                            '">',
1661
-                                            '</a>'
1662
-                                        )
1663
-                                    ),
1664
-                                    'cookies_not_set_msg'     => $cookies_not_set_msg,
1665
-                                    'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1666
-                                    'session_expiration'      => gmdate(
1667
-                                        'M d, Y H:i:s',
1668
-                                        EE_Registry::instance()->SSN->expiration()
1669
-                                        + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1670
-                                    ),
1671
-                                ),
1672
-                            )
1673
-                        ),
1674
-                )
1675
-            );
1676
-            // load template and add to output sent that gets filtered into the_content()
1677
-            EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html());
1678
-        }
1679
-    }
1680
-
1681
-
1682
-
1683
-    /**
1684
-     *    add_extra_finalize_registration_inputs
1685
-     *
1686
-     * @access    public
1687
-     * @param $next_step
1688
-     * @internal  param string $label
1689
-     * @return void
1690
-     */
1691
-    public function add_extra_finalize_registration_inputs($next_step)
1692
-    {
1693
-        if ($next_step === 'finalize_registration') {
1694
-            echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1695
-        }
1696
-    }
1697
-
1698
-
1699
-
1700
-    /**
1701
-     *    display_registration_footer
1702
-     *
1703
-     * @access    public
1704
-     * @return    string
1705
-     */
1706
-    public static function display_registration_footer()
1707
-    {
1708
-        if (
1709
-        apply_filters(
1710
-            'FHEE__EE_Front__Controller__show_reg_footer',
1711
-            EE_Registry::instance()->CFG->admin->show_reg_footer
1712
-        )
1713
-        ) {
1714
-            add_filter(
1715
-                'FHEE__EEH_Template__powered_by_event_espresso__url',
1716
-                function ($url) {
1717
-                    return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1718
-                }
1719
-            );
1720
-            echo apply_filters(
1721
-                'FHEE__EE_Front_Controller__display_registration_footer',
1722
-                \EEH_Template::powered_by_event_espresso(
1723
-                    '',
1724
-                    'espresso-registration-footer-dv',
1725
-                    array('utm_content' => 'registration_checkout')
1726
-                )
1727
-            );
1728
-        }
1729
-        return '';
1730
-    }
1731
-
1732
-
1733
-
1734
-    /**
1735
-     *    unlock_transaction
1736
-     *
1737
-     * @access    public
1738
-     * @return    void
1739
-     * @throws EE_Error
1740
-     */
1741
-    public function unlock_transaction()
1742
-    {
1743
-        if ($this->checkout->transaction instanceof EE_Transaction) {
1744
-            $this->checkout->transaction->unlock();
1745
-        }
1746
-    }
1747
-
1748
-
1749
-
1750
-    /**
1751
-     *        _setup_redirect
1752
-     *
1753
-     * @access    private
1754
-     * @return void
1755
-     */
1756
-    private function _setup_redirect()
1757
-    {
1758
-        if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1759
-            $this->checkout->redirect = true;
1760
-            if (empty($this->checkout->redirect_url)) {
1761
-                $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1762
-            }
1763
-            $this->checkout->redirect_url = apply_filters(
1764
-                'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1765
-                $this->checkout->redirect_url,
1766
-                $this->checkout
1767
-            );
1768
-        }
1769
-    }
1770
-
1771
-
1772
-
1773
-    /**
1774
-     *   handle ajax message responses and redirects
1775
-     *
1776
-     * @access public
1777
-     * @return void
1778
-     * @throws EE_Error
1779
-     */
1780
-    public function go_to_next_step()
1781
-    {
1782
-        if (EE_Registry::instance()->REQ->ajax) {
1783
-            // capture contents of output buffer we started earlier in the request, and insert into JSON response
1784
-            $this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1785
-        }
1786
-        $this->unlock_transaction();
1787
-        // just return for these conditions
1788
-        if (
1789
-            $this->checkout->admin_request
1790
-            || $this->checkout->action === 'redirect_form'
1791
-            || $this->checkout->action === 'update_checkout'
1792
-        ) {
1793
-            return;
1794
-        }
1795
-        // AJAX response
1796
-        $this->_handle_json_response();
1797
-        // redirect to next step or the Thank You page
1798
-        $this->_handle_html_redirects();
1799
-        // hmmm... must be something wrong, so let's just display the form again !
1800
-        $this->_display_spco_reg_form();
1801
-    }
1802
-
1803
-
1804
-
1805
-    /**
1806
-     *   _handle_json_response
1807
-     *
1808
-     * @access protected
1809
-     * @return void
1810
-     */
1811
-    protected function _handle_json_response()
1812
-    {
1813
-        // if this is an ajax request
1814
-        if (EE_Registry::instance()->REQ->ajax) {
1815
-            // DEBUG LOG
1816
-            //$this->checkout->log(
1817
-            //	__CLASS__, __FUNCTION__, __LINE__,
1818
-            //	array(
1819
-            //		'json_response_redirect_url' => $this->checkout->json_response->redirect_url(),
1820
-            //		'redirect'                   => $this->checkout->redirect,
1821
-            //		'continue_reg'               => $this->checkout->continue_reg,
1822
-            //	)
1823
-            //);
1824
-            $this->checkout->json_response->set_registration_time_limit(
1825
-                $this->checkout->get_registration_time_limit()
1826
-            );
1827
-            $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1828
-            // just send the ajax (
1829
-            $json_response = apply_filters(
1830
-                'FHEE__EE_Single_Page_Checkout__JSON_response',
1831
-                $this->checkout->json_response
1832
-            );
1833
-            echo $json_response;
1834
-            exit();
1835
-        }
1836
-    }
1837
-
1838
-
1839
-
1840
-    /**
1841
-     *   _handle_redirects
1842
-     *
1843
-     * @access protected
1844
-     * @return void
1845
-     */
1846
-    protected function _handle_html_redirects()
1847
-    {
1848
-        // going somewhere ?
1849
-        if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1850
-            // store notices in a transient
1851
-            EE_Error::get_notices(false, true, true);
1852
-            // DEBUG LOG
1853
-            //$this->checkout->log(
1854
-            //	__CLASS__, __FUNCTION__, __LINE__,
1855
-            //	array(
1856
-            //		'headers_sent' => headers_sent(),
1857
-            //		'redirect_url'     => $this->checkout->redirect_url,
1858
-            //		'headers_list'    => headers_list(),
1859
-            //	)
1860
-            //);
1861
-            wp_safe_redirect($this->checkout->redirect_url);
1862
-            exit();
1863
-        }
1864
-    }
1865
-
1866
-
1867
-
1868
-    /**
1869
-     *   set_checkout_anchor
1870
-     *
1871
-     * @access public
1872
-     * @return void
1873
-     */
1874
-    public function set_checkout_anchor()
1875
-    {
1876
-        echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1877
-    }
23
+	/**
24
+	 * $_initialized - has the SPCO controller already been initialized ?
25
+	 *
26
+	 * @access private
27
+	 * @var bool $_initialized
28
+	 */
29
+	private static $_initialized = false;
30
+
31
+
32
+	/**
33
+	 * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
34
+	 *
35
+	 * @access private
36
+	 * @var bool $_valid_checkout
37
+	 */
38
+	private static $_checkout_verified = true;
39
+
40
+	/**
41
+	 *    $_reg_steps_array - holds initial array of reg steps
42
+	 *
43
+	 * @access private
44
+	 * @var array $_reg_steps_array
45
+	 */
46
+	private static $_reg_steps_array = array();
47
+
48
+	/**
49
+	 *    $checkout - EE_Checkout object for handling the properties of the current checkout process
50
+	 *
51
+	 * @access public
52
+	 * @var EE_Checkout $checkout
53
+	 */
54
+	public $checkout;
55
+
56
+
57
+
58
+	/**
59
+	 * @return EED_Module|EED_Single_Page_Checkout
60
+	 */
61
+	public static function instance()
62
+	{
63
+		add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
64
+		return parent::get_instance(__CLASS__);
65
+	}
66
+
67
+
68
+
69
+	/**
70
+	 * @return EE_CART
71
+	 */
72
+	public function cart()
73
+	{
74
+		return $this->checkout->cart;
75
+	}
76
+
77
+
78
+
79
+	/**
80
+	 * @return EE_Transaction
81
+	 */
82
+	public function transaction()
83
+	{
84
+		return $this->checkout->transaction;
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 *    set_hooks - for hooking into EE Core, other modules, etc
91
+	 *
92
+	 * @access    public
93
+	 * @return    void
94
+	 * @throws EE_Error
95
+	 */
96
+	public static function set_hooks()
97
+	{
98
+		EED_Single_Page_Checkout::set_definitions();
99
+	}
100
+
101
+
102
+
103
+	/**
104
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
105
+	 *
106
+	 * @access    public
107
+	 * @return    void
108
+	 * @throws EE_Error
109
+	 */
110
+	public static function set_hooks_admin()
111
+	{
112
+		EED_Single_Page_Checkout::set_definitions();
113
+		if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
114
+			return;
115
+		}
116
+		// going to start an output buffer in case anything gets accidentally output
117
+		// that might disrupt our JSON response
118
+		ob_start();
119
+		EED_Single_Page_Checkout::load_request_handler();
120
+		EED_Single_Page_Checkout::load_reg_steps();
121
+		// set ajax hooks
122
+		add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
123
+		add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
124
+		add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
125
+		add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
126
+		add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
127
+		add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 *    process ajax request
134
+	 *
135
+	 * @param string $ajax_action
136
+	 * @throws EE_Error
137
+	 */
138
+	public static function process_ajax_request($ajax_action)
139
+	{
140
+		EE_Registry::instance()->REQ->set('action', $ajax_action);
141
+		EED_Single_Page_Checkout::instance()->_initialize();
142
+	}
143
+
144
+
145
+
146
+	/**
147
+	 *    ajax display registration step
148
+	 *
149
+	 * @throws EE_Error
150
+	 */
151
+	public static function display_reg_step()
152
+	{
153
+		EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
154
+	}
155
+
156
+
157
+
158
+	/**
159
+	 *    ajax process registration step
160
+	 *
161
+	 * @throws EE_Error
162
+	 */
163
+	public static function process_reg_step()
164
+	{
165
+		EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
166
+	}
167
+
168
+
169
+
170
+	/**
171
+	 *    ajax process registration step
172
+	 *
173
+	 * @throws EE_Error
174
+	 */
175
+	public static function update_reg_step()
176
+	{
177
+		EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
178
+	}
179
+
180
+
181
+
182
+	/**
183
+	 *   update_checkout
184
+	 *
185
+	 * @access public
186
+	 * @return void
187
+	 * @throws EE_Error
188
+	 */
189
+	public static function update_checkout()
190
+	{
191
+		EED_Single_Page_Checkout::process_ajax_request('update_checkout');
192
+	}
193
+
194
+
195
+
196
+	/**
197
+	 *    load_request_handler
198
+	 *
199
+	 * @access    public
200
+	 * @return    void
201
+	 */
202
+	public static function load_request_handler()
203
+	{
204
+		// load core Request_Handler class
205
+		if (EE_Registry::instance()->REQ !== null) {
206
+			EE_Registry::instance()->load_core('Request_Handler');
207
+		}
208
+	}
209
+
210
+
211
+
212
+	/**
213
+	 *    set_definitions
214
+	 *
215
+	 * @access    public
216
+	 * @return    void
217
+	 * @throws EE_Error
218
+	 */
219
+	public static function set_definitions()
220
+	{
221
+		if(defined('SPCO_BASE_PATH')) {
222
+			return;
223
+		}
224
+		define(
225
+			'SPCO_BASE_PATH',
226
+			rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
227
+		);
228
+		define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
229
+		define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
230
+		define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
231
+		define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
232
+		define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
233
+		define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
234
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
235
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
236
+			__('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s',
237
+				'event_espresso'),
238
+			'<h4 class="important-notice">',
239
+			'</h4>',
240
+			'<br />',
241
+			'<p>',
242
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
243
+			'">',
244
+			'</a>',
245
+			'</p>'
246
+		);
247
+	}
248
+
249
+
250
+
251
+	/**
252
+	 * load_reg_steps
253
+	 * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
254
+	 *
255
+	 * @access    private
256
+	 * @throws EE_Error
257
+	 */
258
+	public static function load_reg_steps()
259
+	{
260
+		static $reg_steps_loaded = false;
261
+		if ($reg_steps_loaded) {
262
+			return;
263
+		}
264
+		// filter list of reg_steps
265
+		$reg_steps_to_load = (array)apply_filters(
266
+			'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
267
+			EED_Single_Page_Checkout::get_reg_steps()
268
+		);
269
+		// sort by key (order)
270
+		ksort($reg_steps_to_load);
271
+		// loop through folders
272
+		foreach ($reg_steps_to_load as $order => $reg_step) {
273
+			// we need a
274
+			if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
275
+				// copy over to the reg_steps_array
276
+				EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
277
+				// register custom key route for each reg step
278
+				// ie: step=>"slug" - this is the entire reason we load the reg steps array now
279
+				EE_Config::register_route(
280
+					$reg_step['slug'],
281
+					'EED_Single_Page_Checkout',
282
+					'run',
283
+					'step'
284
+				);
285
+				// add AJAX or other hooks
286
+				if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
287
+					// setup autoloaders if necessary
288
+					if ( ! class_exists($reg_step['class_name'])) {
289
+						EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
290
+							$reg_step['file_path'],
291
+							true
292
+						);
293
+					}
294
+					if (is_callable($reg_step['class_name'], 'set_hooks')) {
295
+						call_user_func(array($reg_step['class_name'], 'set_hooks'));
296
+					}
297
+				}
298
+			}
299
+		}
300
+		$reg_steps_loaded = true;
301
+	}
302
+
303
+
304
+
305
+	/**
306
+	 *    get_reg_steps
307
+	 *
308
+	 * @access    public
309
+	 * @return    array
310
+	 */
311
+	public static function get_reg_steps()
312
+	{
313
+		$reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
314
+		if (empty($reg_steps)) {
315
+			$reg_steps = array(
316
+				10  => array(
317
+					'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
318
+					'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
319
+					'slug'       => 'attendee_information',
320
+					'has_hooks'  => false,
321
+				),
322
+				20  => array(
323
+					'file_path'  => SPCO_REG_STEPS_PATH . 'registration_confirmation',
324
+					'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
325
+					'slug'       => 'registration_confirmation',
326
+					'has_hooks'  => false,
327
+				),
328
+				30  => array(
329
+					'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
330
+					'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
331
+					'slug'       => 'payment_options',
332
+					'has_hooks'  => true,
333
+				),
334
+				999 => array(
335
+					'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
336
+					'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
337
+					'slug'       => 'finalize_registration',
338
+					'has_hooks'  => false,
339
+				),
340
+			);
341
+		}
342
+		return $reg_steps;
343
+	}
344
+
345
+
346
+
347
+	/**
348
+	 *    registration_checkout_for_admin
349
+	 *
350
+	 * @access    public
351
+	 * @return    string
352
+	 * @throws EE_Error
353
+	 */
354
+	public static function registration_checkout_for_admin()
355
+	{
356
+		EED_Single_Page_Checkout::load_request_handler();
357
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
358
+		EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
359
+		EE_Registry::instance()->REQ->set('process_form_submission', false);
360
+		EED_Single_Page_Checkout::instance()->_initialize();
361
+		EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
362
+		return EE_Registry::instance()->REQ->get_output();
363
+	}
364
+
365
+
366
+
367
+	/**
368
+	 * process_registration_from_admin
369
+	 *
370
+	 * @access public
371
+	 * @return \EE_Transaction
372
+	 * @throws EE_Error
373
+	 */
374
+	public static function process_registration_from_admin()
375
+	{
376
+		EED_Single_Page_Checkout::load_request_handler();
377
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
378
+		EE_Registry::instance()->REQ->set('action', 'process_reg_step');
379
+		EE_Registry::instance()->REQ->set('process_form_submission', true);
380
+		EED_Single_Page_Checkout::instance()->_initialize();
381
+		if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
382
+			$final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
383
+			if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
384
+				EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
385
+				if ($final_reg_step->process_reg_step()) {
386
+					$final_reg_step->set_completed();
387
+					EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
388
+					return EED_Single_Page_Checkout::instance()->checkout->transaction;
389
+				}
390
+			}
391
+		}
392
+		return null;
393
+	}
394
+
395
+
396
+
397
+	/**
398
+	 *    run
399
+	 *
400
+	 * @access    public
401
+	 * @param WP_Query $WP_Query
402
+	 * @return    void
403
+	 * @throws EE_Error
404
+	 */
405
+	public function run($WP_Query)
406
+	{
407
+		if (
408
+			$WP_Query instanceof WP_Query
409
+			&& $WP_Query->is_main_query()
410
+			&& apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
411
+			&& $this->_is_reg_checkout()
412
+		) {
413
+			$this->_initialize();
414
+		}
415
+	}
416
+
417
+
418
+
419
+	/**
420
+	 * determines whether current url matches reg page url
421
+	 *
422
+	 * @return bool
423
+	 */
424
+	protected function _is_reg_checkout()
425
+	{
426
+		// get current permalink for reg page without any extra query args
427
+		$reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id);
428
+		// get request URI for current request, but without the scheme or host
429
+		$current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI');
430
+		$current_request_uri = html_entity_decode($current_request_uri);
431
+		// get array of query args from the current request URI
432
+		$query_args = \EEH_URL::get_query_string($current_request_uri);
433
+		// grab page id if it is set
434
+		$page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
435
+		// and remove the page id from the query args (we will re-add it later)
436
+		unset($query_args['page_id']);
437
+		// now strip all query args from current request URI
438
+		$current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri);
439
+		// and re-add the page id if it was set
440
+		if ($page_id) {
441
+			$current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
442
+		}
443
+		// remove slashes and ?
444
+		$current_request_uri = trim($current_request_uri, '?/');
445
+		// is current request URI part of the known full reg page URL ?
446
+		return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
447
+	}
448
+
449
+
450
+
451
+	/**
452
+	 * @param WP_Query $wp_query
453
+	 * @return    void
454
+	 * @throws EE_Error
455
+	 */
456
+	public static function init($wp_query)
457
+	{
458
+		EED_Single_Page_Checkout::instance()->run($wp_query);
459
+	}
460
+
461
+
462
+
463
+	/**
464
+	 *    _initialize - initial module setup
465
+	 *
466
+	 * @access    private
467
+	 * @throws EE_Error
468
+	 * @return    void
469
+	 */
470
+	private function _initialize()
471
+	{
472
+		// ensure SPCO doesn't run twice
473
+		if (EED_Single_Page_Checkout::$_initialized) {
474
+			return;
475
+		}
476
+		try {
477
+			EED_Single_Page_Checkout::load_reg_steps();
478
+			$this->_verify_session();
479
+			// setup the EE_Checkout object
480
+			$this->checkout = $this->_initialize_checkout();
481
+			// filter checkout
482
+			$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
483
+			// get the $_GET
484
+			$this->_get_request_vars();
485
+			if ($this->_block_bots()) {
486
+				return;
487
+			}
488
+			// filter continue_reg
489
+			$this->checkout->continue_reg = apply_filters(
490
+				'FHEE__EED_Single_Page_Checkout__init___continue_reg',
491
+				true,
492
+				$this->checkout
493
+			);
494
+			// load the reg steps array
495
+			if ( ! $this->_load_and_instantiate_reg_steps()) {
496
+				EED_Single_Page_Checkout::$_initialized = true;
497
+				return;
498
+			}
499
+			// set the current step
500
+			$this->checkout->set_current_step($this->checkout->step);
501
+			// and the next step
502
+			$this->checkout->set_next_step();
503
+			// verify that everything has been setup correctly
504
+			if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
505
+				EED_Single_Page_Checkout::$_initialized = true;
506
+				return;
507
+			}
508
+			// lock the transaction
509
+			$this->checkout->transaction->lock();
510
+			// make sure all of our cached objects are added to their respective model entity mappers
511
+			$this->checkout->refresh_all_entities();
512
+			// set amount owing
513
+			$this->checkout->amount_owing = $this->checkout->transaction->remaining();
514
+			// initialize each reg step, which gives them the chance to potentially alter the process
515
+			$this->_initialize_reg_steps();
516
+			// DEBUG LOG
517
+			//$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
518
+			// get reg form
519
+			if( ! $this->_check_form_submission()) {
520
+				EED_Single_Page_Checkout::$_initialized = true;
521
+				return;
522
+			}
523
+			// checkout the action!!!
524
+			$this->_process_form_action();
525
+			// add some style and make it dance
526
+			$this->add_styles_and_scripts();
527
+			// kk... SPCO has successfully run
528
+			EED_Single_Page_Checkout::$_initialized = true;
529
+			// set no cache headers and constants
530
+			EE_System::do_not_cache();
531
+			// add anchor
532
+			add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
533
+			// remove transaction lock
534
+			add_action('shutdown', array($this, 'unlock_transaction'), 1);
535
+		} catch (Exception $e) {
536
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
537
+		}
538
+	}
539
+
540
+
541
+
542
+	/**
543
+	 *    _verify_session
544
+	 * checks that the session is valid and not expired
545
+	 *
546
+	 * @access    private
547
+	 * @throws EE_Error
548
+	 */
549
+	private function _verify_session()
550
+	{
551
+		if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
552
+			throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso'));
553
+		}
554
+		$clear_session_requested = filter_var(
555
+			EE_Registry::instance()->REQ->get('clear_session', false),
556
+			FILTER_VALIDATE_BOOLEAN
557
+		);
558
+		// is session still valid ?
559
+		if ($clear_session_requested
560
+			|| ( EE_Registry::instance()->SSN->expired()
561
+			  && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === ''
562
+			)
563
+		) {
564
+			$this->checkout = new EE_Checkout();
565
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
566
+			// EE_Registry::instance()->SSN->reset_cart();
567
+			// EE_Registry::instance()->SSN->reset_checkout();
568
+			// EE_Registry::instance()->SSN->reset_transaction();
569
+			if (! $clear_session_requested) {
570
+				EE_Error::add_attention(
571
+					EE_Registry::$i18n_js_strings['registration_expiration_notice'],
572
+					__FILE__, __FUNCTION__, __LINE__
573
+				);
574
+			}
575
+			// EE_Registry::instance()->SSN->reset_expired();
576
+		}
577
+	}
578
+
579
+
580
+
581
+	/**
582
+	 *    _initialize_checkout
583
+	 * loads and instantiates EE_Checkout
584
+	 *
585
+	 * @access    private
586
+	 * @throws EE_Error
587
+	 * @return EE_Checkout
588
+	 */
589
+	private function _initialize_checkout()
590
+	{
591
+		// look in session for existing checkout
592
+		/** @type EE_Checkout $checkout */
593
+		$checkout = EE_Registry::instance()->SSN->checkout();
594
+		// verify
595
+		if ( ! $checkout instanceof EE_Checkout) {
596
+			// instantiate EE_Checkout object for handling the properties of the current checkout process
597
+			$checkout = EE_Registry::instance()->load_file(
598
+				SPCO_INC_PATH,
599
+				'EE_Checkout',
600
+				'class', array(),
601
+				false
602
+			);
603
+		} else {
604
+			if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
605
+				$this->unlock_transaction();
606
+				wp_safe_redirect($checkout->redirect_url);
607
+				exit();
608
+			}
609
+		}
610
+		$checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
611
+		// verify again
612
+		if ( ! $checkout instanceof EE_Checkout) {
613
+			throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
614
+		}
615
+		// reset anything that needs a clean slate for each request
616
+		$checkout->reset_for_current_request();
617
+		return $checkout;
618
+	}
619
+
620
+
621
+
622
+	/**
623
+	 *    _get_request_vars
624
+	 *
625
+	 * @access    private
626
+	 * @return    void
627
+	 * @throws EE_Error
628
+	 */
629
+	private function _get_request_vars()
630
+	{
631
+		// load classes
632
+		EED_Single_Page_Checkout::load_request_handler();
633
+		//make sure this request is marked as belonging to EE
634
+		EE_Registry::instance()->REQ->set_espresso_page(true);
635
+		// which step is being requested ?
636
+		$this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
637
+		// which step is being edited ?
638
+		$this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
639
+		// and what we're doing on the current step
640
+		$this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
641
+		// timestamp
642
+		$this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0);
643
+		// returning to edit ?
644
+		$this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
645
+		// or some other kind of revisit ?
646
+		$this->checkout->revisit = filter_var(
647
+			EE_Registry::instance()->REQ->get('revisit', false),
648
+			FILTER_VALIDATE_BOOLEAN
649
+		);
650
+		// and whether or not to generate a reg form for this request
651
+		$this->checkout->generate_reg_form = filter_var(
652
+			EE_Registry::instance()->REQ->get('generate_reg_form', true),
653
+			FILTER_VALIDATE_BOOLEAN
654
+		);
655
+		// and whether or not to process a reg form submission for this request
656
+		$this->checkout->process_form_submission = filter_var(
657
+			EE_Registry::instance()->REQ->get(
658
+				'process_form_submission',
659
+				$this->checkout->action === 'process_reg_step'
660
+			),
661
+			FILTER_VALIDATE_BOOLEAN
662
+		);
663
+		$this->checkout->process_form_submission = filter_var(
664
+			$this->checkout->action !== 'display_spco_reg_step'
665
+				? $this->checkout->process_form_submission
666
+				: false,
667
+			FILTER_VALIDATE_BOOLEAN
668
+		);
669
+		// $this->_display_request_vars();
670
+	}
671
+
672
+
673
+
674
+	/**
675
+	 *  _display_request_vars
676
+	 *
677
+	 * @access    protected
678
+	 * @return    void
679
+	 */
680
+	protected function _display_request_vars()
681
+	{
682
+		if ( ! WP_DEBUG) {
683
+			return;
684
+		}
685
+		EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
686
+		EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
687
+		EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
688
+		EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
689
+		EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
690
+		EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
691
+		EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
692
+		EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
693
+	}
694
+
695
+
696
+
697
+	/**
698
+	 * _block_bots
699
+	 * checks that the incoming request has either of the following set:
700
+	 *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
701
+	 *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
702
+	 * so if you're not coming from the Ticket Selector nor returning for a valid IP...
703
+	 * then where you coming from man?
704
+	 *
705
+	 * @return boolean
706
+	 */
707
+	private function _block_bots()
708
+	{
709
+		$invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
710
+		if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
711
+			return true;
712
+		}
713
+		return false;
714
+	}
715
+
716
+
717
+
718
+	/**
719
+	 *    _get_first_step
720
+	 *  gets slug for first step in $_reg_steps_array
721
+	 *
722
+	 * @access    private
723
+	 * @throws EE_Error
724
+	 * @return    string
725
+	 */
726
+	private function _get_first_step()
727
+	{
728
+		$first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
729
+		return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
730
+	}
731
+
732
+
733
+
734
+	/**
735
+	 *    _load_and_instantiate_reg_steps
736
+	 *  instantiates each reg step based on the loaded reg_steps array
737
+	 *
738
+	 * @access    private
739
+	 * @throws EE_Error
740
+	 * @return    bool
741
+	 */
742
+	private function _load_and_instantiate_reg_steps()
743
+	{
744
+		do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout);
745
+		// have reg_steps already been instantiated ?
746
+		if (
747
+			empty($this->checkout->reg_steps)
748
+			|| apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
749
+		) {
750
+			// if not, then loop through raw reg steps array
751
+			foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
752
+				if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
753
+					return false;
754
+				}
755
+			}
756
+			EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true;
757
+			EE_Registry::instance()->CFG->registration->reg_confirmation_last = true;
758
+			// skip the registration_confirmation page ?
759
+			if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
760
+				// just remove it from the reg steps array
761
+				$this->checkout->remove_reg_step('registration_confirmation', false);
762
+			} else if (
763
+				isset($this->checkout->reg_steps['registration_confirmation'])
764
+				&& EE_Registry::instance()->CFG->registration->reg_confirmation_last
765
+			) {
766
+				// set the order to something big like 100
767
+				$this->checkout->set_reg_step_order('registration_confirmation', 100);
768
+			}
769
+			// filter the array for good luck
770
+			$this->checkout->reg_steps = apply_filters(
771
+				'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps',
772
+				$this->checkout->reg_steps
773
+			);
774
+			// finally re-sort based on the reg step class order properties
775
+			$this->checkout->sort_reg_steps();
776
+		} else {
777
+			foreach ($this->checkout->reg_steps as $reg_step) {
778
+				// set all current step stati to FALSE
779
+				$reg_step->set_is_current_step(false);
780
+			}
781
+		}
782
+		if (empty($this->checkout->reg_steps)) {
783
+			EE_Error::add_error(
784
+				__('No Reg Steps were loaded..', 'event_espresso'),
785
+				__FILE__, __FUNCTION__, __LINE__
786
+			);
787
+			return false;
788
+		}
789
+		// make reg step details available to JS
790
+		$this->checkout->set_reg_step_JSON_info();
791
+		return true;
792
+	}
793
+
794
+
795
+
796
+	/**
797
+	 *     _load_and_instantiate_reg_step
798
+	 *
799
+	 * @access    private
800
+	 * @param array $reg_step
801
+	 * @param int   $order
802
+	 * @return bool
803
+	 */
804
+	private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
805
+	{
806
+		// we need a file_path, class_name, and slug to add a reg step
807
+		if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
808
+			// if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
809
+			if (
810
+				$this->checkout->reg_url_link
811
+				&& $this->checkout->step !== $reg_step['slug']
812
+				&& $reg_step['slug'] !== 'finalize_registration'
813
+				// normally at this point we would NOT load the reg step, but this filter can change that
814
+				&& apply_filters(
815
+					'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step',
816
+					true,
817
+					$reg_step,
818
+					$this->checkout
819
+				)
820
+			) {
821
+				return true;
822
+			}
823
+			// instantiate step class using file path and class name
824
+			$reg_step_obj = EE_Registry::instance()->load_file(
825
+				$reg_step['file_path'],
826
+				$reg_step['class_name'],
827
+				'class',
828
+				$this->checkout,
829
+				false
830
+			);
831
+			// did we gets the goods ?
832
+			if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
833
+				// set reg step order based on config
834
+				$reg_step_obj->set_order($order);
835
+				// add instantiated reg step object to the master reg steps array
836
+				$this->checkout->add_reg_step($reg_step_obj);
837
+			} else {
838
+				EE_Error::add_error(
839
+					__('The current step could not be set.', 'event_espresso'),
840
+					__FILE__, __FUNCTION__, __LINE__
841
+				);
842
+				return false;
843
+			}
844
+		} else {
845
+			if (WP_DEBUG) {
846
+				EE_Error::add_error(
847
+					sprintf(
848
+						__(
849
+							'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s',
850
+							'event_espresso'
851
+						),
852
+						isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
853
+						isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
854
+						isset($reg_step['slug']) ? $reg_step['slug'] : '',
855
+						'<ul>',
856
+						'<li>',
857
+						'</li>',
858
+						'</ul>'
859
+					),
860
+					__FILE__, __FUNCTION__, __LINE__
861
+				);
862
+			}
863
+			return false;
864
+		}
865
+		return true;
866
+	}
867
+
868
+
869
+	/**
870
+	 * _verify_transaction_and_get_registrations
871
+	 *
872
+	 * @access private
873
+	 * @return bool
874
+	 * @throws InvalidDataTypeException
875
+	 * @throws InvalidEntityException
876
+	 * @throws EE_Error
877
+	 */
878
+	private function _verify_transaction_and_get_registrations()
879
+	{
880
+		// was there already a valid transaction in the checkout from the session ?
881
+		if ( ! $this->checkout->transaction instanceof EE_Transaction) {
882
+			// get transaction from db or session
883
+			$this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
884
+				? $this->_get_transaction_and_cart_for_previous_visit()
885
+				: $this->_get_cart_for_current_session_and_setup_new_transaction();
886
+			if ( ! $this->checkout->transaction instanceof EE_Transaction) {
887
+				EE_Error::add_error(
888
+					__('Your Registration and Transaction information could not be retrieved from the db.',
889
+						'event_espresso'),
890
+					__FILE__, __FUNCTION__, __LINE__
891
+				);
892
+				$this->checkout->transaction = EE_Transaction::new_instance();
893
+				// add some style and make it dance
894
+				$this->add_styles_and_scripts();
895
+				EED_Single_Page_Checkout::$_initialized = true;
896
+				return false;
897
+			}
898
+			// and the registrations for the transaction
899
+			$this->_get_registrations($this->checkout->transaction);
900
+		}
901
+		return true;
902
+	}
903
+
904
+
905
+
906
+	/**
907
+	 * _get_transaction_and_cart_for_previous_visit
908
+	 *
909
+	 * @access private
910
+	 * @return mixed EE_Transaction|NULL
911
+	 */
912
+	private function _get_transaction_and_cart_for_previous_visit()
913
+	{
914
+		/** @var $TXN_model EEM_Transaction */
915
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
916
+		// because the reg_url_link is present in the request,
917
+		// this is a return visit to SPCO, so we'll get the transaction data from the db
918
+		$transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
919
+		// verify transaction
920
+		if ($transaction instanceof EE_Transaction) {
921
+			// and get the cart that was used for that transaction
922
+			$this->checkout->cart = $this->_get_cart_for_transaction($transaction);
923
+			return $transaction;
924
+		}
925
+		EE_Error::add_error(
926
+			__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
927
+			__FILE__, __FUNCTION__, __LINE__
928
+		);
929
+		return null;
930
+
931
+	}
932
+
933
+
934
+
935
+	/**
936
+	 * _get_cart_for_transaction
937
+	 *
938
+	 * @access private
939
+	 * @param EE_Transaction $transaction
940
+	 * @return EE_Cart
941
+	 */
942
+	private function _get_cart_for_transaction($transaction)
943
+	{
944
+		return $this->checkout->get_cart_for_transaction($transaction);
945
+	}
946
+
947
+
948
+
949
+	/**
950
+	 * get_cart_for_transaction
951
+	 *
952
+	 * @access public
953
+	 * @param EE_Transaction $transaction
954
+	 * @return EE_Cart
955
+	 */
956
+	public function get_cart_for_transaction(EE_Transaction $transaction)
957
+	{
958
+		return $this->checkout->get_cart_for_transaction($transaction);
959
+	}
960
+
961
+
962
+
963
+	/**
964
+	 * _get_transaction_and_cart_for_current_session
965
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
966
+	 *
967
+	 * @access private
968
+	 * @return EE_Transaction
969
+	 * @throws EE_Error
970
+	 */
971
+	private function _get_cart_for_current_session_and_setup_new_transaction()
972
+	{
973
+		//  if there's no transaction, then this is the FIRST visit to SPCO
974
+		// so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
975
+		$this->checkout->cart = $this->_get_cart_for_transaction(null);
976
+		// and then create a new transaction
977
+		$transaction = $this->_initialize_transaction();
978
+		// verify transaction
979
+		if ($transaction instanceof EE_Transaction) {
980
+			// save it so that we have an ID for other objects to use
981
+			$transaction->save();
982
+			// and save TXN data to the cart
983
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
984
+		} else {
985
+			EE_Error::add_error(
986
+				__('A Valid Transaction could not be initialized.', 'event_espresso'),
987
+				__FILE__, __FUNCTION__, __LINE__
988
+			);
989
+		}
990
+		return $transaction;
991
+	}
992
+
993
+
994
+
995
+	/**
996
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
997
+	 *
998
+	 * @access private
999
+	 * @return mixed EE_Transaction|NULL
1000
+	 */
1001
+	private function _initialize_transaction()
1002
+	{
1003
+		try {
1004
+			// ensure cart totals have been calculated
1005
+			$this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
1006
+			// grab the cart grand total
1007
+			$cart_total = $this->checkout->cart->get_cart_grand_total();
1008
+			// create new TXN
1009
+			$transaction = EE_Transaction::new_instance(
1010
+				array(
1011
+					'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
1012
+					'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
1013
+					'TXN_paid'      => 0,
1014
+					'STS_ID'        => EEM_Transaction::failed_status_code,
1015
+				)
1016
+			);
1017
+			// save it so that we have an ID for other objects to use
1018
+			$transaction->save();
1019
+			// set cron job for following up on TXNs after their session has expired
1020
+			EE_Cron_Tasks::schedule_expired_transaction_check(
1021
+				EE_Registry::instance()->SSN->expiration() + 1,
1022
+				$transaction->ID()
1023
+			);
1024
+			return $transaction;
1025
+		} catch (Exception $e) {
1026
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1027
+		}
1028
+		return null;
1029
+	}
1030
+
1031
+
1032
+	/**
1033
+	 * _get_registrations
1034
+	 *
1035
+	 * @access private
1036
+	 * @param EE_Transaction $transaction
1037
+	 * @return void
1038
+	 * @throws InvalidDataTypeException
1039
+	 * @throws InvalidEntityException
1040
+	 * @throws EE_Error
1041
+	 */
1042
+	private function _get_registrations(EE_Transaction $transaction)
1043
+	{
1044
+		// first step: grab the registrants  { : o
1045
+		$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true);
1046
+		// verify registrations have been set
1047
+		if (empty($registrations)) {
1048
+			// if no cached registrations, then check the db
1049
+			$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1050
+			// still nothing ? well as long as this isn't a revisit
1051
+			if (empty($registrations) && ! $this->checkout->revisit) {
1052
+				// generate new registrations from scratch
1053
+				$registrations = $this->_initialize_registrations($transaction);
1054
+			}
1055
+		}
1056
+		// sort by their original registration order
1057
+		usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1058
+		// then loop thru the array
1059
+		foreach ($registrations as $registration) {
1060
+			// verify each registration
1061
+			if ($registration instanceof EE_Registration) {
1062
+				// we display all attendee info for the primary registrant
1063
+				if ($this->checkout->reg_url_link === $registration->reg_url_link()
1064
+					&& $registration->is_primary_registrant()
1065
+				) {
1066
+					$this->checkout->primary_revisit = true;
1067
+					break;
1068
+				}
1069
+				if ($this->checkout->revisit
1070
+						   && $this->checkout->reg_url_link !== $registration->reg_url_link()
1071
+				) {
1072
+					// but hide info if it doesn't belong to you
1073
+					$transaction->clear_cache('Registration', $registration->ID());
1074
+				}
1075
+				$this->checkout->set_reg_status_updated($registration->ID(), false);
1076
+			}
1077
+		}
1078
+	}
1079
+
1080
+
1081
+	/**
1082
+	 *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1083
+	 *
1084
+	 * @access private
1085
+	 * @param EE_Transaction $transaction
1086
+	 * @return    array
1087
+	 * @throws InvalidDataTypeException
1088
+	 * @throws InvalidEntityException
1089
+	 * @throws EE_Error
1090
+	 */
1091
+	private function _initialize_registrations(EE_Transaction $transaction)
1092
+	{
1093
+		$att_nmbr = 0;
1094
+		$registrations = array();
1095
+		if ($transaction instanceof EE_Transaction) {
1096
+			/** @type EE_Registration_Processor $registration_processor */
1097
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1098
+			$this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1099
+			// now let's add the cart items to the $transaction
1100
+			foreach ($this->checkout->cart->get_tickets() as $line_item) {
1101
+				//do the following for each ticket of this type they selected
1102
+				for ($x = 1; $x <= $line_item->quantity(); $x++) {
1103
+					$att_nmbr++;
1104
+					/** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
1105
+					$CreateRegistrationCommand = EE_Registry::instance()->create(
1106
+						'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1107
+						array(
1108
+							$transaction,
1109
+							$line_item,
1110
+							$att_nmbr,
1111
+							$this->checkout->total_ticket_count,
1112
+						)
1113
+					);
1114
+					// override capabilities for frontend registrations
1115
+					if ( ! is_admin()) {
1116
+						$CreateRegistrationCommand->setCapCheck(
1117
+							new PublicCapabilities('', 'create_new_registration')
1118
+						);
1119
+					}
1120
+					$registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1121
+					if ( ! $registration instanceof EE_Registration) {
1122
+						throw new InvalidEntityException($registration, 'EE_Registration');
1123
+					}
1124
+					$registrations[ $registration->ID() ] = $registration;
1125
+				}
1126
+			}
1127
+			$registration_processor->fix_reg_final_price_rounding_issue($transaction);
1128
+		}
1129
+		return $registrations;
1130
+	}
1131
+
1132
+
1133
+
1134
+	/**
1135
+	 * sorts registrations by REG_count
1136
+	 *
1137
+	 * @access public
1138
+	 * @param EE_Registration $reg_A
1139
+	 * @param EE_Registration $reg_B
1140
+	 * @return int
1141
+	 */
1142
+	public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1143
+	{
1144
+		// this shouldn't ever happen within the same TXN, but oh well
1145
+		if ($reg_A->count() === $reg_B->count()) {
1146
+			return 0;
1147
+		}
1148
+		return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1149
+	}
1150
+
1151
+
1152
+
1153
+	/**
1154
+	 *    _final_verifications
1155
+	 * just makes sure that everything is set up correctly before proceeding
1156
+	 *
1157
+	 * @access    private
1158
+	 * @return    bool
1159
+	 * @throws EE_Error
1160
+	 */
1161
+	private function _final_verifications()
1162
+	{
1163
+		// filter checkout
1164
+		$this->checkout = apply_filters(
1165
+			'FHEE__EED_Single_Page_Checkout___final_verifications__checkout',
1166
+			$this->checkout
1167
+		);
1168
+		//verify that current step is still set correctly
1169
+		if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1170
+			EE_Error::add_error(
1171
+				__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'),
1172
+				__FILE__,
1173
+				__FUNCTION__,
1174
+				__LINE__
1175
+			);
1176
+			return false;
1177
+		}
1178
+		// if returning to SPCO, then verify that primary registrant is set
1179
+		if ( ! empty($this->checkout->reg_url_link)) {
1180
+			$valid_registrant = $this->checkout->transaction->primary_registration();
1181
+			if ( ! $valid_registrant instanceof EE_Registration) {
1182
+				EE_Error::add_error(
1183
+					__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'),
1184
+					__FILE__,
1185
+					__FUNCTION__,
1186
+					__LINE__
1187
+				);
1188
+				return false;
1189
+			}
1190
+			$valid_registrant = null;
1191
+			foreach (
1192
+				$this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration
1193
+			) {
1194
+				if (
1195
+					$registration instanceof EE_Registration
1196
+					&& $registration->reg_url_link() === $this->checkout->reg_url_link
1197
+				) {
1198
+					$valid_registrant = $registration;
1199
+				}
1200
+			}
1201
+			if ( ! $valid_registrant instanceof EE_Registration) {
1202
+				// hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1203
+				if (EED_Single_Page_Checkout::$_checkout_verified) {
1204
+					// clear the session, mark the checkout as unverified, and try again
1205
+					EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1206
+					EED_Single_Page_Checkout::$_initialized = false;
1207
+					EED_Single_Page_Checkout::$_checkout_verified = false;
1208
+					$this->_initialize();
1209
+					EE_Error::reset_notices();
1210
+					return false;
1211
+				}
1212
+				EE_Error::add_error(
1213
+					__(
1214
+						'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.',
1215
+						'event_espresso'
1216
+					),
1217
+					__FILE__,
1218
+					__FUNCTION__,
1219
+					__LINE__
1220
+				);
1221
+				return false;
1222
+			}
1223
+		}
1224
+		// now that things have been kinda sufficiently verified,
1225
+		// let's add the checkout to the session so that it's available to other systems
1226
+		EE_Registry::instance()->SSN->set_checkout($this->checkout);
1227
+		return true;
1228
+	}
1229
+
1230
+
1231
+
1232
+	/**
1233
+	 *    _initialize_reg_steps
1234
+	 * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1235
+	 * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1236
+	 *
1237
+	 * @access    private
1238
+	 * @param bool $reinitializing
1239
+	 * @throws EE_Error
1240
+	 */
1241
+	private function _initialize_reg_steps($reinitializing = false)
1242
+	{
1243
+		$this->checkout->set_reg_step_initiated($this->checkout->current_step);
1244
+		// loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1245
+		foreach ($this->checkout->reg_steps as $reg_step) {
1246
+			if ( ! $reg_step->initialize_reg_step()) {
1247
+				// if not initialized then maybe this step is being removed...
1248
+				if ( ! $reinitializing && $reg_step->is_current_step()) {
1249
+					// if it was the current step, then we need to start over here
1250
+					$this->_initialize_reg_steps(true);
1251
+					return;
1252
+				}
1253
+				continue;
1254
+			}
1255
+			// add css and JS for current step
1256
+			$reg_step->enqueue_styles_and_scripts();
1257
+			// i18n
1258
+			$reg_step->translate_js_strings();
1259
+			if ($reg_step->is_current_step()) {
1260
+				// the text that appears on the reg step form submit button
1261
+				$reg_step->set_submit_button_text();
1262
+			}
1263
+		}
1264
+		// dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1265
+		do_action(
1266
+			"AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}",
1267
+			$this->checkout->current_step
1268
+		);
1269
+	}
1270
+
1271
+
1272
+
1273
+	/**
1274
+	 * _check_form_submission
1275
+	 *
1276
+	 * @access private
1277
+	 * @return boolean
1278
+	 */
1279
+	private function _check_form_submission()
1280
+	{
1281
+		//does this request require the reg form to be generated ?
1282
+		if ($this->checkout->generate_reg_form) {
1283
+			// ever heard that song by Blue Rodeo ?
1284
+			try {
1285
+				$this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1286
+				// if not displaying a form, then check for form submission
1287
+				if (
1288
+					$this->checkout->process_form_submission
1289
+					&& $this->checkout->current_step->reg_form->was_submitted()
1290
+				) {
1291
+					// clear out any old data in case this step is being run again
1292
+					$this->checkout->current_step->set_valid_data(array());
1293
+					// capture submitted form data
1294
+					$this->checkout->current_step->reg_form->receive_form_submission(
1295
+						apply_filters(
1296
+							'FHEE__Single_Page_Checkout___check_form_submission__request_params',
1297
+							EE_Registry::instance()->REQ->params(),
1298
+							$this->checkout
1299
+						)
1300
+					);
1301
+					// validate submitted form data
1302
+					if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1303
+						// thou shall not pass !!!
1304
+						$this->checkout->continue_reg = false;
1305
+						// any form validation errors?
1306
+						if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1307
+							$submission_error_messages = array();
1308
+							// bad, bad, bad registrant
1309
+							foreach (
1310
+								$this->checkout->current_step->reg_form->get_validation_errors_accumulated()
1311
+								as $validation_error
1312
+							) {
1313
+								if ($validation_error instanceof EE_Validation_Error) {
1314
+									$submission_error_messages[] = sprintf(
1315
+										__('%s : %s', 'event_espresso'),
1316
+										$validation_error->get_form_section()->html_label_text(),
1317
+										$validation_error->getMessage()
1318
+									);
1319
+								}
1320
+							}
1321
+							EE_Error::add_error(
1322
+								implode('<br />', $submission_error_messages),
1323
+								__FILE__, __FUNCTION__, __LINE__
1324
+							);
1325
+						}
1326
+						// well not really... what will happen is
1327
+						// we'll just get redirected back to redo the current step
1328
+						$this->go_to_next_step();
1329
+						return false;
1330
+					}
1331
+				}
1332
+			} catch (EE_Error $e) {
1333
+				$e->get_error();
1334
+			}
1335
+		}
1336
+		return true;
1337
+	}
1338
+
1339
+
1340
+
1341
+	/**
1342
+	 * _process_action
1343
+	 *
1344
+	 * @access private
1345
+	 * @return void
1346
+	 * @throws EE_Error
1347
+	 */
1348
+	private function _process_form_action()
1349
+	{
1350
+		// what cha wanna do?
1351
+		switch ($this->checkout->action) {
1352
+			// AJAX next step reg form
1353
+			case 'display_spco_reg_step' :
1354
+				$this->checkout->redirect = false;
1355
+				if (EE_Registry::instance()->REQ->ajax) {
1356
+					$this->checkout->json_response->set_reg_step_html(
1357
+						$this->checkout->current_step->display_reg_form()
1358
+					);
1359
+				}
1360
+				break;
1361
+			default :
1362
+				// meh... do one of those other steps first
1363
+				if (
1364
+					! empty($this->checkout->action)
1365
+					&& is_callable(array($this->checkout->current_step, $this->checkout->action))
1366
+				) {
1367
+					// dynamically creates hook point like:
1368
+					//   AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1369
+					do_action(
1370
+						"AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1371
+						$this->checkout->current_step
1372
+					);
1373
+					// call action on current step
1374
+					if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1375
+						// good registrant, you get to proceed
1376
+						if (
1377
+							$this->checkout->current_step->success_message() !== ''
1378
+							&& apply_filters(
1379
+								'FHEE__Single_Page_Checkout___process_form_action__display_success',
1380
+								false
1381
+							)
1382
+						) {
1383
+							EE_Error::add_success(
1384
+								$this->checkout->current_step->success_message()
1385
+								. '<br />' . $this->checkout->next_step->_instructions()
1386
+							);
1387
+						}
1388
+						// pack it up, pack it in...
1389
+						$this->_setup_redirect();
1390
+					}
1391
+					// dynamically creates hook point like:
1392
+					//  AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1393
+					do_action(
1394
+						"AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1395
+						$this->checkout->current_step
1396
+					);
1397
+				} else {
1398
+					EE_Error::add_error(
1399
+						sprintf(
1400
+							__(
1401
+								'The requested form action "%s" does not exist for the current "%s" registration step.',
1402
+								'event_espresso'
1403
+							),
1404
+							$this->checkout->action,
1405
+							$this->checkout->current_step->name()
1406
+						),
1407
+						__FILE__,
1408
+						__FUNCTION__,
1409
+						__LINE__
1410
+					);
1411
+				}
1412
+			// end default
1413
+		}
1414
+		// store our progress so far
1415
+		$this->checkout->stash_transaction_and_checkout();
1416
+		// advance to the next step! If you pass GO, collect $200
1417
+		$this->go_to_next_step();
1418
+	}
1419
+
1420
+
1421
+
1422
+	/**
1423
+	 *        add_styles_and_scripts
1424
+	 *
1425
+	 * @access        public
1426
+	 * @return        void
1427
+	 */
1428
+	public function add_styles_and_scripts()
1429
+	{
1430
+		// i18n
1431
+		$this->translate_js_strings();
1432
+		if ($this->checkout->admin_request) {
1433
+			add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1434
+		} else {
1435
+			add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1436
+		}
1437
+	}
1438
+
1439
+
1440
+
1441
+	/**
1442
+	 *        translate_js_strings
1443
+	 *
1444
+	 * @access        public
1445
+	 * @return        void
1446
+	 */
1447
+	public function translate_js_strings()
1448
+	{
1449
+		EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1450
+		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1451
+		EE_Registry::$i18n_js_strings['server_error'] = __(
1452
+			'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
1453
+			'event_espresso'
1454
+		);
1455
+		EE_Registry::$i18n_js_strings['invalid_json_response'] = __(
1456
+			'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.',
1457
+			'event_espresso'
1458
+		);
1459
+		EE_Registry::$i18n_js_strings['validation_error'] = __(
1460
+			'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.',
1461
+			'event_espresso'
1462
+		);
1463
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __(
1464
+			'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.',
1465
+			'event_espresso'
1466
+		);
1467
+		EE_Registry::$i18n_js_strings['reg_step_error'] = __(
1468
+			'This registration step could not be completed. Please refresh the page and try again.',
1469
+			'event_espresso'
1470
+		);
1471
+		EE_Registry::$i18n_js_strings['invalid_coupon'] = __(
1472
+			'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.',
1473
+			'event_espresso'
1474
+		);
1475
+		EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1476
+			__(
1477
+				'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.',
1478
+				'event_espresso'
1479
+			),
1480
+			'<br/>',
1481
+			'<br/>'
1482
+		);
1483
+		EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1484
+		EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1485
+		EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1486
+		EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1487
+		EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1488
+		EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1489
+		EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1490
+		EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1491
+		EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1492
+		EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1493
+		EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1494
+		EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1495
+		EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1496
+		EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1497
+		EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1498
+		EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1499
+		EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1500
+		EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1501
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
1502
+			__(
1503
+				'%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s',
1504
+				'event_espresso'
1505
+			),
1506
+			'<h4 class="important-notice">',
1507
+			'</h4>',
1508
+			'<br />',
1509
+			'<p>',
1510
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1511
+			'">',
1512
+			'</a>',
1513
+			'</p>'
1514
+		);
1515
+		EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters(
1516
+			'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
1517
+			true
1518
+		);
1519
+		EE_Registry::$i18n_js_strings['session_extension'] = absint(
1520
+			apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1521
+		);
1522
+		EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1523
+			'M d, Y H:i:s',
1524
+			EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1525
+		);
1526
+	}
1527
+
1528
+
1529
+
1530
+	/**
1531
+	 *    enqueue_styles_and_scripts
1532
+	 *
1533
+	 * @access        public
1534
+	 * @return        void
1535
+	 * @throws EE_Error
1536
+	 */
1537
+	public function enqueue_styles_and_scripts()
1538
+	{
1539
+		// load css
1540
+		wp_register_style(
1541
+			'single_page_checkout',
1542
+			SPCO_CSS_URL . 'single_page_checkout.css',
1543
+			array('espresso_default'),
1544
+			EVENT_ESPRESSO_VERSION
1545
+		);
1546
+		wp_enqueue_style('single_page_checkout');
1547
+		// load JS
1548
+		wp_register_script(
1549
+			'jquery_plugin',
1550
+			EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1551
+			array('jquery'),
1552
+			'1.0.1',
1553
+			true
1554
+		);
1555
+		wp_register_script(
1556
+			'jquery_countdown',
1557
+			EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1558
+			array('jquery_plugin'),
1559
+			'2.0.2',
1560
+			true
1561
+		);
1562
+		wp_register_script(
1563
+			'single_page_checkout',
1564
+			SPCO_JS_URL . 'single_page_checkout.js',
1565
+			array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'),
1566
+			EVENT_ESPRESSO_VERSION,
1567
+			true
1568
+		);
1569
+		if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1570
+			$this->checkout->registration_form->enqueue_js();
1571
+		}
1572
+		if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1573
+			$this->checkout->current_step->reg_form->enqueue_js();
1574
+		}
1575
+		wp_enqueue_script('single_page_checkout');
1576
+		/**
1577
+		 * global action hook for enqueueing styles and scripts with
1578
+		 * spco calls.
1579
+		 */
1580
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1581
+		/**
1582
+		 * dynamic action hook for enqueueing styles and scripts with spco calls.
1583
+		 * The hook will end up being something like:
1584
+		 *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1585
+		 */
1586
+		do_action(
1587
+			'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1588
+			$this
1589
+		);
1590
+	}
1591
+
1592
+
1593
+
1594
+	/**
1595
+	 *    display the Registration Single Page Checkout Form
1596
+	 *
1597
+	 * @access    private
1598
+	 * @return    void
1599
+	 * @throws EE_Error
1600
+	 */
1601
+	private function _display_spco_reg_form()
1602
+	{
1603
+		// if registering via the admin, just display the reg form for the current step
1604
+		if ($this->checkout->admin_request) {
1605
+			EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1606
+		} else {
1607
+			// add powered by EE msg
1608
+			add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1609
+			$empty_cart = count(
1610
+				$this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)
1611
+			) < 1;
1612
+			EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1613
+			$cookies_not_set_msg = '';
1614
+			if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) {
1615
+				$cookies_not_set_msg = apply_filters(
1616
+					'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1617
+					sprintf(
1618
+						__(
1619
+							'%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s',
1620
+							'event_espresso'
1621
+						),
1622
+						'<div class="ee-attention">',
1623
+						'</div>',
1624
+						'<h6 class="important-notice">',
1625
+						'</h6>',
1626
+						'<p>',
1627
+						'</p>',
1628
+						'<br />',
1629
+						'<a href="http://www.whatarecookies.com/enable.asp" target="_blank">',
1630
+						'</a>'
1631
+					)
1632
+				);
1633
+			}
1634
+			$this->checkout->registration_form = new EE_Form_Section_Proper(
1635
+				array(
1636
+					'name'            => 'single-page-checkout',
1637
+					'html_id'         => 'ee-single-page-checkout-dv',
1638
+					'layout_strategy' =>
1639
+						new EE_Template_Layout(
1640
+							array(
1641
+								'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1642
+								'template_args'        => array(
1643
+									'empty_cart'              => $empty_cart,
1644
+									'revisit'                 => $this->checkout->revisit,
1645
+									'reg_steps'               => $this->checkout->reg_steps,
1646
+									'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1647
+										? $this->checkout->next_step->slug()
1648
+										: '',
1649
+									'cancel_page_url'         => $this->checkout->cancel_page_url,
1650
+									'empty_msg'               => apply_filters(
1651
+										'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1652
+										sprintf(
1653
+											__(
1654
+												'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1655
+												'event_espresso'
1656
+											),
1657
+											'<a href="'
1658
+											. get_post_type_archive_link('espresso_events')
1659
+											. '" title="',
1660
+											'">',
1661
+											'</a>'
1662
+										)
1663
+									),
1664
+									'cookies_not_set_msg'     => $cookies_not_set_msg,
1665
+									'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1666
+									'session_expiration'      => gmdate(
1667
+										'M d, Y H:i:s',
1668
+										EE_Registry::instance()->SSN->expiration()
1669
+										+ (get_option('gmt_offset') * HOUR_IN_SECONDS)
1670
+									),
1671
+								),
1672
+							)
1673
+						),
1674
+				)
1675
+			);
1676
+			// load template and add to output sent that gets filtered into the_content()
1677
+			EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html());
1678
+		}
1679
+	}
1680
+
1681
+
1682
+
1683
+	/**
1684
+	 *    add_extra_finalize_registration_inputs
1685
+	 *
1686
+	 * @access    public
1687
+	 * @param $next_step
1688
+	 * @internal  param string $label
1689
+	 * @return void
1690
+	 */
1691
+	public function add_extra_finalize_registration_inputs($next_step)
1692
+	{
1693
+		if ($next_step === 'finalize_registration') {
1694
+			echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1695
+		}
1696
+	}
1697
+
1698
+
1699
+
1700
+	/**
1701
+	 *    display_registration_footer
1702
+	 *
1703
+	 * @access    public
1704
+	 * @return    string
1705
+	 */
1706
+	public static function display_registration_footer()
1707
+	{
1708
+		if (
1709
+		apply_filters(
1710
+			'FHEE__EE_Front__Controller__show_reg_footer',
1711
+			EE_Registry::instance()->CFG->admin->show_reg_footer
1712
+		)
1713
+		) {
1714
+			add_filter(
1715
+				'FHEE__EEH_Template__powered_by_event_espresso__url',
1716
+				function ($url) {
1717
+					return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1718
+				}
1719
+			);
1720
+			echo apply_filters(
1721
+				'FHEE__EE_Front_Controller__display_registration_footer',
1722
+				\EEH_Template::powered_by_event_espresso(
1723
+					'',
1724
+					'espresso-registration-footer-dv',
1725
+					array('utm_content' => 'registration_checkout')
1726
+				)
1727
+			);
1728
+		}
1729
+		return '';
1730
+	}
1731
+
1732
+
1733
+
1734
+	/**
1735
+	 *    unlock_transaction
1736
+	 *
1737
+	 * @access    public
1738
+	 * @return    void
1739
+	 * @throws EE_Error
1740
+	 */
1741
+	public function unlock_transaction()
1742
+	{
1743
+		if ($this->checkout->transaction instanceof EE_Transaction) {
1744
+			$this->checkout->transaction->unlock();
1745
+		}
1746
+	}
1747
+
1748
+
1749
+
1750
+	/**
1751
+	 *        _setup_redirect
1752
+	 *
1753
+	 * @access    private
1754
+	 * @return void
1755
+	 */
1756
+	private function _setup_redirect()
1757
+	{
1758
+		if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1759
+			$this->checkout->redirect = true;
1760
+			if (empty($this->checkout->redirect_url)) {
1761
+				$this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1762
+			}
1763
+			$this->checkout->redirect_url = apply_filters(
1764
+				'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1765
+				$this->checkout->redirect_url,
1766
+				$this->checkout
1767
+			);
1768
+		}
1769
+	}
1770
+
1771
+
1772
+
1773
+	/**
1774
+	 *   handle ajax message responses and redirects
1775
+	 *
1776
+	 * @access public
1777
+	 * @return void
1778
+	 * @throws EE_Error
1779
+	 */
1780
+	public function go_to_next_step()
1781
+	{
1782
+		if (EE_Registry::instance()->REQ->ajax) {
1783
+			// capture contents of output buffer we started earlier in the request, and insert into JSON response
1784
+			$this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1785
+		}
1786
+		$this->unlock_transaction();
1787
+		// just return for these conditions
1788
+		if (
1789
+			$this->checkout->admin_request
1790
+			|| $this->checkout->action === 'redirect_form'
1791
+			|| $this->checkout->action === 'update_checkout'
1792
+		) {
1793
+			return;
1794
+		}
1795
+		// AJAX response
1796
+		$this->_handle_json_response();
1797
+		// redirect to next step or the Thank You page
1798
+		$this->_handle_html_redirects();
1799
+		// hmmm... must be something wrong, so let's just display the form again !
1800
+		$this->_display_spco_reg_form();
1801
+	}
1802
+
1803
+
1804
+
1805
+	/**
1806
+	 *   _handle_json_response
1807
+	 *
1808
+	 * @access protected
1809
+	 * @return void
1810
+	 */
1811
+	protected function _handle_json_response()
1812
+	{
1813
+		// if this is an ajax request
1814
+		if (EE_Registry::instance()->REQ->ajax) {
1815
+			// DEBUG LOG
1816
+			//$this->checkout->log(
1817
+			//	__CLASS__, __FUNCTION__, __LINE__,
1818
+			//	array(
1819
+			//		'json_response_redirect_url' => $this->checkout->json_response->redirect_url(),
1820
+			//		'redirect'                   => $this->checkout->redirect,
1821
+			//		'continue_reg'               => $this->checkout->continue_reg,
1822
+			//	)
1823
+			//);
1824
+			$this->checkout->json_response->set_registration_time_limit(
1825
+				$this->checkout->get_registration_time_limit()
1826
+			);
1827
+			$this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1828
+			// just send the ajax (
1829
+			$json_response = apply_filters(
1830
+				'FHEE__EE_Single_Page_Checkout__JSON_response',
1831
+				$this->checkout->json_response
1832
+			);
1833
+			echo $json_response;
1834
+			exit();
1835
+		}
1836
+	}
1837
+
1838
+
1839
+
1840
+	/**
1841
+	 *   _handle_redirects
1842
+	 *
1843
+	 * @access protected
1844
+	 * @return void
1845
+	 */
1846
+	protected function _handle_html_redirects()
1847
+	{
1848
+		// going somewhere ?
1849
+		if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1850
+			// store notices in a transient
1851
+			EE_Error::get_notices(false, true, true);
1852
+			// DEBUG LOG
1853
+			//$this->checkout->log(
1854
+			//	__CLASS__, __FUNCTION__, __LINE__,
1855
+			//	array(
1856
+			//		'headers_sent' => headers_sent(),
1857
+			//		'redirect_url'     => $this->checkout->redirect_url,
1858
+			//		'headers_list'    => headers_list(),
1859
+			//	)
1860
+			//);
1861
+			wp_safe_redirect($this->checkout->redirect_url);
1862
+			exit();
1863
+		}
1864
+	}
1865
+
1866
+
1867
+
1868
+	/**
1869
+	 *   set_checkout_anchor
1870
+	 *
1871
+	 * @access public
1872
+	 * @return void
1873
+	 */
1874
+	public function set_checkout_anchor()
1875
+	{
1876
+		echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1877
+	}
1878 1878
 
1879 1879
 
1880 1880
 
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -218,19 +218,19 @@  discard block
 block discarded – undo
218 218
      */
219 219
     public static function set_definitions()
220 220
     {
221
-        if(defined('SPCO_BASE_PATH')) {
221
+        if (defined('SPCO_BASE_PATH')) {
222 222
             return;
223 223
         }
224 224
         define(
225 225
             'SPCO_BASE_PATH',
226
-            rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
226
+            rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS
227 227
         );
228
-        define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
229
-        define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
230
-        define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
231
-        define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
232
-        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
233
-        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
228
+        define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS);
229
+        define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS);
230
+        define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS);
231
+        define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS);
232
+        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS);
233
+        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS);
234 234
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
235 235
         EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
236 236
             __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s',
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
             '</h4>',
240 240
             '<br />',
241 241
             '<p>',
242
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
242
+            '<a href="'.get_post_type_archive_link('espresso_events').'" title="',
243 243
             '">',
244 244
             '</a>',
245 245
             '</p>'
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
             return;
263 263
         }
264 264
         // filter list of reg_steps
265
-        $reg_steps_to_load = (array)apply_filters(
265
+        $reg_steps_to_load = (array) apply_filters(
266 266
             'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
267 267
             EED_Single_Page_Checkout::get_reg_steps()
268 268
         );
@@ -314,25 +314,25 @@  discard block
 block discarded – undo
314 314
         if (empty($reg_steps)) {
315 315
             $reg_steps = array(
316 316
                 10  => array(
317
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
317
+                    'file_path'  => SPCO_REG_STEPS_PATH.'attendee_information',
318 318
                     'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
319 319
                     'slug'       => 'attendee_information',
320 320
                     'has_hooks'  => false,
321 321
                 ),
322 322
                 20  => array(
323
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'registration_confirmation',
323
+                    'file_path'  => SPCO_REG_STEPS_PATH.'registration_confirmation',
324 324
                     'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
325 325
                     'slug'       => 'registration_confirmation',
326 326
                     'has_hooks'  => false,
327 327
                 ),
328 328
                 30  => array(
329
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
329
+                    'file_path'  => SPCO_REG_STEPS_PATH.'payment_options',
330 330
                     'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
331 331
                     'slug'       => 'payment_options',
332 332
                     'has_hooks'  => true,
333 333
                 ),
334 334
                 999 => array(
335
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
335
+                    'file_path'  => SPCO_REG_STEPS_PATH.'finalize_registration',
336 336
                     'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
337 337
                     'slug'       => 'finalize_registration',
338 338
                     'has_hooks'  => false,
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
             // DEBUG LOG
517 517
             //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
518 518
             // get reg form
519
-            if( ! $this->_check_form_submission()) {
519
+            if ( ! $this->_check_form_submission()) {
520 520
                 EED_Single_Page_Checkout::$_initialized = true;
521 521
                 return;
522 522
             }
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
         );
558 558
         // is session still valid ?
559 559
         if ($clear_session_requested
560
-            || ( EE_Registry::instance()->SSN->expired()
560
+            || (EE_Registry::instance()->SSN->expired()
561 561
               && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === ''
562 562
             )
563 563
         ) {
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
             // EE_Registry::instance()->SSN->reset_cart();
567 567
             // EE_Registry::instance()->SSN->reset_checkout();
568 568
             // EE_Registry::instance()->SSN->reset_transaction();
569
-            if (! $clear_session_requested) {
569
+            if ( ! $clear_session_requested) {
570 570
                 EE_Error::add_attention(
571 571
                     EE_Registry::$i18n_js_strings['registration_expiration_notice'],
572 572
                     __FILE__, __FUNCTION__, __LINE__
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
                     if ( ! $registration instanceof EE_Registration) {
1122 1122
                         throw new InvalidEntityException($registration, 'EE_Registration');
1123 1123
                     }
1124
-                    $registrations[ $registration->ID() ] = $registration;
1124
+                    $registrations[$registration->ID()] = $registration;
1125 1125
                 }
1126 1126
             }
1127 1127
             $registration_processor->fix_reg_final_price_rounding_issue($transaction);
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
                         ) {
1383 1383
                             EE_Error::add_success(
1384 1384
                                 $this->checkout->current_step->success_message()
1385
-                                . '<br />' . $this->checkout->next_step->_instructions()
1385
+                                . '<br />'.$this->checkout->next_step->_instructions()
1386 1386
                             );
1387 1387
                         }
1388 1388
                         // pack it up, pack it in...
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
             '</h4>',
1508 1508
             '<br />',
1509 1509
             '<p>',
1510
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1510
+            '<a href="'.get_post_type_archive_link('espresso_events').'" title="',
1511 1511
             '">',
1512 1512
             '</a>',
1513 1513
             '</p>'
@@ -1539,7 +1539,7 @@  discard block
 block discarded – undo
1539 1539
         // load css
1540 1540
         wp_register_style(
1541 1541
             'single_page_checkout',
1542
-            SPCO_CSS_URL . 'single_page_checkout.css',
1542
+            SPCO_CSS_URL.'single_page_checkout.css',
1543 1543
             array('espresso_default'),
1544 1544
             EVENT_ESPRESSO_VERSION
1545 1545
         );
@@ -1547,21 +1547,21 @@  discard block
 block discarded – undo
1547 1547
         // load JS
1548 1548
         wp_register_script(
1549 1549
             'jquery_plugin',
1550
-            EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1550
+            EE_THIRD_PARTY_URL.'jquery	.plugin.min.js',
1551 1551
             array('jquery'),
1552 1552
             '1.0.1',
1553 1553
             true
1554 1554
         );
1555 1555
         wp_register_script(
1556 1556
             'jquery_countdown',
1557
-            EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1557
+            EE_THIRD_PARTY_URL.'jquery	.countdown.min.js',
1558 1558
             array('jquery_plugin'),
1559 1559
             '2.0.2',
1560 1560
             true
1561 1561
         );
1562 1562
         wp_register_script(
1563 1563
             'single_page_checkout',
1564
-            SPCO_JS_URL . 'single_page_checkout.js',
1564
+            SPCO_JS_URL.'single_page_checkout.js',
1565 1565
             array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'),
1566 1566
             EVENT_ESPRESSO_VERSION,
1567 1567
             true
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
          *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1585 1585
          */
1586 1586
         do_action(
1587
-            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1587
+            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(),
1588 1588
             $this
1589 1589
         );
1590 1590
     }
@@ -1638,7 +1638,7 @@  discard block
 block discarded – undo
1638 1638
                     'layout_strategy' =>
1639 1639
                         new EE_Template_Layout(
1640 1640
                             array(
1641
-                                'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1641
+                                'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php',
1642 1642
                                 'template_args'        => array(
1643 1643
                                     'empty_cart'              => $empty_cart,
1644 1644
                                     'revisit'                 => $this->checkout->revisit,
@@ -1713,7 +1713,7 @@  discard block
 block discarded – undo
1713 1713
         ) {
1714 1714
             add_filter(
1715 1715
                 'FHEE__EEH_Template__powered_by_event_espresso__url',
1716
-                function ($url) {
1716
+                function($url) {
1717 1717
                     return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1718 1718
                 }
1719 1719
             );
Please login to merge, or discard this patch.